@plasmicpkgs/commerce-saleor 0.0.227 → 0.0.229

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.
Files changed (35) hide show
  1. package/dist/cart/index.d.ts +4 -4
  2. package/dist/commerce-saleor.cjs.development.js +185 -185
  3. package/dist/commerce-saleor.cjs.development.js.map +1 -1
  4. package/dist/commerce-saleor.cjs.production.min.js +1 -1
  5. package/dist/commerce-saleor.cjs.production.min.js.map +1 -1
  6. package/dist/commerce-saleor.esm.js +185 -185
  7. package/dist/commerce-saleor.esm.js.map +1 -1
  8. package/dist/index.d.ts +2 -2
  9. package/dist/provider.d.ts +9 -9
  10. package/dist/registerable.d.ts +1 -1
  11. package/dist/types/cart.d.ts +9 -9
  12. package/dist/types.d.ts +2 -2
  13. package/dist/utils/checkout-attach.d.ts +1 -1
  14. package/dist/utils/checkout-create.d.ts +1 -1
  15. package/dist/utils/checkout-to-cart.d.ts +2 -2
  16. package/dist/utils/customer-token.d.ts +1 -1
  17. package/dist/utils/fragments/index.d.ts +2 -2
  18. package/dist/utils/get-categories.d.ts +1 -1
  19. package/dist/utils/handle-fetch-response.d.ts +1 -1
  20. package/dist/utils/handle-login.d.ts +2 -2
  21. package/dist/utils/index.d.ts +13 -13
  22. package/dist/utils/mutations/checkout-create.d.ts +1 -1
  23. package/dist/utils/mutations/checkout-line-add.d.ts +1 -1
  24. package/dist/utils/mutations/checkout-line-update.d.ts +1 -1
  25. package/dist/utils/mutations/index.d.ts +8 -8
  26. package/dist/utils/normalize.d.ts +2 -2
  27. package/dist/utils/queries/collection-many.d.ts +1 -1
  28. package/dist/utils/queries/collection-one.d.ts +1 -1
  29. package/dist/utils/queries/get-all-product-vendors-query.d.ts +1 -1
  30. package/dist/utils/queries/get-all-products-paths-query.d.ts +1 -1
  31. package/dist/utils/queries/index.d.ts +11 -11
  32. package/dist/utils/queries/product-many.d.ts +1 -1
  33. package/dist/utils/queries/product-one-by-id.d.ts +1 -1
  34. package/dist/utils/throw-user-errors.d.ts +1 -1
  35. package/package.json +3 -3
@@ -156,13 +156,6 @@ function _regeneratorDefine(e, r, n, t) {
156
156
  }, _regeneratorDefine(e, r, n, t);
157
157
  }
158
158
 
159
- /*
160
- Forked from https://github.com/vercel/commerce/tree/main/packages/saleor/src
161
- Changes: Removed api_url
162
- */
163
- var CHECKOUT_ID_COOKIE = 'saleor.CheckoutID';
164
- var SALEOR_TOKEN = 'saleor.Token';
165
-
166
159
  /*
167
160
  Forked from https://github.com/vercel/commerce/tree/main/packages/saleor/src
168
161
  Changes: None
@@ -196,9 +189,30 @@ var getSortVariables = function getSortVariables(sort, isCategory) {
196
189
  return output;
197
190
  };
198
191
 
192
+ var getSearchVariables = function getSearchVariables(_ref) {
193
+ var search = _ref.search,
194
+ categoryId = _ref.categoryId,
195
+ sort = _ref.sort,
196
+ count = _ref.count;
197
+ var sortBy = _extends({
198
+ field: 'NAME',
199
+ direction: 'ASC'
200
+ }, getSortVariables(sort), {
201
+ channel: 'default-channel'
202
+ });
203
+ return {
204
+ categoryId: categoryId,
205
+ filter: {
206
+ search: search
207
+ },
208
+ sortBy: sortBy,
209
+ first: count
210
+ };
211
+ };
212
+
199
213
  function getError(errors, status) {
200
214
  errors = errors != null ? errors : [{
201
- message: 'Failed to fetch Saleor API'
215
+ message: "Failed to fetch Saleor API"
202
216
  }];
203
217
  return new FetcherError({
204
218
  errors: errors,
@@ -262,26 +276,12 @@ var handleFetchResponse = /*#__PURE__*/function () {
262
276
  };
