@plasmicpkgs/commerce-shopify 0.0.165 → 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.
@@ -763,29 +763,32 @@ var normalizeProductOption = function normalizeProductOption(_ref2) {
763
763
  })
764
764
  };
765
765
  };
766
- var normalizeProductImages = function normalizeProductImages(_ref3) {
767
- var edges = _ref3.edges;
768
- return edges == null ? void 0 : edges.map(function (_ref4) {
769
- var _ref4$node = _ref4.node,
770
- url = _ref4$node.originalSrc,
771
- rest = _objectWithoutPropertiesLoose(_ref4$node, _excluded);
772
- return _extends({
773
- url: url
774
- }, rest);
766
+ var normalizeImage = function normalizeImage(_ref3) {
767
+ var url = _ref3.originalSrc,
768
+ rest = _objectWithoutPropertiesLoose(_ref3, _excluded);
769
+ return _extends({
770
+ url: url
771
+ }, rest);
772
+ };
773
+ var normalizeProductImages = function normalizeProductImages(_ref4) {
774
+ var edges = _ref4.edges;
775
+ return edges == null ? void 0 : edges.map(function (_ref5) {
776
+ var node = _ref5.node;
777
+ return normalizeImage(node);
775
778
  });
776
779
  };
777
- var normalizeProductVariants = function normalizeProductVariants(_ref5) {
778
- var edges = _ref5.edges;
779
- return edges == null ? void 0 : edges.map(function (_ref6) {
780
- var _ref6$node = _ref6.node,
781
- id = _ref6$node.id,
782
- selectedOptions = _ref6$node.selectedOptions,
783
- sku = _ref6$node.sku,
784
- title = _ref6$node.title,
785
- priceV2 = _ref6$node.priceV2,
786
- compareAtPriceV2 = _ref6$node.compareAtPriceV2,
787
- requiresShipping = _ref6$node.requiresShipping,
788
- availableForSale = _ref6$node.availableForSale;
780
+ var normalizeProductVariants = function normalizeProductVariants(_ref6) {
781
+ var edges = _ref6.edges;
782
+ return edges == null ? void 0 : edges.map(function (_ref7) {
783
+ var _ref7$node = _ref7.node,
784
+ id = _ref7$node.id,
785
+ selectedOptions = _ref7$node.selectedOptions,
786
+ sku = _ref7$node.sku,
787
+ title = _ref7$node.title,
788
+ priceV2 = _ref7$node.priceV2,
789
+ compareAtPriceV2 = _ref7$node.compareAtPriceV2,
790
+ requiresShipping = _ref7$node.requiresShipping,
791
+ availableForSale = _ref7$node.availableForSale;
789
792
  return {
790
793
  id: id,
791
794
  name: selectedOptions.some(function (o) {
@@ -796,9 +799,9 @@ var normalizeProductVariants = function normalizeProductVariants(_ref5) {
796
799
  listPrice: +(compareAtPriceV2 == null ? void 0 : compareAtPriceV2.amount),
797
800
  requiresShipping: requiresShipping,
798
801
  availableForSale: availableForSale,
799
- options: selectedOptions.map(function (_ref7) {
800
- var name = _ref7.name,
801
- value = _ref7.value;
802
+ options: selectedOptions.map(function (_ref8) {
803
+ var name = _ref8.name,
804
+ value = _ref8.value;
802
805
  var options = normalizeProductOption({
803
806
  id: id,
804
807
  name: name,
@@ -809,18 +812,18 @@ var normalizeProductVariants = function normalizeProductVariants(_ref5) {
809
812
  };
810
813
  });
811
814
  };
812
- function normalizeProduct(_ref8) {
813
- var id = _ref8.id,
814
- name = _ref8.title,
815
- vendor = _ref8.vendor,
816
- images = _ref8.images,
817
- variants = _ref8.variants,
818
- description = _ref8.description,
819
- descriptionHtml = _ref8.descriptionHtml,
820
- handle = _ref8.handle,
821
- priceRange = _ref8.priceRange,
822
- options = _ref8.options,
823
- rest = _objectWithoutPropertiesLoose(_ref8, _excluded2);
815
+ function normalizeProduct(_ref9) {
816
+ var id = _ref9.id,
817
+ name = _ref9.title,
818
+ vendor = _ref9.vendor,
819
+ images = _ref9.images,
820
+ variants = _ref9.variants,
821
+ description = _ref9.description,
822
+ descriptionHtml = _ref9.descriptionHtml,
823
+ handle = _ref9.handle,
824
+ priceRange = _ref9.priceRange,
825
+ options = _ref9.options,
826
+ rest = _objectWithoutPropertiesLoose(_ref9, _excluded2);
824
827
  return _extends({
825
828
  id: id,
826
829
  name: name,
@@ -861,13 +864,13 @@ function normalizeCart(checkout) {
861
864
  discounts: []
862
865
  };
863
866
  }
864
- function normalizeLineItem(_ref9) {
867
+ function normalizeLineItem(_ref10) {
865
868
  var _variant$sku, _variant$image, _variant$requiresShip, _variant$priceV, _variant$compareAtPri, _variant$product;
866
- var _ref9$node = _ref9.node,
867
- id = _ref9$node.id,
868
- title = _ref9$node.title,
869
- variant = _ref9$node.variant,
870
- quantity = _ref9$node.quantity;
869
+ var _ref10$node = _ref10.node,
870
+ id = _ref10$node.id,
871
+ title = _ref10$node.title,
872
+ variant = _ref10$node.variant,
873
+ quantity = _ref10$node.quantity;
871
874
  return {
872
875
  id: id,
873
876
  variantId: String(variant == null ? void 0 : variant.id),
@@ -903,17 +906,19 @@ export const normalizePage = (
903
906
  export const normalizePages = (edges: PageEdge[], locale?: string): Page[] =>
904
907
  edges?.map((edge) => normalizePage(edge.node, locale))
905
908
  */
906
- var normalizeCategory = function normalizeCategory(_ref10) {
907
- var name = _ref10.title,
908
- handle = _ref10.handle,
909
- id = _ref10.id,
910
- products = _ref10.products;
909
+ var normalizeCategory = function normalizeCategory(_ref11) {
910
+ var name = _ref11.title,
911
+ handle = _ref11.handle,
912
+ id = _ref11.id,
913
+ products = _ref11.products,
914
+ image = _ref11.image;
911
915
  return {
912
916
  id: id,
913
917
  name: name,
914
918
  slug: handle,
915
919
  path: "/" + handle,
916
- isEmpty: products.edges.length === 0
920
+ isEmpty: products.edges.length === 0,
921
+ images: image ? [normalizeImage(image)] : undefined
917
922
  };
918
923
  };
919
924
 
@@ -955,7 +960,12 @@ var checkoutToCart = function checkoutToCart(checkoutPayload) {
955
960
  };
956
961
 
957
962
  var simpleProductConnection = "\nfragment simpleProductConnection on ProductConnection {\n edges {\n node {\n id\n }\n }\n}\n";
958
- var collectionFieldsFragment = "\n fragment collectionFieldsFragment on Collection {\n id\n title\n handle,\n products(first: $first) {\n ...simpleProductConnection\n }\n }\n " + simpleProductConnection + "\n";
963
+ /*
964
+ Forked from https://github.com/vercel/commerce/tree/main/packages/shopify/src
965
+ Changes:
966
+ - Fetch image.
967
+ */
968
+ 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";
959
969
  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";
960
970
 
961
971
  /*