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