@decocms/apps-vtex 7.27.0 → 7.28.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@decocms/apps-vtex",
3
- "version": "7.27.0",
3
+ "version": "7.28.1",
4
4
  "type": "module",
5
5
  "description": "Deco commerce app: VTEX integration",
6
6
  "repository": {
@@ -51,10 +51,10 @@
51
51
  "lint:unused": "knip"
52
52
  },
53
53
  "dependencies": {
54
- "@decocms/blocks": "7.27.0",
55
- "@decocms/apps-commerce": "7.27.0",
56
- "@decocms/apps-website": "7.27.0",
57
- "@decocms/tanstack": "7.27.0"
54
+ "@decocms/blocks": "7.28.1",
55
+ "@decocms/apps-commerce": "7.28.1",
56
+ "@decocms/apps-website": "7.28.1",
57
+ "@decocms/tanstack": "7.28.1"
58
58
  },
59
59
  "peerDependencies": {
60
60
  "@tanstack/react-query": ">=5.0.0",
@@ -23,6 +23,7 @@ import {
23
23
  toAdditionalPropertySpecification,
24
24
  toBrand,
25
25
  toPostalAddress,
26
+ toProductShelf,
26
27
  toProductVariant,
27
28
  } from "../transform";
28
29
 
@@ -696,3 +697,68 @@ describe("toProductVariant", () => {
696
697
  expect(result.productID).toBe("SKU1");
697
698
  });
698
699
  });
700
+
701
+ describe("toProductShelf", () => {
702
+ const makeSku = (overrides: Record<string, unknown> = {}) =>
703
+ ({
704
+ itemId: "SKU1",
705
+ name: "Test SKU",
706
+ referenceId: [{ Key: "RefId", Value: "REF-SKU1" }],
707
+ images: [{ imageUrl: "https://img.com/1.jpg", imageText: "Front", imageLabel: "front" }],
708
+ sellers: [
709
+ {
710
+ sellerId: "1",
711
+ sellerName: "Seller One",
712
+ commertialOffer: {
713
+ AvailableQuantity: 10,
714
+ Price: 99.9,
715
+ ListPrice: 129.9,
716
+ spotPrice: 89.9,
717
+ PriceValidUntil: "2025-12-31",
718
+ Installments: [],
719
+ GiftSkuIds: [],
720
+ teasers: [],
721
+ },
722
+ },
723
+ ],
724
+ // Campanha is the VTEX spec MonteCarlo uses to tag launches ("Lançamentos").
725
+ variations: [
726
+ { name: "Cor", values: ["Preto"] },
727
+ { name: "Campanha", values: ["Lançamentos"] },
728
+ ],
729
+ }) as any;
730
+
731
+ const makeProduct = (overrides: Record<string, unknown> = {}) =>
732
+ ({
733
+ origin: "intelligent-search",
734
+ productId: "PROD1",
735
+ productName: "Test Product",
736
+ brand: "TestBrand",
737
+ linkText: "test-product",
738
+ categories: ["/Electronics/"],
739
+ categoriesIds: ["/1/"],
740
+ categoryId: "1",
741
+ productClusters: [{ id: "100", name: "Sale" }],
742
+ clusterHighlights: [],
743
+ items: [makeSku()],
744
+ ...overrides,
745
+ }) as any;
746
+
747
+ const options = { baseUrl: "https://example.com", priceCurrency: "BRL" };
748
+
749
+ it("keeps the Campanha launch spec in product-level additionalProperty", () => {
750
+ const result = toProductShelf(makeProduct(), makeSku(), 0, options);
751
+ expect(result.additionalProperty).toEqual(
752
+ expect.arrayContaining([
753
+ expect.objectContaining({ name: "Campanha", value: "Lançamentos" }),
754
+ ]),
755
+ );
756
+ });
757
+
758
+ it("populates isVariantOf.additionalProperty with the launch spec (ReleaseFlag reads it)", () => {
759
+ const result = toProductShelf(makeProduct(), makeSku(), 0, options);
760
+ const groupProps = result.isVariantOf?.additionalProperty ?? [];
761
+ expect(groupProps.length).toBeGreaterThan(0);
762
+ expect(groupProps.some((p) => p.value === "Lançamentos")).toBe(true);
763
+ });
764
+ });
@@ -576,6 +576,7 @@ const buildOfferShelf = (offer: Offer): Offer => {
576
576
  const SHELF_PROPERTY_NAMES = new Set([
577
577
  "category",
578
578
  "cluster",
579
+ "Campanha",
579
580
  "Cor",
580
581
  "Tamanho",
581
582
  "Voltagem",
@@ -621,6 +622,19 @@ export const toProductShelf = <P extends LegacyProductVTEX | ProductVTEX>(
621
622
  const bestOffer = allOffers[0];
622
623
  const leanOffers = bestOffer ? [buildOfferShelf(bestOffer)] : [];
623
624
 
625
+ // additionalProperty: filter to known-used names
626
+ const specificationsAdditionalProperty = isLegacySku(sku)
627
+ ? toAdditionalPropertiesLegacy(sku)
628
+ : toAdditionalProperties(sku);
629
+ const categoryAdditionalProperties = toAdditionalPropertyCategories(product) ?? [];
630
+ const clusterAdditionalProperties = toAdditionalPropertyClusters(product) ?? [];
631
+
632
+ const additionalProperty = [
633
+ ...specificationsAdditionalProperty,
634
+ ...categoryAdditionalProperties,
635
+ ...clusterAdditionalProperties,
636
+ ].filter((prop) => SHELF_PROPERTY_NAMES.has(prop.name ?? ""));
637
+
624
638
  // isVariantOf: single in-stock variant at level 0
625
639
  const isVariantOf =
626
640
  level < 1
@@ -633,24 +647,14 @@ export const toProductShelf = <P extends LegacyProductVTEX | ProductVTEX>(
633
647
  hasVariant: singleVariant,
634
648
  url: getProductGroupURL(baseUrl, product).href,
635
649
  name: product.productName,
636
- additionalProperty: [],
650
+ // Carry the shelf-safe group props (incl. "Campanha") so ProductCard
651
+ // flags that read isVariantOf.additionalProperty (e.g. ReleaseFlag ->
652
+ // "Lançamento") still fire on shelf/carousel cards.
653
+ additionalProperty,
637
654
  } satisfies ProductGroup;
638
655
  })()
639
656
  : undefined;
640
657
 
641
- // additionalProperty: filter to known-used names
642
- const specificationsAdditionalProperty = isLegacySku(sku)
643
- ? toAdditionalPropertiesLegacy(sku)
644
- : toAdditionalProperties(sku);
645
- const categoryAdditionalProperties = toAdditionalPropertyCategories(product) ?? [];
646
- const clusterAdditionalProperties = toAdditionalPropertyClusters(product) ?? [];
647
-
648
- const additionalProperty = [
649
- ...specificationsAdditionalProperty,
650
- ...categoryAdditionalProperties,
651
- ...clusterAdditionalProperties,
652
- ].filter((prop) => SHELF_PROPERTY_NAMES.has(prop.name ?? ""));
653
-
654
658
  const categoriesString = splitCategory(product.categories[0]).join(DEFAULT_CATEGORY_SEPARATOR);
655
659
 
656
660
  return {