@plasmicpkgs/commerce-saleor 0.0.227 → 0.0.228

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 +1 -1
@@ -1,4 +1,4 @@
1
- export { default as useCart } from './use-cart';
2
- export { default as useAddItem } from './use-add-item';
3
- export { default as useUpdateItem } from './use-update-item';
4
- export { default as useRemoveItem } from './use-remove-item';
1
+ export { default as useAddItem } from "./use-add-item";
2
+ export { default as useCart } from "./use-cart";
3
+ export { default as useRemoveItem } from "./use-remove-item";
4
+ export { default as useUpdateItem } from "./use-update-item";
@@ -163,13 +163,6 @@ function _regeneratorDefine(e, r, n, t) {
163
163
  }, _regeneratorDefine(e, r, n, t);
164
164
  }
165
165
 
166
- /*
167
- Forked from https://github.com/vercel/commerce/tree/main/packages/saleor/src
168
- Changes: Removed api_url
169
- */
170
- var CHECKOUT_ID_COOKIE = 'saleor.CheckoutID';
171
- var SALEOR_TOKEN = 'saleor.Token';
172
-
173
166
  /*
174
167
  Forked from https://github.com/vercel/commerce/tree/main/packages/saleor/src
175
168
  Changes: None
@@ -203,9 +196,30 @@ var getSortVariables = function getSortVariables(sort, isCategory) {
203
196
  return output;
204
197
  };
205
198
 
199
+ var getSearchVariables = function getSearchVariables(_ref) {
200
+ var search = _ref.search,
201
+ categoryId = _ref.categoryId,
202
+ sort = _ref.sort,
203
+ count = _ref.count;
204
+ var sortBy = _extends({
205
+ field: 'NAME',
206
+ direction: 'ASC'
207
+ }, getSortVariables(sort), {
208
+ channel: 'default-channel'
209
+ });
210
+ return {
211
+ categoryId: categoryId,
212
+ filter: {
213
+ search: search
214
+ },
215
+ sortBy: sortBy,
216
+ first: count
217
+ };
218
+ };
219
+
206
220
  function getError(errors, status) {
207
221
  errors = errors != null ? errors : [{
208
- message: 'Failed to fetch Saleor API'
222
+ message: "Failed to fetch Saleor API"
209
223
  }];
210
224
  return new commerce.FetcherError({
211
225
  errors: errors,
@@ -269,26 +283,12 @@ var handleFetchResponse = /*#__PURE__*/function () {
269
283
  };
270
284
  }();
271
285
 
272
- var getSearchVariables = function getSearchVariables(_ref) {
273
- var search = _ref.search,
274
- categoryId = _ref.categoryId,
275
- sort = _ref.sort,
276
- count = _ref.count;
277
- var sortBy = _extends({
278
- field: 'NAME',
279
- direction: 'ASC'
280
- }, getSortVariables(sort), {
281
- channel: 'default-channel'
282
- });
283
- return {
284
- categoryId: categoryId,
285
- filter: {
286
- search: search
287
- },
288
- sortBy: sortBy,
289
- first: count
290
- };
291
- };
286
+ /*
287
+ Forked from https://github.com/vercel/commerce/tree/main/packages/saleor/src
288
+ Changes: Removed api_url
289
+ */
290
+ var CHECKOUT_ID_COOKIE = "saleor.CheckoutID";
291
+ var SALEOR_TOKEN = "saleor.Token";
292
292
 
293
293
  /*
294
294
  Forked from https://github.com/vercel/commerce/tree/main/packages/saleor/src
@@ -307,37 +307,37 @@ var getCheckoutId = function getCheckoutId(id) {
307
307
  Forked from https://github.com/vercel/commerce/tree/main/packages/saleor/src
308
308
  Changes: None
309
309
  */
310
- 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
+ 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";
311
311
 
312
312
  /*
313
313
  Forked from https://github.com/vercel/commerce/tree/main/packages/saleor/src
314
314
  Changes: None
315
315
  */
316
- 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";
316
+ 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";
317
317
 
318
318
  /*
319
319
  Forked from https://github.com/vercel/commerce/tree/main/packages/saleor/src
320
320
  Changes: None
321
321
  */
322
- 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";
322
+ 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";
323
323
 
324
324
  /*
325
325
  Forked from https://github.com/vercel/commerce/tree/main/packages/saleor/src
326
326
  Changes: None
327
327
  */
