@decocms/apps-vtex 7.28.0 → 7.28.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@decocms/apps-vtex",
3
- "version": "7.28.0",
3
+ "version": "7.28.2",
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.28.0",
55
- "@decocms/apps-commerce": "7.28.0",
56
- "@decocms/apps-website": "7.28.0",
57
- "@decocms/tanstack": "7.28.0"
54
+ "@decocms/blocks": "7.28.2",
55
+ "@decocms/apps-commerce": "7.28.2",
56
+ "@decocms/apps-website": "7.28.2",
57
+ "@decocms/tanstack": "7.28.2"
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,73 @@ 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
+ variations: [{ name: "Cor", values: ["Preto"] }],
725
+ }) as any;
726
+
727
+ // Campanha is a PRODUCT specification (in specificationGroups), NOT a sku.variation.
728
+ // It is the marker MonteCarlo uses to tag launches ("Lançamentos").
729
+ const makeProduct = (overrides: Record<string, unknown> = {}) =>
730
+ ({
731
+ origin: "intelligent-search",
732
+ productId: "PROD1",
733
+ productName: "Test Product",
734
+ brand: "TestBrand",
735
+ linkText: "test-product",
736
+ categories: ["/Electronics/"],
737
+ categoriesIds: ["/1/"],
738
+ categoryId: "1",
739
+ productClusters: [{ id: "100", name: "Sale" }],
740
+ clusterHighlights: [],
741
+ specificationGroups: [
742
+ { name: "Campanha", specifications: [{ name: "Campanha", values: ["Lançamentos"] }] },
743
+ ],
744
+ items: [makeSku()],
745
+ ...overrides,
746
+ }) as any;
747
+
748
+ const options = { baseUrl: "https://example.com", priceCurrency: "BRL" };
749
+
750
+ it("surfaces the Campanha launch spec in isVariantOf.additionalProperty (ReleaseFlag reads it)", () => {
751
+ const result = toProductShelf(makeProduct(), makeSku(), 0, options);
752
+ const groupProps = result.isVariantOf?.additionalProperty ?? [];
753
+ expect(groupProps).toEqual(
754
+ expect.arrayContaining([
755
+ expect.objectContaining({ name: "Campanha", value: "Lançamentos" }),
756
+ ]),
757
+ );
758
+ });
759
+
760
+ it("leaves isVariantOf.additionalProperty empty when there is no shelf-safe group spec", () => {
761
+ const result = toProductShelf(
762
+ makeProduct({ specificationGroups: [] }),
763
+ makeSku(),
764
+ 0,
765
+ options,
766
+ );
767
+ expect(result.isVariantOf?.additionalProperty).toEqual([]);
768
+ });
769
+ });
@@ -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,28 @@ 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
+
638
+ // Product-group specs (from specificationGroups) filtered to shelf-safe names.
639
+ // Launch markers like "Campanha" live here, NOT in sku.variations, so they only
640
+ // reach the card through the ProductGroup's additionalProperty (mirrors toProduct).
641
+ const groupAdditionalProperty = (
642
+ isLegacyProduct(product)
643
+ ? legacyToProductGroupAdditionalProperties(product)
644
+ : toProductGroupAdditionalProperties(product)
645
+ ).filter((prop) => SHELF_PROPERTY_NAMES.has(prop.name ?? ""));
646
+
624
647
  // isVariantOf: single in-stock variant at level 0
625
648
  const isVariantOf =
626
649
  level < 1
@@ -633,24 +656,14 @@ export const toProductShelf = <P extends LegacyProductVTEX | ProductVTEX>(
633
656
  hasVariant: singleVariant,
634
657
  url: getProductGroupURL(baseUrl, product).href,
635
658
  name: product.productName,
636
- additionalProperty: [],
659
+ // Carry the shelf-safe group specs (incl. "Campanha") so ProductCard
660
+ // flags that read isVariantOf.additionalProperty (e.g. ReleaseFlag ->
661
+ // "Lançamento") still fire on shelf/carousel cards.
662
+ additionalProperty: groupAdditionalProperty,
637
663
  } satisfies ProductGroup;
638
664
  })()
639
665
  : undefined;
640
666
 
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
667
  const categoriesString = splitCategory(product.categories[0]).join(DEFAULT_CATEGORY_SEPARATOR);
655
668
 
656
669
  return {