@gem-sdk/core 1.0.5 → 1.0.8
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.
|
@@ -14,45 +14,34 @@ const prefetchQueries = (input, isSample) => {
|
|
|
14
14
|
case 'Product': {
|
|
15
15
|
if (item.settings?.isAuto)
|
|
16
16
|
break;
|
|
17
|
+
const variables = { id: item.settings?.productSetting?.productId ?? 'latest', isSample };
|
|
17
18
|
data = {
|
|
18
|
-
key: useSWR.unstable_serialize([
|
|
19
|
-
'query/product',
|
|
20
|
-
{ id: item.settings?.productSetting?.productId ?? 'latest', isSample },
|
|
21
|
-
]),
|
|
19
|
+
key: useSWR.unstable_serialize(['query/product', variables]),
|
|
22
20
|
func: getProduct.getProduct,
|
|
23
|
-
variables
|
|
21
|
+
variables,
|
|
24
22
|
};
|
|
25
23
|
break;
|
|
26
24
|
}
|
|
27
25
|
case 'ProductList': {
|
|
28
26
|
if (item?.settings?.productSrc === 'Collection') {
|
|
27
|
+
const variables = {
|
|
28
|
+
id: item.settings?.collectionId ?? 'latest',
|
|
29
|
+
numberOfProducts: item.settings?.numberOfProducts ?? 4,
|
|
30
|
+
orderBy: item.settings?.orderBy,
|
|
31
|
+
isSample,
|
|
32
|
+
};
|
|
29
33
|
data = {
|
|
30
|
-
key: useSWR.unstable_serialize([
|
|
31
|
-
'query/collection',
|
|
32
|
-
{
|
|
33
|
-
id: item.settings?.collectionId ?? 'latest',
|
|
34
|
-
numberOfProducts: item.settings?.numberOfProducts ?? 4,
|
|
35
|
-
orderBy: item.settings?.orderBy,
|
|
36
|
-
isSample,
|
|
37
|
-
},
|
|
38
|
-
]),
|
|
34
|
+
key: useSWR.unstable_serialize(['query/collection', variables]),
|
|
39
35
|
func: getCollection.getCollection,
|
|
40
|
-
variables
|
|
41
|
-
id: item.settings?.collectionId ?? 'latest',
|
|
42
|
-
numberOfProducts: item.settings?.numberOfProducts ?? 4,
|
|
43
|
-
orderBy: item.settings?.orderBy,
|
|
44
|
-
isSample,
|
|
45
|
-
},
|
|
36
|
+
variables,
|
|
46
37
|
};
|
|
47
38
|
}
|
|
48
39
|
else {
|
|
40
|
+
const variables = { ids: item?.settings?.productIds?.sort?.(), isSample };
|
|
49
41
|
data = {
|
|
50
|
-
key: useSWR.unstable_serialize([
|
|
51
|
-
'query/products',
|
|
52
|
-
{ ids: item?.settings?.productIds?.sort(), isSample },
|
|
53
|
-
]),
|
|
42
|
+
key: useSWR.unstable_serialize(['query/products', variables]),
|
|
54
43
|
func: getProducts.getProducts,
|
|
55
|
-
variables
|
|
44
|
+
variables,
|
|
56
45
|
};
|
|
57
46
|
}
|
|
58
47
|
break;
|
|
@@ -62,7 +51,12 @@ const prefetchQueries = (input, isSample) => {
|
|
|
62
51
|
queries.push(data);
|
|
63
52
|
}
|
|
64
53
|
});
|
|
65
|
-
return queries
|
|
54
|
+
return queries.reduce((accumulator, current) => {
|
|
55
|
+
if (!accumulator.some((x) => x.key === current.key)) {
|
|
56
|
+
return [...accumulator, current];
|
|
57
|
+
}
|
|
58
|
+
return accumulator;
|
|
59
|
+
}, []);
|
|
66
60
|
};
|
|
67
61
|
|
|
68
62
|
exports.prefetchQueries = prefetchQueries;
|
|
@@ -61,7 +61,7 @@ const loopFetchCollection = async (fetcher, arg) => {
|
|
|
61
61
|
},
|
|
62
62
|
firstProduct: calculateFirstProduct(arg.numberOfProducts, currentPage, productsPerPage),
|
|
63
63
|
...(!arg.id || arg.id.toLowerCase() === 'latest'
|
|
64
|
-
? { where: { hasCollectionProducts: true } }
|
|
64
|
+
? { where: { hasCollectionProducts: true, isSample: arg.isSample } }
|
|
65
65
|
: { where: { baseID: arg.id } }),
|
|
66
66
|
orderByProduct: productSortedByOrder(arg.orderBy),
|
|
67
67
|
whereProduct: {
|
|
@@ -12,45 +12,34 @@ const prefetchQueries = (input, isSample) => {
|
|
|
12
12
|
case 'Product': {
|
|
13
13
|
if (item.settings?.isAuto)
|
|
14
14
|
break;
|
|
15
|
+
const variables = { id: item.settings?.productSetting?.productId ?? 'latest', isSample };
|
|
15
16
|
data = {
|
|
16
|
-
key: unstable_serialize([
|
|
17
|
-
'query/product',
|
|
18
|
-
{ id: item.settings?.productSetting?.productId ?? 'latest', isSample },
|
|
19
|
-
]),
|
|
17
|
+
key: unstable_serialize(['query/product', variables]),
|
|
20
18
|
func: getProduct,
|
|
21
|
-
variables
|
|
19
|
+
variables,
|
|
22
20
|
};
|
|
23
21
|
break;
|
|
24
22
|
}
|
|
25
23
|
case 'ProductList': {
|
|
26
24
|
if (item?.settings?.productSrc === 'Collection') {
|
|
25
|
+
const variables = {
|
|
26
|
+
id: item.settings?.collectionId ?? 'latest',
|
|
27
|
+
numberOfProducts: item.settings?.numberOfProducts ?? 4,
|
|
28
|
+
orderBy: item.settings?.orderBy,
|
|
29
|
+
isSample,
|
|
30
|
+
};
|
|
27
31
|
data = {
|
|
28
|
-
key: unstable_serialize([
|
|
29
|
-
'query/collection',
|
|
30
|
-
{
|
|
31
|
-
id: item.settings?.collectionId ?? 'latest',
|
|
32
|
-
numberOfProducts: item.settings?.numberOfProducts ?? 4,
|
|
33
|
-
orderBy: item.settings?.orderBy,
|
|
34
|
-
isSample,
|
|
35
|
-
},
|
|
36
|
-
]),
|
|
32
|
+
key: unstable_serialize(['query/collection', variables]),
|
|
37
33
|
func: getCollection,
|
|
38
|
-
variables
|
|
39
|
-
id: item.settings?.collectionId ?? 'latest',
|
|
40
|
-
numberOfProducts: item.settings?.numberOfProducts ?? 4,
|
|
41
|
-
orderBy: item.settings?.orderBy,
|
|
42
|
-
isSample,
|
|
43
|
-
},
|
|
34
|
+
variables,
|
|
44
35
|
};
|
|
45
36
|
}
|
|
46
37
|
else {
|
|
38
|
+
const variables = { ids: item?.settings?.productIds?.sort?.(), isSample };
|
|
47
39
|
data = {
|
|
48
|
-
key: unstable_serialize([
|
|
49
|
-
'query/products',
|
|
50
|
-
{ ids: item?.settings?.productIds?.sort(), isSample },
|
|
51
|
-
]),
|
|
40
|
+
key: unstable_serialize(['query/products', variables]),
|
|
52
41
|
func: getProducts,
|
|
53
|
-
variables
|
|
42
|
+
variables,
|
|
54
43
|
};
|
|
55
44
|
}
|
|
56
45
|
break;
|
|
@@ -60,7 +49,12 @@ const prefetchQueries = (input, isSample) => {
|
|
|
60
49
|
queries.push(data);
|
|
61
50
|
}
|
|
62
51
|
});
|
|
63
|
-
return queries
|
|
52
|
+
return queries.reduce((accumulator, current) => {
|
|
53
|
+
if (!accumulator.some((x) => x.key === current.key)) {
|
|
54
|
+
return [...accumulator, current];
|
|
55
|
+
}
|
|
56
|
+
return accumulator;
|
|
57
|
+
}, []);
|
|
64
58
|
};
|
|
65
59
|
|
|
66
60
|
export { prefetchQueries };
|
|
@@ -59,7 +59,7 @@ const loopFetchCollection = async (fetcher, arg) => {
|
|
|
59
59
|
},
|
|
60
60
|
firstProduct: calculateFirstProduct(arg.numberOfProducts, currentPage, productsPerPage),
|
|
61
61
|
...(!arg.id || arg.id.toLowerCase() === 'latest'
|
|
62
|
-
? { where: { hasCollectionProducts: true } }
|
|
62
|
+
? { where: { hasCollectionProducts: true, isSample: arg.isSample } }
|
|
63
63
|
: { where: { baseID: arg.id } }),
|
|
64
64
|
orderByProduct: productSortedByOrder(arg.orderBy),
|
|
65
65
|
whereProduct: {
|