263
277
  }();
264
278
 
265
- var getSearchVariables = function getSearchVariables(_ref) {
266
- var search = _ref.search,
267
- categoryId = _ref.categoryId,
268
- sort = _ref.sort,
269
- count = _ref.count;
270
- var sortBy = _extends({
271
- field: 'NAME',
272
- direction: 'ASC'
273
- }, getSortVariables(sort), {
274
- channel: 'default-channel'
275
- });
276
- return {
277
- categoryId: categoryId,
278
- filter: {
279
- search: search
280
- },
281
- sortBy: sortBy,
282
- first: count
283
- };
284
- };
279
+ /*
280
+ Forked from https://github.com/vercel/commerce/tree/main/packages/saleor/src
281
+ Changes: Removed api_url
282
+ */
283
+ var CHECKOUT_ID_COOKIE = "saleor.CheckoutID";
284
+ var SALEOR_TOKEN = "saleor.Token";
285
285
 
286
286
  /*
287
287
  Forked from https://github.com/vercel/commerce/tree/main/packages/saleor/src
@@ -300,37 +300,37 @@ var getCheckoutId = function getCheckoutId(id) {
300
300
  Forked from https://github.com/vercel/commerce/tree/main/packages/saleor/src
301
301
  Changes: None
302
302
  */
303
- var ProductConnection = /* GraphQL */"\n fragment ProductConnection on ProductCountableConnection {\n pageInfo {\n hasNextPage\n hasPreviousPage\n }\n edges {\n node {\n id\n name\n description\n slug\n pricing {\n priceRange {\n start {\n net {\n amount\n }\n }\n }\n }\n media {\n url\n alt\n }\n variants {\n id\n name\n attributes {\n attribute {\n name\n }\n values {\n name\n }\n }\n pricing {\n price {\n net {\n amount\n currency\n }\n }\n }\n }\n }\n }\n }\n";
303
+ 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";
304
304
 
305
305
  /*
306
306
  Forked from https://github.com/vercel/commerce/tree/main/packages/saleor/src
307
307
  Changes: None
308
308
  */
309
- 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";
309
+ var ProductConnection = /* GraphQL */"\n fragment ProductConnection on ProductCountableConnection {\n pageInfo {\n hasNextPage\n hasPreviousPage\n }\n edges {\n node {\n id\n name\n description\n slug\n pricing {\n priceRange {\n start {\n net {\n amount\n }\n }\n }\n }\n media {\n url\n alt\n }\n variants {\n id\n name\n attributes {\n attribute {\n name\n }\n values {\n name\n }\n }\n pricing {\n price {\n net {\n amount\n currency\n }\n }\n }\n }\n }\n }\n }\n";
310
310
 
311
311
  /*
312
312
  Forked from https://github.com/vercel/commerce/tree/main/packages/saleor/src
313
313
  Changes: None
314
314
  */
315
- var CheckoutCreate = /* GraphQL */"\n mutation CheckoutCreate {\n checkoutCreate(input: { email: \"customer@example.com\", lines: [], channel: \"default-channel\" }) {\n errors {\n code\n field\n message\n }\n checkout {\n ...CheckoutDetails\n }\n }\n }\n " + CheckoutDetails + "\n";
315
+ var CheckoutCreate = /* GraphQL */"\n mutation CheckoutCreate {\n checkoutCreate(\n input: {\n email: \"customer@example.com\"\n lines: []\n channel: \"default-channel\"\n }\n ) {\n errors {\n code\n field\n message\n }\n checkout {\n ...CheckoutDetails\n }\n }\n }\n " + CheckoutDetails + "\n";
316
316
 
317
317
  /*
318
318
  Forked from https://github.com/vercel/commerce/tree/main/packages/saleor/src
319
319
  Changes: None
320
320
  */
