@jay-framework/wix-stores 0.17.1 → 0.17.2

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.
@@ -475,9 +475,7 @@ function setupCardInteractions(refs, cards, storesContext) {
475
475
  const productIndex = currentResults.findIndex((p) => p._id === productId);
476
476
  if (productIndex === -1) return;
477
477
  const product = currentResults[productIndex];
478
- const textChoice = product.secondQuickOption?.choices?.find(
479
- (c) => c.choiceId === choiceId
480
- );
478
+ const textChoice = product.secondQuickOption?.choices?.find((c) => c.choiceId === choiceId);
481
479
  const selectedColor = product.quickOption?.choices?.find((c) => c.isSelected);
482
480
  if (!textChoice || !textChoice.inStock) return;
483
481
  cards.set(
package/dist/index.d.ts CHANGED
@@ -893,9 +893,7 @@ interface RelatedProductsProps {
893
893
  limit?: number;
894
894
  }
895
895
  interface RelatedSlowCarryForward {
896
- categoryId: string;
897
- productId: string;
898
- limit: number;
896
+ products: ProductCardViewState[];
899
897
  }
900
898
  declare const relatedProducts: _jay_framework_fullstack_component.JayStackComponentDefinition<RelatedProductsRefs, RelatedProductsSlowViewState, RelatedProductsFastViewState, RelatedProductsInteractiveViewState, [RelatedSlowCarryForward, WixStoresService], [Signals<RelatedProductsFastViewState>, Record<string, never>, WixStoresContext], PageProps & RelatedProductsProps, {}, _jay_framework_component.JayComponentCore<PageProps & RelatedProductsProps, RelatedProductsInteractiveViewState>>;
901
899
 
package/dist/index.js CHANGED
@@ -1554,11 +1554,14 @@ const DEFAULT_LIMIT = 4;
1554
1554
  async function renderSlowlyChanging$1(props, wixStores) {
1555
1555
  const Pipeline = RenderPipeline.for();
1556
1556
  const limit = props.limit ?? DEFAULT_LIMIT;
1557
+ const categorySlug = props.categorySlug;
1558
+ if (!categorySlug) {
1559
+ return Pipeline.ok({ categoryName: "" }).toPhaseOutput((viewState) => ({
1560
+ viewState,
1561
+ carryForward: { products: [] }
1562
+ }));
1563
+ }
1557
1564
  return Pipeline.try(async () => {
1558
- const categorySlug = props.categorySlug;
1559
- if (!categorySlug) {
1560
- return { categoryId: "", categoryName: "" };
1561
- }
1562
1565
  const tree = await wixStores.getCategoryTree();
1563
1566
  let categoryId = "";
1564
1567
  let categoryName = "";
@@ -1569,55 +1572,35 @@ async function renderSlowlyChanging$1(props, wixStores) {
1569
1572
  break;
1570
1573
  }
1571
1574
  }
1572
- if (categoryId) {
1573
- try {
1574
- const result = await wixStores.categories.queryCategories({ treeReference: { appNamespace: "@wix/stores" } }).eq("_id", categoryId).limit(1).find();
1575
- if (result.items?.[0]?.name) {
1576
- categoryName = result.items[0].name;
1577
- }
1578
- } catch {
1579
- }
1575
+ if (!categoryId) {
1576
+ return { categoryName: "", products: [] };
1577
+ }
1578
+ const [categoryResult, searchResult] = await Promise.all([
1579
+ wixStores.categories.queryCategories({ treeReference: { appNamespace: "@wix/stores" } }).eq("_id", categoryId).limit(1).find().catch(() => null),
1580
+ searchProducts({
1581
+ query: "",
1582
+ filters: { categoryIds: [categoryId] },
1583
+ pageSize: limit + 1
1584
+ })
1585
+ ]);
1586
+ if (categoryResult?.items?.[0]?.name) {
1587
+ categoryName = categoryResult.items[0].name;
1580
1588
  }
1581
- return { categoryId, categoryName };
1589
+ const products = searchResult.products.filter((p) => p._id !== props.productId).slice(0, limit);
1590
+ return { categoryName, products };
1582
1591
  }).recover((error) => {
1583
1592
  return handleError(error);
1584
- }).toPhaseOutput(({ categoryId, categoryName }) => ({
1585
- viewState: {
1586
- categoryName
1587
- },
1588
- carryForward: {
1589
- categoryId,
1590
- productId: props.productId,
1591
- limit
1592
- }
1593
+ }).toPhaseOutput(({ categoryName, products }) => ({
1594
+ viewState: { categoryName },
1595
+ carryForward: { products }
1593
1596
  }));
1594
1597
  }
1595
1598
  async function renderFastChanging(_props, slowCarryForward, _wixStores) {
1596
1599
  const Pipeline = RenderPipeline.for();
1597
- const { categoryId, productId, limit } = slowCarryForward;
1598
- if (!categoryId) {
1599
- return Pipeline.ok({
1600
- products: [],
1601
- hasProducts: false
1602
- }).toPhaseOutput((viewState) => ({ viewState, carryForward: {} }));
1603
- }
1604
- return Pipeline.try(async () => {
1605
- const result = await searchProducts({
1606
- query: "",
1607
- filters: { categoryIds: [categoryId] },
1608
- pageSize: limit + 1
1609
- });
1610
- const products = result.products.filter((p) => p._id !== productId).slice(0, limit);
1611
- return {
1612
- products,
1613
- hasProducts: products.length > 0
1614
- };
1615
- }).recover((error) => {
1616
- console.error("Failed to load related products:", error);
1617
- return Pipeline.ok({
1618
- products: [],
1619
- hasProducts: false
1620
- });
1600
+ const { products } = slowCarryForward;
1601
+ return Pipeline.ok({
1602
+ products,
1603
+ hasProducts: products.length > 0
1621
1604
  }).toPhaseOutput((viewState) => ({ viewState, carryForward: {} }));
1622
1605
  }
1623
1606
  const relatedProducts = makeJayStackComponent().withProps().withServices(WIX_STORES_SERVICE_MARKER).withSlowlyRender(renderSlowlyChanging$1).withFastRender(renderFastChanging);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jay-framework/wix-stores",
3
- "version": "0.17.1",
3
+ "version": "0.17.2",
4
4
  "type": "module",
5
5
  "description": "Wix Stores API client for Jay Framework",
6
6
  "license": "Apache-2.0",
@@ -38,16 +38,16 @@
38
38
  "test": ":"
39
39
  },
40
40
  "dependencies": {
41
- "@jay-framework/component": "^0.17.1",
42
- "@jay-framework/fullstack-component": "^0.17.1",
43
- "@jay-framework/reactive": "^0.17.1",
44
- "@jay-framework/runtime": "^0.17.1",
45
- "@jay-framework/secure": "^0.17.1",
46
- "@jay-framework/stack-client-runtime": "^0.17.1",
47
- "@jay-framework/stack-server-runtime": "^0.17.1",
48
- "@jay-framework/wix-cart": "^0.17.1",
49
- "@jay-framework/wix-server-client": "^0.17.1",
50
- "@jay-framework/wix-utils": "^0.17.1",
41
+ "@jay-framework/component": "^0.17.2",
42
+ "@jay-framework/fullstack-component": "^0.17.2",
43
+ "@jay-framework/reactive": "^0.17.2",
44
+ "@jay-framework/runtime": "^0.17.2",
45
+ "@jay-framework/secure": "^0.17.2",
46
+ "@jay-framework/stack-client-runtime": "^0.17.2",
47
+ "@jay-framework/stack-server-runtime": "^0.17.2",
48
+ "@jay-framework/wix-cart": "^0.17.2",
49
+ "@jay-framework/wix-server-client": "^0.17.2",
50
+ "@jay-framework/wix-utils": "^0.17.2",
51
51
  "@wix/categories": "^1.0.185",
52
52
  "@wix/data-extension-schema": "^1.0.221",
53
53
  "@wix/sdk": "^1.21.5",
@@ -59,10 +59,10 @@
59
59
  "@babel/core": "^7.23.7",
60
60
  "@babel/preset-env": "^7.23.8",
61
61
  "@babel/preset-typescript": "^7.23.3",
62
- "@jay-framework/compiler-jay-stack": "^0.17.1",
63
- "@jay-framework/jay-cli": "^0.17.1",
64
- "@jay-framework/jay-stack-cli": "^0.17.1",
65
- "@jay-framework/vite-plugin": "^0.17.1",
62
+ "@jay-framework/compiler-jay-stack": "^0.17.2",
63
+ "@jay-framework/jay-cli": "^0.17.2",
64
+ "@jay-framework/jay-stack-cli": "^0.17.2",
65
+ "@jay-framework/vite-plugin": "^0.17.2",
66
66
  "nodemon": "^3.0.3",
67
67
  "rimraf": "^5.0.5",
68
68
  "tslib": "^2.6.2",