@plasmicpkgs/commerce-shopify 0.0.151 → 0.0.154

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.
@@ -884,7 +884,7 @@ var getCheckoutId = function getCheckoutId(id) {
884
884
  Forked from https://github.com/vercel/commerce/tree/main/packages/shopify/src
885
885
  Changes: None
886
886
  */
887
- var checkoutDetailsFragment = /* GraphQL */"\n fragment checkoutDetails on Checkout {\n id\n webUrl\n subtotalPriceV2 {\n amount\n currencyCode\n }\n totalTaxV2 {\n amount\n currencyCode\n }\n totalPriceV2 {\n amount\n currencyCode\n }\n completedAt\n createdAt\n taxesIncluded\n lineItems(first: 250) {\n pageInfo {\n hasNextPage\n hasPreviousPage\n }\n edges {\n node {\n id\n title\n variant {\n id\n sku\n title\n selectedOptions {\n name\n value\n }\n image {\n originalSrc\n altText\n width\n height\n }\n priceV2 {\n amount\n currencyCode\n }\n compareAtPriceV2 {\n amount\n currencyCode\n }\n product {\n handle\n }\n }\n quantity\n }\n }\n }\n }\n";
887
+ var checkoutDetailsFragment = /* GraphQL */"\n fragment checkoutDetails on Checkout {\n id\n webUrl\n subtotalPriceV2 {\n amount\n currencyCode\n }\n totalTaxV2 {\n amount\n currencyCode\n }\n totalPriceV2 {\n amount\n currencyCode\n }\n completedAt\n createdAt\n taxesIncluded\n lineItems(first: 250) {\n pageInfo {\n hasNextPage\n hasPreviousPage\n }\n edges {\n node {\n id\n title\n variant {\n id\n sku\n title\n selectedOptions {\n name\n value\n }\n image {\n originalSrc\n altText\n width\n height\n }\n priceV2 {\n amount\n currencyCode\n }\n compareAtPriceV2 {\n amount\n currencyCode\n }\n product {\n id\n handle\n }\n }\n quantity\n }\n }\n }\n }\n";
888
888
  var getCheckoutQuery = /* GraphQL */"\n query getCheckout($checkoutId: ID!) {\n node(id: $checkoutId) {\n ...checkoutDetails\n }\n }\n " + checkoutDetailsFragment + "\n";
889
889
 
890
890
  /*
@@ -1115,7 +1115,7 @@ var normalizeProductOption = function normalizeProductOption(_ref2) {
1115
1115
  displayName = _ref2.name,
1116
1116
  values = _ref2.values;
1117
1117
  return {
1118
- __typename: 'MultipleChoiceOption',
1118
+ __typename: "MultipleChoiceOption",
1119
1119
  id: id,
1120
1120
  displayName: displayName.toLowerCase(),
1121
1121
  values: values.map(function (value) {
@@ -1123,7 +1123,7 @@ var normalizeProductOption = function normalizeProductOption(_ref2) {
1123
1123
  label: value
1124
1124
  };
1125
1125
  if (displayName.match(/colou?r/gi)) {
1126
- var mapedColor = colorMap[value.toLowerCase().replace(/ /g, '')];
1126
+ var mapedColor = colorMap[value.toLowerCase().replace(/ /g, "")];
1127
1127
  if (mapedColor) {
1128
1128
  output = _extends({}, output, {
1129
1129
  hexColors: [mapedColor]
@@ -1197,7 +1197,7 @@ function normalizeProduct(_ref8) {
1197
1197
  name: name,
1198
1198
  vendor: vendor,
1199
1199
  path: "/" + handle,
1200
- slug: handle == null ? void 0 : handle.replace(/^\/+|\/+$/g, ''),
1200
+ slug: handle == null ? void 0 : handle.replace(/^\/+|\/+$/g, ""),
1201
1201
  price: money(priceRange == null ? void 0 : priceRange.minVariantPrice),
1202
1202
  images: normalizeProductImages(images),
1203
1203
  variants: variants ? normalizeProductVariants(variants) : [],
@@ -1218,8 +1218,8 @@ function normalizeCart(checkout) {
1218
1218
  return {
1219
1219
  id: checkout.id,
1220
1220
  url: checkout.webUrl,
1221
- customerId: '',
1222
- email: '',
1221
+ customerId: "",
1222
+ email: "",
1223
1223
  createdAt: checkout.createdAt,
1224
1224
  currency: {
1225
1225
  code: (_checkout$totalPriceV = checkout.totalPriceV2) == null ? void 0 : _checkout$totalPriceV.currencyCode
@@ -1242,15 +1242,15 @@ function normalizeLineItem(_ref9) {
1242
1242
  return {
1243
1243
  id: id,
1244
1244
  variantId: String(variant == null ? void 0 : variant.id),
1245
- productId: String(variant == null ? void 0 : variant.id),
1245
+ productId: String(variant == null ? void 0 : variant.product.id),
1246
1246
  name: "" + title,
1247
1247
  quantity: quantity,
1248
1248
  variant: {
1249
1249
  id: String(variant == null ? void 0 : variant.id),
1250
- sku: (_variant$sku = variant == null ? void 0 : variant.sku) != null ? _variant$sku : '',
1250
+ sku: (_variant$sku = variant == null ? void 0 : variant.sku) != null ? _variant$sku : "",
1251
1251
  name: variant == null ? void 0 : variant.title,
1252
1252
  image: {
1253
- url: (variant == null ? void 0 : (_variant$image = variant.image) == null ? void 0 : _variant$image.originalSrc) || '/product-img-placeholder.svg'
1253
+ url: (variant == null ? void 0 : (_variant$image = variant.image) == null ? void 0 : _variant$image.originalSrc) || "/product-img-placeholder.svg"
1254
1254
  },
1255
1255
  requiresShipping: (_variant$requiresShip = variant == null ? void 0 : variant.requiresShipping) != null ? _variant$requiresShip : false,
1256
1256
  price: variant == null ? void 0 : (_variant$priceV = variant.priceV2) == null ? void 0 : _variant$priceV.amount,
@@ -1258,7 +1258,7 @@ function normalizeLineItem(_ref9) {
1258
1258
  },
1259
1259
  path: String(variant == null ? void 0 : (_variant$product = variant.product) == null ? void 0 : _variant$product.handle),
1260
1260
  discounts: [],
1261
- options: (variant == null ? void 0 : variant.title) == 'Default Title' ? [] : variant == null ? void 0 : variant.selectedOptions
1261
+ options: (variant == null ? void 0 : variant.title) == "Default Title" ? [] : variant == null ? void 0 : variant.selectedOptions
1262
1262
  };
1263
1263
  }
1264
1264
  /*
@@ -1857,41 +1857,37 @@ var handler$5 = {
1857
1857
  mutate = _useCart.mutate;
1858
1858
  return React.useCallback(debounce( /*#__PURE__*/function () {
1859
1859
  var _ref3 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(input) {
1860
- var _input$id, _input$productId, _input$productId2;
1861
- var itemId, productId, variantId, data;
1860
+ var _input$id;
1861
+ var itemId, data;
1862
1862
  return runtime_1.wrap(function _callee2$(_context2) {
1863
1863
  while (1) {
1864
1864
  switch (_context2.prev = _context2.next) {
1865
1865
  case 0:
1866
1866
  itemId = (_input$id = input.id) != null ? _input$id : item == null ? void 0 : item.id;
1867
- productId = (_input$productId = input.productId) != null ? _input$productId : item == null ? void 0 : item.productId;
1868
- variantId = (_input$productId2 = input.productId) != null ? _input$productId2 : item == null ? void 0 : item.variantId;
1869
- if (!(!itemId || !productId || !variantId)) {
1870
- _context2.next = 5;
1867
+ if (!(!itemId || input.quantity == null)) {
1868
+ _context2.next = 3;
1871
1869
  break;
1872
1870
  }
1873
1871
  throw new commerce.ValidationError({
1874
1872
  message: "Invalid input used for this operation"
1875
1873
  });
1876
- case 5:
1877
- _context2.next = 7;
1874
+ case 3:
1875
+ _context2.next = 5;
1878
1876
  return fetch({
1879
1877
  input: {
1880
1878
  item: {
1881
- productId: productId,
1882
- variantId: variantId,
1883
1879
  quantity: input.quantity
1884
1880
  },
1885
1881
  itemId: itemId
1886
1882
  }
1887
1883
  });
1888
- case 7:
1884
+ case 5:
1889
1885
  data = _context2.sent;
1890
- _context2.next = 10;
1886
+ _context2.next = 8;
1891
1887
  return mutate(data, false);
1892
- case 10:
1888
+ case 8:
1893
1889
  return _context2.abrupt("return", data);
1894
- case 11:
1890
+ case 9:
1895
1891
  case "end":
1896
1892
  return _context2.stop();
1897
1893
  }
@@ -2127,8 +2123,9 @@ var getCommerceProvider = function getCommerceProvider(storeDomain, accessToken)
2127
2123
  return commerce.getCommerceProvider(getShopifyProvider(storeDomain, accessToken));
2128
2124
  };
2129
2125
 
2126
+ var globalContextName = "plasmic-commerce-shopify-provider";
2130
2127
  var commerceProviderMeta = {
2131
- name: "plasmic-commerce-shopify-provider",
2128
+ name: globalContextName,
2132
2129
  displayName: "Shopify Provider",
2133
2130
  props: {
2134
2131
  storeDomain: {
@@ -2140,6 +2137,7 @@ var commerceProviderMeta = {
2140
2137
  defaultValue: "ef7d41c7bf7e1c214074d0d3047bcd7b"
2141
2138
  }
2142
2139
  },
2140
+ unstable__globalActions: commerce.globalActionsRegistrations,
2143
2141
  description: "Your store domain usually looks like **storename.myshopify.com**.\n\nFor your access token, get it by following [this video](https://www.youtube.com/watch?v=wB_6cM7tdv4).\n\nSee also the [getting started video](https://www.youtube.com/watch?v=1OJ_gXmta2Q).",
2144
2142
  importPath: "@plasmicpkgs/commerce-shopify",
2145
2143
  importName: "CommerceProviderComponent"
@@ -2151,7 +2149,9 @@ function CommerceProviderComponent(props) {
2151
2149
  var CommerceProvider = React__default.useMemo(function () {
2152
2150
  return getCommerceProvider(storeDomain, accessToken);
2153
2151
  }, [storeDomain, accessToken]);
2154
- return React__default.createElement(CommerceProvider, null, children);
2152
+ return React__default.createElement(CommerceProvider, null, React__default.createElement(commerce.CartActionsProvider, {
2153
+ globalContextName: globalContextName
2154
+ }, children));
2155
2155
  }
2156
2156
  function registerCommerceProvider(loader, customCommerceProviderMeta) {
2157
2157
  var doRegisterComponent = function doRegisterComponent() {