@plasmicpkgs/commerce-shopify 0.0.166 → 0.0.167

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.
@@ -756,29 +756,32 @@ var normalizeProductOption = function normalizeProductOption(_ref2) {
756
756
  })
757
757
  };
758
758
  };
759
- var normalizeProductImages = function normalizeProductImages(_ref3) {
760
- var edges = _ref3.edges;
761
- return edges == null ? void 0 : edges.map(function (_ref4) {
762
- var _ref4$node = _ref4.node,
763
- url = _ref4$node.originalSrc,
764
- rest = _objectWithoutPropertiesLoose(_ref4$node, _excluded);
765
- return _extends({
766
- url: url
767
- }, rest);
759
+ var normalizeImage = function normalizeImage(_ref3) {
760
+ var url = _ref3.originalSrc,
761
+ rest = _objectWithoutPropertiesLoose(_ref3, _excluded);
762
+ return _extends({
763
+ url: url
764
+ }, rest);
765
+ };
766
+ var normalizeProductImages = function normalizeProductImages(_ref4) {
767
+ var edges = _ref4.edges;
768
+ return edges == null ? void 0 : edges.map(function (_ref5) {
769
+ var node = _ref5.node;
770
+ return normalizeImage(node);
768
771
  });
769
772
  };
770
- var normalizeProductVariants = function normalizeProductVariants(_ref5) {
771
- var edges = _ref5.edges;
772
- return edges == null ? void 0 : edges.map(function (_ref6) {
773
- var _ref6$node = _ref6.node,
774
- id = _ref6$node.id,
775
- selectedOptions = _ref6$node.selectedOptions,
776
- sku = _ref6$node.sku,
777
- title = _ref6$node.title,
778
- priceV2 = _ref6$node.priceV2,
779
- compareAtPriceV2 = _ref6$node.compareAtPriceV2,
780
- requiresShipping = _ref6$node.requiresShipping,
781
- availableForSale = _ref6$node.availableForSale;
773
+ var normalizeProductVariants = function normalizeProductVariants(_ref6) {
774
+ var edges = _ref6.edges;
775
+ return edges == null ? void 0 : edges.map(function (_ref7) {
776
+ var _ref7$node = _ref7.node,
777
+ id = _ref7$node.id,
778
+ selectedOptions = _ref7$node.selectedOptions,
779
+ sku = _ref7$node.sku,
780
+ title = _ref7$node.title,
781
+ priceV2 = _ref7$node.priceV2,
782
+ compareAtPriceV2 = _ref7$node.compareAtPriceV2,
783
+ requiresShipping = _ref7$node.requiresShipping,
784
+ availableForSale = _ref7$node.availableForSale;
782
785
  return {
783
786
  id: id,
784
787
  name: selectedOptions.some(function (o) {
@@ -789,9 +792,9 @@ var normalizeProductVariants = function normalizeProductVariants(_ref5) {
789
792
  listPrice: +(compareAtPriceV2 == null ? void 0 : compareAtPriceV2.amount),
790
793
  requiresShipping: requiresShipping,
791
794
  availableForSale: availableForSale,
792
- options: selectedOptions.map(function (_ref7) {
793
- var name = _ref7.name,
794
- value = _ref7.value;
795
+ options: selectedOptions.map(function (_ref8) {
796
+ var name = _ref8.name,
797
+ value = _ref8.value;
795
798
  var options = normalizeProductOption({
796
799
  id: id,
797
800
  name: name,
@@ -802,18 +805,18 @@ var normalizeProductVariants = function normalizeProductVariants(_ref5) {
802
805
  };
803
806
  });
804
807
  };
805
- function normalizeProduct(_ref8) {
806
- var id = _ref8.id,
807
- name = _ref8.title,
808
- vendor = _ref8.vendor,
809
- images = _ref8.images,
810
- variants = _ref8.variants,
811
- description = _ref8.description,
812
- descriptionHtml = _ref8.descriptionHtml,
813
- handle = _ref8.handle,
814
- priceRange = _ref8.priceRange,
815
- options = _ref8.options,
816
- rest = _objectWithoutPropertiesLoose(_ref8, _excluded2);
808
+ function normalizeProduct(_ref9) {
809
+ var id = _ref9.id,
810
+ name = _ref9.title,
811
+ vendor = _ref9.vendor,
812
+ images = _ref9.images,
813
+ variants = _ref9.variants,
814
+ description = _ref9.description,
815
+ descriptionHtml = _ref9.descriptionHtml,
816
+ handle = _ref9.handle,
817
+ priceRange = _ref9.priceRange,
818
+ options = _ref9.options,
819
+ rest = _objectWithoutPropertiesLoose(_ref9, _excluded2);
817
820
  return _extends({
818
821
  id: id,
819
822
  name: name,
@@ -854,13 +857,13 @@ function normalizeCart(checkout) {
854
857
  discounts: []
855
858
  };
856
859
  }
857
- function normalizeLineItem(_ref9) {
860
+ function normalizeLineItem(_ref10) {
858
861
  var _variant$sku, _variant$image, _variant$requiresShip, _variant$priceV, _variant$compareAtPri, _variant$product;
859
- var _ref9$node = _ref9.node,
860
- id = _ref9$node.id,
861
- title = _ref9$node.title,
862
- variant = _ref9$node.variant,
863
- quantity = _ref9$node.quantity;
862
+ var _ref10$node = _ref10.node,
863
+ id = _ref10$node.id,
864
+ title = _ref10$node.title,
865
+ variant = _ref10$node.variant,
866
+ quantity = _ref10$node.quantity;
864
867
  return {
865
868
  id: id,
866
869
  variantId: String(variant == null ? void 0 : variant.id),
@@ -896,17 +899,19 @@ export const normalizePage = (
896
899
  export const normalizePages = (edges: PageEdge[], locale?: string): Page[] =>
897
900
  edges?.map((edge) => normalizePage(edge.node, locale))
898
901
  */
899
- var normalizeCategory = function normalizeCategory(_ref10) {
900
- var name = _ref10.title,
901
- handle = _ref10.handle,
902
- id = _ref10.id,
903
- products = _ref10.products;
902
+ var normalizeCategory = function normalizeCategory(_ref11) {
903
+ var name = _ref11.title,
904
+ handle = _ref11.handle,
905
+ id = _ref11.id,
906
+ products = _ref11.products,
907
+ image = _ref11.image;
904
908
  return {
905
909
  id: id,
906
910
  name: name,
907
911
  slug: handle,
908
912
  path: "/" + handle,
909
- isEmpty: products.edges.length === 0
913
+ isEmpty: products.edges.length === 0,
914
+ images: image ? [normalizeImage(image)] : undefined
910
915
  };
911
916
  };
912
917
 
@@ -948,7 +953,12 @@ var checkoutToCart = function checkoutToCart(checkoutPayload) {
948
953
  };
949
954
 
950
955
  var simpleProductConnection = "\nfragment simpleProductConnection on ProductConnection {\n edges {\n node {\n id\n }\n }\n}\n";
951
- var collectionFieldsFragment = "\n fragment collectionFieldsFragment on Collection {\n id\n title\n handle,\n products(first: $first) {\n ...simpleProductConnection\n }\n }\n " + simpleProductConnection + "\n";
956
+ /*
957
+ Forked from https://github.com/vercel/commerce/tree/main/packages/shopify/src
958
+ Changes:
959
+ - Fetch image.
960
+ */
961
+ var collectionFieldsFragment = "\n fragment collectionFieldsFragment on Collection {\n id\n title\n handle\n image {\n originalSrc\n altText\n width\n height\n }\n products(first: $first) {\n ...simpleProductConnection\n }\n }\n " + simpleProductConnection + "\n";
952
962
  var getCollectionQueryById = /* GraphQL */"\n query getSiteCollection($id: ID, $handle: String, $first: Int = 1) {\n collection(id: $id, handle: $handle) {\n ...collectionFieldsFragment\n }\n }\n " + collectionFieldsFragment + "\n";
953
963
 
954
964
  /*