@plasmicpkgs/commerce-saleor 0.0.109 → 0.0.112

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.
@@ -885,7 +885,7 @@ var ProductConnection = /* GraphQL */"\n fragment ProductConnection on ProductC
885
885
  Forked from https://github.com/vercel/commerce/tree/main/packages/saleor/src
886
886
  Changes: None
887
887
  */
888
- var CheckoutDetails = /* GraphQL */"\n fragment CheckoutDetails on Checkout {\n id\n token\n created\n totalPrice {\n currency\n gross {\n amount\n }\n }\n subtotalPrice {\n currency\n gross {\n amount\n }\n }\n\n lines {\n id\n variant {\n id\n name\n sku\n product {\n name\n slug\n }\n media {\n url\n }\n pricing {\n price {\n gross {\n amount\n }\n }\n }\n }\n quantity\n totalPrice {\n currency\n gross {\n amount\n }\n }\n }\n }\n";
888
+ var CheckoutDetails = /* GraphQL */"\n fragment CheckoutDetails on Checkout {\n id\n token\n created\n totalPrice {\n currency\n gross {\n amount\n }\n }\n subtotalPrice {\n currency\n gross {\n amount\n }\n }\n\n lines {\n id\n variant {\n id\n name\n sku\n product {\n name\n slug\n id\n }\n media {\n url\n }\n pricing {\n price {\n gross {\n amount\n }\n }\n }\n }\n quantity\n totalPrice {\n currency\n gross {\n amount\n }\n }\n }\n }\n";
889
889
 
890
890
  /*
891
891
  Forked from https://github.com/vercel/commerce/tree/main/packages/saleor/src
@@ -951,18 +951,19 @@ var checkoutCreate = /*#__PURE__*/function () {
951
951
  }();
952
952
 
953
953
  var _excluded = ["id", "name", "media", "variants", "description", "slug", "pricing"];
954
+ /* eslint-disable */
954
955
  /*
955
956
  Forked from https://github.com/vercel/commerce/tree/main/packages/saleor/src
956
957
  Changes: None
957
958
  */
958
959
  // TODO: Check nextjs-commerce bug if no images are added for a product
959
- var placeholderImg = '/product-img-placeholder.svg';
960
+ var placeholderImg = "/product-img-placeholder.svg";
960
961
  var money = function money(_ref) {
961
962
  var amount = _ref.amount,
962
963
  currency = _ref.currency;
963
964
  return {
964
965
  value: +amount,
965
- currencyCode: currency || 'USD'
966
+ currencyCode: currency || "USD"
966
967
  };
967
968
  };
968
969
  var normalizeProductOptions = function normalizeProductOptions(options) {
@@ -984,9 +985,9 @@ var normalizeProductOptions = function normalizeProductOptions(options) {
984
985
  });
985
986
  }