321
- var CheckoutLineAdd = /* GraphQL */"\n mutation CheckoutLineAdd($checkoutId: ID!, $lineItems: [CheckoutLineInput!]!) {\n checkoutLinesAdd(checkoutId: $checkoutId, lines: $lineItems) {\n errors {\n code\n field\n message\n }\n checkout {\n ...CheckoutDetails\n }\n }\n }\n " + CheckoutDetails + "\n";
321
+ var CheckoutLineAdd = /* GraphQL */"\n mutation CheckoutLineAdd(\n $checkoutId: ID!\n $lineItems: [CheckoutLineInput!]!\n ) {\n checkoutLinesAdd(checkoutId: $checkoutId, lines: $lineItems) {\n errors {\n code\n field\n message\n }\n checkout {\n ...CheckoutDetails\n }\n }\n }\n " + CheckoutDetails + "\n";
322
322
 
323
323
  /*
324
324
  Forked from https://github.com/vercel/commerce/tree/main/packages/saleor/src
325
325
  Changes: None
326
326
  */
327
- var CheckoutLineUpdate = /* GraphQL */"\n mutation CheckoutLineUpdate($checkoutId: ID!, $lineItems: [CheckoutLineInput!]!) {\n checkoutLinesUpdate(checkoutId: $checkoutId, lines: $lineItems) {\n errors {\n code\n field\n message\n }\n checkout {\n ...CheckoutDetails\n }\n }\n }\n " + CheckoutDetails + "\n";
327
+ var CheckoutLineDelete = /* GraphQL */"\n mutation CheckoutLineDelete($checkoutId: ID!, $lineId: ID!) {\n checkoutLineDelete(checkoutId: $checkoutId, lineId: $lineId) {\n errors {\n code\n field\n message\n }\n checkout {\n ...CheckoutDetails\n }\n }\n }\n " + CheckoutDetails + "\n";
328
328
 
329
329
  /*
330
330
  Forked from https://github.com/vercel/commerce/tree/main/packages/saleor/src
331
331
  Changes: None
332
332
  */
333
- var CheckoutLineDelete = /* GraphQL */"\n mutation CheckoutLineDelete($checkoutId: ID!, $lineId: ID!) {\n checkoutLineDelete(checkoutId: $checkoutId, lineId: $lineId) {\n errors {\n code\n field\n message\n }\n checkout {\n ...CheckoutDetails\n }\n }\n }\n " + CheckoutDetails + "\n";
333
+ var CheckoutLineUpdate = /* GraphQL */"\n mutation CheckoutLineUpdate(\n $checkoutId: ID!\n $lineItems: [CheckoutLineInput!]!\n ) {\n checkoutLinesUpdate(checkoutId: $checkoutId, lines: $lineItems) {\n errors {\n code\n field\n message\n }\n checkout {\n ...CheckoutDetails\n }\n }\n }\n " + CheckoutDetails + "\n";
334
334
 
335
335
  var checkoutCreate = /*#__PURE__*/function () {
336
336
  var _ref = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(fetch) {
@@ -532,8 +532,8 @@ var throwUserErrors = function throwUserErrors(errors) {
532
532
  var code = _ref.code,
533
533
  message = _ref.message;
534
534
  return {
535
- code: code != null ? code : 'validation_error',
536
- message: message || ''
535
+ code: code != null ? code : "validation_error",
536
+ message: message || ""
537
537
  };
538
538
  })
539
539
  });
