@plasmicpkgs/commerce-saleor 0.0.207 → 0.0.208

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.
@@ -54,306 +54,113 @@ function _objectWithoutPropertiesLoose(r, e) {
54
54
  }
55
55
  return t;
56
56
  }
57
- function _regeneratorRuntime() {
58
- _regeneratorRuntime = function () {
59
- return e;
60
- };
61
- var t,
62
- e = {},
63
- r = Object.prototype,
64
- n = r.hasOwnProperty,
65
- o = Object.defineProperty || function (t, e, r) {
66
- t[e] = r.value;
67
- },
68
- i = "function" == typeof Symbol ? Symbol : {},
69
- a = i.iterator || "@@iterator",
70
- c = i.asyncIterator || "@@asyncIterator",
71
- u = i.toStringTag || "@@toStringTag";
72
- function define(t, e, r) {
73
- return Object.defineProperty(t, e, {
74
- value: r,
75
- enumerable: !0,
76
- configurable: !0,
77
- writable: !0
78
- }), t[e];
79
- }
80
- try {
81
- define({}, "");
82
- } catch (t) {
83
- define = function (t, e, r) {
84
- return t[e] = r;
85
- };
86
- }
87
- function wrap(t, e, r, n) {
88
- var i = e && e.prototype instanceof Generator ? e : Generator,
89
- a = Object.create(i.prototype),
90
- c = new Context(n || []);
91
- return o(a, "_invoke", {
92
- value: makeInvokeMethod(t, r, c)
93
- }), a;
94
- }
95
- function tryCatch(t, e, r) {
96
- try {
97
- return {
98
- type: "normal",
99
- arg: t.call(e, r)
100
- };
101
- } catch (t) {
102
- return {
103
- type: "throw",
104
- arg: t
105
- };
106
- }
107
- }
108
- e.wrap = wrap;
109
- var h = "suspendedStart",
110
- l = "suspendedYield",
111
- f = "executing",
112
- s = "completed",
113
- y = {};
114
- function Generator() {}
115
- function GeneratorFunction() {}
116
- function GeneratorFunctionPrototype() {}
117
- var p = {};
118
- define(p, a, function () {
119
- return this;
120
- });
121
- var d = Object.getPrototypeOf,
122
- v = d && d(d(values([])));
123
- v && v !== r && n.call(v, a) && (p = v);
124
- var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p);
125
- function defineIteratorMethods(t) {
126
- ["next", "throw", "return"].forEach(function (e) {
127
- define(t, e, function (t) {
128
- return this._invoke(e, t);
129
- });
130
- });
131
- }
132
- function AsyncIterator(t, e) {
133
- function invoke(r, o, i, a) {
134
- var c = tryCatch(t[r], t, o);
135
- if ("throw" !== c.type) {
136
- var u = c.arg,
137
- h = u.value;
138
- return h && "object" == typeof h && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) {
139
- invoke("next", t, i, a);
140
- }, function (t) {
141
- invoke("throw", t, i, a);
142
- }) : e.resolve(h).then(function (t) {
143
- u.value = t, i(u);
144
- }, function (t) {
145
- return invoke("throw", t, i, a);
146
- });
147
- }
148
- a(c.arg);
149
- }
150
- var r;
151
- o(this, "_invoke", {
152
- value: function (t, n) {
153
- function callInvokeWithMethodAndArg() {
154
- return new e(function (e, r) {
155
- invoke(t, n, e, r);
156
- });
57
+ function _regenerator() {
58
+ /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
59
+ var e,
60
+ t,
61
+ r = "function" == typeof Symbol ? Symbol : {},
62
+ n = r.iterator || "@@iterator",
63
+ o = r.toStringTag || "@@toStringTag";
64
+ function i(r, n, o, i) {
65
+ var c = n && n.prototype instanceof Generator ? n : Generator,
66
+ u = Object.create(c.prototype);
67
+ return _regeneratorDefine(u, "_invoke", function (r, n, o) {
68
+ var i,
69
+ c,
70
+ u,
71
+ f = 0,
72
+ p = o || [],
73
+ y = !1,
74
+ G = {
75
+ p: 0,
76
+ n: 0,
77
+ v: e,
78
+ a: d,
79
+ f: d.bind(e, 4),
80
+ d: function (t, r) {
81
+ return i = t, c = 0, u = e, G.n = r, a;
82
+ }
83
+ };
84
+ function d(r, n) {
85
+ for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) {
86
+ var o,
87
+ i = p[t],
88
+ d = G.p,
89
+ l = i[2];
90
+ r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0));
157
91
  }
158
- return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
92
+ if (o || r > 1) return a;
93
+ throw y = !0, n;
159
94
  }
160
- });
161
- }
162
- function makeInvokeMethod(e, r, n) {
163
- var o = h;
164
- return function (i, a) {
165
- if (o === f) throw Error("Generator is already running");
166
- if (o === s) {
167
- if ("throw" === i) throw a;
95
+ return function (o, p, l) {
96
+ if (f > 1) throw TypeError("Generator is already running");
97
+ for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) {
98
+ i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u);
99
+ try {
100
+ if (f = 2, i) {
101
+ if (c || (o = "next"), t = i[o]) {
102
+ if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object");
103
+ if (!t.done) return t;
104
+ u = t.value, c < 2 && (c = 0);
105
+ } else 1 === c && (t = i.return) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1);
106
+ i = e;
107
+ } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break;
108
+ } catch (t) {
109
+ i = e, c = 1, u = t;
110
+ } finally {
111
+ f = 1;
112
+ }
113
+ }
168
114
  return {
169
115
  value: t,
170
- done: !0
116
+ done: y
171
117
  };
172
- }
173
- for (n.method = i, n.arg = a;;) {
174
- var c = n.delegate;
175
- if (c) {
176
- var u = maybeInvokeDelegate(c, n);
177
- if (u) {
178
- if (u === y) continue;
179
- return u;
180
- }
181
- }
182
- if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) {
183
- if (o === h) throw o = s, n.arg;
184
- n.dispatchException(n.arg);
185
- } else "return" === n.method && n.abrupt("return", n.arg);
186
- o = f;
187
- var p = tryCatch(e, r, n);
188
- if ("normal" === p.type) {
189
- if (o = n.done ? s : l, p.arg === y) continue;
190
- return {
191
- value: p.arg,
192
- done: n.done
193
- };
194
- }
195
- "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg);
196
- }
197
- };
198
- }
199
- function maybeInvokeDelegate(e, r) {
200
- var n = r.method,
201
- o = e.iterator[n];
202
- if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y;
203
- var i = tryCatch(o, e.iterator, r.arg);
204
- if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y;
205
- var a = i.arg;
206
- return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y);
207
- }
208
- function pushTryEntry(t) {
209
- var e = {
210
- tryLoc: t[0]
211
- };
212
- 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e);
213
- }
214
- function resetTryEntry(t) {
215
- var e = t.completion || {};
216
- e.type = "normal", delete e.arg, t.completion = e;
217
- }
218
- function Context(t) {
219
- this.tryEntries = [{
220
- tryLoc: "root"
221
- }], t.forEach(pushTryEntry, this), this.reset(!0);
118
+ };
119
+ }(r, o, i), !0), u;
222
120
  }