328
- 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";
328
+ 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";
329
329
 
330
330
  /*
331
331
  Forked from https://github.com/vercel/commerce/tree/main/packages/saleor/src
332
332
  Changes: None
333
333
  */
334
- 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";
334
+ 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";
335
335
 
336
336
  /*
337
337
  Forked from https://github.com/vercel/commerce/tree/main/packages/saleor/src
338
338
  Changes: None
339
339
  */
340
- 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";
340
+ 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";
341
341
 
342
342
  var checkoutCreate = /*#__PURE__*/function () {
343
343
  var _ref = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(fetch) {
@@ -539,8 +539,8 @@ var throwUserErrors = function throwUserErrors(errors) {
539
539
  var code = _ref.code,
540
540
  message = _ref.message;
541
541
  return {
542
- code: code != null ? code : 'validation_error',
543
- message: message || ''
542
+ code: code != null ? code : "validation_error",
543
+ message: message || ""
544
544
  };
545
545
  })
546
546
  });
@@ -555,7 +555,7 @@ var checkoutToCart = function checkoutToCart(checkoutPayload) {
555
555
  var _checkoutPayload$erro;
556
556
  if (!checkoutPayload) {
557
557
  throw new commerce.CommerceError({
558
- message: 'Missing checkout payload from response'
558
+ message: "Missing checkout payload from response"
559
559
  });
560
560
  }
561
561
  var checkout = checkoutPayload == null ? void 0 : checkoutPayload.checkout;
@@ -568,7 +568,7 @@ var checkoutToCart = function checkoutToCart(checkoutPayload) {
568
568
  }
569
569
  if (!checkout) {
570
570
  throw new commerce.CommerceError({
571
- message: 'Missing checkout object from response'
571
+ message: "Missing checkout object from response"
572
572
  });
573
573
  }
574
574
  return normalizeCart(checkout);
@@ -586,37 +586,37 @@ var getToken = function getToken() {
586
586
  Forked from https://github.com/vercel/commerce/tree/main/packages/saleor/src
587
587
  Changes: None
588
588
  */
589
- 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
+ var CheckoutOne = /* GraphQL */"\n query CheckoutOne($checkoutId: UUID!) {\n checkout(token: $checkoutId) {\n ... on Checkout {\n ...CheckoutDetails\n }\n }\n }\n " + CheckoutDetails + "\n";
590
590
 
591
591
  /*
592
592
  Forked from https://github.com/vercel/commerce/tree/main/packages/saleor/src
593
593
  Changes: None
594
594
  */
595
- 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";
595
+ 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";
596
596
 
597
597
  /*
598
598
  Forked from https://github.com/vercel/commerce/tree/main/packages/saleor/src
599
599
  Changes: None
600
600
  */
601
- 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";
601
+ 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";
602
602
 
603
603
  /*
604
604
  Forked from https://github.com/vercel/commerce/tree/main/packages/saleor/src
605
605
  Changes: None
606
606
  */
607
- 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";
607
+ 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";
608
608
 
609
609
  /*
610
610
  Forked from https://github.com/vercel/commerce/tree/main/packages/saleor/src
611
611
  Changes: None
612
612
  */
613
- var CheckoutOne = /* GraphQL */"\n query CheckoutOne($checkoutId: UUID!) {\n checkout(token: $checkoutId) {\n ... on Checkout {\n ...CheckoutDetails\n }\n }\n }\n " + CheckoutDetails + "\n";
613
+ 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";
614
614
 
615
615
  /*
616
616
  Forked from https://github.com/vercel/commerce/tree/main/packages/saleor/src
617
617
  Changes: None
618
618
  */
619
- 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";
619
+ 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";
620
620
 
621
621
  var _default = commerce.useCart;
622
622
  var handler = {
@@ -934,114 +934,107 @@ var handler$3 = {
934
934
  }
935
935
  };
936
936
 
937
+ var _excluded$1 = ["locale"];
938
+ var getFetcher = function getFetcher(saleorApiUrl) {
939
+ return /*#__PURE__*/function () {
940
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref) {
941
+ var _ref$url, url, _ref$method, method, query, variables, _ref3, vars, token, _t;
942
+ return _regenerator().w(function (_context) {
943
+ while (1) switch (_context.n) {
944
+ case 0:
945
+ _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;
946
+ _ref3 = variables != null ? variables : {}, vars = _objectWithoutPropertiesLoose(_ref3, _excluded$1);
947
+ token = getToken();
948
+ _t = handleFetchResponse;
949
+ _context.n = 1;
950
+ return fetch(url, {
951
+ method: method,
952
+ body: JSON.stringify({
953
+ query: query,
954
+ variables: vars
955
+ }),
956
+ headers: {
957
+ Authorization: "JWT " + token,
958
+ 'Content-Type': 'application/json'
959
+ }
960
+ });
961
+ case 1:
962
+ return _context.a(2, _t(_context.v));
963
+ }
964
+ }, _callee);
965
+ }));
966
+ return function (_x) {
967
+ return _ref2.apply(this, arguments);
968
+ };
969
+ }();
970
+ };
971
+
972
+ 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";
973
+
937
974
  var handler$4 = {
938
975
  fetchOptions: {
939
- query: CollectionMany
976
+ query: ProductOneById
940
977
  },
941
978
  fetcher: function fetcher(_ref) {
942
979
  return _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
943
- var input, fetch, categoryId, _data$collections$edg, _data$collections, data, _data;
980
+ var input, fetch, id, data, response;
944
981
  return _regenerator().w(function (_context) {
945
982
  while (1) switch (_context.n) {
946
983
  case 0:
947
984
  input = _ref.input, fetch = _ref.fetch;
948
- categoryId = input.categoryId;
949
- if (categoryId) {
950
- _context.n = 2;
985
+ id = input.id;
986
+ if (id) {
987
+ _context.n = 1;
951
988
  break;
952
989
  }
953
- _context.n = 1;
990
+ return _context.a(2, null);
991
+ case 1:
992
+ _context.n = 2;
954
993
  return fetch({
955
- query: CollectionMany,
994
+ query: ProductOneById,
956
995
  variables: {
957
- first: 250
996
+ id: id
958
997
  }
959
998
  });
960
- case 1:
961
- data = _context.v;
962
- 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) {
963
- var node = _ref2.node;
964
- return normalizeCategory(node);
965
- })) != null ? _data$collections$edg : []);
966
999
  case 2:
1000
+ data = _context.v;
1001
+ if (data.product) {
1002
+ _context.n = 4;
1003
+ break;
1004
+ }
967
1005
  _context.n = 3;
968
1006
  return fetch({
969
- query: CollectionOne,
1007
+ query: ProductOneBySlug,
970
1008
  variables: {
971
- categoryId: categoryId
1009
+ slug: id
972
1010
  }
973
1011
  });
974
1012
  case 3:
975
- _data = _context.v;
976
- return _context.a(2, _data != null && _data.collection ? [normalizeCategory(_data == null ? void 0 : _data.collection)] : []);
1013
+ response = _context.v;
1014
+ return _context.a(2, response.product ? normalizeProduct(response.product) : null);
977
1015
  case 4:
978
- return _context.a(2);
1016
+ return _context.a(2, data.product ? normalizeProduct(data.product) : null);
979
1017
  }
980
1018
  }, _callee);