@@ -548,7 +548,7 @@ var checkoutToCart = function checkoutToCart(checkoutPayload) {
548
548
  var _checkoutPayload$erro;
549
549
  if (!checkoutPayload) {
550
550
  throw new CommerceError({
551
- message: 'Missing checkout payload from response'
551
+ message: "Missing checkout payload from response"
552
552
  });
553
553
  }
554
554
  var checkout = checkoutPayload == null ? void 0 : checkoutPayload.checkout;
@@ -561,7 +561,7 @@ var checkoutToCart = function checkoutToCart(checkoutPayload) {
561
561
  }
562
562
  if (!checkout) {
563
563
  throw new CommerceError({
564
- message: 'Missing checkout object from response'
564
+ message: "Missing checkout object from response"
565
565
  });
566
566
  }
567
567
  return normalizeCart(checkout);
@@ -579,37 +579,37 @@ var getToken = function getToken() {
579
579
  Forked from https://github.com/vercel/commerce/tree/main/packages/saleor/src
580
580
  Changes: None
581
581
  */
582
- var CollectionMany = /* GraphQL */"\n query CollectionMany( $channel: String = \"default-channel\") {\n collections(first:100, channel: $channel) {\n edges {\n node {\n id\n name\n slug\n }\n }\n }\n }\n";
582
+ var CheckoutOne = /* GraphQL */"\n query CheckoutOne($checkoutId: UUID!) {\n checkout(token: $checkoutId) {\n ... on Checkout {\n ...CheckoutDetails\n }\n }\n }\n " + CheckoutDetails + "\n";
583
583
 
584
584
  /*
585
585
  Forked from https://github.com/vercel/commerce/tree/main/packages/saleor/src
586
586
  Changes: None
587
587
  */
588
- var ProductOneBySlug = /* GraphQL */"\n query ProductOneBySlug($slug: String!, $channel: String = \"default-channel\") {\n product(slug: $slug, channel: $channel) {\n id\n slug\n name\n description\n pricing {\n priceRange {\n start {\n net {\n amount\n }\n }\n }\n }\n variants {\n id\n name\n attributes {\n attribute {\n name\n }\n values {\n name\n }\n }\n pricing {\n price {\n net {\n amount\n currency\n }\n }\n }\n }\n media {\n url\n alt\n }\n }\n }\n";
588
+ var CollectionMany = /* GraphQL */"\n query CollectionMany($channel: String = \"default-channel\") {\n collections(first: 100, channel: $channel) {\n edges {\n node {\n id\n name\n slug\n }\n }\n }\n }\n";
589
589
 
590
590
  /*
591
591
  Forked from https://github.com/vercel/commerce/tree/main/packages/saleor/src
592
592
  Changes: None
593
593
  */
594
- var ProductMany = /* GraphQL */"\n query ProductMany(\n $first: Int = 100\n $filter: ProductFilterInput\n $sortBy: ProductOrder\n $channel: String = \"default-channel\"\n ) {\n products(first: $first, channel: $channel, filter: $filter, sortBy: $sortBy) {\n ...ProductConnection\n }\n }\n " + ProductConnection + "\n";
594
+ var CollectionOne = /* GraphQL */"\n query getProductsFromCollection(\n $categoryId: ID!\n $first: Int = 100\n $channel: String = \"default-channel\"\n ) {\n collection(id: $categoryId, channel: $channel) {\n id\n name\n slug\n products(first: $first) {\n ...ProductConnection\n }\n }\n }\n " + ProductConnection + "\n";
595
595
 
596
596
  /*
597
597
  Forked from https://github.com/vercel/commerce/tree/main/packages/saleor/src
598
598
  Changes: None
599
599
  */
600
- var CollectionOne = /* GraphQL */"\n query getProductsFromCollection($categoryId: ID!, $first: Int = 100, $channel: String = \"default-channel\") {\n collection(id: $categoryId, channel: $channel) {\n id\n name\n slug\n products(first: $first) {\n ...ProductConnection\n }\n }\n }\n " + ProductConnection + "\n";
600
+ var ProductMany = /* GraphQL */"\n query ProductMany(\n $first: Int = 100\n $filter: ProductFilterInput\n $sortBy: ProductOrder\n $channel: String = \"default-channel\"\n ) {\n products(\n first: $first\n channel: $channel\n filter: $filter\n sortBy: $sortBy\n ) {\n ...ProductConnection\n }\n }\n " + ProductConnection + "\n";
601
601
 
602
602
  /*
603
603
  Forked from https://github.com/vercel/commerce/tree/main/packages/saleor/src
604
604
  Changes: None
605
605
  */
606
- var CheckoutOne = /* GraphQL */"\n query CheckoutOne($checkoutId: UUID!) {\n checkout(token: $checkoutId) {\n ... on Checkout {\n ...CheckoutDetails\n }\n }\n }\n " + CheckoutDetails + "\n";
606
+ var ProductOneBySlug = /* GraphQL */"\n query ProductOneBySlug($slug: String!, $channel: String = \"default-channel\") {\n product(slug: $slug, channel: $channel) {\n id\n slug\n name\n description\n pricing {\n priceRange {\n start {\n net {\n amount\n }\n }\n }\n }\n variants {\n id\n name\n attributes {\n attribute {\n name\n }\n values {\n name\n }\n }\n pricing {\n price {\n net {\n amount\n currency\n }\n }\n }\n }\n media {\n url\n alt\n }\n }\n }\n";
607
607
 
608
608
  /*
609
609
  Forked from https://github.com/vercel/commerce/tree/main/packages/saleor/src
610
610
  Changes: None
611
611
  */
612
- var getAllProductVendors = /* GraphQL */"\n query getAllProductVendors($cursor: String, $channel: String = \"default-channel\") {\n products(first:100,channel: $channel, after: $cursor) {\n pageInfo {\n hasNextPage\n hasPreviousPage\n }\n edges {\n node {\n slug\n }\n cursor\n }\n }\n }\n";
612
+ var getAllProductVendors = /* GraphQL */"\n query getAllProductVendors(\n $cursor: String\n $channel: String = \"default-channel\"\n ) {\n products(first: 100, channel: $channel, after: $cursor) {\n pageInfo {\n hasNextPage\n hasPreviousPage\n }\n edges {\n node {\n slug\n }\n cursor\n }\n }\n }\n";
613
613
 
614
614
  var _default = useCart;
615
615
  var handler = {
@@ -927,114 +927,107 @@ var handler$3 = {
927
927
  }
928
928
  };
929
929
 
930
+ var _excluded$1 = ["locale"];
931
+ var getFetcher = function getFetcher(saleorApiUrl) {
932
+ return /*#__PURE__*/function () {
933
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref) {
934
+ var _ref$url, url, _ref$method, method, query, variables, _ref3, vars, token, _t;
935
+ return _regenerator().w(function (_context) {
936
+ while (1) switch (_context.n) {
937
+ case 0:
938
+ _ref$url = _ref.url, url = _ref$url === void 0 ? saleorApiUrl : _ref$url, _ref$method = _ref.method, method = _ref$method === void 0 ? 'POST' : _ref$method, query = _ref.query, variables = _ref.variables;
939
+ _ref3 = variables != null ? variables : {}, vars = _objectWithoutPropertiesLoose(_ref3, _excluded$1);
940
+ token = getToken();
941
+ _t = handleFetchResponse;
942
+ _context.n = 1;
943
+ return fetch(url, {
944
+ method: method,
945
+ body: JSON.stringify({
946
+ query: query,
947
+ variables: vars
948
+ }),
949
+ headers: {
950
+ Authorization: "JWT " + token,
951
+ 'Content-Type': 'application/json'
952
+ }
953
+ });
954
+ case 1:
955
+ return _context.a(2, _t(_context.v));
956
+ }
957
+ }, _callee);
958
+ }));
959
+ return function (_x) {
960
+ return _ref2.apply(this, arguments);
961
+ };
962
+ }();
963
+ };
964
+
965
+ var ProductOneById = /* GraphQL */"\n query ProductOneById($id: ID!, $channel: String = \"default-channel\") {\n product(id: $id, channel: $channel) {\n slug\n name\n description\n pricing {\n priceRange {\n start {\n net {\n amount\n }\n }\n }\n }\n variants {\n id\n name\n attributes {\n attribute {\n name\n }\n values {\n name\n }\n }\n pricing {\n price {\n net {\n amount\n currency\n }\n }\n }\n }\n media {\n url\n alt\n }\n }\n }\n";
966
+
930
967
  var handler$4 = {
931
968
  fetchOptions: {
932
- query: CollectionMany
969
+ query: ProductOneById
933
970
  },
934
971
  fetcher: function fetcher(_ref) {
935
972
  return _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
936
- var input, fetch, categoryId, _data$collections$edg, _data$collections, data, _data;
973
+ var input, fetch, id, data, response;
937
974
  return _regenerator().w(function (_context) {
938
975
  while (1) switch (_context.n) {
939
976
  case 0:
940
977
  input = _ref.input, fetch = _ref.fetch;
941
- categoryId = input.categoryId;
942
- if (categoryId) {
943
- _context.n = 2;
978
+ id = input.id;
979
+ if (id) {
980
+ _context.n = 1;
944
981
  break;
945
982
  }
946
- _context.n = 1;
983
+ return _context.a(2, null);
984
+ case 1:
985
+ _context.n = 2;
947
986
  return fetch({
948
- query: CollectionMany,
987
+ query: ProductOneById,
949
988
  variables: {
950
- first: 250
989
+ id: id
951
990
  }
952
991
  });
953
- case 1:
954
- data = _context.v;
955
- return _context.a(2, (_data$collections$edg = (_data$collections = data.collections) == null || (_data$collections = _data$collections.edges) == null ? void 0 : _data$collections.map(function (_ref2) {
956
- var node = _ref2.node;
957
- return normalizeCategory(node);
958
- })) != null ? _data$collections$edg : []);
959
992
  case 2:
993
+ data = _context.v;
994
+ if (data.product) {
995
+ _context.n = 4;
996
+ break;
997
+ }
960
998
  _context.n = 3;
961
999
  return fetch({
962
- query: CollectionOne,
1000
+ query: ProductOneBySlug,
963
1001
  variables: {
964
- categoryId: categoryId
1002
+ slug: id
965
1003
  }
966
1004
  });
967
1005
  case 3:
968
- _data = _context.v;
969
- return _context.a(2, _data != null && _data.collection ? [normalizeCategory(_data == null ? void 0 : _data.collection)] : []);
1006
+ response = _context.v;
1007
+ return _context.a(2, response.product ? normalizeProduct(response.product) : null);
970
1008
  case 4:
971
- return _context.a(2);
1009
+ return _context.a(2, data.product ? normalizeProduct(data.product) : null);
972
1010
  }
973
1011
  }, _callee);
974
1012
  }))();