223
- function values(e) {
224
- if (e || "" === e) {
225
- var r = e[a];
226
- if (r) return r.call(e);
227
- if ("function" == typeof e.next) return e;
228
- if (!isNaN(e.length)) {
229
- var o = -1,
230
- i = function next() {
231
- for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next;
232
- return next.value = t, next.done = !0, next;
233
- };
234
- return i.next = i;
235
- }
236
- }
237
- throw new TypeError(typeof e + " is not iterable");
121
+ var a = {};
122
+ function Generator() {}
123
+ function GeneratorFunction() {}
124
+ function GeneratorFunctionPrototype() {}
125
+ t = Object.getPrototypeOf;
126
+ var c = [][n] ? t(t([][n]())) : (_regeneratorDefine(t = {}, n, function () {
127
+ return this;
128
+ }), t),
129
+ u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c);
130
+ function f(e) {
131
+ return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e;
238
132
  }
239
- return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", {
240
- value: GeneratorFunctionPrototype,
241
- configurable: !0
242
- }), o(GeneratorFunctionPrototype, "constructor", {
243
- value: GeneratorFunction,
244
- configurable: !0
245
- }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) {
246
- var e = "function" == typeof t && t.constructor;
247
- return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name));
248
- }, e.mark = function (t) {
249
- return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t;
250
- }, e.awrap = function (t) {
251
- return {
252
- __await: t
253
- };
254
- }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () {
133
+ return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine(u), _regeneratorDefine(u, o, "Generator"), _regeneratorDefine(u, n, function () {
255
134
  return this;
256
- }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) {
257
- void 0 === i && (i = Promise);
258
- var a = new AsyncIterator(wrap(t, r, n, o), i);
259
- return e.isGeneratorFunction(r) ? a : a.next().then(function (t) {
260
- return t.done ? t.value : a.next();
261
- });
262
- }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () {
263
- return this;
264
- }), define(g, "toString", function () {
135
+ }), _regeneratorDefine(u, "toString", function () {
265
136
  return "[object Generator]";
266
- }), e.keys = function (t) {
267
- var e = Object(t),
268
- r = [];
269
- for (var n in e) r.push(n);
270
- return r.reverse(), function next() {
271
- for (; r.length;) {
272
- var t = r.pop();
273
- if (t in e) return next.value = t, next.done = !1, next;
274
- }
275
- return next.done = !0, next;
137
+ }), (_regenerator = function () {
138
+ return {
139
+ w: i,
140
+ m: f
276
141
  };
277
- }, e.values = values, Context.prototype = {
278
- constructor: Context,
279
- reset: function (e) {
280
- if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t);
281
- },
282
- stop: function () {
283
- this.done = !0;
284
- var t = this.tryEntries[0].completion;
285
- if ("throw" === t.type) throw t.arg;
286
- return this.rval;
287
- },
288
- dispatchException: function (e) {
289
- if (this.done) throw e;
290
- var r = this;
291
- function handle(n, o) {
292
- return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o;
293
- }
294
- for (var o = this.tryEntries.length - 1; o >= 0; --o) {
295
- var i = this.tryEntries[o],
296
- a = i.completion;
297
- if ("root" === i.tryLoc) return handle("end");
298
- if (i.tryLoc <= this.prev) {
299
- var c = n.call(i, "catchLoc"),
300
- u = n.call(i, "finallyLoc");
301
- if (c && u) {
302
- if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
303
- if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
304
- } else if (c) {
305
- if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
306
- } else {
307
- if (!u) throw Error("try statement without catch or finally");
308
- if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
309
- }
310
- }
311
- }
312
- },
313
- abrupt: function (t, e) {
314
- for (var r = this.tryEntries.length - 1; r >= 0; --r) {
315
- var o = this.tryEntries[r];
316
- if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) {
317
- var i = o;
318
- break;
319
- }
320
- }
321
- i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null);
322
- var a = i ? i.completion : {};
323
- return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a);
324
- },
325
- complete: function (t, e) {
326
- if ("throw" === t.type) throw t.arg;
327
- return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y;
328
- },
329
- finish: function (t) {
330
- for (var e = this.tryEntries.length - 1; e >= 0; --e) {
331
- var r = this.tryEntries[e];
332
- if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y;
333
- }
334
- },
335
- catch: function (t) {
336
- for (var e = this.tryEntries.length - 1; e >= 0; --e) {
337
- var r = this.tryEntries[e];
338
- if (r.tryLoc === t) {
339
- var n = r.completion;
340
- if ("throw" === n.type) {
341
- var o = n.arg;
342
- resetTryEntry(r);
343
- }
344
- return o;
345
- }
346
- }
347
- throw Error("illegal catch attempt");
348
- },
349
- delegateYield: function (e, r, n) {
350
- return this.delegate = {
351
- iterator: values(e),
352
- resultName: r,
353
- nextLoc: n
354
- }, "next" === this.method && (this.arg = t), y;
142
+ })();
143
+ }
144
+ function _regeneratorDefine(e, r, n, t) {
145
+ var i = Object.defineProperty;
146
+ try {
147
+ i({}, "", {});
148
+ } catch (e) {
149
+ i = 0;
150
+ }
151
+ _regeneratorDefine = function (e, r, n, t) {
152
+ function o(r, n) {
153
+ _regeneratorDefine(e, r, function (e) {
154
+ return this._invoke(r, n, e);
155
+ });
355
156
  }
356
- }, e;
157
+ r ? i ? i(e, r, {
158
+ value: n,
159
+ enumerable: !t,
160
+ configurable: !t,
161
+ writable: !t
162
+ }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2));
163
+ }, _regeneratorDefine(e, r, n, t);
357
164
  }