986
987
  return acc.concat({
987
- __typename: 'MultipleChoiceOption',
988
+ __typename: "MultipleChoiceOption",
988
989
  displayName: x.attribute.name,
989
- variant: 'size',
990
+ variant: "size",
990
991
  values: x.values.map(function (value) {
991
992
  return {
992
993
  label: value == null ? void 0 : value.name
@@ -1028,13 +1029,13 @@ function normalizeProduct(productNode) {
1028
1029
  var product = _extends({
1029
1030
  id: id,
1030
1031
  name: name,
1031
- vendor: '',
1032
- description: description ? (_JSON$parse = JSON.parse(description)) == null ? void 0 : (_JSON$parse$blocks$ = _JSON$parse.blocks[0]) == null ? void 0 : _JSON$parse$blocks$.data.text : '',
1032
+ vendor: "",
1033
+ description: description ? (_JSON$parse = JSON.parse(description)) == null ? void 0 : (_JSON$parse$blocks$ = _JSON$parse.blocks[0]) == null ? void 0 : _JSON$parse$blocks$.data.text : "",
1033
1034
  path: "/" + slug,
1034
- slug: slug == null ? void 0 : slug.replace(/^\/+|\/+$/g, ''),
1035
+ slug: slug == null ? void 0 : slug.replace(/^\/+|\/+$/g, ""),
1035
1036
  price: (pricing == null ? void 0 : (_pricing$priceRange = pricing.priceRange) == null ? void 0 : (_pricing$priceRange$s = _pricing$priceRange.start) == null ? void 0 : _pricing$priceRange$s.net) && money(pricing.priceRange.start.net) || {
1036
1037
  value: 0,
1037
- currencyCode: 'USD'
1038
+ currencyCode: "USD"
1038
1039
  },
1039
1040
  // TODO: Check nextjs-commerce bug if no images are added for a product
1040
1041
  images: media != null && media.length ? media : [{
@@ -1051,8 +1052,8 @@ function normalizeCart(checkout) {
1051
1052
  var lineItems = lines.length > 0 ? lines == null ? void 0 : lines.map(normalizeLineItem) : [];
1052
1053
  return {
1053
1054
  id: checkout.id,
1054
- customerId: '',
1055
- email: '',
1055
+ customerId: "",
1056
+ email: "",
1056
1057
  createdAt: checkout.created,
1057
1058
  currency: {
1058
1059
  code: (_checkout$totalPrice = checkout.totalPrice) == null ? void 0 : _checkout$totalPrice.currency
@@ -1066,19 +1067,19 @@ function normalizeCart(checkout) {
1066
1067
  };
1067
1068
  }
1068
1069
  function normalizeLineItem(_ref3) {
1069
- var _variant$sku, _variant$pricing, _variant$pricing$pric, _variant$product;
1070
+ var _variant$product, _variant$sku, _variant$pricing, _variant$pricing$pric, _variant$product2;
1070
1071
  var id = _ref3.id,
1071
1072
  variant = _ref3.variant,
1072
1073
  quantity = _ref3.quantity;
1073
1074
  return {
1074
1075
  id: id,
1075
1076
  variantId: String(variant == null ? void 0 : variant.id),
1076
- productId: String(variant == null ? void 0 : variant.id),
1077
+ productId: String(variant == null ? void 0 : (_variant$product = variant.product) == null ? void 0 : _variant$product.id),
1077
1078
  name: "" + variant.product.name,
1078
1079
  quantity: quantity,
1079
1080
  variant: {
1080
1081
  id: String(variant == null ? void 0 : variant.id),
1081
- sku: (_variant$sku = variant == null ? void 0 : variant.sku) != null ? _variant$sku : '',
1082
+ sku: (_variant$sku = variant == null ? void 0 : variant.sku) != null ? _variant$sku : "",
1082
1083
  name: variant == null ? void 0 : variant.name,
1083
1084
  image: {
1084
1085
  url: variant != null && variant.media[0] ? variant == null ? void 0 : variant.media[0].url : placeholderImg
@@ -1087,7 +1088,7 @@ function normalizeLineItem(_ref3) {
1087
1088
  price: variant == null ? void 0 : (_variant$pricing = variant.pricing) == null ? void 0 : (_variant$pricing$pric = _variant$pricing.price) == null ? void 0 : _variant$pricing$pric.gross.amount,
1088
1089
  listPrice: 0
1089
1090
  },
1090
- path: String(variant == null ? void 0 : (_variant$product = variant.product) == null ? void 0 : _variant$product.slug),
1091
+ path: String(variant == null ? void 0 : (_variant$product2 = variant.product) == null ? void 0 : _variant$product2.slug),
1091
1092
  discounts: [],
1092
1093
  options: []
1093
1094
  };
@@ -1469,7 +1470,7 @@ var handler$3 = {
1469
1470
  variables: {
1470
1471
  checkoutId: checkoutId,
1471
1472
  lineItems: [{
1472
- variantId: item.variantId,
1473
+ itemId: itemId,
1473
1474
  quantity: item.quantity
1474
1475
  }]
1475
1476
  }
@@ -1499,41 +1500,37 @@ var handler$3 = {
1499
1500
  mutate = _useCart.mutate;
1500
1501
  return React.useCallback(debounce( /*#__PURE__*/function () {
1501
1502
  var _ref3 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(input) {
1502
- var _input$id, _input$productId, _input$productId2;
1503
- var itemId, productId, variantId, data;
1503
+ var _input$id;
1504
+ var itemId, data;
1504
1505
  return runtime_1.wrap(function _callee2$(_context2) {
1505
1506
  while (1) {
1506
1507
  switch (_context2.prev = _context2.next) {
1507
1508
  case 0:
1508
1509
  itemId = (_input$id = input.id) != null ? _input$id : item == null ? void 0 : item.id;
1509
- productId = (_input$productId = input.productId) != null ? _input$productId : item == null ? void 0 : item.productId;
1510
- variantId = (_input$productId2 = input.productId) != null ? _input$productId2 : item == null ? void 0 : item.variantId;
1511
- if (!(!itemId || !productId || !variantId)) {
1512
- _context2.next = 5;
1510
+ if (itemId) {
1511
+ _context2.next = 3;
1513
1512
  break;
1514
1513
  }
1515
1514
  throw new commerce.ValidationError({
1516
1515
  message: "Invalid input used for this operation"
1517
1516
  });
1518
- case 5:
1519
- _context2.next = 7;
1517
+ case 3:
1518
+ _context2.next = 5;
1520
1519
  return fetch({
1521
1520
  input: {
1522
1521
  item: {
1523
- productId: productId,
1524
- variantId: variantId,
1525
1522
  quantity: input.quantity
1526
1523
  },
1527
1524
  itemId: itemId
1528
1525
  }
1529
1526
  });
1530
- case 7:
1527
+ case 5:
1531
1528
  data = _context2.sent;
1532
- _context2.next = 10;
1529
+ _context2.next = 8;
1533
1530
  return mutate(data, false);
1534
- case 10:
1531
+ case 8:
1535
1532
  return _context2.abrupt("return", data);
1536
- case 11:
1533
+ case 9:
1537
1534
  case "end":
1538
1535
  return _context2.stop();
1539
1536
  }
@@ -1878,8 +1875,9 @@ var getCommerceProvider = function getCommerceProvider(saleorApiUrl) {
1878
1875
  return commerce.getCommerceProvider(getSaleorProvider(saleorApiUrl));
1879
1876
  };
1880
1877
 
1878
+ var globalContextName = "plasmic-commerce-saleor-provider";
1881
1879
  var commerceProviderMeta = {
1882
- name: "plasmic-commerce-saleor-provider",
1880
+ name: globalContextName,
1883
1881
  displayName: "Saleor Provider",
1884
1882
  props: {
1885
1883
  saleorApiUrl: {
@@ -1887,6 +1885,7 @@ var commerceProviderMeta = {
1887
1885
  defaultValue: "https://vercel.saleor.cloud/graphql/"
1888
1886
  }
1889
1887
  },
1888
+ unstable__globalActions: commerce.globalActionsRegistrations,
1890
1889
  importPath: "@plasmicpkgs/commerce-saleor",
1891
1890
  importName: "CommerceProviderComponent"
1892
1891
  };
@@ -1896,7 +1895,9 @@ function CommerceProviderComponent(props) {
1896
1895
  var CommerceProvider = React__default.useMemo(function () {
1897
1896
  return getCommerceProvider(saleorApiUrl);
1898
1897
  }, [saleorApiUrl]);
1899
- return React__default.createElement(CommerceProvider, null, children);
1898
+ return React__default.createElement(CommerceProvider, null, React__default.createElement(commerce.CartActionsProvider, {
1899
+ globalContextName: globalContextName
1900
+ }, children));
1900
1901
  }
1901
1902
  function registerCommerceProvider(loader, customCommerceProviderMeta) {
1902
1903
  var doRegisterComponent = function doRegisterComponent() {