975
1013
  },
976
- useHook: function useHook(_ref3) {
977
- var useData = _ref3.useData;
1014
+ useHook: function useHook(_ref2) {
1015
+ var useData = _ref2.useData;
978
1016
  return function (input) {
979
- var response = useData({
980
- input: [["categoryId", input == null ? void 0 : input.categoryId]],
1017
+ if (input === void 0) {
1018
+ input = {};
1019
+ }
1020
+ return useData({
1021
+ input: [["id", input.id]],
981
1022
  swrOptions: _extends({
982
1023
  revalidateOnFocus: false
983
- }, input == null ? void 0 : input.swrOptions)
1024
+ }, input.swrOptions)
984
1025
  });
985
- return useMemo(function () {
986
- return Object.create(response, {
987
- isEmpty: {
988
- get: function get() {
989
- var _response$data$length, _response$data;
990
- return ((_response$data$length = (_response$data = response.data) == null ? void 0 : _response$data.length) != null ? _response$data$length : 0) <= 0;
991
- },
992
- enumerable: true
993
- }
994
- });
995
- }, [response]);
996
1026
  };
997
1027
  }
998
1028
  };
999
1029
 
1000
1030
  var handler$5 = {
1001
- fetchOptions: {
1002
- query: getAllProductVendors
1003
- },
1004
- fetcher: function fetcher() {
1005
- return _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
1006
- return _regenerator().w(function (_context) {
1007
- while (1) switch (_context.n) {
1008
- case 0:
1009
- return _context.a(2, []);
1010
- }
1011
- }, _callee);
1012
- }))();
1013
- },
1014
- useHook: function useHook(_ref) {
1015
- var useData = _ref.useData;
1016
- return function (input) {
1017
- var response = useData({
1018
- swrOptions: _extends({
1019
- revalidateOnFocus: false
1020
- }, input == null ? void 0 : input.swrOptions)
1021
- });
1022
- return useMemo(function () {
1023
- return Object.create(response, {
1024
- isEmpty: {
1025
- get: function get() {
1026
- var _response$data$length, _response$data;
1027
- return ((_response$data$length = (_response$data = response.data) == null ? void 0 : _response$data.length) != null ? _response$data$length : 0) <= 0;
1028
- },
1029
- enumerable: true
1030
- }
1031
- });
1032
- }, [response]);
1033
- };
1034
- }
1035
- };
1036
-
1037
- var handler$6 = {
1038
1031
  fetchOptions: {
1039
1032
  query: ProductMany
1040
1033
  },
@@ -1093,106 +1086,113 @@ var handler$6 = {
1093
1086
  }
1094
1087
  };