981
1019
  }))();
982
1020
  },
983
- useHook: function useHook(_ref3) {
984
- var useData = _ref3.useData;
1021
+ useHook: function useHook(_ref2) {
1022
+ var useData = _ref2.useData;
985
1023
  return function (input) {
986
- var response = useData({
987
- input: [["categoryId", input == null ? void 0 : input.categoryId]],
1024
+ if (input === void 0) {
1025
+ input = {};
1026
+ }
1027
+ return useData({
1028
+ input: [["id", input.id]],
988
1029
  swrOptions: _extends({
989
1030
  revalidateOnFocus: false
990
- }, input == null ? void 0 : input.swrOptions)
1031
+ }, input.swrOptions)
991
1032
  });
992
- return React.useMemo(function () {
993
- return Object.create(response, {
994
- isEmpty: {
995
- get: function get() {
996
- var _response$data$length, _response$data;
997
- return ((_response$data$length = (_response$data = response.data) == null ? void 0 : _response$data.length) != null ? _response$data$length : 0) <= 0;
998
- },
999
- enumerable: true
1000
- }
1001
- });
1002
- }, [response]);
1003
1033
  };
1004
1034
  }
1005
1035
  };
1006
1036
 
1007
1037
  var handler$5 = {
1008
- fetchOptions: {
1009
- query: getAllProductVendors
1010
- },
1011
- fetcher: function fetcher() {
1012
- return _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
1013
- return _regenerator().w(function (_context) {
1014
- while (1) switch (_context.n) {
1015
- case 0:
1016
- return _context.a(2, []);
1017
- }
1018
- }, _callee);
1019
- }))();
1020
- },
1021
- useHook: function useHook(_ref) {
1022
- var useData = _ref.useData;
1023
- return function (input) {
1024
- var response = useData({
1025
- swrOptions: _extends({
1026
- revalidateOnFocus: false
1027
- }, input == null ? void 0 : input.swrOptions)
1028
- });
1029
- return React.useMemo(function () {
1030
- return Object.create(response, {
1031
- isEmpty: {
1032
- get: function get() {
1033
- var _response$data$length, _response$data;
1034
- return ((_response$data$length = (_response$data = response.data) == null ? void 0 : _response$data.length) != null ? _response$data$length : 0) <= 0;
1035
- },
1036
- enumerable: true
1037
- }
1038
- });
1039
- }, [response]);
1040
- };
1041
- }
1042
- };
1043
-
1044
- var handler$6 = {
1045
1038
  fetchOptions: {
1046
1039
  query: ProductMany
1047
1040
  },
@@ -1100,106 +1093,113 @@ var handler$6 = {
1100
1093
  }
1101
1094
  };
