@gem-sdk/core 12.0.0-dev.25 → 12.0.0-dev.26
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/constant.js +1 -1
- package/dist/cjs/contexts/PageContext.js +1 -1
- package/dist/cjs/contexts/ProductContext.js +1 -1
- package/dist/cjs/graphql/queries/products.generated.js +0 -6
- package/dist/cjs/index.js +1 -1
- package/dist/esm/components/constant.js +1 -1
- package/dist/esm/contexts/PageContext.js +1 -1
- package/dist/esm/contexts/ProductContext.js +1 -1
- package/dist/esm/graphql/queries/products.generated.js +0 -6
- package/dist/esm/index.js +1 -1
- package/dist/types/index.d.ts +91 -908
- package/package.json +3 -3
- package/dist/cjs/graphql/fragments/product-variants-with-selling-plans-select.generated.js +0 -40
- package/dist/cjs/graphql/queries/product-variant-with-selling-plans.generated.js +0 -25
- package/dist/cjs/graphql/queries/products-with-selling-plans.generated.js +0 -82
- package/dist/cjs/graphql-app-api/queries/ThemePageMeta.generated.js +0 -30
- package/dist/cjs/helpers/queries/getProductOffers.js +0 -1
- package/dist/cjs/hooks/shop/useProductOffersQuery.js +0 -2
- package/dist/esm/graphql/fragments/product-variants-with-selling-plans-select.generated.js +0 -40
- package/dist/esm/graphql/queries/product-variant-with-selling-plans.generated.js +0 -25
- package/dist/esm/graphql/queries/products-with-selling-plans.generated.js +0 -82
- package/dist/esm/graphql-app-api/queries/ThemePageMeta.generated.js +0 -30
- package/dist/esm/helpers/queries/getProductOffers.js +0 -1
- package/dist/esm/hooks/shop/useProductOffersQuery.js +0 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gem-sdk/core",
|
|
3
|
-
"version": "12.0.0-dev.
|
|
3
|
+
"version": "12.0.0-dev.26",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "dist/cjs/index.js",
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
"type-check": "yarn tsc --noEmit"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@gem-sdk/adapter-shopify": "12.0.0-dev.
|
|
31
|
-
"@gem-sdk/styles": "12.0.0-dev.
|
|
30
|
+
"@gem-sdk/adapter-shopify": "12.0.0-dev.25",
|
|
31
|
+
"@gem-sdk/styles": "12.0.0-dev.25",
|
|
32
32
|
"@types/classnames": "^2.3.1"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
"use strict";const ProductVariantsWithSellingPlansSelect=`
|
|
2
|
-
fragment ProductVariantsWithSellingPlansSelect on ProductVariant {
|
|
3
|
-
id
|
|
4
|
-
title
|
|
5
|
-
barcode
|
|
6
|
-
baseID
|
|
7
|
-
costPrice
|
|
8
|
-
height
|
|
9
|
-
inventoryPolicy
|
|
10
|
-
inventoryQuantity
|
|
11
|
-
inventoryStatus
|
|
12
|
-
isDigital
|
|
13
|
-
length
|
|
14
|
-
lowInventoryAmount
|
|
15
|
-
manageInventory
|
|
16
|
-
mediaId
|
|
17
|
-
platform
|
|
18
|
-
price
|
|
19
|
-
salePrice
|
|
20
|
-
sku
|
|
21
|
-
soldIndividually
|
|
22
|
-
weight
|
|
23
|
-
width
|
|
24
|
-
selectedOptions {
|
|
25
|
-
...SelectedOptionSelect
|
|
26
|
-
}
|
|
27
|
-
media {
|
|
28
|
-
...MediaSelect
|
|
29
|
-
}
|
|
30
|
-
sellingPlanGroups {
|
|
31
|
-
id
|
|
32
|
-
appID
|
|
33
|
-
sellingPlans {
|
|
34
|
-
id
|
|
35
|
-
name
|
|
36
|
-
baseID
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
`;exports.ProductVariantsWithSellingPlansSelect=ProductVariantsWithSellingPlansSelect;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";var productVariantsWithSellingPlansSelect_generated=require("../fragments/product-variants-with-selling-plans-select.generated.js"),selectedOption_generated=require("../fragments/selected-option.generated.js"),media_generated=require("../fragments/media.generated.js");const ProductVariantsWithSellingPlansDocument=`
|
|
2
|
-
query ProductVariantsWithSellingPlans($firstVariant: Int = 50, $afterVariant: Cursor, $orderBy: ProductOrder, $orderByVariant: ProductVariantOrder, $where: ProductWhereInput, $first: Int = 1) {
|
|
3
|
-
variants: products(first: $first, orderBy: $orderBy, where: $where) {
|
|
4
|
-
edges {
|
|
5
|
-
node {
|
|
6
|
-
id
|
|
7
|
-
variants(first: $firstVariant, after: $afterVariant, orderBy: $orderByVariant) {
|
|
8
|
-
edges {
|
|
9
|
-
cursor
|
|
10
|
-
node {
|
|
11
|
-
...ProductVariantsWithSellingPlansSelect
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
pageInfo {
|
|
15
|
-
hasNextPage
|
|
16
|
-
endCursor
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
${productVariantsWithSellingPlansSelect_generated.ProductVariantsWithSellingPlansSelect}
|
|
24
|
-
${selectedOption_generated.SelectedOptionSelect}
|
|
25
|
-
${media_generated.MediaSelect}`;exports.ProductVariantsWithSellingPlansDocument=ProductVariantsWithSellingPlansDocument;
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
"use strict";var productOption_generated=require("../fragments/product-option.generated.js"),productOptionValue_generated=require("../fragments/product-option-value.generated.js"),media_generated=require("../fragments/media.generated.js"),productVariantsWithSellingPlansSelect_generated=require("../fragments/product-variants-with-selling-plans-select.generated.js"),selectedOption_generated=require("../fragments/selected-option.generated.js");const ProductWithSellingPlansSelectFragment=`
|
|
2
|
-
fragment ProductWithSellingPlansSelectFragment on ProductEdge {
|
|
3
|
-
cursor
|
|
4
|
-
node {
|
|
5
|
-
id
|
|
6
|
-
title
|
|
7
|
-
createdAt
|
|
8
|
-
description
|
|
9
|
-
descriptionHtml
|
|
10
|
-
handle
|
|
11
|
-
averageRating
|
|
12
|
-
isStorefront
|
|
13
|
-
isSample
|
|
14
|
-
baseID
|
|
15
|
-
sku
|
|
16
|
-
requiresSellingPlan
|
|
17
|
-
options {
|
|
18
|
-
...ProductOptionSelect
|
|
19
|
-
}
|
|
20
|
-
vendor
|
|
21
|
-
featuredImage {
|
|
22
|
-
...MediaSelect
|
|
23
|
-
}
|
|
24
|
-
collections {
|
|
25
|
-
edges {
|
|
26
|
-
node {
|
|
27
|
-
id
|
|
28
|
-
title
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
tags
|
|
33
|
-
sellingPlanGroups {
|
|
34
|
-
appID
|
|
35
|
-
baseID
|
|
36
|
-
id
|
|
37
|
-
name
|
|
38
|
-
}
|
|
39
|
-
medias(first: $firstMedia, after: $afterMedia, orderBy: $orderByMedia) {
|
|
40
|
-
edges {
|
|
41
|
-
cursor
|
|
42
|
-
node {
|
|
43
|
-
...MediaSelect
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
pageInfo {
|
|
47
|
-
endCursor
|
|
48
|
-
hasNextPage
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
variants(first: $firstVariant, after: $afterVariant) {
|
|
52
|
-
edges {
|
|
53
|
-
cursor
|
|
54
|
-
node {
|
|
55
|
-
...ProductVariantsWithSellingPlansSelect
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
pageInfo {
|
|
59
|
-
hasNextPage
|
|
60
|
-
endCursor
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
`,ProductsWithSellingPlansDocument=`
|
|
66
|
-
query ProductsWithSellingPlans($first: Int, $where: ProductWhereInput, $firstMedia: Int, $orderBy: ProductOrder, $after: Cursor, $firstVariant: Int, $afterVariant: Cursor, $afterMedia: Cursor, $orderByMedia: MediaOrder) {
|
|
67
|
-
products(first: $first, where: $where, orderBy: $orderBy, after: $after) {
|
|
68
|
-
edges {
|
|
69
|
-
...ProductWithSellingPlansSelectFragment
|
|
70
|
-
}
|
|
71
|
-
pageInfo {
|
|
72
|
-
endCursor
|
|
73
|
-
hasNextPage
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
${ProductWithSellingPlansSelectFragment}
|
|
78
|
-
${productOption_generated.ProductOptionSelect}
|
|
79
|
-
${productOptionValue_generated.ProductOptionValueSelect}
|
|
80
|
-
${media_generated.MediaSelect}
|
|
81
|
-
${productVariantsWithSellingPlansSelect_generated.ProductVariantsWithSellingPlansSelect}
|
|
82
|
-
${selectedOption_generated.SelectedOptionSelect}`;exports.ProductWithSellingPlansSelectFragment=ProductWithSellingPlansSelectFragment,exports.ProductsWithSellingPlansDocument=ProductsWithSellingPlansDocument;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";const ThemePageMetaDocument=`
|
|
2
|
-
query themePageMeta($after: Cursor, $before: Cursor, $first: Int, $last: Int, $themePageID: ID!, $where: ThemePageMetaWhereInput) {
|
|
3
|
-
themePageMeta(
|
|
4
|
-
after: $after
|
|
5
|
-
before: $before
|
|
6
|
-
first: $first
|
|
7
|
-
last: $last
|
|
8
|
-
themePageID: $themePageID
|
|
9
|
-
where: $where
|
|
10
|
-
) {
|
|
11
|
-
edges {
|
|
12
|
-
cursor
|
|
13
|
-
node {
|
|
14
|
-
createdAt
|
|
15
|
-
id
|
|
16
|
-
key
|
|
17
|
-
updatedAt
|
|
18
|
-
value
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
pageInfo {
|
|
22
|
-
endCursor
|
|
23
|
-
hasNextPage
|
|
24
|
-
hasPreviousPage
|
|
25
|
-
startCursor
|
|
26
|
-
}
|
|
27
|
-
totalCount
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
`;exports.ThemePageMetaDocument=ThemePageMetaDocument;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";var productVariantWithSellingPlans_generated=require("../../graphql/queries/product-variant-with-selling-plans.generated.js"),productsWithSellingPlans_generated=require("../../graphql/queries/products-with-selling-plans.generated.js"),getCollection=require("./get-collection.js"),getProduct=require("./get-product.js");const getProductOffers=async(e,{ids:t,isSample:r,isStorefront:a,defaultSelectedProductCount:s,allStatus:n})=>{let d=await loopFetchProducts(e,{ids:t,isSample:r,isStorefront:a,defaultSelectedProductCount:s,allStatus:n});if(!d)throw Error("Product not found");let[o,i]=await Promise.all([getVariantsOfProducts({fetcher:e,products:d,isSample:r,isStorefront:a}),getMediasOfProduct({fetcher:e,products:d,isSample:r,isStorefront:a})]);return{...d,products:{...d.products,edges:d.products?.edges.map(e=>{let t=i.find(t=>t.productId===e.node?.baseID),r=o.find(t=>t.productId===e.node?.baseID);return e.node?{...e,node:{...e.node,variants:{...e.node?.variants,edges:r?.items??[]},medias:{...e.node?.medias,edges:t?.items??[]}}}:e})??[]}}},loopFetchProducts=async(e,{ids:t,isSample:r,isStorefront:a,defaultSelectedProductCount:s,allStatus:n})=>{let d,o,i,c,l;let u=s||4,g=(t?.length==0?u:t?.length)??u,p=1,f=Math.ceil(g/8);for(;p<=f&&!1!==c;){let s=n?{}:{status:"ACTIVE"};d={first:getCollection.calculateFirstProduct(g,p,8),firstMedia:1,firstVariant:1,orderBy:{field:"PLATFORM_CREATED_AT",direction:"DESC"},orderByMedia:{field:"POSITION",direction:"ASC"},where:{...s,isSample:r,...a&&{isStorefront:a},...t?.length?{baseIDIn:t}:{}},after:o};let u=await e([productsWithSellingPlans_generated.ProductsWithSellingPlansDocument,d]);if(o=u?.products?.pageInfo?.endCursor,1===p?(i=u,l=u):l?.products&&u?.products?.edges.length&&(l.products={edges:l.products.edges.concat(u?.products?.edges),pageInfo:u?.products?.pageInfo}),p++,!l){c=!1;break}}return i},getVariantsOfProducts=async({fetcher:e,products:t,isSample:r,isStorefront:a})=>{let s=await Promise.all(t?.products?.edges?.map(async t=>{let s=await fetchVariants(e,{id:t?.node?.baseID,isSample:r,isStorefront:a});return{productId:t?.node?.baseID,items:s}})??[]);return s},getMediasOfProduct=async({fetcher:e,products:t,isSample:r,isStorefront:a})=>{let s=await Promise.all(t?.products?.edges?.map(async t=>{let s=await getProduct.fetchMedias(e,{id:t?.node?.baseID,isSample:r,isStorefront:a});return{productId:t?.node?.baseID,items:s}})??[]);return s},fetchVariants=async(e,{id:t,isSample:r,isStorefront:a})=>{let s={field:"CREATED_AT",direction:"DESC"},n={orderBy:s,where:{isSample:r,...a&&{isStorefront:a},...(!t||t&&"latest"==t.toLowerCase())&&{status:"ACTIVE"},...t&&"latest"!==t.toLowerCase()&&{baseID:t}},orderByVariant:{field:"POSITION",direction:"ASC"}},d=async(t,r)=>{try{let a=await e([productVariantWithSellingPlans_generated.ProductVariantsWithSellingPlansDocument,t]),s=a.variants?.edges?.[0],n=r?.concat(s?.node?.variants?.edges??[]);if(s?.node?.variants?.pageInfo?.hasNextPage)return d({...t,afterVariant:s?.node?.variants?.pageInfo.endCursor},n);return n??[]}catch{return r??[]}};return d(n,[])};exports.getProductOffers=getProductOffers;
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
"use strict";var useSWR=require("swr"),query=require("../../helpers/query.js"),shop=require("../shop.js"),useFetchHandle=require("../useFetchHandle.js"),react=require("react"),PageContext=require("../../contexts/PageContext.js"),createStoreFrontFetcher=require("../../helpers/create-store-front-fetcher.js"),getProductOffers=require("../../helpers/queries/getProductOffers.js");const useProductOffersQuery=(e,r,t)=>{let u=useFetchHandle.useFetchHandle(),s=PageContext.usePageStore(e=>e.publicStoreFrontData),o=react.useMemo(()=>createStoreFrontFetcher.hasPublicStoreFrontData(s)?createStoreFrontFetcher.createStoreFrontFetcher(s):u,[s]),c=shop.useIsSampleProduct(),a=shop.useIsStorefrontProduct();return useSWR(e?query.generateProductsQueryKey({ids:e,isSample:c,isStorefront:a,defaultSelectedProductCount:t?.defaultSelectedProductCount,allStatus:t?.allStatus}):null,async([,e])=>getProductOffers.getProductOffers(t?.fetcher||o,e),r)};exports.useProductOffersQuery=useProductOffersQuery;
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
let ProductVariantsWithSellingPlansSelect=`
|
|
2
|
-
fragment ProductVariantsWithSellingPlansSelect on ProductVariant {
|
|
3
|
-
id
|
|
4
|
-
title
|
|
5
|
-
barcode
|
|
6
|
-
baseID
|
|
7
|
-
costPrice
|
|
8
|
-
height
|
|
9
|
-
inventoryPolicy
|
|
10
|
-
inventoryQuantity
|
|
11
|
-
inventoryStatus
|
|
12
|
-
isDigital
|
|
13
|
-
length
|
|
14
|
-
lowInventoryAmount
|
|
15
|
-
manageInventory
|
|
16
|
-
mediaId
|
|
17
|
-
platform
|
|
18
|
-
price
|
|
19
|
-
salePrice
|
|
20
|
-
sku
|
|
21
|
-
soldIndividually
|
|
22
|
-
weight
|
|
23
|
-
width
|
|
24
|
-
selectedOptions {
|
|
25
|
-
...SelectedOptionSelect
|
|
26
|
-
}
|
|
27
|
-
media {
|
|
28
|
-
...MediaSelect
|
|
29
|
-
}
|
|
30
|
-
sellingPlanGroups {
|
|
31
|
-
id
|
|
32
|
-
appID
|
|
33
|
-
sellingPlans {
|
|
34
|
-
id
|
|
35
|
-
name
|
|
36
|
-
baseID
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
`;export{ProductVariantsWithSellingPlansSelect};
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import{ProductVariantsWithSellingPlansSelect as r}from"../fragments/product-variants-with-selling-plans-select.generated.js";import{SelectedOptionSelect as e}from"../fragments/selected-option.generated.js";import{MediaSelect as t}from"../fragments/media.generated.js";let ProductVariantsWithSellingPlansDocument=`
|
|
2
|
-
query ProductVariantsWithSellingPlans($firstVariant: Int = 50, $afterVariant: Cursor, $orderBy: ProductOrder, $orderByVariant: ProductVariantOrder, $where: ProductWhereInput, $first: Int = 1) {
|
|
3
|
-
variants: products(first: $first, orderBy: $orderBy, where: $where) {
|
|
4
|
-
edges {
|
|
5
|
-
node {
|
|
6
|
-
id
|
|
7
|
-
variants(first: $firstVariant, after: $afterVariant, orderBy: $orderByVariant) {
|
|
8
|
-
edges {
|
|
9
|
-
cursor
|
|
10
|
-
node {
|
|
11
|
-
...ProductVariantsWithSellingPlansSelect
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
pageInfo {
|
|
15
|
-
hasNextPage
|
|
16
|
-
endCursor
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
${r}
|
|
24
|
-
${e}
|
|
25
|
-
${t}`;export{ProductVariantsWithSellingPlansDocument};
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import{ProductOptionSelect as e}from"../fragments/product-option.generated.js";import{ProductOptionValueSelect as r}from"../fragments/product-option-value.generated.js";import{MediaSelect as t}from"../fragments/media.generated.js";import{ProductVariantsWithSellingPlansSelect as a}from"../fragments/product-variants-with-selling-plans-select.generated.js";import{SelectedOptionSelect as n}from"../fragments/selected-option.generated.js";let ProductWithSellingPlansSelectFragment=`
|
|
2
|
-
fragment ProductWithSellingPlansSelectFragment on ProductEdge {
|
|
3
|
-
cursor
|
|
4
|
-
node {
|
|
5
|
-
id
|
|
6
|
-
title
|
|
7
|
-
createdAt
|
|
8
|
-
description
|
|
9
|
-
descriptionHtml
|
|
10
|
-
handle
|
|
11
|
-
averageRating
|
|
12
|
-
isStorefront
|
|
13
|
-
isSample
|
|
14
|
-
baseID
|
|
15
|
-
sku
|
|
16
|
-
requiresSellingPlan
|
|
17
|
-
options {
|
|
18
|
-
...ProductOptionSelect
|
|
19
|
-
}
|
|
20
|
-
vendor
|
|
21
|
-
featuredImage {
|
|
22
|
-
...MediaSelect
|
|
23
|
-
}
|
|
24
|
-
collections {
|
|
25
|
-
edges {
|
|
26
|
-
node {
|
|
27
|
-
id
|
|
28
|
-
title
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
tags
|
|
33
|
-
sellingPlanGroups {
|
|
34
|
-
appID
|
|
35
|
-
baseID
|
|
36
|
-
id
|
|
37
|
-
name
|
|
38
|
-
}
|
|
39
|
-
medias(first: $firstMedia, after: $afterMedia, orderBy: $orderByMedia) {
|
|
40
|
-
edges {
|
|
41
|
-
cursor
|
|
42
|
-
node {
|
|
43
|
-
...MediaSelect
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
pageInfo {
|
|
47
|
-
endCursor
|
|
48
|
-
hasNextPage
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
variants(first: $firstVariant, after: $afterVariant) {
|
|
52
|
-
edges {
|
|
53
|
-
cursor
|
|
54
|
-
node {
|
|
55
|
-
...ProductVariantsWithSellingPlansSelect
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
pageInfo {
|
|
59
|
-
hasNextPage
|
|
60
|
-
endCursor
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
`,ProductsWithSellingPlansDocument=`
|
|
66
|
-
query ProductsWithSellingPlans($first: Int, $where: ProductWhereInput, $firstMedia: Int, $orderBy: ProductOrder, $after: Cursor, $firstVariant: Int, $afterVariant: Cursor, $afterMedia: Cursor, $orderByMedia: MediaOrder) {
|
|
67
|
-
products(first: $first, where: $where, orderBy: $orderBy, after: $after) {
|
|
68
|
-
edges {
|
|
69
|
-
...ProductWithSellingPlansSelectFragment
|
|
70
|
-
}
|
|
71
|
-
pageInfo {
|
|
72
|
-
endCursor
|
|
73
|
-
hasNextPage
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
${ProductWithSellingPlansSelectFragment}
|
|
78
|
-
${e}
|
|
79
|
-
${r}
|
|
80
|
-
${t}
|
|
81
|
-
${a}
|
|
82
|
-
${n}`;export{ProductWithSellingPlansSelectFragment,ProductsWithSellingPlansDocument};
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
let ThemePageMetaDocument=`
|
|
2
|
-
query themePageMeta($after: Cursor, $before: Cursor, $first: Int, $last: Int, $themePageID: ID!, $where: ThemePageMetaWhereInput) {
|
|
3
|
-
themePageMeta(
|
|
4
|
-
after: $after
|
|
5
|
-
before: $before
|
|
6
|
-
first: $first
|
|
7
|
-
last: $last
|
|
8
|
-
themePageID: $themePageID
|
|
9
|
-
where: $where
|
|
10
|
-
) {
|
|
11
|
-
edges {
|
|
12
|
-
cursor
|
|
13
|
-
node {
|
|
14
|
-
createdAt
|
|
15
|
-
id
|
|
16
|
-
key
|
|
17
|
-
updatedAt
|
|
18
|
-
value
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
pageInfo {
|
|
22
|
-
endCursor
|
|
23
|
-
hasNextPage
|
|
24
|
-
hasPreviousPage
|
|
25
|
-
startCursor
|
|
26
|
-
}
|
|
27
|
-
totalCount
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
`;export{ThemePageMetaDocument};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{ProductVariantsWithSellingPlansDocument as e}from"../../graphql/queries/product-variant-with-selling-plans.generated.js";import{ProductsWithSellingPlansDocument as t}from"../../graphql/queries/products-with-selling-plans.generated.js";import{calculateFirstProduct as r}from"./get-collection.js";import{fetchMedias as a}from"./get-product.js";let getProductOffers=async(e,{ids:t,isSample:r,isStorefront:a,defaultSelectedProductCount:s,allStatus:o})=>{let d=await loopFetchProducts(e,{ids:t,isSample:r,isStorefront:a,defaultSelectedProductCount:s,allStatus:o});if(!d)throw Error("Product not found");let[n,i]=await Promise.all([getVariantsOfProducts({fetcher:e,products:d,isSample:r,isStorefront:a}),getMediasOfProduct({fetcher:e,products:d,isSample:r,isStorefront:a})]);return{...d,products:{...d.products,edges:d.products?.edges.map(e=>{let t=i.find(t=>t.productId===e.node?.baseID),r=n.find(t=>t.productId===e.node?.baseID);return e.node?{...e,node:{...e.node,variants:{...e.node?.variants,edges:r?.items??[]},medias:{...e.node?.medias,edges:t?.items??[]}}}:e})??[]}}},loopFetchProducts=async(e,{ids:a,isSample:s,isStorefront:o,defaultSelectedProductCount:d,allStatus:n})=>{let i,c,u,l,p;let g=d||4,f=(a?.length==0?g:a?.length)??g,I=1,m=Math.ceil(f/8);for(;I<=m&&!1!==l;){let d=n?{}:{status:"ACTIVE"};i={first:r(f,I,8),firstMedia:1,firstVariant:1,orderBy:{field:"PLATFORM_CREATED_AT",direction:"DESC"},orderByMedia:{field:"POSITION",direction:"ASC"},where:{...d,isSample:s,...o&&{isStorefront:o},...a?.length?{baseIDIn:a}:{}},after:c};let g=await e([t,i]);if(c=g?.products?.pageInfo?.endCursor,1===I?(u=g,p=g):p?.products&&g?.products?.edges.length&&(p.products={edges:p.products.edges.concat(g?.products?.edges),pageInfo:g?.products?.pageInfo}),I++,!p){l=!1;break}}return u},getVariantsOfProducts=async({fetcher:e,products:t,isSample:r,isStorefront:a})=>{let s=await Promise.all(t?.products?.edges?.map(async t=>{let s=await fetchVariants(e,{id:t?.node?.baseID,isSample:r,isStorefront:a});return{productId:t?.node?.baseID,items:s}})??[]);return s},getMediasOfProduct=async({fetcher:e,products:t,isSample:r,isStorefront:s})=>{let o=await Promise.all(t?.products?.edges?.map(async t=>{let o=await a(e,{id:t?.node?.baseID,isSample:r,isStorefront:s});return{productId:t?.node?.baseID,items:o}})??[]);return o},fetchVariants=async(t,{id:r,isSample:a,isStorefront:s})=>{let o={field:"CREATED_AT",direction:"DESC"},d={orderBy:o,where:{isSample:a,...s&&{isStorefront:s},...(!r||r&&"latest"==r.toLowerCase())&&{status:"ACTIVE"},...r&&"latest"!==r.toLowerCase()&&{baseID:r}},orderByVariant:{field:"POSITION",direction:"ASC"}},n=async(r,a)=>{try{let s=await t([e,r]),o=s.variants?.edges?.[0],d=a?.concat(o?.node?.variants?.edges??[]);if(o?.node?.variants?.pageInfo?.hasNextPage)return n({...r,afterVariant:o?.node?.variants?.pageInfo.endCursor},d);return d??[]}catch{return a??[]}};return n(d,[])};export{getProductOffers};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import e from"swr";import{generateProductsQueryKey as r}from"../../helpers/query.js";import{useIsSampleProduct as t,useIsStorefrontProduct as o}from"../shop.js";import{useFetchHandle as s}from"../useFetchHandle.js";import{useMemo as u}from"react";import{usePageStore as f}from"../../contexts/PageContext.js";import{hasPublicStoreFrontData as l,createStoreFrontFetcher as m}from"../../helpers/create-store-front-fetcher.js";import{getProductOffers as c}from"../../helpers/queries/getProductOffers.js";let useProductOffersQuery=(p,a,d)=>{let i=s(),n=f(e=>e.publicStoreFrontData),h=u(()=>l(n)?m(n):i,[n]),j=t(),P=o();return e(p?r({ids:p,isSample:j,isStorefront:P,defaultSelectedProductCount:d?.defaultSelectedProductCount,allStatus:d?.allStatus}):null,async([,e])=>c(d?.fetcher||h,e),a)};export{useProductOffersQuery};
|