1095
1088
 
1096
- var ProductOneById = /* GraphQL */"\n query ProductOneById($id: ID!, $channel: String = \"default-channel\") {\n product(id: $id, channel: $channel) {\n\n slug\n name\n description\n pricing {\n priceRange {\n start {\n net {\n amount\n }\n }\n }\n }\n variants {\n id\n name\n attributes {\n attribute {\n name\n }\n values {\n name\n }\n }\n pricing {\n price {\n net {\n amount\n currency\n }\n }\n }\n }\n media {\n url\n alt\n }\n }\n }";
1089
+ var handler$6 = {
1090
+ fetchOptions: {
1091
+ query: getAllProductVendors
1092
+ },
1093
+ fetcher: function fetcher() {
1094
+ return _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
1095
+ return _regenerator().w(function (_context) {
1096
+ while (1) switch (_context.n) {
1097
+ case 0:
1098
+ return _context.a(2, []);
1099
+ }
1100
+ }, _callee);
1101
+ }))();
1102
+ },
1103
+ useHook: function useHook(_ref) {
1104
+ var useData = _ref.useData;
1105
+ return function (input) {
1106
+ var response = useData({
1107
+ swrOptions: _extends({
1108
+ revalidateOnFocus: false
1109
+ }, input == null ? void 0 : input.swrOptions)
1110
+ });
1111
+ return useMemo(function () {
1112
+ return Object.create(response, {
1113
+ isEmpty: {
1114
+ get: function get() {
1115
+ var _response$data$length, _response$data;
1116
+ return ((_response$data$length = (_response$data = response.data) == null ? void 0 : _response$data.length) != null ? _response$data$length : 0) <= 0;
1117
+ },
1118
+ enumerable: true
1119
+ }
1120
+ });
1121
+ }, [response]);
1122
+ };
1123
+ }
1124
+ };
1097
1125
 
