@plasmicpkgs/commerce-swell 0.0.253 → 0.0.254
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.
- package/dist/commerce-swell.cjs.development.js +300 -521
- package/dist/commerce-swell.cjs.development.js.map +1 -1
- package/dist/commerce-swell.cjs.production.min.js +1 -1
- package/dist/commerce-swell.cjs.production.min.js.map +1 -1
- package/dist/commerce-swell.esm.js +300 -521
- package/dist/commerce-swell.esm.js.map +1 -1
- package/package.json +4 -4
|
@@ -77,306 +77,130 @@ function _objectWithoutPropertiesLoose(r, e) {
|
|
|
77
77
|
}
|
|
78
78
|
return t;
|
|
79
79
|
}
|
|
80
|
-
function
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
return o(a, "_invoke", {
|
|
115
|
-
value: makeInvokeMethod(t, r, c)
|
|
116
|
-
}), a;
|
|
117
|
-
}
|
|
118
|
-
function tryCatch(t, e, r) {
|
|
119
|
-
try {
|
|
120
|
-
return {
|
|
121
|
-
type: "normal",
|
|
122
|
-
arg: t.call(e, r)
|
|
123
|
-
};
|
|
124
|
-
} catch (t) {
|
|
125
|
-
return {
|
|
126
|
-
type: "throw",
|
|
127
|
-
arg: t
|
|
128
|
-
};
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
e.wrap = wrap;
|
|
132
|
-
var h = "suspendedStart",
|
|
133
|
-
l = "suspendedYield",
|
|
134
|
-
f = "executing",
|
|
135
|
-
s = "completed",
|
|
136
|
-
y = {};
|
|
137
|
-
function Generator() {}
|
|
138
|
-
function GeneratorFunction() {}
|
|
139
|
-
function GeneratorFunctionPrototype() {}
|
|
140
|
-
var p = {};
|
|
141
|
-
define(p, a, function () {
|
|
142
|
-
return this;
|
|
143
|
-
});
|
|
144
|
-
var d = Object.getPrototypeOf,
|
|
145
|
-
v = d && d(d(values([])));
|
|
146
|
-
v && v !== r && n.call(v, a) && (p = v);
|
|
147
|
-
var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p);
|
|
148
|
-
function defineIteratorMethods(t) {
|
|
149
|
-
["next", "throw", "return"].forEach(function (e) {
|
|
150
|
-
define(t, e, function (t) {
|
|
151
|
-
return this._invoke(e, t);
|
|
152
|
-
});
|
|
153
|
-
});
|
|
154
|
-
}
|
|
155
|
-
function AsyncIterator(t, e) {
|
|
156
|
-
function invoke(r, o, i, a) {
|
|
157
|
-
var c = tryCatch(t[r], t, o);
|
|
158
|
-
if ("throw" !== c.type) {
|
|
159
|
-
var u = c.arg,
|
|
160
|
-
h = u.value;
|
|
161
|
-
return h && "object" == typeof h && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) {
|
|
162
|
-
invoke("next", t, i, a);
|
|
163
|
-
}, function (t) {
|
|
164
|
-
invoke("throw", t, i, a);
|
|
165
|
-
}) : e.resolve(h).then(function (t) {
|
|
166
|
-
u.value = t, i(u);
|
|
167
|
-
}, function (t) {
|
|
168
|
-
return invoke("throw", t, i, a);
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
|
-
a(c.arg);
|
|
172
|
-
}
|
|
173
|
-
var r;
|
|
174
|
-
o(this, "_invoke", {
|
|
175
|
-
value: function (t, n) {
|
|
176
|
-
function callInvokeWithMethodAndArg() {
|
|
177
|
-
return new e(function (e, r) {
|
|
178
|
-
invoke(t, n, e, r);
|
|
179
|
-
});
|
|
80
|
+
function _regenerator() {
|
|
81
|
+
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
|
|
82
|
+
var e,
|
|
83
|
+
t,
|
|
84
|
+
r = "function" == typeof Symbol ? Symbol : {},
|
|
85
|
+
n = r.iterator || "@@iterator",
|
|
86
|
+
o = r.toStringTag || "@@toStringTag";
|
|
87
|
+
function i(r, n, o, i) {
|
|
88
|
+
var c = n && n.prototype instanceof Generator ? n : Generator,
|
|
89
|
+
u = Object.create(c.prototype);
|
|
90
|
+
return _regeneratorDefine(u, "_invoke", function (r, n, o) {
|
|
91
|
+
var i,
|
|
92
|
+
c,
|
|
93
|
+
u,
|
|
94
|
+
f = 0,
|
|
95
|
+
p = o || [],
|
|
96
|
+
y = !1,
|
|
97
|
+
G = {
|
|
98
|
+
p: 0,
|
|
99
|
+
n: 0,
|
|
100
|
+
v: e,
|
|
101
|
+
a: d,
|
|
102
|
+
f: d.bind(e, 4),
|
|
103
|
+
d: function (t, r) {
|
|
104
|
+
return i = t, c = 0, u = e, G.n = r, a;
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
function d(r, n) {
|
|
108
|
+
for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) {
|
|
109
|
+
var o,
|
|
110
|
+
i = p[t],
|
|
111
|
+
d = G.p,
|
|
112
|
+
l = i[2];
|
|
113
|
+
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));
|
|
180
114
|
}
|
|
181
|
-
|
|
115
|
+
if (o || r > 1) return a;
|
|
116
|
+
throw y = !0, n;
|
|
182
117
|
}
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
118
|
+
return function (o, p, l) {
|
|
119
|
+
if (f > 1) throw TypeError("Generator is already running");
|
|
120
|
+
for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) {
|
|
121
|
+
i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u);
|
|
122
|
+
try {
|
|
123
|
+
if (f = 2, i) {
|
|
124
|
+
if (c || (o = "next"), t = i[o]) {
|
|
125
|
+
if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object");
|
|
126
|
+
if (!t.done) return t;
|
|
127
|
+
u = t.value, c < 2 && (c = 0);
|
|
128
|
+
} else 1 === c && (t = i.return) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1);
|
|
129
|
+
i = e;
|
|
130
|
+
} else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break;
|
|
131
|
+
} catch (t) {
|
|
132
|
+
i = e, c = 1, u = t;
|
|
133
|
+
} finally {
|
|
134
|
+
f = 1;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
191
137
|
return {
|
|
192
138
|
value: t,
|
|
193
|
-
done:
|
|
139
|
+
done: y
|
|
194
140
|
};
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
var c = n.delegate;
|
|
198
|
-
if (c) {
|
|
199
|
-
var u = maybeInvokeDelegate(c, n);
|
|
200
|
-
if (u) {
|
|
201
|
-
if (u === y) continue;
|
|
202
|
-
return u;
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) {
|
|
206
|
-
if (o === h) throw o = s, n.arg;
|
|
207
|
-
n.dispatchException(n.arg);
|
|
208
|
-
} else "return" === n.method && n.abrupt("return", n.arg);
|
|
209
|
-
o = f;
|
|
210
|
-
var p = tryCatch(e, r, n);
|
|
211
|
-
if ("normal" === p.type) {
|
|
212
|
-
if (o = n.done ? s : l, p.arg === y) continue;
|
|
213
|
-
return {
|
|
214
|
-
value: p.arg,
|
|
215
|
-
done: n.done
|
|
216
|
-
};
|
|
217
|
-
}
|
|
218
|
-
"throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg);
|
|
219
|
-
}
|
|
220
|
-
};
|
|
141
|
+
};
|
|
142
|
+
}(r, o, i), !0), u;
|
|
221
143
|
}
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
144
|
+
var a = {};
|
|
145
|
+
function Generator() {}
|
|
146
|
+
function GeneratorFunction() {}
|
|
147
|
+
function GeneratorFunctionPrototype() {}
|
|
148
|
+
t = Object.getPrototypeOf;
|
|
149
|
+
var c = [][n] ? t(t([][n]())) : (_regeneratorDefine(t = {}, n, function () {
|
|
150
|
+
return this;
|
|
151
|
+
}), t),
|
|
152
|
+
u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c);
|
|
153
|
+
function f(e) {
|
|
154
|
+
return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e;
|
|
230
155
|
}
|
|
231
|
-
function
|
|
232
|
-
|
|
233
|
-
|
|
156
|
+
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 () {
|
|
157
|
+
return this;
|
|
158
|
+
}), _regeneratorDefine(u, "toString", function () {
|
|
159
|
+
return "[object Generator]";
|
|
160
|
+
}), (_regenerator = function () {
|
|
161
|
+
return {
|
|
162
|
+
w: i,
|
|
163
|
+
m: f
|
|
234
164
|
};
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
tryLoc: "root"
|
|
244
|
-
}], t.forEach(pushTryEntry, this), this.reset(!0);
|
|
165
|
+
})();
|
|
166
|
+
}
|
|
167
|
+
function _regeneratorDefine(e, r, n, t) {
|
|
168
|
+
var i = Object.defineProperty;
|
|
169
|
+
try {
|
|
170
|
+
i({}, "", {});
|
|
171
|
+
} catch (e) {
|
|
172
|
+
i = 0;
|
|
245
173
|
}
|
|
246
|
-
function
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
if (!isNaN(e.length)) {
|
|
252
|
-
var o = -1,
|
|
253
|
-
i = function next() {
|
|
254
|
-
for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next;
|
|
255
|
-
return next.value = t, next.done = !0, next;
|
|
256
|
-
};
|
|
257
|
-
return i.next = i;
|
|
258
|
-
}
|
|
174
|
+
_regeneratorDefine = function (e, r, n, t) {
|
|
175
|
+
function o(r, n) {
|
|
176
|
+
_regeneratorDefine(e, r, function (e) {
|
|
177
|
+
return this._invoke(r, n, e);
|
|
178
|
+
});
|
|
259
179
|
}
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
return {
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
void 0 === i && (i = Promise);
|
|
281
|
-
var a = new AsyncIterator(wrap(t, r, n, o), i);
|
|
282
|
-
return e.isGeneratorFunction(r) ? a : a.next().then(function (t) {
|
|
283
|
-
return t.done ? t.value : a.next();
|
|
284
|
-
});
|
|
285
|
-
}, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () {
|
|
286
|
-
return this;
|
|
287
|
-
}), define(g, "toString", function () {
|
|
288
|
-
return "[object Generator]";
|
|
289
|
-
}), e.keys = function (t) {
|
|
290
|
-
var e = Object(t),
|
|
291
|
-
r = [];
|
|
292
|
-
for (var n in e) r.push(n);
|
|
293
|
-
return r.reverse(), function next() {
|
|
294
|
-
for (; r.length;) {
|
|
295
|
-
var t = r.pop();
|
|
296
|
-
if (t in e) return next.value = t, next.done = !1, next;
|
|
180
|
+
r ? i ? i(e, r, {
|
|
181
|
+
value: n,
|
|
182
|
+
enumerable: !t,
|
|
183
|
+
configurable: !t,
|
|
184
|
+
writable: !t
|
|
185
|
+
}) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2));
|
|
186
|
+
}, _regeneratorDefine(e, r, n, t);
|
|
187
|
+
}
|
|
188
|
+
function _regeneratorValues(e) {
|
|
189
|
+
if (null != e) {
|
|
190
|
+
var t = e["function" == typeof Symbol && Symbol.iterator || "@@iterator"],
|
|
191
|
+
r = 0;
|
|
192
|
+
if (t) return t.call(e);
|
|
193
|
+
if ("function" == typeof e.next) return e;
|
|
194
|
+
if (!isNaN(e.length)) return {
|
|
195
|
+
next: function () {
|
|
196
|
+
return e && r >= e.length && (e = void 0), {
|
|
197
|
+
value: e && e[r++],
|
|
198
|
+
done: !e
|
|
199
|
+
};
|
|
297
200
|
}
|
|
298
|
-
return next.done = !0, next;
|
|
299
201
|
};
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
reset: function (e) {
|
|
303
|
-
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);
|
|
304
|
-
},
|
|
305
|
-
stop: function () {
|
|
306
|
-
this.done = !0;
|
|
307
|
-
var t = this.tryEntries[0].completion;
|
|
308
|
-
if ("throw" === t.type) throw t.arg;
|
|
309
|
-
return this.rval;
|
|
310
|
-
},
|
|
311
|
-
dispatchException: function (e) {
|
|
312
|
-
if (this.done) throw e;
|
|
313
|
-
var r = this;
|
|
314
|
-
function handle(n, o) {
|
|
315
|
-
return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o;
|
|
316
|
-
}
|
|
317
|
-
for (var o = this.tryEntries.length - 1; o >= 0; --o) {
|
|
318
|
-
var i = this.tryEntries[o],
|
|
319
|
-
a = i.completion;
|
|
320
|
-
if ("root" === i.tryLoc) return handle("end");
|
|
321
|
-
if (i.tryLoc <= this.prev) {
|
|
322
|
-
var c = n.call(i, "catchLoc"),
|
|
323
|
-
u = n.call(i, "finallyLoc");
|
|
324
|
-
if (c && u) {
|
|
325
|
-
if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
|
|
326
|
-
if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
|
|
327
|
-
} else if (c) {
|
|
328
|
-
if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
|
|
329
|
-
} else {
|
|
330
|
-
if (!u) throw Error("try statement without catch or finally");
|
|
331
|
-
if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
},
|
|
336
|
-
abrupt: function (t, e) {
|
|
337
|
-
for (var r = this.tryEntries.length - 1; r >= 0; --r) {
|
|
338
|
-
var o = this.tryEntries[r];
|
|
339
|
-
if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) {
|
|
340
|
-
var i = o;
|
|
341
|
-
break;
|
|
342
|
-
}
|
|
343
|
-
}
|
|
344
|
-
i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null);
|
|
345
|
-
var a = i ? i.completion : {};
|
|
346
|
-
return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a);
|
|
347
|
-
},
|
|
348
|
-
complete: function (t, e) {
|
|
349
|
-
if ("throw" === t.type) throw t.arg;
|
|
350
|
-
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;
|
|
351
|
-
},
|
|
352
|
-
finish: function (t) {
|
|
353
|
-
for (var e = this.tryEntries.length - 1; e >= 0; --e) {
|
|
354
|
-
var r = this.tryEntries[e];
|
|
355
|
-
if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y;
|
|
356
|
-
}
|
|
357
|
-
},
|
|
358
|
-
catch: function (t) {
|
|
359
|
-
for (var e = this.tryEntries.length - 1; e >= 0; --e) {
|
|
360
|
-
var r = this.tryEntries[e];
|
|
361
|
-
if (r.tryLoc === t) {
|
|
362
|
-
var n = r.completion;
|
|
363
|
-
if ("throw" === n.type) {
|
|
364
|
-
var o = n.arg;
|
|
365
|
-
resetTryEntry(r);
|
|
366
|
-
}
|
|
367
|
-
return o;
|
|
368
|
-
}
|
|
369
|
-
}
|
|
370
|
-
throw Error("illegal catch attempt");
|
|
371
|
-
},
|
|
372
|
-
delegateYield: function (e, r, n) {
|
|
373
|
-
return this.delegate = {
|
|
374
|
-
iterator: values(e),
|
|
375
|
-
resultName: r,
|
|
376
|
-
nextLoc: n
|
|
377
|
-
}, "next" === this.method && (this.arg = t), y;
|
|
378
|
-
}
|
|
379
|
-
}, e;
|
|
202
|
+
}
|
|
203
|
+
throw new TypeError(typeof e + " is not iterable");
|
|
380
204
|
}
|
|
381
205
|
function _unsupportedIterableToArray(r, a) {
|
|
382
206
|
if (r) {
|
|
@@ -613,26 +437,23 @@ function normalizeCategory(_ref7) {
|
|
|
613
437
|
}
|
|
614
438
|
|
|
615
439
|
var handleFetchResponse = /*#__PURE__*/function () {
|
|
616
|
-
var _ref = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/
|
|
617
|
-
return
|
|
618
|
-
while (1) switch (_context.
|
|
440
|
+
var _ref = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(res) {
|
|
441
|
+
return _regenerator().w(function (_context) {
|
|
442
|
+
while (1) switch (_context.n) {
|
|
619
443
|
case 0:
|
|
620
444
|
if (!res) {
|
|
621
|
-
_context.
|
|
445
|
+
_context.n = 2;
|
|
622
446
|
break;
|
|
623
447
|
}
|
|
624
448
|
if (!res.error) {
|
|
625
|
-
_context.
|
|
449
|
+
_context.n = 1;
|
|
626
450
|
break;
|
|
627
451
|
}
|
|
628
452
|
throw new commerce.CommerceError(res.error);
|
|
629
|
-
case
|
|
630
|
-
return _context.
|
|
631
|
-
case
|
|
632
|
-
return _context.
|
|
633
|
-
case 5:
|
|
634
|
-
case "end":
|
|
635
|
-
return _context.stop();
|
|
453
|
+
case 1:
|
|
454
|
+
return _context.a(2, res);
|
|
455
|
+
case 2:
|
|
456
|
+
return _context.a(2, null);
|
|
636
457
|
}
|
|
637
458
|
}, _callee);
|
|
638
459
|
}));
|
|
@@ -663,29 +484,29 @@ var checkoutToCart = function checkoutToCart(checkoutPayload) {
|
|
|
663
484
|
};
|
|
664
485
|
|
|
665
486
|
var checkoutCreate = /*#__PURE__*/function () {
|
|
666
|
-
var _ref = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/
|
|
487
|
+
var _ref = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(fetch) {
|
|
667
488
|
var cart, checkoutUrl, options;
|
|
668
|
-
return
|
|
669
|
-
while (1) switch (_context.
|
|
489
|
+
return _regenerator().w(function (_context) {
|
|
490
|
+
while (1) switch (_context.n) {
|
|
670
491
|
case 0:
|
|
671
|
-
_context.
|
|
492
|
+
_context.n = 1;
|
|
672
493
|
return fetch({
|
|
673
494
|
query: 'cart',
|
|
674
495
|
method: 'get'
|
|
675
496
|
});
|
|
676
|
-
case
|
|
677
|
-
cart = _context.
|
|
497
|
+
case 1:
|
|
498
|
+
cart = _context.v;
|
|
678
499
|
if (cart) {
|
|
679
|
-
_context.
|
|
500
|
+
_context.n = 2;
|
|
680
501
|
break;
|
|
681
502
|
}
|
|
682
|
-
_context.
|
|
503
|
+
_context.n = 2;
|
|
683
504
|
return fetch({
|
|
684
505
|
query: 'cart',
|
|
685
506
|
method: 'setItems',
|
|
686
507
|
variables: [[]]
|
|
687
508
|
});
|
|
688
|
-
case
|
|
509
|
+
case 2:
|
|
689
510
|
checkoutUrl = cart == null ? void 0 : cart.checkout_url;
|
|
690
511
|
options = {
|
|
691
512
|
expires: SWELL_COOKIE_EXPIRE,
|
|
@@ -695,10 +516,7 @@ var checkoutCreate = /*#__PURE__*/function () {
|
|
|
695
516
|
if (checkoutUrl) {
|
|
696
517
|
Cookies.set(SWELL_CHECKOUT_URL_COOKIE, checkoutUrl, options);
|
|
697
518
|
}
|
|
698
|
-
return _context.
|
|
699
|
-
case 10:
|
|
700
|
-
case "end":
|
|
701
|
-
return _context.stop();
|
|
519
|
+
return _context.a(2, cart);
|
|
702
520
|
}
|
|
703
521
|
}, _callee);
|
|
704
522
|
}));
|
|
@@ -713,20 +531,17 @@ var handler = {
|
|
|
713
531
|
method: 'get'
|
|
714
532
|
},
|
|
715
533
|
fetcher: function fetcher(_ref) {
|
|
716
|
-
return _asyncToGenerator(/*#__PURE__*/
|
|
534
|
+
return _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
|
|
717
535
|
var fetch, cart;
|
|
718
|
-
return
|
|
719
|
-
while (1) switch (_context.
|
|
536
|
+
return _regenerator().w(function (_context) {
|
|
537
|
+
while (1) switch (_context.n) {
|
|
720
538
|
case 0:
|
|
721
539
|
fetch = _ref.fetch;
|
|
722
|
-
_context.
|
|
540
|
+
_context.n = 1;
|
|
723
541
|
return checkoutCreate(fetch);
|
|
724
|
-
case
|
|
725
|
-
cart = _context.
|
|
726
|
-
return _context.
|
|
727
|
-
case 5:
|
|
728
|
-
case "end":
|
|
729
|
-
return _context.stop();
|
|
542
|
+
case 1:
|
|
543
|
+
cart = _context.v;
|
|
544
|
+
return _context.a(2, cart ? normalizeCart(cart) : null);
|
|
730
545
|
}
|
|
731
546
|
}, _callee);
|
|
732
547
|
}))();
|
|
@@ -760,20 +575,20 @@ var handler$1 = {
|
|
|
760
575
|
method: 'addItem'
|
|
761
576
|
},
|
|
762
577
|
fetcher: function fetcher(_ref) {
|
|
763
|
-
return _asyncToGenerator(/*#__PURE__*/
|
|
578
|
+
return _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
|
|
764
579
|
var item, options, fetch, variables, response;
|
|
765
|
-
return
|
|
766
|
-
while (1) switch (_context.
|
|
580
|
+
return _regenerator().w(function (_context) {
|
|
581
|
+
while (1) switch (_context.n) {
|
|
767
582
|
case 0:
|
|
768
583
|
item = _ref.input, options = _ref.options, fetch = _ref.fetch;
|
|
769
584
|
if (!(item.quantity && (!Number.isInteger(item.quantity) || item.quantity < 1))) {
|
|
770
|
-
_context.
|
|
585
|
+
_context.n = 1;
|
|
771
586
|
break;
|
|
772
587
|
}
|
|
773
588
|
throw new commerce.CommerceError({
|
|
774
589
|
message: 'The item quantity has to be a valid integer greater than 0'
|
|
775
590
|
});
|
|
776
|
-
case
|
|
591
|
+
case 1:
|
|
777
592
|
variables = {
|
|
778
593
|
checkoutId: getCheckoutId(),
|
|
779
594
|
product_id: item.productId,
|
|
@@ -782,16 +597,13 @@ var handler$1 = {
|
|
|
782
597
|
if (item.productId !== item.variantId) {
|
|
783
598
|
variables.variant_id = item.variantId;
|
|
784
599
|
}
|
|
785
|
-
_context.
|
|
600
|
+
_context.n = 2;
|
|
786
601
|
return fetch(_extends({}, options, {
|
|
787
602
|
variables: variables
|
|
788
603
|
}));
|
|
789
|
-
case
|
|
790
|
-
response = _context.
|
|
791
|
-
return _context.
|
|
792
|
-
case 9:
|
|
793
|
-
case "end":
|
|
794
|
-
return _context.stop();
|
|
604
|
+
case 2:
|
|
605
|
+
response = _context.v;
|
|
606
|
+
return _context.a(2, checkoutToCart(response));
|
|
795
607
|
}
|
|
796
608
|
}, _callee);
|
|
797
609
|
}))();
|
|
@@ -802,24 +614,21 @@ var handler$1 = {
|
|
|
802
614
|
var _useCart = commerce.useCart(),
|
|
803
615
|
mutate = _useCart.mutate;
|
|
804
616
|
return React.useCallback(/*#__PURE__*/function () {
|
|
805
|
-
var _addItem = _asyncToGenerator(/*#__PURE__*/
|
|
617
|
+
var _addItem = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(input) {
|
|
806
618
|
var data;
|
|
807
|
-
return
|
|
808
|
-
while (1) switch (_context2.
|
|
619
|
+
return _regenerator().w(function (_context2) {
|
|
620
|
+
while (1) switch (_context2.n) {
|
|
809
621
|
case 0:
|
|
810
|
-
_context2.
|
|
622
|
+
_context2.n = 1;
|
|
811
623
|
return fetch({
|
|
812
624
|
input: input
|
|
813
625
|
});
|
|
814
|
-
case
|
|
815
|
-
data = _context2.
|
|
816
|
-
_context2.
|
|
626
|
+
case 1:
|
|
627
|
+
data = _context2.v;
|
|
628
|
+
_context2.n = 2;
|
|
817
629
|
return mutate(data, false);
|
|
818
|
-
case
|
|
819
|
-
return _context2.
|
|
820
|
-
case 6:
|
|
821
|
-
case "end":
|
|
822
|
-
return _context2.stop();
|
|
630
|
+
case 2:
|
|
631
|
+
return _context2.a(2, data);
|
|
823
632
|
}
|
|
824
633
|
}, _callee2);
|
|
825
634
|
}));
|
|
@@ -838,22 +647,19 @@ var handler$2 = {
|
|
|
838
647
|
method: "removeItem"
|
|
839
648
|
},
|
|
840
649
|
fetcher: function fetcher(_ref) {
|
|
841
|
-
return _asyncToGenerator(/*#__PURE__*/
|
|
650
|
+
return _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
|
|
842
651
|
var itemId, options, fetch, response;
|
|
843
|
-
return
|
|
844
|
-
while (1) switch (_context.
|
|
652
|
+
return _regenerator().w(function (_context) {
|
|
653
|
+
while (1) switch (_context.n) {
|
|
845
654
|
case 0:
|
|
846
655
|
itemId = _ref.input.itemId, options = _ref.options, fetch = _ref.fetch;
|
|
847
|
-
_context.
|
|
656
|
+
_context.n = 1;
|
|
848
657
|
return fetch(_extends({}, options, {
|
|
849
658
|
variables: [itemId]
|
|
850
659
|
}));
|
|
851
|
-
case
|
|
852
|
-
response = _context.
|
|
853
|
-
return _context.
|
|
854
|
-
case 5:
|
|
855
|
-
case "end":
|
|
856
|
-
return _context.stop();
|
|
660
|
+
case 1:
|
|
661
|
+
response = _context.v;
|
|
662
|
+
return _context.a(2, checkoutToCart(response));
|
|
857
663
|
}
|
|
858
664
|
}, _callee);
|
|
859
665
|
}))();
|
|
@@ -864,26 +670,23 @@ var handler$2 = {
|
|
|
864
670
|
var _useCart = commerce.useCart(),
|
|
865
671
|
mutate = _useCart.mutate;
|
|
866
672
|
return React.useCallback(/*#__PURE__*/function () {
|
|
867
|
-
var _removeItem = _asyncToGenerator(/*#__PURE__*/
|
|
673
|
+
var _removeItem = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(input) {
|
|
868
674
|
var data;
|
|
869
|
-
return
|
|
870
|
-
while (1) switch (_context2.
|
|
675
|
+
return _regenerator().w(function (_context2) {
|
|
676
|
+
while (1) switch (_context2.n) {
|
|
871
677
|
case 0:
|
|
872
|
-
_context2.
|
|
678
|
+
_context2.n = 1;
|
|
873
679
|
return fetch({
|
|
874
680
|
input: {
|
|
875
681
|
itemId: input.id
|
|
876
682
|
}
|
|
877
683
|
});
|
|
878
|
-
case
|
|
879
|
-
data = _context2.
|
|
880
|
-
_context2.
|
|
684
|
+
case 1:
|
|
685
|
+
data = _context2.v;
|
|
686
|
+
_context2.n = 2;
|
|
881
687
|
return mutate(data, false);
|
|
882
|
-
case
|
|
883
|
-
return _context2.
|
|
884
|
-
case 6:
|
|
885
|
-
case "end":
|
|
886
|
-
return _context2.stop();
|
|
688
|
+
case 2:
|
|
689
|
+
return _context2.a(2, data);
|
|
887
690
|
}
|
|
888
691
|
}, _callee2);
|
|
889
692
|
}));
|
|
@@ -902,51 +705,48 @@ var handler$3 = {
|
|
|
902
705
|
method: "updateItem"
|
|
903
706
|
},
|
|
904
707
|
fetcher: function fetcher(_ref) {
|
|
905
|
-
return _asyncToGenerator(/*#__PURE__*/
|
|
708
|
+
return _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
|
|
906
709
|
var _ref$input, itemId, item, options, fetch, response;
|
|
907
|
-
return
|
|
908
|
-
while (1) switch (_context.
|
|
710
|
+
return _regenerator().w(function (_context) {
|
|
711
|
+
while (1) switch (_context.n) {
|
|
909
712
|
case 0:
|
|
910
713
|
_ref$input = _ref.input, itemId = _ref$input.itemId, item = _ref$input.item, options = _ref.options, fetch = _ref.fetch;
|
|
911
714
|
if (!Number.isInteger(item.quantity)) {
|
|
912
|
-
_context.
|
|
715
|
+
_context.n = 2;
|
|
913
716
|
break;
|
|
914
717
|
}
|
|
915
718
|
if (!(item.quantity < 1)) {
|
|
916
|
-
_context.
|
|
719
|
+
_context.n = 1;
|
|
917
720
|
break;
|
|
918
721
|
}
|
|
919
|
-
return _context.
|
|
722
|
+
return _context.a(2, handler$2.fetcher({
|
|
920
723
|
options: handler$2.fetchOptions,
|
|
921
724
|
input: {
|
|
922
725
|
itemId: itemId
|
|
923
726
|
},
|
|
924
727
|
fetch: fetch
|
|
925
728
|
}));
|
|
926
|
-
case
|
|
927
|
-
_context.
|
|
729
|
+
case 1:
|
|
730
|
+
_context.n = 3;
|
|
928
731
|
break;
|
|
929
|
-
case
|
|
732
|
+
case 2:
|
|
930
733
|
if (!item.quantity) {
|
|
931
|
-
_context.
|
|
734
|
+
_context.n = 3;
|
|
932
735
|
break;
|
|
933
736
|
}
|
|
934
737
|
throw new commerce.ValidationError({
|
|
935
738
|
message: "The item quantity has to be a valid integer"
|
|
936
739
|
});
|
|
937
|
-
case
|
|
938
|
-
_context.
|
|
740
|
+
case 3:
|
|
741
|
+
_context.n = 4;
|
|
939
742
|
return fetch(_extends({}, options, {
|
|
940
743
|
variables: [itemId, {
|
|
941
744
|
quantity: item.quantity
|
|
942
745
|
}]
|
|
943
746
|
}));
|
|
944
|
-
case
|
|
945
|
-
response = _context.
|
|
946
|
-
return _context.
|
|
947
|
-
case 12:
|
|
948
|
-
case "end":
|
|
949
|
-
return _context.stop();
|
|
747
|
+
case 4:
|
|
748
|
+
response = _context.v;
|
|
749
|
+
return _context.a(2, checkoutToCart(response));
|
|
950
750
|
}
|
|
951
751
|
}, _callee);
|
|
952
752
|
}))();
|
|
@@ -963,22 +763,22 @@ var handler$3 = {
|
|
|
963
763
|
var _useCart = commerce.useCart(),
|
|
964
764
|
mutate = _useCart.mutate;
|
|
965
765
|
return React.useCallback(debounce(/*#__PURE__*/function () {
|
|
966
|
-
var _ref3 = _asyncToGenerator(/*#__PURE__*/
|
|
766
|
+
var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(input) {
|
|
967
767
|
var _input$id;
|
|
968
768
|
var itemId, data;
|
|
969
|
-
return
|
|
970
|
-
while (1) switch (_context2.
|
|
769
|
+
return _regenerator().w(function (_context2) {
|
|
770
|
+
while (1) switch (_context2.n) {
|
|
971
771
|
case 0:
|
|
972
772
|
itemId = (_input$id = input.id) != null ? _input$id : item == null ? void 0 : item.id;
|
|
973
773
|
if (itemId) {
|
|
974
|
-
_context2.
|
|
774
|
+
_context2.n = 1;
|
|
975
775
|
break;
|
|
976
776
|
}
|
|
977
777
|
throw new commerce.ValidationError({
|
|
978
778
|
message: "Invalid input used for this operation"
|
|
979
779
|
});
|
|
980
|
-
case
|
|
981
|
-
_context2.
|
|
780
|
+
case 1:
|
|
781
|
+
_context2.n = 2;
|
|
982
782
|
return fetch({
|
|
983
783
|
input: {
|
|
984
784
|
item: {
|
|
@@ -987,15 +787,12 @@ var handler$3 = {
|
|
|
987
787
|
itemId: itemId
|
|
988
788
|
}
|
|
989
789
|
});
|
|
990
|
-
case
|
|
991
|
-
data = _context2.
|
|
992
|
-
_context2.
|
|
790
|
+
case 2:
|
|
791
|
+
data = _context2.v;
|
|
792
|
+
_context2.n = 3;
|
|
993
793
|
return mutate(data, false);
|
|
994
|
-
case
|
|
995
|
-
return _context2.
|
|
996
|
-
case 9:
|
|
997
|
-
case "end":
|
|
998
|
-
return _context2.stop();
|
|
794
|
+
case 3:
|
|
795
|
+
return _context2.a(2, data);
|
|
999
796
|
}
|
|
1000
797
|
}, _callee2);
|
|
1001
798
|
}));
|
|
@@ -1008,37 +805,36 @@ var handler$3 = {
|
|
|
1008
805
|
};
|
|
1009
806
|
|
|
1010
807
|
var fetcher = /*#__PURE__*/function () {
|
|
1011
|
-
var _ref2 = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/
|
|
808
|
+
var _ref2 = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(_ref) {
|
|
1012
809
|
var _ref$method, method, variables, query, callSwell, _callSwell;
|
|
1013
|
-
return
|
|
1014
|
-
while (1) switch (_context2.
|
|
810
|
+
return _regenerator().w(function (_context2) {
|
|
811
|
+
while (1) switch (_context2.n) {
|
|
1015
812
|
case 0:
|
|
1016
813
|
_callSwell = function _callSwell3() {
|
|
1017
|
-
_callSwell = _asyncToGenerator(/*#__PURE__*/
|
|
814
|
+
_callSwell = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
|
|
1018
815
|
var arg1, arg2, response, _response;
|
|
1019
|
-
return
|
|
1020
|
-
while (1) switch (_context.
|
|
816
|
+
return _regenerator().w(function (_context) {
|
|
817
|
+
while (1) switch (_context.n) {
|
|
1021
818
|
case 0:
|
|
1022
819
|
if (!Array.isArray(variables)) {
|
|
1023
|
-
_context.
|
|
820
|
+
_context.n = 2;
|
|
1024
821
|
break;
|
|
1025
822
|
}
|
|
1026
823
|
arg1 = variables[0];
|
|
1027
824
|
arg2 = variables[1];
|
|
1028
|
-
_context.
|
|
825
|
+
_context.n = 1;
|
|
1029
826
|
return swell[query][method](arg1, arg2);
|
|
1030
|
-
case
|
|
1031
|
-
response = _context.
|
|
1032
|
-
return _context.
|
|
1033
|
-
case
|
|
1034
|
-
_context.
|
|
827
|
+
case 1:
|
|
828
|
+
response = _context.v;
|
|
829
|
+
return _context.a(2, handleFetchResponse(response));
|
|
830
|
+
case 2:
|
|
831
|
+
_context.n = 3;
|
|
1035
832
|
return swell[query][method](variables);
|
|
1036
|
-
case
|
|
1037
|
-
_response = _context.
|
|
1038
|
-
return _context.
|
|
1039
|
-
case
|
|
1040
|
-
|
|
1041
|
-
return _context.stop();
|
|
833
|
+
case 3:
|
|
834
|
+
_response = _context.v;
|
|
835
|
+
return _context.a(2, handleFetchResponse(_response));
|
|
836
|
+
case 4:
|
|
837
|
+
return _context.a(2);
|
|
1042
838
|
}
|
|
1043
839
|
}, _callee);
|
|
1044
840
|
}));
|
|
@@ -1049,20 +845,19 @@ var fetcher = /*#__PURE__*/function () {
|
|
|
1049
845
|
};
|
|
1050
846
|
_ref$method = _ref.method, method = _ref$method === void 0 ? 'get' : _ref$method, variables = _ref.variables, query = _ref.query;
|
|
1051
847
|
if (!(query && query in swell)) {
|
|
1052
|
-
_context2.
|
|
848
|
+
_context2.n = 2;
|
|
1053
849
|
break;
|
|
1054
850
|
}
|
|
1055
|
-
_context2.
|
|
851
|
+
_context2.n = 1;
|
|
1056
852
|
return callSwell();
|
|
1057
|
-
case
|
|
1058
|
-
return _context2.
|
|
1059
|
-
case
|
|
853
|
+
case 1:
|
|
854
|
+
return _context2.a(2, _context2.v);
|
|
855
|
+
case 2:
|
|
1060
856
|
throw new commerce.CommerceError({
|
|
1061
857
|
message: 'Invalid query argument!'
|
|
1062
858
|
});
|
|
1063
|
-
case
|
|
1064
|
-
|
|
1065
|
-
return _context2.stop();
|
|
859
|
+
case 3:
|
|
860
|
+
return _context2.a(2);
|
|
1066
861
|
}
|
|
1067
862
|
}, _callee2);
|
|
1068
863
|
}));
|
|
@@ -1077,31 +872,28 @@ var handler$4 = {
|
|
|
1077
872
|
method: 'get'
|
|
1078
873
|
},
|
|
1079
874
|
fetcher: function fetcher(_ref) {
|
|
1080
|
-
return _asyncToGenerator(/*#__PURE__*/
|
|
875
|
+
return _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
|
|
1081
876
|
var input, options, fetch, id, product;
|
|
1082
|
-
return
|
|
1083
|
-
while (1) switch (_context.
|
|
877
|
+
return _regenerator().w(function (_context) {
|
|
878
|
+
while (1) switch (_context.n) {
|
|
1084
879
|
case 0:
|
|
1085
880
|
input = _ref.input, options = _ref.options, fetch = _ref.fetch;
|
|
1086
881
|
id = input.id;
|
|
1087
|
-
_context.
|
|
882
|
+
_context.n = 1;
|
|
1088
883
|
return fetch({
|
|
1089
884
|
query: options.query,
|
|
1090
885
|
method: options.method,
|
|
1091
886
|
variables: [id]
|
|
1092
887
|
});
|
|
1093
|
-
case
|
|
1094
|
-
product = _context.
|
|
888
|
+
case 1:
|
|
889
|
+
product = _context.v;
|
|
1095
890
|
if (product) {
|
|
1096
|
-
_context.
|
|
891
|
+
_context.n = 2;
|
|
1097
892
|
break;
|
|
1098
893
|
}
|
|
1099
|
-
return _context.
|
|
1100
|
-
case
|
|
1101
|
-
return _context.
|
|
1102
|
-
case 8:
|
|
1103
|
-
case "end":
|
|
1104
|
-
return _context.stop();
|
|
894
|
+
return _context.a(2, null);
|
|
895
|
+
case 2:
|
|
896
|
+
return _context.a(2, normalizeProduct(product));
|
|
1105
897
|
}
|
|
1106
898
|
}, _callee);
|
|
1107
899
|
}))();
|
|
@@ -1172,10 +964,10 @@ var handler$5 = {
|
|
|
1172
964
|
method: "list"
|
|
1173
965
|
},
|
|
1174
966
|
fetcher: function fetcher(_ref) {
|
|
1175
|
-
return _asyncToGenerator(/*#__PURE__*/
|
|
967
|
+
return _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
|
|
1176
968
|
var input, options, fetch, sortMap, categoryId, includeSubCategories, categories, brandId, search, _input$sort, sort, count, mappedSort, includedCategories, _yield$fetch, products;
|
|
1177
|
-
return
|
|
1178
|
-
while (1) switch (_context.
|
|
969
|
+
return _regenerator().w(function (_context) {
|
|
970
|
+
while (1) switch (_context.n) {
|
|
1179
971
|
case 0:
|
|
1180
972
|
input = _ref.input, options = _ref.options, fetch = _ref.fetch;
|
|
1181
973
|
sortMap = new Map([["latest-desc", ""], ["price-asc", "price asc"], ["price-desc", "price desc"], ["trending-desc", "popularity"]]);
|
|
@@ -1184,7 +976,7 @@ var handler$5 = {
|
|
|
1184
976
|
includedCategories = includeSubCategories ? walkCategoryTree(categories == null ? void 0 : categories.find(function (category) {
|
|
1185
977
|
return category.id === categoryId;
|
|
1186
978
|
}), categories) : undefined;
|
|
1187
|
-
_context.
|
|
979
|
+
_context.n = 1;
|
|
1188
980
|
return fetch({
|
|
1189
981
|
query: options.query,
|
|
1190
982
|
method: options.method,
|
|
@@ -1202,18 +994,15 @@ var handler$5 = {
|
|
|
1202
994
|
} : {})
|
|
1203
995
|
})
|
|
1204
996
|
});
|
|
1205
|
-
case
|
|
1206
|
-
_yield$fetch = _context.
|
|
997
|
+
case 1:
|
|
998
|
+
_yield$fetch = _context.v;
|
|
1207
999
|
products = _yield$fetch.results;
|
|
1208
|
-
return _context.
|
|
1000
|
+
return _context.a(2, {
|
|
1209
1001
|
products: products.map(function (product) {
|
|
1210
1002
|
return normalizeProduct(product);
|
|
1211
1003
|
}),
|
|
1212
1004
|
found: products.length > 0
|
|
1213
1005
|
});
|
|
1214
|
-
case 10:
|
|
1215
|
-
case "end":
|
|
1216
|
-
return _context.stop();
|
|
1217
1006
|
}
|
|
1218
1007
|
}, _callee);
|
|
1219
1008
|
}))();
|
|
@@ -1240,53 +1029,50 @@ var handler$6 = {
|
|
|
1240
1029
|
method: "get"
|
|
1241
1030
|
},
|
|
1242
1031
|
fetcher: function fetcher(_ref) {
|
|
1243
|
-
return _asyncToGenerator(/*#__PURE__*/
|
|
1032
|
+
return _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
|
|
1244
1033
|
var _yield$fetch$values, _yield$fetch;
|
|
1245
|
-
var fetch, vendors;
|
|
1246
|
-
return
|
|
1247
|
-
while (1) switch (_context.
|
|
1034
|
+
var fetch, vendors, _t, _t2, _t3, _t4;
|
|
1035
|
+
return _regenerator().w(function (_context) {
|
|
1036
|
+
while (1) switch (_context.n) {
|
|
1248
1037
|
case 0:
|
|
1249
1038
|
fetch = _ref.fetch;
|
|
1250
|
-
_context.
|
|
1039
|
+
_context.n = 1;
|
|
1251
1040
|
return fetch({
|
|
1252
1041
|
query: "attributes",
|
|
1253
1042
|
method: "get",
|
|
1254
1043
|
variables: "brand"
|
|
1255
1044
|
});
|
|
1256
|
-
case
|
|
1257
|
-
|
|
1258
|
-
if (!(
|
|
1259
|
-
_context.
|
|
1045
|
+
case 1:
|
|
1046
|
+
_t = _yield$fetch = _context.v;
|
|
1047
|
+
if (!(_t == null)) {
|
|
1048
|
+
_context.n = 2;
|
|
1260
1049
|
break;
|
|
1261
1050
|
}
|
|
1262
|
-
|
|
1263
|
-
_context.
|
|
1051
|
+
_t2 = void 0;
|
|
1052
|
+
_context.n = 3;
|
|
1264
1053
|
break;
|
|
1265
|
-
case
|
|
1266
|
-
|
|
1267
|
-
case
|
|
1268
|
-
|
|
1269
|
-
if (!(
|
|
1270
|
-
_context.
|
|
1054
|
+
case 2:
|
|
1055
|
+
_t2 = _yield$fetch.values;
|
|
1056
|
+
case 3:
|
|
1057
|
+
_t3 = _yield$fetch$values = _t2;
|
|
1058
|
+
if (!(_t3 != null)) {
|
|
1059
|
+
_context.n = 4;
|
|
1271
1060
|
break;
|
|
1272
1061
|
}
|
|
1273
|
-
|
|
1274
|
-
_context.
|
|
1062
|
+
_t4 = _yield$fetch$values;
|
|
1063
|
+
_context.n = 5;
|
|
1275
1064
|
break;
|
|
1276
|
-
case
|
|
1277
|
-
|
|
1278
|
-
case
|
|
1279
|
-
vendors =
|
|
1280
|
-
return _context.
|
|
1065
|
+
case 4:
|
|
1066
|
+
_t4 = [];
|
|
1067
|
+
case 5:
|
|
1068
|
+
vendors = _t4;
|
|
1069
|
+
return _context.a(2, Array.from(new Set(vendors).values()).map(function (v) {
|
|
1281
1070
|
return {
|
|
1282
1071
|
entityId: v,
|
|
1283
1072
|
name: v,
|
|
1284
1073
|
path: "brands/" + v
|
|
1285
1074
|
};
|
|
1286
1075
|
}));
|
|
1287
|
-
case 17:
|
|
1288
|
-
case "end":
|
|
1289
|
-
return _context.stop();
|
|
1290
1076
|
}
|
|
1291
1077
|
}, _callee);
|
|
1292
1078
|
}))();
|
|
@@ -1320,15 +1106,15 @@ var handler$7 = {
|
|
|
1320
1106
|
method: "get"
|
|
1321
1107
|
},
|
|
1322
1108
|
fetcher: function fetcher(_ref) {
|
|
1323
|
-
return _asyncToGenerator(/*#__PURE__*/
|
|
1109
|
+
return _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2() {
|
|
1324
1110
|
var _data$results;
|
|
1325
1111
|
var input, options, fetch, addIsEmptyField, categoryId, data, categories, normalizedCategories, _loop, _iterator, _step;
|
|
1326
|
-
return
|
|
1327
|
-
while (1) switch (_context3.
|
|
1112
|
+
return _regenerator().w(function (_context3) {
|
|
1113
|
+
while (1) switch (_context3.n) {
|
|
1328
1114
|
case 0:
|
|
1329
1115
|
input = _ref.input, options = _ref.options, fetch = _ref.fetch;
|
|
1330
1116
|
addIsEmptyField = input.addIsEmptyField, categoryId = input.categoryId;
|
|
1331
|
-
_context3.
|
|
1117
|
+
_context3.n = 1;
|
|
1332
1118
|
return fetch({
|
|
1333
1119
|
query: options.query,
|
|
1334
1120
|
method: options.method,
|
|
@@ -1337,23 +1123,24 @@ var handler$7 = {
|
|
|
1337
1123
|
id: categoryId
|
|
1338
1124
|
})
|
|
1339
1125
|
});
|
|
1340
|
-
case
|
|
1341
|
-
data = _context3.
|
|
1126
|
+
case 1:
|
|
1127
|
+
data = _context3.v;
|
|
1342
1128
|
categories = (_data$results = data == null ? void 0 : data.results) != null ? _data$results : [];
|
|
1343
1129
|
if (!addIsEmptyField) {
|
|
1344
|
-
_context3.
|
|
1130
|
+
_context3.n = 3;
|
|
1345
1131
|
break;
|
|
1346
1132
|
}
|
|
1347
|
-
_context3.
|
|
1133
|
+
_context3.n = 2;
|
|
1348
1134
|
return Promise.all(categories.map(/*#__PURE__*/function () {
|
|
1349
|
-
var _ref2 = _asyncToGenerator(/*#__PURE__*/
|
|
1350
|
-
|
|
1351
|
-
|
|
1135
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(category) {
|
|
1136
|
+
var _t, _t2, _t3, _t4;
|
|
1137
|
+
return _regenerator().w(function (_context) {
|
|
1138
|
+
while (1) switch (_context.n) {
|
|
1352
1139
|
case 0:
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
_context.
|
|
1140
|
+
_t = _extends;
|
|
1141
|
+
_t2 = {};
|
|
1142
|
+
_t3 = category;
|
|
1143
|
+
_context.n = 1;
|
|
1357
1144
|
return fetch({
|
|
1358
1145
|
query: "products",
|
|
1359
1146
|
method: "list",
|
|
@@ -1362,15 +1149,11 @@ var handler$7 = {
|
|
|
1362
1149
|
category: category.id
|
|
1363
1150
|
})
|
|
1364
1151
|
});
|
|
1365
|
-
case
|
|
1366
|
-
|
|
1367
|
-
_context.
|
|
1368
|
-
products:
|
|
1369
|
-
};
|
|
1370
|
-
return _context.abrupt("return", (0, _context.t0)(_context.t1, _context.t2, _context.t4));
|
|
1371
|
-
case 8:
|
|
1372
|
-
case "end":
|
|
1373
|
-
return _context.stop();
|
|
1152
|
+
case 1:
|
|
1153
|
+
_t4 = _context.v.results;
|
|
1154
|
+
return _context.a(2, _t(_t2, _t3, {
|
|
1155
|
+
products: _t4
|
|
1156
|
+
}));
|
|
1374
1157
|
}
|
|
1375
1158
|
}, _callee);
|
|
1376
1159
|
}));
|
|
@@ -1378,41 +1161,37 @@ var handler$7 = {
|
|
|
1378
1161
|
return _ref2.apply(this, arguments);
|
|
1379
1162
|
};
|
|
1380
1163
|
}()));
|
|
1381
|
-
case
|
|
1382
|
-
categories = _context3.
|
|
1383
|
-
case
|
|
1164
|
+
case 2:
|
|
1165
|
+
categories = _context3.v;
|
|
1166
|
+
case 3:
|
|
1384
1167
|
normalizedCategories = !categoryId ? topologicalSortForCategoryTree(categories.map(normalizeCategory)) : categories.map(normalizeCategory);
|
|
1385
|
-
_loop = /*#__PURE__*/
|
|
1168
|
+
_loop = /*#__PURE__*/_regenerator().m(function _loop() {
|
|
1386
1169
|
var _normalizedCategories, _normalizedCategories2;
|
|
1387
1170
|
var category;
|
|
1388
|
-
return
|
|
1389
|
-
while (1) switch (_context2.
|
|
1171
|
+
return _regenerator().w(function (_context2) {
|
|
1172
|
+
while (1) switch (_context2.n) {
|
|
1390
1173
|
case 0:
|
|
1391
1174
|
category = _step.value;
|
|
1392
1175
|
category.depth = ((_normalizedCategories = (_normalizedCategories2 = normalizedCategories.find(function (c) {
|
|
1393
1176
|
return c.id === category.parentId;
|
|
1394
1177
|
})) == null ? void 0 : _normalizedCategories2.depth) != null ? _normalizedCategories : -1) + 1;
|
|
1395
|
-
case
|
|
1396
|
-
|
|
1397
|
-
return _context2.stop();
|
|
1178
|
+
case 1:
|
|
1179
|
+
return _context2.a(2);
|
|
1398
1180
|
}
|
|
1399
1181
|
}, _loop);
|
|
1400
1182
|
});
|
|
1401
1183
|
_iterator = _createForOfIteratorHelperLoose(normalizedCategories);
|
|
1402
|
-
case
|
|
1184
|
+
case 4:
|
|
1403
1185
|
if ((_step = _iterator()).done) {
|
|
1404
|
-
_context3.
|
|
1186
|
+
_context3.n = 6;
|
|
1405
1187
|
break;
|
|
1406
1188
|
}
|
|
1407
|
-
return _context3.
|
|
1408
|
-
case
|
|
1409
|
-
_context3.
|
|
1189
|
+
return _context3.d(_regeneratorValues(_loop()), 5);
|
|
1190
|
+
case 5:
|
|
1191
|
+
_context3.n = 4;
|
|
1410
1192
|
break;
|
|
1411
|
-
case
|
|
1412
|
-
return _context3.
|
|
1413
|
-
case 18:
|
|
1414
|
-
case "end":
|
|
1415
|
-
return _context3.stop();
|
|
1193
|
+
case 6:
|
|
1194
|
+
return _context3.a(2, normalizedCategories);
|
|
1416
1195
|
}
|
|
1417
1196
|
}, _callee2);
|
|
1418
1197
|
}))();
|