1102
1095
 
1103
- 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 }";
1096
+ var handler$6 = {
1097
+ fetchOptions: {
1098
+ query: getAllProductVendors
1099
+ },
1100
+ fetcher: function fetcher() {
1101
+ return _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
1102
+ return _regenerator().w(function (_context) {
1103
+ while (1) switch (_context.n) {
1104
+ case 0:
1105
+ return _context.a(2, []);
1106
+ }
1107
+ }, _callee);
1108
+ }))();
1109
+ },
1110
+ useHook: function useHook(_ref) {
1111
+ var useData = _ref.useData;
1112
+ return function (input) {
1113
+ var response = useData({
1114
+ swrOptions: _extends({
1115
+ revalidateOnFocus: false
1116
+ }, input == null ? void 0 : input.swrOptions)
1117
+ });
1118
+ return React.useMemo(function () {
1119
+ return Object.create(response, {
1120
+ isEmpty: {
1121
+ get: function get() {
1122
+ var _response$data$length, _response$data;
1123
+ return ((_response$data$length = (_response$data = response.data) == null ? void 0 : _response$data.length) != null ? _response$data$length : 0) <= 0;
1124
+ },
1125
+ enumerable: true
1126
+ }
1127
+ });
1128
+ }, [response]);
1129
+ };
1130
+ }
1131
+ };
1104
1132
 
1105
1133
  var handler$7 = {
1106
1134
  fetchOptions: {
1107
- query: ProductOneById
1135
+ query: CollectionMany
1108
1136
  },
1109
1137
  fetcher: function fetcher(_ref) {
1110
1138
  return _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
1111
- var input, fetch, id, data, response;
1139
+ var input, fetch, categoryId, _data$collections$edg, _data$collections, data, _data;
1112
1140
  return _regenerator().w(function (_context) {
1113
1141
  while (1) switch (_context.n) {
1114
1142
  case 0:
1115
1143
  input = _ref.input, fetch = _ref.fetch;
1116
- id = input.id;
1117
- if (id) {
1118
- _context.n = 1;
1144
+ categoryId = input.categoryId;
1145
+ if (categoryId) {
1146
+ _context.n = 2;
1119
1147
  break;
1120
1148
  }
1121
- return _context.a(2, null);
1122
- case 1:
1123
- _context.n = 2;
1149
+ _context.n = 1;
1124
1150
  return fetch({
1125
- query: ProductOneById,
1151
+ query: CollectionMany,
1126
1152
  variables: {
1127
- id: id
1153
+ first: 250
1128
1154
  }
1129
1155
  });
1130
- case 2:
1156
+ case 1:
1131
1157
  data = _context.v;
1132
- if (data.product) {
1133
- _context.n = 4;
1134
- break;
1135
- }
1158
+ 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) {
1159
+ var node = _ref2.node;
1160
+ return normalizeCategory(node);
1161
+ })) != null ? _data$collections$edg : []);
1162
+ case 2:
1136
1163
  _context.n = 3;
1137
1164
  return fetch({
1138
- query: ProductOneBySlug,
1165
+ query: CollectionOne,
1139
1166
  variables: {
1140
- slug: id
1167
+ categoryId: categoryId
1141
1168
  }
1142
1169
  });
1143
1170
  case 3:
1144
- response = _context.v;
1145
- return _context.a(2, response.product ? normalizeProduct(response.product) : null);
1171
+ _data = _context.v;
1172
+ return _context.a(2, _data != null && _data.collection ? [normalizeCategory(_data == null ? void 0 : _data.collection)] : []);
1146
1173
  case 4:
1147
- return _context.a(2, data.product ? normalizeProduct(data.product) : null);
1174
+ return _context.a(2);
1148
1175
  }
1149
1176
  }, _callee);