1098
1126
  var handler$7 = {
1099
1127
  fetchOptions: {
1100
- query: ProductOneById
1128
+ query: CollectionMany
1101
1129
  },
1102
1130
  fetcher: function fetcher(_ref) {
1103
1131
  return _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
1104
- var input, fetch, id, data, response;
1132
+ var input, fetch, categoryId, _data$collections$edg, _data$collections, data, _data;
1105
1133
  return _regenerator().w(function (_context) {
1106
1134
  while (1) switch (_context.n) {
1107
1135
  case 0:
1108
1136
  input = _ref.input, fetch = _ref.fetch;
1109
- id = input.id;
1110
- if (id) {
1111
- _context.n = 1;
1137
+ categoryId = input.categoryId;
1138
+ if (categoryId) {
1139
+ _context.n = 2;
1112
1140
  break;
1113
1141
  }
1114
- return _context.a(2, null);
1115
- case 1:
1116
- _context.n = 2;
1142
+ _context.n = 1;
1117
1143
  return fetch({
1118
- query: ProductOneById,
1144
+ query: CollectionMany,
1119
1145
  variables: {
1120
- id: id
1146
+ first: 250
1121
1147
  }
1122
1148
  });
1123
- case 2:
1149
+ case 1:
1124
1150
  data = _context.v;
1125
- if (data.product) {
1126
- _context.n = 4;
1127
- break;
1128
- }
1151
+ return _context.a(2, (_data$collections$edg = (_data$collections = data.collections) == null || (_data$collections = _data$collections.edges) == null ? void 0 : _data$collections.map(function (_ref2) {
1152
+ var node = _ref2.node;
1153
+ return normalizeCategory(node);
1154
+ })) != null ? _data$collections$edg : []);
1155
+ case 2:
1129
1156
  _context.n = 3;
1130
1157
  return fetch({
1131
- query: ProductOneBySlug,
1158
+ query: CollectionOne,
1132
1159
  variables: {
1133
- slug: id
1160
+ categoryId: categoryId
1134
1161
  }
1135
1162
  });
1136
1163
  case 3:
1137
- response = _context.v;
1138
- return _context.a(2, response.product ? normalizeProduct(response.product) : null);
1164
+ _data = _context.v;
1165
+ return _context.a(2, _data != null && _data.collection ? [normalizeCategory(_data == null ? void 0 : _data.collection)] : []);
1139
1166
  case 4:
1140
- return _context.a(2, data.product ? normalizeProduct(data.product) : null);
1167
+ return _context.a(2);
1141
1168
  }
1142
1169
  }, _callee);
1143
1170
  }))();