358
165
 
359
166
  /*
@@ -397,8 +204,7 @@ var getSortVariables = function getSortVariables(sort, isCategory) {
397
204
  };
398
205
 
399
206
  function getError(errors, status) {
400
- var _errors;
401
- errors = (_errors = errors) != null ? _errors : [{
207
+ errors = errors != null ? errors : [{
402
208
  message: 'Failed to fetch Saleor API'
403
209
  }];
404
210
  return new commerce.FetcherError({
@@ -410,55 +216,51 @@ function getAsyncError(_x) {
410
216
  return _getAsyncError.apply(this, arguments);
411
217
  }
412
218
  function _getAsyncError() {
413
- _getAsyncError = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(res) {
219
+ _getAsyncError = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(res) {
414
220
  var data;
415
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
416
- while (1) switch (_context2.prev = _context2.next) {
221
+ return _regenerator().w(function (_context2) {
222
+ while (1) switch (_context2.n) {
417
223
  case 0:
418
- _context2.next = 2;
224
+ _context2.n = 1;
419
225
  return res.json();
420
- case 2:
421
- data = _context2.sent;
422
- return _context2.abrupt("return", getError(data.errors, res.status));
423
- case 4:
424
- case "end":
425
- return _context2.stop();
226
+ case 1:
227
+ data = _context2.v;
228
+ return _context2.a(2, getError(data.errors, res.status));
426
229
  }
427
230
  }, _callee2);
428
231
  }));
429
232
  return _getAsyncError.apply(this, arguments);
430
233
  }
431
234
  var handleFetchResponse = /*#__PURE__*/function () {
432
- var _ref = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(res) {
235
+ var _ref = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(res) {
433
236
  var _yield$res$json, data, errors;
434
- return _regeneratorRuntime().wrap(function _callee$(_context) {
435
- while (1) switch (_context.prev = _context.next) {
237
+ return _regenerator().w(function (_context) {
238
+ while (1) switch (_context.n) {
436
239
  case 0:
437
240
  if (!res.ok) {
438
- _context.next = 9;
241
+ _context.n = 3;
439
242
  break;
440
243
  }
441
- _context.next = 3;
244
+ _context.n = 1;
442
245
  return res.json();
443
- case 3:
444
- _yield$res$json = _context.sent;
246
+ case 1:
247
+ _yield$res$json = _context.v;
445
248
  data = _yield$res$json.data;
446
249
  errors = _yield$res$json.errors;
447
250
  if (!(errors && errors.length)) {
448
- _context.next = 8;
251
+ _context.n = 2;
449
252
  break;
450
253
  }
451
254
  throw getError(errors, res.status);
452
- case 8:
453
- return _context.abrupt("return", data);
454
- case 9:
455
- _context.next = 11;
255
+ case 2:
256
+ return _context.a(2, data);
257
+ case 3:
258
+ _context.n = 4;
456
259
  return getAsyncError(res);
457
- case 11:
458
- throw _context.sent;
459
- case 12:
460
- case "end":
461
- return _context.stop();
260
+ case 4:
261
+ throw _context.v;
262
+ case 5:
263
+ return _context.a(2);
462
264
  }
463
265
  }, _callee);
464
266
  }));
@@ -538,18 +340,18 @@ var CheckoutLineUpdate = /* GraphQL */"\n mutation CheckoutLineUpdate($checkout
538
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";
539
341
 
540
342
  var checkoutCreate = /*#__PURE__*/function () {
541
- var _ref = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(fetch) {
343
+ var _ref = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(fetch) {
542
344
  var _data$checkoutCreate;
543
345
  var data, checkout, checkoutId, checkoutToken, value, options;
544
- return _regeneratorRuntime().wrap(function _callee$(_context) {
545
- while (1) switch (_context.prev = _context.next) {
346
+ return _regenerator().w(function (_context) {
347
+ while (1) switch (_context.n) {
546
348
  case 0:
547
- _context.next = 2;
349
+ _context.n = 1;
548
350
  return fetch({
549
351
  query: CheckoutCreate
550
352
  });
551
- case 2:
552
- data = _context.sent;
353
+ case 1:
354
+ data = _context.v;
553
355
  checkout = (_data$checkoutCreate = data.checkoutCreate) == null ? void 0 : _data$checkoutCreate.checkout;
554
356
  checkoutId = checkout == null ? void 0 : checkout.id;
555
357
  checkoutToken = checkout == null ? void 0 : checkout.token;
@@ -562,10 +364,7 @@ var checkoutCreate = /*#__PURE__*/function () {
562
364
  };
563
365
  Cookies.set(CHECKOUT_ID_COOKIE, value, options);
564
366
  }
565
- return _context.abrupt("return", checkout);
566
- case 9:
567
- case "end":
568
- return _context.stop();
367
+ return _context.a(2, checkout);
569
368
  }
570
369
  }, _callee);
571
370
  }));
@@ -824,41 +623,38 @@ var handler = {
824
623
  query: CheckoutOne
825
624
  },
826
625
  fetcher: function fetcher(_ref) {
827
- return _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
626
+ return _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
828
627
  var _checkout;
829
628
  var checkoutId, options, fetch, checkout, _checkoutId, data;
830
- return _regeneratorRuntime().wrap(function _callee$(_context) {
831
- while (1) switch (_context.prev = _context.next) {
629
+ return _regenerator().w(function (_context) {
630
+ while (1) switch (_context.n) {
832
631
  case 0:
833
632
  checkoutId = _ref.input.cartId, options = _ref.options, fetch = _ref.fetch;
834
633
  if (!checkoutId) {
835
- _context.next = 7;
634
+ _context.n = 2;
836
635
  break;
837
636
  }
838
637
  _checkoutId = getCheckoutId().checkoutToken;
839
- _context.next = 5;
638
+ _context.n = 1;
840
639
  return fetch(_extends({}, options, {
841
640
  variables: {
842
641
  checkoutId: _checkoutId
843
642
  }
844
643
  }));
845
- case 5:
846
- data = _context.sent;
644
+ case 1:
645
+ data = _context.v;
847
646
  checkout = data;
848
- case 7:
647
+ case 2:
849
648
  if (!((_checkout = checkout) != null && _checkout.completedAt || !checkoutId)) {
850
- _context.next = 11;
649
+ _context.n = 4;
851
650
  break;
852
651
  }
853
- _context.next = 10;
652
+ _context.n = 3;
854
653
  return checkoutCreate(fetch);
855
- case 10:
856
- checkout = _context.sent;
857
- case 11:
858
- return _context.abrupt("return", checkoutToCart(checkout));
859
- case 12:
860
- case "end":
861
- return _context.stop();
654
+ case 3:
655
+ checkout = _context.v;
656
+ case 4:
657
+ return _context.a(2, checkoutToCart(checkout));
862
658
  }
863
659
  }, _callee);
864
660
  }))();
@@ -891,22 +687,22 @@ var handler$1 = {
891
687
  query: CheckoutLineAdd
892
688
  },
893
689
  fetcher: function fetcher(_ref) {
894
- return _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
690
+ return _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
895
691
  var _item$quantity;
896
692
  var item, options, fetch, _yield$fetch, checkoutLinesAdd;
897
- return _regeneratorRuntime().wrap(function _callee$(_context) {
898
- while (1) switch (_context.prev = _context.next) {
693
+ return _regenerator().w(function (_context) {
694
+ while (1) switch (_context.n) {
899
695
  case 0:
900
696
  item = _ref.input, options = _ref.options, fetch = _ref.fetch;
901
697
  if (!(item.quantity && (!Number.isInteger(item.quantity) || item.quantity < 1))) {
902
- _context.next = 3;
698
+ _context.n = 1;
903
699
  break;
904
700
  }
905
701
  throw new commerce.CommerceError({
906
702
  message: "The item quantity has to be a valid integer greater than 0"
907
703
  });
908
- case 3:
909
- _context.next = 5;
704
+ case 1:
705
+ _context.n = 2;
910
706
  return fetch(_extends({}, options, {
911
707
  variables: {
912
708
  checkoutId: getCheckoutId().checkoutId,
@@ -916,13 +712,10 @@ var handler$1 = {
916
712
  }]
917
713
  }
918
714
  }));
919
- case 5:
920
- _yield$fetch = _context.sent;
715
+ case 2:
716
+ _yield$fetch = _context.v;
921
717
  checkoutLinesAdd = _yield$fetch.checkoutLinesAdd;
922
- return _context.abrupt("return", checkoutToCart(checkoutLinesAdd));
923
- case 8:
924
- case "end":
925
- return _context.stop();
718
+ return _context.a(2, checkoutToCart(checkoutLinesAdd));
926
719
  }
927
720
  }, _callee);
928
721
  }))();
@@ -933,34 +726,31 @@ var handler$1 = {
933
726
  var _useCart = commerce.useCart(),
934
727
  mutate = _useCart.mutate;
935
728
  return React.useCallback(/*#__PURE__*/function () {
936
- var _addItem = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(input) {
729
+ var _addItem = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(input) {
937
730
  var data;
938
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
939
- while (1) switch (_context2.prev = _context2.next) {
731
+ return _regenerator().w(function (_context2) {
732
+ while (1) switch (_context2.n) {
940
733
  case 0:
941
- _context2.next = 2;
734
+ _context2.n = 1;
942
735
  return fetch({
943
736
  input: input
944
737
  });
945
- case 2:
946
- data = _context2.sent;
738
+ case 1:
739
+ data = _context2.v;
947
740
  if (!data) {
948
- _context2.next = 8;
741
+ _context2.n = 3;
949
742
  break;
950
743
  }
951
- _context2.next = 6;
744
+ _context2.n = 2;
952
745
  return mutate(data, false);
953
- case 6:
954
- _context2.next = 10;
746
+ case 2:
747
+ _context2.n = 4;
955
748
  break;
956
- case 8:
957
- _context2.next = 10;
749
+ case 3:
750
+ _context2.n = 4;
958
751
  return mutate();
959
- case 10:
960
- return _context2.abrupt("return", data);
961
- case 11:
962
- case "end":
963
- return _context2.stop();
752
+ case 4:
753
+ return _context2.a(2, data);
964
754
  }
965
755
  }, _callee2);
966
756
  }));
@@ -978,25 +768,22 @@ var handler$2 = {
978
768
  query: CheckoutLineDelete
979
769
  },
980
770
  fetcher: function fetcher(_ref) {
981
- return _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
771
+ return _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
982
772
  var itemId, options, fetch, data;
983
- return _regeneratorRuntime().wrap(function _callee$(_context) {
984
- while (1) switch (_context.prev = _context.next) {
773
+ return _regenerator().w(function (_context) {
774
+ while (1) switch (_context.n) {
985
775
  case 0:
986
776
  itemId = _ref.input.itemId, options = _ref.options, fetch = _ref.fetch;
987
- _context.next = 3;
777
+ _context.n = 1;
988
778
  return fetch(_extends({}, options, {
989
779
  variables: {
990
780
  checkoutId: getCheckoutId().checkoutId,
991
781
  lineId: itemId
992
782
  }
993
783
  }));
994
- case 3:
995
- data = _context.sent;
996
- return _context.abrupt("return", checkoutToCart(data.checkoutLineDelete));
997
- case 5:
998
- case "end":
999
- return _context.stop();
784
+ case 1:
785
+ data = _context.v;
786
+ return _context.a(2, checkoutToCart(data.checkoutLineDelete));
1000
787
  }
1001
788
  }, _callee);
1002
789
  }))();
@@ -1007,26 +794,23 @@ var handler$2 = {
1007
794
  var _useCart = commerce.useCart(),
1008
795
  mutate = _useCart.mutate;
1009
796
  return React.useCallback(/*#__PURE__*/function () {
1010
- var _removeItem = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(input) {
797
+ var _removeItem = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(input) {
1011
798
  var data;
1012
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
1013
- while (1) switch (_context2.prev = _context2.next) {
799
+ return _regenerator().w(function (_context2) {
800
+ while (1) switch (_context2.n) {
1014
801
  case 0:
1015
- _context2.next = 2;
802
+ _context2.n = 1;
1016
803
  return fetch({
1017
804
  input: {
1018
805
  itemId: input.id
1019
806
  }
1020
807
  });
1021
- case 2:
1022
- data = _context2.sent;
1023
- _context2.next = 5;
808
+ case 1:
809
+ data = _context2.v;
810
+ _context2.n = 2;
1024
811
  return mutate(data, false);
1025
- case 5:
1026
- return _context2.abrupt("return", data);
1027
- case 6:
1028
- case "end":
1029
- return _context2.stop();
812
+ case 2:
813
+ return _context2.a(2, data);
1030
814
  }
1031
815
  }, _callee2);
1032
816
  }));
@@ -1044,41 +828,41 @@ var handler$3 = {
1044
828
  query: CheckoutLineUpdate
1045
829
  },
1046
830
  fetcher: function fetcher(_ref) {
1047
- return _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
831
+ return _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
1048
832
  var _ref$input, itemId, item, options, fetch, checkoutId, _yield$fetch, checkoutLinesUpdate;
1049
- return _regeneratorRuntime().wrap(function _callee$(_context) {
1050
- while (1) switch (_context.prev = _context.next) {
833
+ return _regenerator().w(function (_context) {
834
+ while (1) switch (_context.n) {
1051
835
  case 0:
1052
836
  _ref$input = _ref.input, itemId = _ref$input.itemId, item = _ref$input.item, options = _ref.options, fetch = _ref.fetch;
1053
837
  if (!Number.isInteger(item.quantity)) {
1054
- _context.next = 6;
838
+ _context.n = 2;
1055
839
  break;
1056
840
  }
1057
841
  if (!(item.quantity < 1)) {
1058
- _context.next = 4;
842
+ _context.n = 1;
1059
843
  break;
1060
844
  }
1061
- return _context.abrupt("return", handler$2.fetcher({
845
+ return _context.a(2, handler$2.fetcher({
1062
846
  options: handler$2.fetchOptions,
1063
847
  input: {
1064
848
  itemId: itemId
1065
849
  },
1066
850
  fetch: fetch
1067
851
  }));
1068
- case 4:
1069
- _context.next = 8;
852
+ case 1:
853
+ _context.n = 3;
1070
854
  break;
1071
- case 6:
855
+ case 2:
1072
856
  if (!item.quantity) {
1073
- _context.next = 8;
857
+ _context.n = 3;
1074
858
  break;
1075
859
  }
1076
860
  throw new commerce.ValidationError({
1077
861
  message: "The item quantity has to be a valid integer"
1078
862
  });
1079
- case 8:
863
+ case 3:
1080
864
  checkoutId = getCheckoutId().checkoutId;
1081
- _context.next = 11;
865
+ _context.n = 4;
1082
866
  return fetch(_extends({}, options, {
1083
867
  variables: {
1084
868
  checkoutId: checkoutId,
@@ -1088,13 +872,10 @@ var handler$3 = {
1088
872
  }]
1089
873
  }
1090
874
  }));
1091
- case 11:
1092
- _yield$fetch = _context.sent;
875
+ case 4:
876
+ _yield$fetch = _context.v;
1093
877
  checkoutLinesUpdate = _yield$fetch.checkoutLinesUpdate;
1094
- return _context.abrupt("return", checkoutToCart(checkoutLinesUpdate));
1095
- case 14:
1096
- case "end":
1097
- return _context.stop();
878
+ return _context.a(2, checkoutToCart(checkoutLinesUpdate));
1098
879
  }
1099
880
  }, _callee);
1100
881
  }))();
@@ -1111,22 +892,22 @@ var handler$3 = {
1111
892
  var _useCart = commerce.useCart(),
1112
893
  mutate = _useCart.mutate;
1113
894
  return React.useCallback(debounce(/*#__PURE__*/function () {
1114
- var _ref3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(input) {
895
+ var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(input) {
1115
896
  var _input$id;
1116
897
  var itemId, data;
1117
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
1118
- while (1) switch (_context2.prev = _context2.next) {
898
+ return _regenerator().w(function (_context2) {
899
+ while (1) switch (_context2.n) {
1119
900
  case 0:
1120
901
  itemId = (_input$id = input.id) != null ? _input$id : item == null ? void 0 : item.id;
1121
902
  if (itemId) {
1122
- _context2.next = 3;
903
+ _context2.n = 1;
1123
904
  break;
1124
905
  }
1125
906
  throw new commerce.ValidationError({
1126
907
  message: "Invalid input used for this operation"
1127
908
  });
1128
- case 3:
1129
- _context2.next = 5;
909
+ case 1:
910
+ _context2.n = 2;
1130
911
  return fetch({
1131
912
  input: {
1132
913
  item: {
@@ -1135,15 +916,12 @@ var handler$3 = {
1135
916
  itemId: itemId
1136
917
  }
1137
918
  });
1138
- case 5:
1139
- data = _context2.sent;
1140
- _context2.next = 8;
919
+ case 2:
920
+ data = _context2.v;
921
+ _context2.n = 3;
1141
922
  return mutate(data, false);
1142
- case 8:
1143
- return _context2.abrupt("return", data);
1144
- case 9:
1145
- case "end":
1146
- return _context2.stop();
923
+ case 3:
924
+ return _context2.a(2, data);
1147
925
  }
1148
926
  }, _callee2);
1149
927
  }));
@@ -1160,44 +938,43 @@ var handler$4 = {
1160
938
  query: CollectionMany
1161
939
  },
1162
940
  fetcher: function fetcher(_ref) {
1163
- return _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
941
+ return _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
1164
942
  var input, fetch, categoryId, _data$collections$edg, _data$collections, data, _data;
1165
- return _regeneratorRuntime().wrap(function _callee$(_context) {
1166
- while (1) switch (_context.prev = _context.next) {
943
+ return _regenerator().w(function (_context) {
944
+ while (1) switch (_context.n) {
1167
945
  case 0:
1168
946
  input = _ref.input, fetch = _ref.fetch;
1169
947
  categoryId = input.categoryId;
1170
948
  if (categoryId) {
1171
- _context.next = 9;
949
+ _context.n = 2;
1172
950
  break;
1173
951
  }
1174
- _context.next = 5;
952
+ _context.n = 1;
1175
953
  return fetch({
1176
954
  query: CollectionMany,
1177
955
  variables: {
1178
956
  first: 250
1179
957
  }
1180
958
  });
1181
- case 5:
1182
- data = _context.sent;
1183
- return _context.abrupt("return", (_data$collections$edg = (_data$collections = data.collections) == null || (_data$collections = _data$collections.edges) == null ? void 0 : _data$collections.map(function (_ref2) {
959
+ case 1:
960
+ data = _context.v;
961
+ 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) {
1184
962
  var node = _ref2.node;
1185
963
  return normalizeCategory(node);
1186
964
  })) != null ? _data$collections$edg : []);
1187
- case 9:
1188
- _context.next = 11;
965
+ case 2:
966
+ _context.n = 3;
1189
967
  return fetch({
1190
968
  query: CollectionOne,
1191
969
  variables: {
1192
970
  categoryId: categoryId
1193
971
  }
1194
972
  });
1195
- case 11:
1196
- _data = _context.sent;
1197
- return _context.abrupt("return", !!(_data != null && _data.collection) ? [normalizeCategory(_data == null ? void 0 : _data.collection)] : []);
1198
- case 13:
1199
- case "end":
1200
- return _context.stop();
973
+ case 3:
974
+ _data = _context.v;
975
+ return _context.a(2, !!(_data != null && _data.collection) ? [normalizeCategory(_data == null ? void 0 : _data.collection)] : []);
976
+ case 4:
977
+ return _context.a(2);
1201
978
  }
1202
979
  }, _callee);
1203
980
  }))();
@@ -1231,14 +1008,11 @@ var handler$5 = {
1231
1008
  query: getAllProductVendors
1232
1009
  },
1233
1010
  fetcher: function fetcher(_ref) {
1234
- return _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
1235
- return _regeneratorRuntime().wrap(function _callee$(_context) {
1236
- while (1) switch (_context.prev = _context.next) {
1011
+ return _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
1012
+ return _regenerator().w(function (_context) {
1013
+ while (1) switch (_context.n) {
1237
1014
  case 0:
1238
- return _context.abrupt("return", []);
1239
- case 2:
1240
- case "end":
1241
- return _context.stop();
1015
+ return _context.a(2, []);
1242
1016
  }
1243
1017
  }, _callee);
1244
1018
  }))();
@@ -1271,21 +1045,21 @@ var handler$6 = {
1271
1045
  query: ProductMany
1272
1046
  },
1273
1047
  fetcher: function fetcher(_ref) {
1274
- return _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
1048
+ return _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
1275
1049
  var input, options, fetch, categoryId, brandId, data, edges, _data$collection$prod, _data$collection, _data$products$edges, _data$products;
1276
- return _regeneratorRuntime().wrap(function _callee$(_context) {
1277
- while (1) switch (_context.prev = _context.next) {
1050
+ return _regenerator().w(function (_context) {
1051
+ while (1) switch (_context.n) {
1278
1052
  case 0:
1279
1053
  input = _ref.input, options = _ref.options, fetch = _ref.fetch;
1280
1054
  categoryId = input.categoryId, brandId = input.brandId;
1281
- _context.next = 4;
1055
+ _context.n = 1;
1282
1056
  return fetch({
1283
1057
  query: categoryId ? CollectionOne : options.query,
1284
1058
  method: options == null ? void 0 : options.method,
1285
1059
  variables: getSearchVariables(input)
1286
1060
  });
1287
- case 4:
1288
- data = _context.sent;
1061
+ case 1:
1062
+ data = _context.v;
1289
1063
  if (categoryId) {
1290
1064
  edges = (_data$collection$prod = (_data$collection = data.collection) == null || (_data$collection = _data$collection.products) == null ? void 0 : _data$collection.edges) != null ? _data$collection$prod : [];
1291
1065
  // FIXME @zaiste, no `vendor` in Saleor
@@ -1298,16 +1072,13 @@ var handler$6 = {
1298
1072
  } else {
1299
1073
  edges = (_data$products$edges = (_data$products = data.products) == null ? void 0 : _data$products.edges) != null ? _data$products$edges : [];
1300
1074
  }
1301
- return _context.abrupt("return", {
1075
+ return _context.a(2, {
1302
1076
  products: edges.map(function (_ref2) {
1303
1077
  var node = _ref2.node;
1304
1078
  return normalizeProduct(node);
1305
1079
  }),
1306
1080
  found: !!edges.length
1307
1081
  });
1308
- case 7:
1309
- case "end":
1310
- return _context.stop();
1311
1082
  }
1312
1083
  }, _callee);
1313
1084
  }))();
@@ -1335,47 +1106,44 @@ var handler$7 = {
1335
1106
  query: ProductOneById
1336
1107
  },
1337
1108
  fetcher: function fetcher(_ref) {
1338
- return _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
1109
+ return _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
1339
1110
  var input, fetch, id, data, response;
1340
- return _regeneratorRuntime().wrap(function _callee$(_context) {
1341
- while (1) switch (_context.prev = _context.next) {
1111
+ return _regenerator().w(function (_context) {
1112
+ while (1) switch (_context.n) {
1342
1113
  case 0:
1343
1114
  input = _ref.input, fetch = _ref.fetch;
1344
1115
  id = input.id;
1345
1116
  if (id) {
1346
- _context.next = 4;
1117
+ _context.n = 1;
1347
1118
  break;
1348
1119
  }
1349
- return _context.abrupt("return", null);
1350
- case 4:
1351
- _context.next = 6;
1120
+ return _context.a(2, null);
1121
+ case 1:
1122
+ _context.n = 2;
1352
1123
  return fetch({
1353
1124
  query: ProductOneById,
1354
1125
  variables: {
1355
1126
  id: id
1356
1127
  }
1357
1128
  });
1358
- case 6:
1359
- data = _context.sent;
1129
+ case 2:
1130
+ data = _context.v;
1360
1131
  if (data.product) {
1361
- _context.next = 12;
1132
+ _context.n = 4;
1362
1133
  break;
1363
1134
  }
1364
- _context.next = 10;
1135
+ _context.n = 3;
1365
1136
  return fetch({
1366
1137
  query: ProductOneBySlug,
1367
1138
  variables: {
1368
1139
  slug: id
1369
1140
  }
1370
1141
  });
1371
- case 10:
1372
- response = _context.sent;
1373
- return _context.abrupt("return", response.product ? normalizeProduct(response.product) : null);
1374
- case 12:
1375
- return _context.abrupt("return", data.product ? normalizeProduct(data.product) : null);
1376
- case 13:
1377
- case "end":
1378
- return _context.stop();
1142
+ case 3:
1143
+ response = _context.v;
1144
+ return _context.a(2, response.product ? normalizeProduct(response.product) : null);
1145
+ case 4:
1146
+ return _context.a(2, data.product ? normalizeProduct(data.product) : null);
1379
1147
  }
1380
1148
  }, _callee);
1381
1149
  }))();
@@ -1399,16 +1167,16 @@ var handler$7 = {
1399
1167
  var _excluded$1 = ["locale"];
1400
1168
  var getFetcher = function getFetcher(saleorApiUrl) {
1401
1169
  return /*#__PURE__*/function () {
1402
- var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref) {
1403
- var _ref$url, url, _ref$method, method, query, variables, _ref3, vars, token;
1404
- return _regeneratorRuntime().wrap(function _callee$(_context) {
1405
- while (1) switch (_context.prev = _context.next) {
1170
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref) {
1171
+ var _ref$url, url, _ref$method, method, query, variables, _ref3, vars, token, _t;
1172
+ return _regenerator().w(function (_context) {
1173
+ while (1) switch (_context.n) {
1406
1174
  case 0:
1407
1175
  _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;
1408
1176
  _ref3 = variables != null ? variables : {}, vars = _objectWithoutPropertiesLoose(_ref3, _excluded$1);
1409
1177
  token = getToken();
1410
- _context.t0 = handleFetchResponse;
1411
- _context.next = 6;
1178
+ _t = handleFetchResponse;
1179
+ _context.n = 1;
1412
1180
  return fetch(url, {
1413
1181
  method: method,
1414
1182
  body: JSON.stringify({
@@ -1420,12 +1188,8 @@ var getFetcher = function getFetcher(saleorApiUrl) {
1420
1188
  'Content-Type': 'application/json'
1421
1189
  }
1422
1190
  });
1423
- case 6:
1424
- _context.t1 = _context.sent;
1425
- return _context.abrupt("return", (0, _context.t0)(_context.t1));
1426
- case 8:
1427
- case "end":
1428
- return _context.stop();
1191
+ case 1:
1192
+ return _context.a(2, _t(_context.v));
1429
1193
  }
1430
1194
  }, _callee);
1431
1195
  }));