@bacano/sdk 1.2.5 → 1.2.7
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/CONTENT_ICONS.md +113 -0
- package/CONTENT_TYPE_MANAGEMENT.md +8 -2
- package/README.md +11 -7
- package/STOREFRONT_PAYMENTS.md +8 -0
- package/STOREFRONT_PERFORMANCE.md +47 -5
- package/content-management-types.d.ts +9 -1
- package/graphql.cjs +59 -0
- package/graphql.js +59 -0
- package/icons.cjs +5515 -0
- package/icons.d.ts +20 -0
- package/icons.js +5496 -0
- package/index.cjs +102 -11
- package/index.js +102 -11
- package/package.json +11 -1
- package/react/icon.cjs +5555 -0
- package/react/icon.d.ts +10 -0
- package/react/icon.js +5534 -0
- package/react.cjs +102 -11
- package/react.js +102 -11
- package/skills/bacano-web/references/common.md +13 -0
- package/skills/bacano-web/references/storefront.md +16 -0
- package/transport/documents.d.ts +10 -10
- package/types.d.ts +5 -2
package/index.cjs
CHANGED
|
@@ -551,6 +551,12 @@ var GET_PRODUCTS = (
|
|
|
551
551
|
id
|
|
552
552
|
name
|
|
553
553
|
description
|
|
554
|
+
product_website_publications(
|
|
555
|
+
where: { website_id: { _eq: $websiteId }, is_visible: { _eq: true } }
|
|
556
|
+
limit: 1
|
|
557
|
+
) {
|
|
558
|
+
show_when_out_of_stock
|
|
559
|
+
}
|
|
554
560
|
long_description
|
|
555
561
|
slug
|
|
556
562
|
seo_title
|
|
@@ -786,6 +792,12 @@ var GET_PRODUCT_BY_PK = (
|
|
|
786
792
|
limit: 1
|
|
787
793
|
) {
|
|
788
794
|
id
|
|
795
|
+
product_website_publications(
|
|
796
|
+
where: { website_id: { _eq: $websiteId }, is_visible: { _eq: true } }
|
|
797
|
+
limit: 1
|
|
798
|
+
) {
|
|
799
|
+
show_when_out_of_stock
|
|
800
|
+
}
|
|
789
801
|
product_option_group_members(limit: 1) {
|
|
790
802
|
group {
|
|
791
803
|
id
|
|
@@ -1035,6 +1047,12 @@ var GET_PRODUCT_SEO_ENTRIES = (
|
|
|
1035
1047
|
id
|
|
1036
1048
|
name
|
|
1037
1049
|
slug
|
|
1050
|
+
product_website_publications(
|
|
1051
|
+
where: { website_id: { _eq: $websiteId }, is_visible: { _eq: true } }
|
|
1052
|
+
limit: 1
|
|
1053
|
+
) {
|
|
1054
|
+
show_when_out_of_stock
|
|
1055
|
+
}
|
|
1038
1056
|
seo_title
|
|
1039
1057
|
seo_description
|
|
1040
1058
|
seo_image_file_id
|
|
@@ -2668,6 +2686,7 @@ var GET_PRODUCT_FILTERS = (
|
|
|
2668
2686
|
query GetProductFilters(
|
|
2669
2687
|
$companyId: uuid!
|
|
2670
2688
|
$chainId: uuid!
|
|
2689
|
+
$websiteId: uuid!
|
|
2671
2690
|
$where: products_bool_exp = {}
|
|
2672
2691
|
$attributeListKey: String!
|
|
2673
2692
|
) {
|
|
@@ -2675,6 +2694,12 @@ var GET_PRODUCT_FILTERS = (
|
|
|
2675
2694
|
where: {
|
|
2676
2695
|
_and: [
|
|
2677
2696
|
{ company_id: { _eq: $companyId } }
|
|
2697
|
+
{
|
|
2698
|
+
product_website_publications: {
|
|
2699
|
+
website_id: { _eq: $websiteId }
|
|
2700
|
+
is_visible: { _eq: true }
|
|
2701
|
+
}
|
|
2702
|
+
}
|
|
2678
2703
|
{
|
|
2679
2704
|
chain_products: {
|
|
2680
2705
|
chain_id: { _eq: $chainId }
|
|
@@ -2687,6 +2712,12 @@ var GET_PRODUCT_FILTERS = (
|
|
|
2687
2712
|
}
|
|
2688
2713
|
) {
|
|
2689
2714
|
id
|
|
2715
|
+
product_website_publications(
|
|
2716
|
+
where: { website_id: { _eq: $websiteId }, is_visible: { _eq: true } }
|
|
2717
|
+
limit: 1
|
|
2718
|
+
) {
|
|
2719
|
+
show_when_out_of_stock
|
|
2720
|
+
}
|
|
2690
2721
|
category
|
|
2691
2722
|
subcategory
|
|
2692
2723
|
color
|
|
@@ -2794,6 +2825,7 @@ var GET_SEARCH_SUGGESTIONS = (
|
|
|
2794
2825
|
query GetSearchSuggestions(
|
|
2795
2826
|
$companyId: uuid!
|
|
2796
2827
|
$chainId: uuid!
|
|
2828
|
+
$websiteId: uuid!
|
|
2797
2829
|
$term: String!
|
|
2798
2830
|
$productLimit: Int = 5
|
|
2799
2831
|
$brandLimit: Int = 3
|
|
@@ -2801,6 +2833,10 @@ var GET_SEARCH_SUGGESTIONS = (
|
|
|
2801
2833
|
products(
|
|
2802
2834
|
where: {
|
|
2803
2835
|
company_id: { _eq: $companyId }
|
|
2836
|
+
product_website_publications: {
|
|
2837
|
+
website_id: { _eq: $websiteId }
|
|
2838
|
+
is_visible: { _eq: true }
|
|
2839
|
+
}
|
|
2804
2840
|
chain_products: {
|
|
2805
2841
|
chain_id: { _eq: $chainId }
|
|
2806
2842
|
is_enabled: { _eq: true }
|
|
@@ -2813,6 +2849,29 @@ var GET_SEARCH_SUGGESTIONS = (
|
|
|
2813
2849
|
) {
|
|
2814
2850
|
id
|
|
2815
2851
|
name
|
|
2852
|
+
product_website_publications(
|
|
2853
|
+
where: { website_id: { _eq: $websiteId }, is_visible: { _eq: true } }
|
|
2854
|
+
limit: 1
|
|
2855
|
+
) {
|
|
2856
|
+
show_when_out_of_stock
|
|
2857
|
+
}
|
|
2858
|
+
product_variants(where: { is_disabled: { _eq: false } }) {
|
|
2859
|
+
id
|
|
2860
|
+
product_variant_prices(
|
|
2861
|
+
where: {
|
|
2862
|
+
price_type: { _eq: CLIENT }
|
|
2863
|
+
_or: [
|
|
2864
|
+
{ chain_id: { _eq: $chainId } }
|
|
2865
|
+
{ chain_id: { _is_null: true } }
|
|
2866
|
+
]
|
|
2867
|
+
}
|
|
2868
|
+
) {
|
|
2869
|
+
id
|
|
2870
|
+
price
|
|
2871
|
+
price_type
|
|
2872
|
+
chain_id
|
|
2873
|
+
}
|
|
2874
|
+
}
|
|
2816
2875
|
}
|
|
2817
2876
|
brands(
|
|
2818
2877
|
where: {
|
|
@@ -3972,6 +4031,7 @@ function mapProduct(raw, storageUrl, labels, chainId) {
|
|
|
3972
4031
|
createdAt: raw.created_at,
|
|
3973
4032
|
updatedAt: raw.updated_at ?? raw.created_at,
|
|
3974
4033
|
variants,
|
|
4034
|
+
outOfStockVisibilityOverride: raw.product_website_publications?.[0]?.show_when_out_of_stock ?? null,
|
|
3975
4035
|
detailVariants,
|
|
3976
4036
|
media: raw.product_media.map((m) => mapMedia(m, storageUrl)),
|
|
3977
4037
|
attributes: raw.product_attributes.map(
|
|
@@ -4333,7 +4393,7 @@ async function getWebsiteAvailabilityByVariantId(graphqlUrl, getHeaders, variant
|
|
|
4333
4393
|
}
|
|
4334
4394
|
return availabilityByVariantId;
|
|
4335
4395
|
}
|
|
4336
|
-
async function filterProductsForWebsiteStock(graphqlUrl, getHeaders, products, chainId, websiteId) {
|
|
4396
|
+
async function filterProductsForWebsiteStock(graphqlUrl, getHeaders, products, chainId, websiteId, showOutOfStockByDefault = false, onlyInStock = false) {
|
|
4337
4397
|
const variantIds = products.flatMap(
|
|
4338
4398
|
(product) => product.variants.map((variant) => variant.id)
|
|
4339
4399
|
);
|
|
@@ -4359,11 +4419,11 @@ async function filterProductsForWebsiteStock(graphqlUrl, getHeaders, products, c
|
|
|
4359
4419
|
pricing: resolveProductPricing(prices)
|
|
4360
4420
|
};
|
|
4361
4421
|
}).filter(
|
|
4362
|
-
(variant) => inStockVariantIds.has(variant.id) && variant.pricing.currentPrice != null
|
|
4422
|
+
(variant) => (inStockVariantIds.has(variant.id) || !onlyInStock && (product.outOfStockVisibilityOverride ?? showOutOfStockByDefault)) && variant.pricing.currentPrice != null
|
|
4363
4423
|
)
|
|
4364
4424
|
})).filter((product) => product.variants.length > 0);
|
|
4365
4425
|
}
|
|
4366
|
-
async function filterSeoProductsForWebsiteStock(graphqlUrl, getHeaders, products, chainId, websiteId) {
|
|
4426
|
+
async function filterSeoProductsForWebsiteStock(graphqlUrl, getHeaders, products, chainId, websiteId, showOutOfStockByDefault = false) {
|
|
4367
4427
|
const variantIds = products.flatMap(
|
|
4368
4428
|
(product) => product.product_variants.map((variant) => variant.id)
|
|
4369
4429
|
);
|
|
@@ -4385,7 +4445,7 @@ async function filterSeoProductsForWebsiteStock(graphqlUrl, getHeaders, products
|
|
|
4385
4445
|
const pricing = resolveProductPricing(
|
|
4386
4446
|
selectPublicPrices(prices, chainId)
|
|
4387
4447
|
);
|
|
4388
|
-
return inStockVariantIds.has(variant.id) && pricing.currentPrice != null;
|
|
4448
|
+
return (inStockVariantIds.has(variant.id) || (product.product_website_publications?.[0]?.show_when_out_of_stock ?? showOutOfStockByDefault)) && pricing.currentPrice != null;
|
|
4389
4449
|
})
|
|
4390
4450
|
);
|
|
4391
4451
|
}
|
|
@@ -4456,7 +4516,8 @@ function createCatalogModule(graphqlUrl, getHeaders, getContext, storageUrl) {
|
|
|
4456
4516
|
getHeaders,
|
|
4457
4517
|
[mappedProduct],
|
|
4458
4518
|
ctx.chainId,
|
|
4459
|
-
ctx.websiteId
|
|
4519
|
+
ctx.websiteId,
|
|
4520
|
+
ctx.config?.show_out_of_stock_products === true
|
|
4460
4521
|
);
|
|
4461
4522
|
if (!filteredProducts[0]) return null;
|
|
4462
4523
|
const specifications = await loadProductSpecifications([product.id]);
|
|
@@ -4689,7 +4750,8 @@ function createCatalogModule(graphqlUrl, getHeaders, getContext, storageUrl) {
|
|
|
4689
4750
|
getHeaders,
|
|
4690
4751
|
data.products ?? [],
|
|
4691
4752
|
ctx.chainId,
|
|
4692
|
-
ctx.websiteId
|
|
4753
|
+
ctx.websiteId,
|
|
4754
|
+
ctx.config?.show_out_of_stock_products === true
|
|
4693
4755
|
);
|
|
4694
4756
|
const entries = availableProducts.slice(0, limit).map((product) => mapProductSeoEntry(product, storageUrl)).filter((entry) => Boolean(entry));
|
|
4695
4757
|
return {
|
|
@@ -4766,7 +4828,9 @@ function createCatalogModule(graphqlUrl, getHeaders, getContext, storageUrl) {
|
|
|
4766
4828
|
(p) => mapProduct(p, storageUrl, publicAttributeLabels, chainId)
|
|
4767
4829
|
),
|
|
4768
4830
|
chainId,
|
|
4769
|
-
ctx.websiteId
|
|
4831
|
+
ctx.websiteId,
|
|
4832
|
+
ctx.config?.show_out_of_stock_products === true,
|
|
4833
|
+
opts?.inStock === true
|
|
4770
4834
|
);
|
|
4771
4835
|
const specifications = await loadProductSpecifications(
|
|
4772
4836
|
products.map((product) => product.id)
|
|
@@ -4873,6 +4937,7 @@ function createCatalogModule(graphqlUrl, getHeaders, getContext, storageUrl) {
|
|
|
4873
4937
|
{
|
|
4874
4938
|
companyId: ctx.companyId,
|
|
4875
4939
|
chainId,
|
|
4940
|
+
websiteId: ctx.websiteId,
|
|
4876
4941
|
attributeListKey: DEFAULT_FILTER_ATTRIBUTE_LIST_KEY,
|
|
4877
4942
|
where: buildProductWhere(opts.filters ?? {}, chainId)
|
|
4878
4943
|
},
|
|
@@ -4896,7 +4961,7 @@ function createCatalogModule(graphqlUrl, getHeaders, getContext, storageUrl) {
|
|
|
4896
4961
|
variant.product_variant_prices.map(mapPrice),
|
|
4897
4962
|
chainId
|
|
4898
4963
|
);
|
|
4899
|
-
return prices.length > 0 && (availabilityByVariantId.get(variant.id)?.inStock ?? false);
|
|
4964
|
+
return prices.length > 0 && ((availabilityByVariantId.get(variant.id)?.inStock ?? false) || (product.product_website_publications?.[0]?.show_when_out_of_stock ?? ctx.config?.show_out_of_stock_products === true));
|
|
4900
4965
|
});
|
|
4901
4966
|
if (!hasVisibleVariant) continue;
|
|
4902
4967
|
applicableCategories.add(product.category);
|
|
@@ -4984,6 +5049,7 @@ function createCatalogModule(graphqlUrl, getHeaders, getContext, storageUrl) {
|
|
|
4984
5049
|
{
|
|
4985
5050
|
companyId: ctx.companyId,
|
|
4986
5051
|
chainId,
|
|
5052
|
+
websiteId: ctx.websiteId,
|
|
4987
5053
|
attributeListKey: opts?.attributeListKey ?? DEFAULT_FILTER_ATTRIBUTE_LIST_KEY,
|
|
4988
5054
|
where: {
|
|
4989
5055
|
...opts?.categoryName ? { category: { _eq: opts.categoryName } } : {},
|
|
@@ -5038,7 +5104,9 @@ function createCatalogModule(graphqlUrl, getHeaders, getContext, storageUrl) {
|
|
|
5038
5104
|
chainId
|
|
5039
5105
|
),
|
|
5040
5106
|
inStock: availabilityByVariantId.get(variant.id)?.inStock ?? false
|
|
5041
|
-
})).filter(
|
|
5107
|
+
})).filter(
|
|
5108
|
+
(variant) => (variant.inStock || (product.product_website_publications?.[0]?.show_when_out_of_stock ?? ctx.config?.show_out_of_stock_products === true)) && variant.prices.length > 0
|
|
5109
|
+
);
|
|
5042
5110
|
if (visibleVariants.length === 0) continue;
|
|
5043
5111
|
categoryCounts.set(
|
|
5044
5112
|
product.category,
|
|
@@ -5123,6 +5191,7 @@ function createCatalogModule(graphqlUrl, getHeaders, getContext, storageUrl) {
|
|
|
5123
5191
|
"NO_CHAIN"
|
|
5124
5192
|
);
|
|
5125
5193
|
}
|
|
5194
|
+
const chainId = ctx.chainId;
|
|
5126
5195
|
const term = `%${opts.query}%`;
|
|
5127
5196
|
const limit = opts.limit ?? 8;
|
|
5128
5197
|
const data = await executeGraphQL(
|
|
@@ -5130,7 +5199,8 @@ function createCatalogModule(graphqlUrl, getHeaders, getContext, storageUrl) {
|
|
|
5130
5199
|
GET_SEARCH_SUGGESTIONS,
|
|
5131
5200
|
{
|
|
5132
5201
|
companyId: ctx.companyId,
|
|
5133
|
-
chainId
|
|
5202
|
+
chainId,
|
|
5203
|
+
websiteId: ctx.websiteId,
|
|
5134
5204
|
term,
|
|
5135
5205
|
productLimit: Math.min(limit, 5),
|
|
5136
5206
|
brandLimit: Math.max(limit - 5, 3)
|
|
@@ -5138,8 +5208,29 @@ function createCatalogModule(graphqlUrl, getHeaders, getContext, storageUrl) {
|
|
|
5138
5208
|
getHeaders
|
|
5139
5209
|
);
|
|
5140
5210
|
const suggestions = [];
|
|
5211
|
+
const availability = await getWebsiteAvailabilityByVariantId(
|
|
5212
|
+
graphqlUrl,
|
|
5213
|
+
getHeaders,
|
|
5214
|
+
(data.products ?? []).flatMap(
|
|
5215
|
+
(product) => product.product_variants.map((variant) => variant.id)
|
|
5216
|
+
),
|
|
5217
|
+
chainId,
|
|
5218
|
+
ctx.websiteId
|
|
5219
|
+
);
|
|
5141
5220
|
for (const p of data.products ?? []) {
|
|
5142
|
-
|
|
5221
|
+
const showWithoutStock = p.product_website_publications?.[0]?.show_when_out_of_stock ?? ctx.config?.show_out_of_stock_products === true;
|
|
5222
|
+
const isVisible = p.product_variants.some((variant) => {
|
|
5223
|
+
const hasPrice = resolveProductPricing(
|
|
5224
|
+
selectPublicPrices(
|
|
5225
|
+
variant.product_variant_prices.map(mapPrice),
|
|
5226
|
+
chainId
|
|
5227
|
+
)
|
|
5228
|
+
).currentPrice != null;
|
|
5229
|
+
return hasPrice && (showWithoutStock || availability.get(variant.id)?.inStock === true);
|
|
5230
|
+
});
|
|
5231
|
+
if (isVisible) {
|
|
5232
|
+
suggestions.push({ type: "product", text: p.name, id: p.id });
|
|
5233
|
+
}
|
|
5143
5234
|
}
|
|
5144
5235
|
for (const b of data.brands ?? []) {
|
|
5145
5236
|
suggestions.push({ type: "brand", text: b.name, id: b.id });
|
package/index.js
CHANGED
|
@@ -490,6 +490,12 @@ var GET_PRODUCTS = (
|
|
|
490
490
|
id
|
|
491
491
|
name
|
|
492
492
|
description
|
|
493
|
+
product_website_publications(
|
|
494
|
+
where: { website_id: { _eq: $websiteId }, is_visible: { _eq: true } }
|
|
495
|
+
limit: 1
|
|
496
|
+
) {
|
|
497
|
+
show_when_out_of_stock
|
|
498
|
+
}
|
|
493
499
|
long_description
|
|
494
500
|
slug
|
|
495
501
|
seo_title
|
|
@@ -725,6 +731,12 @@ var GET_PRODUCT_BY_PK = (
|
|
|
725
731
|
limit: 1
|
|
726
732
|
) {
|
|
727
733
|
id
|
|
734
|
+
product_website_publications(
|
|
735
|
+
where: { website_id: { _eq: $websiteId }, is_visible: { _eq: true } }
|
|
736
|
+
limit: 1
|
|
737
|
+
) {
|
|
738
|
+
show_when_out_of_stock
|
|
739
|
+
}
|
|
728
740
|
product_option_group_members(limit: 1) {
|
|
729
741
|
group {
|
|
730
742
|
id
|
|
@@ -974,6 +986,12 @@ var GET_PRODUCT_SEO_ENTRIES = (
|
|
|
974
986
|
id
|
|
975
987
|
name
|
|
976
988
|
slug
|
|
989
|
+
product_website_publications(
|
|
990
|
+
where: { website_id: { _eq: $websiteId }, is_visible: { _eq: true } }
|
|
991
|
+
limit: 1
|
|
992
|
+
) {
|
|
993
|
+
show_when_out_of_stock
|
|
994
|
+
}
|
|
977
995
|
seo_title
|
|
978
996
|
seo_description
|
|
979
997
|
seo_image_file_id
|
|
@@ -2607,6 +2625,7 @@ var GET_PRODUCT_FILTERS = (
|
|
|
2607
2625
|
query GetProductFilters(
|
|
2608
2626
|
$companyId: uuid!
|
|
2609
2627
|
$chainId: uuid!
|
|
2628
|
+
$websiteId: uuid!
|
|
2610
2629
|
$where: products_bool_exp = {}
|
|
2611
2630
|
$attributeListKey: String!
|
|
2612
2631
|
) {
|
|
@@ -2614,6 +2633,12 @@ var GET_PRODUCT_FILTERS = (
|
|
|
2614
2633
|
where: {
|
|
2615
2634
|
_and: [
|
|
2616
2635
|
{ company_id: { _eq: $companyId } }
|
|
2636
|
+
{
|
|
2637
|
+
product_website_publications: {
|
|
2638
|
+
website_id: { _eq: $websiteId }
|
|
2639
|
+
is_visible: { _eq: true }
|
|
2640
|
+
}
|
|
2641
|
+
}
|
|
2617
2642
|
{
|
|
2618
2643
|
chain_products: {
|
|
2619
2644
|
chain_id: { _eq: $chainId }
|
|
@@ -2626,6 +2651,12 @@ var GET_PRODUCT_FILTERS = (
|
|
|
2626
2651
|
}
|
|
2627
2652
|
) {
|
|
2628
2653
|
id
|
|
2654
|
+
product_website_publications(
|
|
2655
|
+
where: { website_id: { _eq: $websiteId }, is_visible: { _eq: true } }
|
|
2656
|
+
limit: 1
|
|
2657
|
+
) {
|
|
2658
|
+
show_when_out_of_stock
|
|
2659
|
+
}
|
|
2629
2660
|
category
|
|
2630
2661
|
subcategory
|
|
2631
2662
|
color
|
|
@@ -2733,6 +2764,7 @@ var GET_SEARCH_SUGGESTIONS = (
|
|
|
2733
2764
|
query GetSearchSuggestions(
|
|
2734
2765
|
$companyId: uuid!
|
|
2735
2766
|
$chainId: uuid!
|
|
2767
|
+
$websiteId: uuid!
|
|
2736
2768
|
$term: String!
|
|
2737
2769
|
$productLimit: Int = 5
|
|
2738
2770
|
$brandLimit: Int = 3
|
|
@@ -2740,6 +2772,10 @@ var GET_SEARCH_SUGGESTIONS = (
|
|
|
2740
2772
|
products(
|
|
2741
2773
|
where: {
|
|
2742
2774
|
company_id: { _eq: $companyId }
|
|
2775
|
+
product_website_publications: {
|
|
2776
|
+
website_id: { _eq: $websiteId }
|
|
2777
|
+
is_visible: { _eq: true }
|
|
2778
|
+
}
|
|
2743
2779
|
chain_products: {
|
|
2744
2780
|
chain_id: { _eq: $chainId }
|
|
2745
2781
|
is_enabled: { _eq: true }
|
|
@@ -2752,6 +2788,29 @@ var GET_SEARCH_SUGGESTIONS = (
|
|
|
2752
2788
|
) {
|
|
2753
2789
|
id
|
|
2754
2790
|
name
|
|
2791
|
+
product_website_publications(
|
|
2792
|
+
where: { website_id: { _eq: $websiteId }, is_visible: { _eq: true } }
|
|
2793
|
+
limit: 1
|
|
2794
|
+
) {
|
|
2795
|
+
show_when_out_of_stock
|
|
2796
|
+
}
|
|
2797
|
+
product_variants(where: { is_disabled: { _eq: false } }) {
|
|
2798
|
+
id
|
|
2799
|
+
product_variant_prices(
|
|
2800
|
+
where: {
|
|
2801
|
+
price_type: { _eq: CLIENT }
|
|
2802
|
+
_or: [
|
|
2803
|
+
{ chain_id: { _eq: $chainId } }
|
|
2804
|
+
{ chain_id: { _is_null: true } }
|
|
2805
|
+
]
|
|
2806
|
+
}
|
|
2807
|
+
) {
|
|
2808
|
+
id
|
|
2809
|
+
price
|
|
2810
|
+
price_type
|
|
2811
|
+
chain_id
|
|
2812
|
+
}
|
|
2813
|
+
}
|
|
2755
2814
|
}
|
|
2756
2815
|
brands(
|
|
2757
2816
|
where: {
|
|
@@ -3911,6 +3970,7 @@ function mapProduct(raw, storageUrl, labels, chainId) {
|
|
|
3911
3970
|
createdAt: raw.created_at,
|
|
3912
3971
|
updatedAt: raw.updated_at ?? raw.created_at,
|
|
3913
3972
|
variants,
|
|
3973
|
+
outOfStockVisibilityOverride: raw.product_website_publications?.[0]?.show_when_out_of_stock ?? null,
|
|
3914
3974
|
detailVariants,
|
|
3915
3975
|
media: raw.product_media.map((m) => mapMedia(m, storageUrl)),
|
|
3916
3976
|
attributes: raw.product_attributes.map(
|
|
@@ -4272,7 +4332,7 @@ async function getWebsiteAvailabilityByVariantId(graphqlUrl, getHeaders, variant
|
|
|
4272
4332
|
}
|
|
4273
4333
|
return availabilityByVariantId;
|
|
4274
4334
|
}
|
|
4275
|
-
async function filterProductsForWebsiteStock(graphqlUrl, getHeaders, products, chainId, websiteId) {
|
|
4335
|
+
async function filterProductsForWebsiteStock(graphqlUrl, getHeaders, products, chainId, websiteId, showOutOfStockByDefault = false, onlyInStock = false) {
|
|
4276
4336
|
const variantIds = products.flatMap(
|
|
4277
4337
|
(product) => product.variants.map((variant) => variant.id)
|
|
4278
4338
|
);
|
|
@@ -4298,11 +4358,11 @@ async function filterProductsForWebsiteStock(graphqlUrl, getHeaders, products, c
|
|
|
4298
4358
|
pricing: resolveProductPricing(prices)
|
|
4299
4359
|
};
|
|
4300
4360
|
}).filter(
|
|
4301
|
-
(variant) => inStockVariantIds.has(variant.id) && variant.pricing.currentPrice != null
|
|
4361
|
+
(variant) => (inStockVariantIds.has(variant.id) || !onlyInStock && (product.outOfStockVisibilityOverride ?? showOutOfStockByDefault)) && variant.pricing.currentPrice != null
|
|
4302
4362
|
)
|
|
4303
4363
|
})).filter((product) => product.variants.length > 0);
|
|
4304
4364
|
}
|
|
4305
|
-
async function filterSeoProductsForWebsiteStock(graphqlUrl, getHeaders, products, chainId, websiteId) {
|
|
4365
|
+
async function filterSeoProductsForWebsiteStock(graphqlUrl, getHeaders, products, chainId, websiteId, showOutOfStockByDefault = false) {
|
|
4306
4366
|
const variantIds = products.flatMap(
|
|
4307
4367
|
(product) => product.product_variants.map((variant) => variant.id)
|
|
4308
4368
|
);
|
|
@@ -4324,7 +4384,7 @@ async function filterSeoProductsForWebsiteStock(graphqlUrl, getHeaders, products
|
|
|
4324
4384
|
const pricing = resolveProductPricing(
|
|
4325
4385
|
selectPublicPrices(prices, chainId)
|
|
4326
4386
|
);
|
|
4327
|
-
return inStockVariantIds.has(variant.id) && pricing.currentPrice != null;
|
|
4387
|
+
return (inStockVariantIds.has(variant.id) || (product.product_website_publications?.[0]?.show_when_out_of_stock ?? showOutOfStockByDefault)) && pricing.currentPrice != null;
|
|
4328
4388
|
})
|
|
4329
4389
|
);
|
|
4330
4390
|
}
|
|
@@ -4395,7 +4455,8 @@ function createCatalogModule(graphqlUrl, getHeaders, getContext, storageUrl) {
|
|
|
4395
4455
|
getHeaders,
|
|
4396
4456
|
[mappedProduct],
|
|
4397
4457
|
ctx.chainId,
|
|
4398
|
-
ctx.websiteId
|
|
4458
|
+
ctx.websiteId,
|
|
4459
|
+
ctx.config?.show_out_of_stock_products === true
|
|
4399
4460
|
);
|
|
4400
4461
|
if (!filteredProducts[0]) return null;
|
|
4401
4462
|
const specifications = await loadProductSpecifications([product.id]);
|
|
@@ -4628,7 +4689,8 @@ function createCatalogModule(graphqlUrl, getHeaders, getContext, storageUrl) {
|
|
|
4628
4689
|
getHeaders,
|
|
4629
4690
|
data.products ?? [],
|
|
4630
4691
|
ctx.chainId,
|
|
4631
|
-
ctx.websiteId
|
|
4692
|
+
ctx.websiteId,
|
|
4693
|
+
ctx.config?.show_out_of_stock_products === true
|
|
4632
4694
|
);
|
|
4633
4695
|
const entries = availableProducts.slice(0, limit).map((product) => mapProductSeoEntry(product, storageUrl)).filter((entry) => Boolean(entry));
|
|
4634
4696
|
return {
|
|
@@ -4705,7 +4767,9 @@ function createCatalogModule(graphqlUrl, getHeaders, getContext, storageUrl) {
|
|
|
4705
4767
|
(p) => mapProduct(p, storageUrl, publicAttributeLabels, chainId)
|
|
4706
4768
|
),
|
|
4707
4769
|
chainId,
|
|
4708
|
-
ctx.websiteId
|
|
4770
|
+
ctx.websiteId,
|
|
4771
|
+
ctx.config?.show_out_of_stock_products === true,
|
|
4772
|
+
opts?.inStock === true
|
|
4709
4773
|
);
|
|
4710
4774
|
const specifications = await loadProductSpecifications(
|
|
4711
4775
|
products.map((product) => product.id)
|
|
@@ -4812,6 +4876,7 @@ function createCatalogModule(graphqlUrl, getHeaders, getContext, storageUrl) {
|
|
|
4812
4876
|
{
|
|
4813
4877
|
companyId: ctx.companyId,
|
|
4814
4878
|
chainId,
|
|
4879
|
+
websiteId: ctx.websiteId,
|
|
4815
4880
|
attributeListKey: DEFAULT_FILTER_ATTRIBUTE_LIST_KEY,
|
|
4816
4881
|
where: buildProductWhere(opts.filters ?? {}, chainId)
|
|
4817
4882
|
},
|
|
@@ -4835,7 +4900,7 @@ function createCatalogModule(graphqlUrl, getHeaders, getContext, storageUrl) {
|
|
|
4835
4900
|
variant.product_variant_prices.map(mapPrice),
|
|
4836
4901
|
chainId
|
|
4837
4902
|
);
|
|
4838
|
-
return prices.length > 0 && (availabilityByVariantId.get(variant.id)?.inStock ?? false);
|
|
4903
|
+
return prices.length > 0 && ((availabilityByVariantId.get(variant.id)?.inStock ?? false) || (product.product_website_publications?.[0]?.show_when_out_of_stock ?? ctx.config?.show_out_of_stock_products === true));
|
|
4839
4904
|
});
|
|
4840
4905
|
if (!hasVisibleVariant) continue;
|
|
4841
4906
|
applicableCategories.add(product.category);
|
|
@@ -4923,6 +4988,7 @@ function createCatalogModule(graphqlUrl, getHeaders, getContext, storageUrl) {
|
|
|
4923
4988
|
{
|
|
4924
4989
|
companyId: ctx.companyId,
|
|
4925
4990
|
chainId,
|
|
4991
|
+
websiteId: ctx.websiteId,
|
|
4926
4992
|
attributeListKey: opts?.attributeListKey ?? DEFAULT_FILTER_ATTRIBUTE_LIST_KEY,
|
|
4927
4993
|
where: {
|
|
4928
4994
|
...opts?.categoryName ? { category: { _eq: opts.categoryName } } : {},
|
|
@@ -4977,7 +5043,9 @@ function createCatalogModule(graphqlUrl, getHeaders, getContext, storageUrl) {
|
|
|
4977
5043
|
chainId
|
|
4978
5044
|
),
|
|
4979
5045
|
inStock: availabilityByVariantId.get(variant.id)?.inStock ?? false
|
|
4980
|
-
})).filter(
|
|
5046
|
+
})).filter(
|
|
5047
|
+
(variant) => (variant.inStock || (product.product_website_publications?.[0]?.show_when_out_of_stock ?? ctx.config?.show_out_of_stock_products === true)) && variant.prices.length > 0
|
|
5048
|
+
);
|
|
4981
5049
|
if (visibleVariants.length === 0) continue;
|
|
4982
5050
|
categoryCounts.set(
|
|
4983
5051
|
product.category,
|
|
@@ -5062,6 +5130,7 @@ function createCatalogModule(graphqlUrl, getHeaders, getContext, storageUrl) {
|
|
|
5062
5130
|
"NO_CHAIN"
|
|
5063
5131
|
);
|
|
5064
5132
|
}
|
|
5133
|
+
const chainId = ctx.chainId;
|
|
5065
5134
|
const term = `%${opts.query}%`;
|
|
5066
5135
|
const limit = opts.limit ?? 8;
|
|
5067
5136
|
const data = await executeGraphQL(
|
|
@@ -5069,7 +5138,8 @@ function createCatalogModule(graphqlUrl, getHeaders, getContext, storageUrl) {
|
|
|
5069
5138
|
GET_SEARCH_SUGGESTIONS,
|
|
5070
5139
|
{
|
|
5071
5140
|
companyId: ctx.companyId,
|
|
5072
|
-
chainId
|
|
5141
|
+
chainId,
|
|
5142
|
+
websiteId: ctx.websiteId,
|
|
5073
5143
|
term,
|
|
5074
5144
|
productLimit: Math.min(limit, 5),
|
|
5075
5145
|
brandLimit: Math.max(limit - 5, 3)
|
|
@@ -5077,8 +5147,29 @@ function createCatalogModule(graphqlUrl, getHeaders, getContext, storageUrl) {
|
|
|
5077
5147
|
getHeaders
|
|
5078
5148
|
);
|
|
5079
5149
|
const suggestions = [];
|
|
5150
|
+
const availability = await getWebsiteAvailabilityByVariantId(
|
|
5151
|
+
graphqlUrl,
|
|
5152
|
+
getHeaders,
|
|
5153
|
+
(data.products ?? []).flatMap(
|
|
5154
|
+
(product) => product.product_variants.map((variant) => variant.id)
|
|
5155
|
+
),
|
|
5156
|
+
chainId,
|
|
5157
|
+
ctx.websiteId
|
|
5158
|
+
);
|
|
5080
5159
|
for (const p of data.products ?? []) {
|
|
5081
|
-
|
|
5160
|
+
const showWithoutStock = p.product_website_publications?.[0]?.show_when_out_of_stock ?? ctx.config?.show_out_of_stock_products === true;
|
|
5161
|
+
const isVisible = p.product_variants.some((variant) => {
|
|
5162
|
+
const hasPrice = resolveProductPricing(
|
|
5163
|
+
selectPublicPrices(
|
|
5164
|
+
variant.product_variant_prices.map(mapPrice),
|
|
5165
|
+
chainId
|
|
5166
|
+
)
|
|
5167
|
+
).currentPrice != null;
|
|
5168
|
+
return hasPrice && (showWithoutStock || availability.get(variant.id)?.inStock === true);
|
|
5169
|
+
});
|
|
5170
|
+
if (isVisible) {
|
|
5171
|
+
suggestions.push({ type: "product", text: p.name, id: p.id });
|
|
5172
|
+
}
|
|
5082
5173
|
}
|
|
5083
5174
|
for (const b of data.brands ?? []) {
|
|
5084
5175
|
suggestions.push({ type: "brand", text: b.name, id: b.id });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bacano/sdk",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.7",
|
|
4
4
|
"description": "TypeScript SDK for building websites on the Bacano ERP",
|
|
5
5
|
"main": "./index.cjs",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -23,6 +23,11 @@
|
|
|
23
23
|
"import": "./graphql.js",
|
|
24
24
|
"require": "./graphql.cjs"
|
|
25
25
|
},
|
|
26
|
+
"./icons": {
|
|
27
|
+
"types": "./icons.d.ts",
|
|
28
|
+
"import": "./icons.js",
|
|
29
|
+
"require": "./icons.cjs"
|
|
30
|
+
},
|
|
26
31
|
"./content-management": {
|
|
27
32
|
"types": "./content-management.d.ts",
|
|
28
33
|
"import": "./content-management.js",
|
|
@@ -42,6 +47,11 @@
|
|
|
42
47
|
"types": "./react/forms.d.ts",
|
|
43
48
|
"import": "./react/forms.js",
|
|
44
49
|
"require": "./react/forms.cjs"
|
|
50
|
+
},
|
|
51
|
+
"./react/icon": {
|
|
52
|
+
"types": "./react/icon.d.ts",
|
|
53
|
+
"import": "./react/icon.js",
|
|
54
|
+
"require": "./react/icon.cjs"
|
|
45
55
|
}
|
|
46
56
|
},
|
|
47
57
|
"sideEffects": false,
|