1144
1171
  },
1145
- useHook: function useHook(_ref2) {
1146
- var useData = _ref2.useData;
1172
+ useHook: function useHook(_ref3) {
1173
+ var useData = _ref3.useData;
1147
1174
  return function (input) {
1148
- if (input === void 0) {
1149
- input = {};
1150
- }
1151
- return useData({
1152
- input: [["id", input.id]],
1175
+ var response = useData({
1176
+ input: [["categoryId", input == null ? void 0 : input.categoryId]],
1153
1177
  swrOptions: _extends({
1154
1178
  revalidateOnFocus: false
1155
- }, input.swrOptions)
1179
+ }, input == null ? void 0 : input.swrOptions)
1156
1180
  });
1181
+ return useMemo(function () {
1182
+ return Object.create(response, {
1183
+ isEmpty: {
1184
+ get: function get() {
1185
+ var _response$data$length, _response$data;
1186
+ return ((_response$data$length = (_response$data = response.data) == null ? void 0 : _response$data.length) != null ? _response$data$length : 0) <= 0;
1187
+ },
1188
+ enumerable: true
1189
+ }
1190
+ });
1191
+ }, [response]);
1157
1192
  };
1158
1193
  }
1159
1194
  };
1160
1195
 
1161
- var _excluded$1 = ["locale"];
1162
- var getFetcher = function getFetcher(saleorApiUrl) {
1163
- return /*#__PURE__*/function () {
1164
- var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref) {
1165
- var _ref$url, url, _ref$method, method, query, variables, _ref3, vars, token, _t;
1166
- return _regenerator().w(function (_context) {
1167
- while (1) switch (_context.n) {
1168
- case 0:
1169
- _ref$url = _ref.url, url = _ref$url === void 0 ? saleorApiUrl : _ref$url, _ref$method = _ref.method, method = _ref$method === void 0 ? 'POST' : _ref$method, query = _ref.query, variables = _ref.variables;
1170
- _ref3 = variables != null ? variables : {}, vars = _objectWithoutPropertiesLoose(_ref3, _excluded$1);
1171
- token = getToken();
1172
- _t = handleFetchResponse;
1173
- _context.n = 1;
1174
- return fetch(url, {
1175
- method: method,
1176
- body: JSON.stringify({
1177
- query: query,
1178
- variables: vars
1179
- }),
1180
- headers: {
1181
- Authorization: "JWT " + token,
1182
- 'Content-Type': 'application/json'
1183
- }
1184
- });
1185
- case 1:
1186
- return _context.a(2, _t(_context.v));
1187
- }
1188
- }, _callee);
1189
- }));
1190
- return function (_x) {
1191
- return _ref2.apply(this, arguments);
1192
- };
1193
- }();
1194
- };
1195
-
1196
1196
  /*
1197
1197
  Forked from https://github.com/vercel/commerce/tree/main/packages/saleor/src
1198
1198
  Changes:
@@ -1201,7 +1201,7 @@ var getFetcher = function getFetcher(saleorApiUrl) {
1201
1201
  */
1202
1202
  var getSaleorProvider = function getSaleorProvider(saleorApiUrl) {
1203
1203
  return {
1204
- locale: 'en-us',
1204
+ locale: "en-us",
1205
1205
  cartCookie: CHECKOUT_ID_COOKIE,
1206
1206
  fetcher: getFetcher(saleorApiUrl),
1207
1207
  cart: {
@@ -1211,12 +1211,12 @@ var getSaleorProvider = function getSaleorProvider(saleorApiUrl) {
1211
1211
  useRemoveItem: handler$2
1212
1212
  },
1213
1213
  products: {
1214
- useSearch: handler$6,
1215
- useProduct: handler$7
1214
+ useSearch: handler$5,
1215
+ useProduct: handler$4
1216
1216
  },
1217
1217
  site: {
1218
- useCategories: handler$4,
1219
- useBrands: handler$5
1218
+ useCategories: handler$7,
1219
+ useBrands: handler$6
1220
1220
  }
1221
1221
  };
1222
1222
  };