1150
1177
  }))();
1151
1178
  },
1152
- useHook: function useHook(_ref2) {
1153
- var useData = _ref2.useData;
1179
+ useHook: function useHook(_ref3) {
1180
+ var useData = _ref3.useData;
1154
1181
  return function (input) {
1155
- if (input === void 0) {
1156
- input = {};
1157
- }
1158
- return useData({
1159
- input: [["id", input.id]],
1182
+ var response = useData({
1183
+ input: [["categoryId", input == null ? void 0 : input.categoryId]],
1160
1184
  swrOptions: _extends({
1161
1185
  revalidateOnFocus: false
1162
- }, input.swrOptions)
1186
+ }, input == null ? void 0 : input.swrOptions)
1163
1187
  });
1188
+ return React.useMemo(function () {
1189
+ return Object.create(response, {
1190
+ isEmpty: {
1191
+ get: function get() {
1192
+ var _response$data$length, _response$data;
1193
+ return ((_response$data$length = (_response$data = response.data) == null ? void 0 : _response$data.length) != null ? _response$data$length : 0) <= 0;
1194
+ },
1195
+ enumerable: true
1196
+ }
1197
+ });
1198
+ }, [response]);
1164
1199
  };
1165
1200
  }
1166
1201
  };
1167
1202
 
1168
- var _excluded$1 = ["locale"];
1169
- var getFetcher = function getFetcher(saleorApiUrl) {
1170
- return /*#__PURE__*/function () {
1171
- var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref) {
1172
- var _ref$url, url, _ref$method, method, query, variables, _ref3, vars, token, _t;
1173
- return _regenerator().w(function (_context) {
1174
- while (1) switch (_context.n) {
1175
- case 0:
1176
- _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;
1177
- _ref3 = variables != null ? variables : {}, vars = _objectWithoutPropertiesLoose(_ref3, _excluded$1);
1178
- token = getToken();
1179
- _t = handleFetchResponse;
1180
- _context.n = 1;
1181
- return fetch(url, {
1182
- method: method,
1183
- body: JSON.stringify({
1184
- query: query,
1185
- variables: vars
1186
- }),
1187
- headers: {
1188
- Authorization: "JWT " + token,
1189
- 'Content-Type': 'application/json'
1190
- }
1191
- });
1192
- case 1:
1193
- return _context.a(2, _t(_context.v));
1194
- }
1195
- }, _callee);
1196
- }));
1197
- return function (_x) {
1198
- return _ref2.apply(this, arguments);
1199
- };
1200
- }();
1201
- };
1202
-
1203
1203
  /*
1204
1204
  Forked from https://github.com/vercel/commerce/tree/main/packages/saleor/src
1205
1205
  Changes:
@@ -1208,7 +1208,7 @@ var getFetcher = function getFetcher(saleorApiUrl) {
1208
1208
  */
1209
1209
  var getSaleorProvider = function getSaleorProvider(saleorApiUrl) {
1210
1210
  return {
1211
- locale: 'en-us',
1211
+ locale: "en-us",
1212
1212
  cartCookie: CHECKOUT_ID_COOKIE,
1213
1213
  fetcher: getFetcher(saleorApiUrl),
1214
1214
  cart: {
@@ -1218,12 +1218,12 @@ var getSaleorProvider = function getSaleorProvider(saleorApiUrl) {
1218
1218
  useRemoveItem: handler$2
1219
1219
  },
1220
1220
  products: {
1221
- useSearch: handler$6,
1222
- useProduct: handler$7
1221
+ useSearch: handler$5,
1222
+ useProduct: handler$4
1223
1223
  },
1224
1224
  site: {
1225
- useCategories: handler$4,
1226
- useBrands: handler$5
1225
+ useCategories: handler$7,
1226
+ useBrands: handler$6
1227
1227
  }
1228
1228
  };
1229
1229
  };