@faststore/api 1.2.23
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/CHANGELOG.md +333 -0
- package/README.md +115 -0
- package/dist/__generated__/schema.d.ts +281 -0
- package/dist/api.cjs.development.js +2226 -0
- package/dist/api.cjs.development.js.map +1 -0
- package/dist/api.cjs.production.min.js +2 -0
- package/dist/api.cjs.production.min.js.map +1 -0
- package/dist/api.esm.js +2217 -0
- package/dist/api.esm.js.map +1 -0
- package/dist/index.d.ts +136 -0
- package/dist/index.js +8 -0
- package/dist/platforms/vtex/clients/commerce/index.d.ts +29 -0
- package/dist/platforms/vtex/clients/commerce/types/Brand.d.ts +8 -0
- package/dist/platforms/vtex/clients/commerce/types/CategoryTree.d.ts +9 -0
- package/dist/platforms/vtex/clients/commerce/types/OrderForm.d.ts +347 -0
- package/dist/platforms/vtex/clients/commerce/types/Simulation.d.ts +154 -0
- package/dist/platforms/vtex/clients/fetch.d.ts +1 -0
- package/dist/platforms/vtex/clients/index.d.ts +32 -0
- package/dist/platforms/vtex/clients/search/index.d.ts +22 -0
- package/dist/platforms/vtex/clients/search/types/AttributeSearchResult.d.ts +56 -0
- package/dist/platforms/vtex/clients/search/types/ProductSearchResult.d.ts +199 -0
- package/dist/platforms/vtex/index.d.ts +144 -0
- package/dist/platforms/vtex/loaders/index.d.ts +7 -0
- package/dist/platforms/vtex/loaders/simulation.d.ts +5 -0
- package/dist/platforms/vtex/loaders/sku.d.ts +6 -0
- package/dist/platforms/vtex/resolvers/aggregateOffer.d.ts +7 -0
- package/dist/platforms/vtex/resolvers/aggregateRating.d.ts +2 -0
- package/dist/platforms/vtex/resolvers/collection.d.ts +8 -0
- package/dist/platforms/vtex/resolvers/facet.d.ts +5 -0
- package/dist/platforms/vtex/resolvers/facetValue.d.ts +5 -0
- package/dist/platforms/vtex/resolvers/mutation.d.ts +58 -0
- package/dist/platforms/vtex/resolvers/offer.d.ts +11 -0
- package/dist/platforms/vtex/resolvers/organization.d.ts +2 -0
- package/dist/platforms/vtex/resolvers/product.d.ts +5 -0
- package/dist/platforms/vtex/resolvers/productGroup.d.ts +3 -0
- package/dist/platforms/vtex/resolvers/query.d.ts +51 -0
- package/dist/platforms/vtex/resolvers/review.d.ts +2 -0
- package/dist/platforms/vtex/resolvers/searchResult.d.ts +5 -0
- package/dist/platforms/vtex/resolvers/seo.d.ts +7 -0
- package/dist/platforms/vtex/resolvers/validateCart.d.ts +71 -0
- package/dist/platforms/vtex/utils/enhanceSku.d.ts +5 -0
- package/dist/platforms/vtex/utils/facets.d.ts +12 -0
- package/dist/platforms/vtex/utils/slugify.d.ts +1 -0
- package/dist/platforms/vtex/utils/sort.d.ts +10 -0
- package/dist/typeDefs/index.d.ts +1 -0
- package/package.json +44 -0
- package/src/__generated__/schema.ts +324 -0
- package/src/index.ts +33 -0
- package/src/platforms/vtex/clients/commerce/index.ts +100 -0
- package/src/platforms/vtex/clients/commerce/types/Brand.ts +8 -0
- package/src/platforms/vtex/clients/commerce/types/CategoryTree.ts +9 -0
- package/src/platforms/vtex/clients/commerce/types/OrderForm.ts +371 -0
- package/src/platforms/vtex/clients/commerce/types/Simulation.ts +170 -0
- package/src/platforms/vtex/clients/fetch.ts +13 -0
- package/src/platforms/vtex/clients/index.ts +15 -0
- package/src/platforms/vtex/clients/search/index.ts +83 -0
- package/src/platforms/vtex/clients/search/types/AttributeSearchResult.ts +61 -0
- package/src/platforms/vtex/clients/search/types/ProductSearchResult.ts +223 -0
- package/src/platforms/vtex/index.ts +62 -0
- package/src/platforms/vtex/loaders/index.ts +16 -0
- package/src/platforms/vtex/loaders/simulation.ts +42 -0
- package/src/platforms/vtex/loaders/sku.ts +61 -0
- package/src/platforms/vtex/resolvers/aggregateOffer.ts +20 -0
- package/src/platforms/vtex/resolvers/aggregateRating.ts +7 -0
- package/src/platforms/vtex/resolvers/collection.ts +43 -0
- package/src/platforms/vtex/resolvers/facet.ts +11 -0
- package/src/platforms/vtex/resolvers/facetValue.ts +11 -0
- package/src/platforms/vtex/resolvers/mutation.ts +5 -0
- package/src/platforms/vtex/resolvers/offer.ts +26 -0
- package/src/platforms/vtex/resolvers/organization.ts +5 -0
- package/src/platforms/vtex/resolvers/product.ts +75 -0
- package/src/platforms/vtex/resolvers/productGroup.ts +9 -0
- package/src/platforms/vtex/resolvers/query.ts +115 -0
- package/src/platforms/vtex/resolvers/review.ts +11 -0
- package/src/platforms/vtex/resolvers/searchResult.ts +46 -0
- package/src/platforms/vtex/resolvers/seo.ts +10 -0
- package/src/platforms/vtex/resolvers/validateCart.ts +166 -0
- package/src/platforms/vtex/utils/enhanceSku.ts +8 -0
- package/src/platforms/vtex/utils/facets.ts +31 -0
- package/src/platforms/vtex/utils/slugify.ts +4 -0
- package/src/platforms/vtex/utils/sort.ts +10 -0
- package/src/typeDefs/aggregateOffer.graphql +10 -0
- package/src/typeDefs/aggregateRating.graphql +4 -0
- package/src/typeDefs/author.graphql +3 -0
- package/src/typeDefs/brand.graphql +3 -0
- package/src/typeDefs/breadcrumb.graphql +10 -0
- package/src/typeDefs/cart.graphql +13 -0
- package/src/typeDefs/collection.graphql +26 -0
- package/src/typeDefs/facet.graphql +14 -0
- package/src/typeDefs/image.graphql +9 -0
- package/src/typeDefs/index.ts +47 -0
- package/src/typeDefs/mutation.graphql +4 -0
- package/src/typeDefs/offer.graphql +21 -0
- package/src/typeDefs/order.graphql +9 -0
- package/src/typeDefs/organization.graphql +7 -0
- package/src/typeDefs/pageInfo.graphql +8 -0
- package/src/typeDefs/product.graphql +25 -0
- package/src/typeDefs/productGroup.graphql +5 -0
- package/src/typeDefs/query.graphql +64 -0
- package/src/typeDefs/review.graphql +9 -0
- package/src/typeDefs/seo.graphql +6 -0
- package/src/typeDefs/status.graphql +5 -0
- package/src/typings/schema.d.ts +7 -0
package/dist/api.esm.js
ADDED
|
@@ -0,0 +1,2217 @@
|
|
|
1
|
+
import { makeExecutableSchema } from '@graphql-tools/schema';
|
|
2
|
+
import fetch from 'isomorphic-unfetch';
|
|
3
|
+
import DataLoader from 'dataloader';
|
|
4
|
+
import rawSlugify from 'slugify';
|
|
5
|
+
import deepEquals from 'fast-deep-equal';
|
|
6
|
+
import { print } from 'graphql';
|
|
7
|
+
|
|
8
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
9
|
+
try {
|
|
10
|
+
var info = gen[key](arg);
|
|
11
|
+
var value = info.value;
|
|
12
|
+
} catch (error) {
|
|
13
|
+
reject(error);
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
if (info.done) {
|
|
18
|
+
resolve(value);
|
|
19
|
+
} else {
|
|
20
|
+
Promise.resolve(value).then(_next, _throw);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function _asyncToGenerator(fn) {
|
|
25
|
+
return function () {
|
|
26
|
+
var self = this,
|
|
27
|
+
args = arguments;
|
|
28
|
+
return new Promise(function (resolve, reject) {
|
|
29
|
+
var gen = fn.apply(self, args);
|
|
30
|
+
|
|
31
|
+
function _next(value) {
|
|
32
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function _throw(err) {
|
|
36
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
_next(undefined);
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function _extends() {
|
|
45
|
+
_extends = Object.assign || function (target) {
|
|
46
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
47
|
+
var source = arguments[i];
|
|
48
|
+
|
|
49
|
+
for (var key in source) {
|
|
50
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
51
|
+
target[key] = source[key];
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return target;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
return _extends.apply(this, arguments);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function _unsupportedIterableToArray(o, minLen) {
|
|
63
|
+
if (!o) return;
|
|
64
|
+
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
65
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
66
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
67
|
+
if (n === "Map" || n === "Set") return Array.from(o);
|
|
68
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function _arrayLikeToArray(arr, len) {
|
|
72
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
73
|
+
|
|
74
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
75
|
+
|
|
76
|
+
return arr2;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function _createForOfIteratorHelperLoose(o, allowArrayLike) {
|
|
80
|
+
var it;
|
|
81
|
+
|
|
82
|
+
if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) {
|
|
83
|
+
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
|
|
84
|
+
if (it) o = it;
|
|
85
|
+
var i = 0;
|
|
86
|
+
return function () {
|
|
87
|
+
if (i >= o.length) return {
|
|
88
|
+
done: true
|
|
89
|
+
};
|
|
90
|
+
return {
|
|
91
|
+
done: false,
|
|
92
|
+
value: o[i++]
|
|
93
|
+
};
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
it = o[Symbol.iterator]();
|
|
101
|
+
return it.next.bind(it);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function createCommonjsModule(fn, module) {
|
|
105
|
+
return module = { exports: {} }, fn(module, module.exports), module.exports;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
|
|
109
|
+
/**
|
|
110
|
+
* Copyright (c) 2014-present, Facebook, Inc.
|
|
111
|
+
*
|
|
112
|
+
* This source code is licensed under the MIT license found in the
|
|
113
|
+
* LICENSE file in the root directory of this source tree.
|
|
114
|
+
*/
|
|
115
|
+
var runtime = function (exports) {
|
|
116
|
+
|
|
117
|
+
var Op = Object.prototype;
|
|
118
|
+
var hasOwn = Op.hasOwnProperty;
|
|
119
|
+
var undefined$1; // More compressible than void 0.
|
|
120
|
+
|
|
121
|
+
var $Symbol = typeof Symbol === "function" ? Symbol : {};
|
|
122
|
+
var iteratorSymbol = $Symbol.iterator || "@@iterator";
|
|
123
|
+
var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
|
|
124
|
+
var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
|
|
125
|
+
|
|
126
|
+
function define(obj, key, value) {
|
|
127
|
+
Object.defineProperty(obj, key, {
|
|
128
|
+
value: value,
|
|
129
|
+
enumerable: true,
|
|
130
|
+
configurable: true,
|
|
131
|
+
writable: true
|
|
132
|
+
});
|
|
133
|
+
return obj[key];
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
try {
|
|
137
|
+
// IE 8 has a broken Object.defineProperty that only works on DOM objects.
|
|
138
|
+
define({}, "");
|
|
139
|
+
} catch (err) {
|
|
140
|
+
define = function define(obj, key, value) {
|
|
141
|
+
return obj[key] = value;
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
function wrap(innerFn, outerFn, self, tryLocsList) {
|
|
146
|
+
// If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
|
|
147
|
+
var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
|
|
148
|
+
var generator = Object.create(protoGenerator.prototype);
|
|
149
|
+
var context = new Context(tryLocsList || []); // The ._invoke method unifies the implementations of the .next,
|
|
150
|
+
// .throw, and .return methods.
|
|
151
|
+
|
|
152
|
+
generator._invoke = makeInvokeMethod(innerFn, self, context);
|
|
153
|
+
return generator;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
exports.wrap = wrap; // Try/catch helper to minimize deoptimizations. Returns a completion
|
|
157
|
+
// record like context.tryEntries[i].completion. This interface could
|
|
158
|
+
// have been (and was previously) designed to take a closure to be
|
|
159
|
+
// invoked without arguments, but in all the cases we care about we
|
|
160
|
+
// already have an existing method we want to call, so there's no need
|
|
161
|
+
// to create a new function object. We can even get away with assuming
|
|
162
|
+
// the method takes exactly one argument, since that happens to be true
|
|
163
|
+
// in every case, so we don't have to touch the arguments object. The
|
|
164
|
+
// only additional allocation required is the completion record, which
|
|
165
|
+
// has a stable shape and so hopefully should be cheap to allocate.
|
|
166
|
+
|
|
167
|
+
function tryCatch(fn, obj, arg) {
|
|
168
|
+
try {
|
|
169
|
+
return {
|
|
170
|
+
type: "normal",
|
|
171
|
+
arg: fn.call(obj, arg)
|
|
172
|
+
};
|
|
173
|
+
} catch (err) {
|
|
174
|
+
return {
|
|
175
|
+
type: "throw",
|
|
176
|
+
arg: err
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
var GenStateSuspendedStart = "suspendedStart";
|
|
182
|
+
var GenStateSuspendedYield = "suspendedYield";
|
|
183
|
+
var GenStateExecuting = "executing";
|
|
184
|
+
var GenStateCompleted = "completed"; // Returning this object from the innerFn has the same effect as
|
|
185
|
+
// breaking out of the dispatch switch statement.
|
|
186
|
+
|
|
187
|
+
var ContinueSentinel = {}; // Dummy constructor functions that we use as the .constructor and
|
|
188
|
+
// .constructor.prototype properties for functions that return Generator
|
|
189
|
+
// objects. For full spec compliance, you may wish to configure your
|
|
190
|
+
// minifier not to mangle the names of these two functions.
|
|
191
|
+
|
|
192
|
+
function Generator() {}
|
|
193
|
+
|
|
194
|
+
function GeneratorFunction() {}
|
|
195
|
+
|
|
196
|
+
function GeneratorFunctionPrototype() {} // This is a polyfill for %IteratorPrototype% for environments that
|
|
197
|
+
// don't natively support it.
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
var IteratorPrototype = {};
|
|
201
|
+
|
|
202
|
+
IteratorPrototype[iteratorSymbol] = function () {
|
|
203
|
+
return this;
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
var getProto = Object.getPrototypeOf;
|
|
207
|
+
var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
|
|
208
|
+
|
|
209
|
+
if (NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
|
|
210
|
+
// This environment has a native %IteratorPrototype%; use it instead
|
|
211
|
+
// of the polyfill.
|
|
212
|
+
IteratorPrototype = NativeIteratorPrototype;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
|
|
216
|
+
GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;
|
|
217
|
+
GeneratorFunctionPrototype.constructor = GeneratorFunction;
|
|
218
|
+
GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"); // Helper for defining the .next, .throw, and .return methods of the
|
|
219
|
+
// Iterator interface in terms of a single ._invoke method.
|
|
220
|
+
|
|
221
|
+
function defineIteratorMethods(prototype) {
|
|
222
|
+
["next", "throw", "return"].forEach(function (method) {
|
|
223
|
+
define(prototype, method, function (arg) {
|
|
224
|
+
return this._invoke(method, arg);
|
|
225
|
+
});
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
exports.isGeneratorFunction = function (genFun) {
|
|
230
|
+
var ctor = typeof genFun === "function" && genFun.constructor;
|
|
231
|
+
return ctor ? ctor === GeneratorFunction || // For the native GeneratorFunction constructor, the best we can
|
|
232
|
+
// do is to check its .name property.
|
|
233
|
+
(ctor.displayName || ctor.name) === "GeneratorFunction" : false;
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
exports.mark = function (genFun) {
|
|
237
|
+
if (Object.setPrototypeOf) {
|
|
238
|
+
Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
|
|
239
|
+
} else {
|
|
240
|
+
genFun.__proto__ = GeneratorFunctionPrototype;
|
|
241
|
+
define(genFun, toStringTagSymbol, "GeneratorFunction");
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
genFun.prototype = Object.create(Gp);
|
|
245
|
+
return genFun;
|
|
246
|
+
}; // Within the body of any async function, `await x` is transformed to
|
|
247
|
+
// `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
|
|
248
|
+
// `hasOwn.call(value, "__await")` to determine if the yielded value is
|
|
249
|
+
// meant to be awaited.
|
|
250
|
+
|
|
251
|
+
|
|
252
|
+
exports.awrap = function (arg) {
|
|
253
|
+
return {
|
|
254
|
+
__await: arg
|
|
255
|
+
};
|
|
256
|
+
};
|
|
257
|
+
|
|
258
|
+
function AsyncIterator(generator, PromiseImpl) {
|
|
259
|
+
function invoke(method, arg, resolve, reject) {
|
|
260
|
+
var record = tryCatch(generator[method], generator, arg);
|
|
261
|
+
|
|
262
|
+
if (record.type === "throw") {
|
|
263
|
+
reject(record.arg);
|
|
264
|
+
} else {
|
|
265
|
+
var result = record.arg;
|
|
266
|
+
var value = result.value;
|
|
267
|
+
|
|
268
|
+
if (value && typeof value === "object" && hasOwn.call(value, "__await")) {
|
|
269
|
+
return PromiseImpl.resolve(value.__await).then(function (value) {
|
|
270
|
+
invoke("next", value, resolve, reject);
|
|
271
|
+
}, function (err) {
|
|
272
|
+
invoke("throw", err, resolve, reject);
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
return PromiseImpl.resolve(value).then(function (unwrapped) {
|
|
277
|
+
// When a yielded Promise is resolved, its final value becomes
|
|
278
|
+
// the .value of the Promise<{value,done}> result for the
|
|
279
|
+
// current iteration.
|
|
280
|
+
result.value = unwrapped;
|
|
281
|
+
resolve(result);
|
|
282
|
+
}, function (error) {
|
|
283
|
+
// If a rejected Promise was yielded, throw the rejection back
|
|
284
|
+
// into the async generator function so it can be handled there.
|
|
285
|
+
return invoke("throw", error, resolve, reject);
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
var previousPromise;
|
|
291
|
+
|
|
292
|
+
function enqueue(method, arg) {
|
|
293
|
+
function callInvokeWithMethodAndArg() {
|
|
294
|
+
return new PromiseImpl(function (resolve, reject) {
|
|
295
|
+
invoke(method, arg, resolve, reject);
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
return previousPromise = // If enqueue has been called before, then we want to wait until
|
|
300
|
+
// all previous Promises have been resolved before calling invoke,
|
|
301
|
+
// so that results are always delivered in the correct order. If
|
|
302
|
+
// enqueue has not been called before, then it is important to
|
|
303
|
+
// call invoke immediately, without waiting on a callback to fire,
|
|
304
|
+
// so that the async generator function has the opportunity to do
|
|
305
|
+
// any necessary setup in a predictable way. This predictability
|
|
306
|
+
// is why the Promise constructor synchronously invokes its
|
|
307
|
+
// executor callback, and why async functions synchronously
|
|
308
|
+
// execute code before the first await. Since we implement simple
|
|
309
|
+
// async functions in terms of async generators, it is especially
|
|
310
|
+
// important to get this right, even though it requires care.
|
|
311
|
+
previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, // Avoid propagating failures to Promises returned by later
|
|
312
|
+
// invocations of the iterator.
|
|
313
|
+
callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
|
|
314
|
+
} // Define the unified helper method that is used to implement .next,
|
|
315
|
+
// .throw, and .return (see defineIteratorMethods).
|
|
316
|
+
|
|
317
|
+
|
|
318
|
+
this._invoke = enqueue;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
defineIteratorMethods(AsyncIterator.prototype);
|
|
322
|
+
|
|
323
|
+
AsyncIterator.prototype[asyncIteratorSymbol] = function () {
|
|
324
|
+
return this;
|
|
325
|
+
};
|
|
326
|
+
|
|
327
|
+
exports.AsyncIterator = AsyncIterator; // Note that simple async functions are implemented on top of
|
|
328
|
+
// AsyncIterator objects; they just return a Promise for the value of
|
|
329
|
+
// the final result produced by the iterator.
|
|
330
|
+
|
|
331
|
+
exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
|
|
332
|
+
if (PromiseImpl === void 0) PromiseImpl = Promise;
|
|
333
|
+
var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
|
|
334
|
+
return exports.isGeneratorFunction(outerFn) ? iter // If outerFn is a generator, return the full iterator.
|
|
335
|
+
: iter.next().then(function (result) {
|
|
336
|
+
return result.done ? result.value : iter.next();
|
|
337
|
+
});
|
|
338
|
+
};
|
|
339
|
+
|
|
340
|
+
function makeInvokeMethod(innerFn, self, context) {
|
|
341
|
+
var state = GenStateSuspendedStart;
|
|
342
|
+
return function invoke(method, arg) {
|
|
343
|
+
if (state === GenStateExecuting) {
|
|
344
|
+
throw new Error("Generator is already running");
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
if (state === GenStateCompleted) {
|
|
348
|
+
if (method === "throw") {
|
|
349
|
+
throw arg;
|
|
350
|
+
} // Be forgiving, per 25.3.3.3.3 of the spec:
|
|
351
|
+
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
|
|
352
|
+
|
|
353
|
+
|
|
354
|
+
return doneResult();
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
context.method = method;
|
|
358
|
+
context.arg = arg;
|
|
359
|
+
|
|
360
|
+
while (true) {
|
|
361
|
+
var delegate = context.delegate;
|
|
362
|
+
|
|
363
|
+
if (delegate) {
|
|
364
|
+
var delegateResult = maybeInvokeDelegate(delegate, context);
|
|
365
|
+
|
|
366
|
+
if (delegateResult) {
|
|
367
|
+
if (delegateResult === ContinueSentinel) continue;
|
|
368
|
+
return delegateResult;
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
if (context.method === "next") {
|
|
373
|
+
// Setting context._sent for legacy support of Babel's
|
|
374
|
+
// function.sent implementation.
|
|
375
|
+
context.sent = context._sent = context.arg;
|
|
376
|
+
} else if (context.method === "throw") {
|
|
377
|
+
if (state === GenStateSuspendedStart) {
|
|
378
|
+
state = GenStateCompleted;
|
|
379
|
+
throw context.arg;
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
context.dispatchException(context.arg);
|
|
383
|
+
} else if (context.method === "return") {
|
|
384
|
+
context.abrupt("return", context.arg);
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
state = GenStateExecuting;
|
|
388
|
+
var record = tryCatch(innerFn, self, context);
|
|
389
|
+
|
|
390
|
+
if (record.type === "normal") {
|
|
391
|
+
// If an exception is thrown from innerFn, we leave state ===
|
|
392
|
+
// GenStateExecuting and loop back for another invocation.
|
|
393
|
+
state = context.done ? GenStateCompleted : GenStateSuspendedYield;
|
|
394
|
+
|
|
395
|
+
if (record.arg === ContinueSentinel) {
|
|
396
|
+
continue;
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
return {
|
|
400
|
+
value: record.arg,
|
|
401
|
+
done: context.done
|
|
402
|
+
};
|
|
403
|
+
} else if (record.type === "throw") {
|
|
404
|
+
state = GenStateCompleted; // Dispatch the exception by looping back around to the
|
|
405
|
+
// context.dispatchException(context.arg) call above.
|
|
406
|
+
|
|
407
|
+
context.method = "throw";
|
|
408
|
+
context.arg = record.arg;
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
};
|
|
412
|
+
} // Call delegate.iterator[context.method](context.arg) and handle the
|
|
413
|
+
// result, either by returning a { value, done } result from the
|
|
414
|
+
// delegate iterator, or by modifying context.method and context.arg,
|
|
415
|
+
// setting context.delegate to null, and returning the ContinueSentinel.
|
|
416
|
+
|
|
417
|
+
|
|
418
|
+
function maybeInvokeDelegate(delegate, context) {
|
|
419
|
+
var method = delegate.iterator[context.method];
|
|
420
|
+
|
|
421
|
+
if (method === undefined$1) {
|
|
422
|
+
// A .throw or .return when the delegate iterator has no .throw
|
|
423
|
+
// method always terminates the yield* loop.
|
|
424
|
+
context.delegate = null;
|
|
425
|
+
|
|
426
|
+
if (context.method === "throw") {
|
|
427
|
+
// Note: ["return"] must be used for ES3 parsing compatibility.
|
|
428
|
+
if (delegate.iterator["return"]) {
|
|
429
|
+
// If the delegate iterator has a return method, give it a
|
|
430
|
+
// chance to clean up.
|
|
431
|
+
context.method = "return";
|
|
432
|
+
context.arg = undefined$1;
|
|
433
|
+
maybeInvokeDelegate(delegate, context);
|
|
434
|
+
|
|
435
|
+
if (context.method === "throw") {
|
|
436
|
+
// If maybeInvokeDelegate(context) changed context.method from
|
|
437
|
+
// "return" to "throw", let that override the TypeError below.
|
|
438
|
+
return ContinueSentinel;
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
context.method = "throw";
|
|
443
|
+
context.arg = new TypeError("The iterator does not provide a 'throw' method");
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
return ContinueSentinel;
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
var record = tryCatch(method, delegate.iterator, context.arg);
|
|
450
|
+
|
|
451
|
+
if (record.type === "throw") {
|
|
452
|
+
context.method = "throw";
|
|
453
|
+
context.arg = record.arg;
|
|
454
|
+
context.delegate = null;
|
|
455
|
+
return ContinueSentinel;
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
var info = record.arg;
|
|
459
|
+
|
|
460
|
+
if (!info) {
|
|
461
|
+
context.method = "throw";
|
|
462
|
+
context.arg = new TypeError("iterator result is not an object");
|
|
463
|
+
context.delegate = null;
|
|
464
|
+
return ContinueSentinel;
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
if (info.done) {
|
|
468
|
+
// Assign the result of the finished delegate to the temporary
|
|
469
|
+
// variable specified by delegate.resultName (see delegateYield).
|
|
470
|
+
context[delegate.resultName] = info.value; // Resume execution at the desired location (see delegateYield).
|
|
471
|
+
|
|
472
|
+
context.next = delegate.nextLoc; // If context.method was "throw" but the delegate handled the
|
|
473
|
+
// exception, let the outer generator proceed normally. If
|
|
474
|
+
// context.method was "next", forget context.arg since it has been
|
|
475
|
+
// "consumed" by the delegate iterator. If context.method was
|
|
476
|
+
// "return", allow the original .return call to continue in the
|
|
477
|
+
// outer generator.
|
|
478
|
+
|
|
479
|
+
if (context.method !== "return") {
|
|
480
|
+
context.method = "next";
|
|
481
|
+
context.arg = undefined$1;
|
|
482
|
+
}
|
|
483
|
+
} else {
|
|
484
|
+
// Re-yield the result returned by the delegate method.
|
|
485
|
+
return info;
|
|
486
|
+
} // The delegate iterator is finished, so forget it and continue with
|
|
487
|
+
// the outer generator.
|
|
488
|
+
|
|
489
|
+
|
|
490
|
+
context.delegate = null;
|
|
491
|
+
return ContinueSentinel;
|
|
492
|
+
} // Define Generator.prototype.{next,throw,return} in terms of the
|
|
493
|
+
// unified ._invoke helper method.
|
|
494
|
+
|
|
495
|
+
|
|
496
|
+
defineIteratorMethods(Gp);
|
|
497
|
+
define(Gp, toStringTagSymbol, "Generator"); // A Generator should always return itself as the iterator object when the
|
|
498
|
+
// @@iterator function is called on it. Some browsers' implementations of the
|
|
499
|
+
// iterator prototype chain incorrectly implement this, causing the Generator
|
|
500
|
+
// object to not be returned from this call. This ensures that doesn't happen.
|
|
501
|
+
// See https://github.com/facebook/regenerator/issues/274 for more details.
|
|
502
|
+
|
|
503
|
+
Gp[iteratorSymbol] = function () {
|
|
504
|
+
return this;
|
|
505
|
+
};
|
|
506
|
+
|
|
507
|
+
Gp.toString = function () {
|
|
508
|
+
return "[object Generator]";
|
|
509
|
+
};
|
|
510
|
+
|
|
511
|
+
function pushTryEntry(locs) {
|
|
512
|
+
var entry = {
|
|
513
|
+
tryLoc: locs[0]
|
|
514
|
+
};
|
|
515
|
+
|
|
516
|
+
if (1 in locs) {
|
|
517
|
+
entry.catchLoc = locs[1];
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
if (2 in locs) {
|
|
521
|
+
entry.finallyLoc = locs[2];
|
|
522
|
+
entry.afterLoc = locs[3];
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
this.tryEntries.push(entry);
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
function resetTryEntry(entry) {
|
|
529
|
+
var record = entry.completion || {};
|
|
530
|
+
record.type = "normal";
|
|
531
|
+
delete record.arg;
|
|
532
|
+
entry.completion = record;
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
function Context(tryLocsList) {
|
|
536
|
+
// The root entry object (effectively a try statement without a catch
|
|
537
|
+
// or a finally block) gives us a place to store values thrown from
|
|
538
|
+
// locations where there is no enclosing try statement.
|
|
539
|
+
this.tryEntries = [{
|
|
540
|
+
tryLoc: "root"
|
|
541
|
+
}];
|
|
542
|
+
tryLocsList.forEach(pushTryEntry, this);
|
|
543
|
+
this.reset(true);
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
exports.keys = function (object) {
|
|
547
|
+
var keys = [];
|
|
548
|
+
|
|
549
|
+
for (var key in object) {
|
|
550
|
+
keys.push(key);
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
keys.reverse(); // Rather than returning an object with a next method, we keep
|
|
554
|
+
// things simple and return the next function itself.
|
|
555
|
+
|
|
556
|
+
return function next() {
|
|
557
|
+
while (keys.length) {
|
|
558
|
+
var key = keys.pop();
|
|
559
|
+
|
|
560
|
+
if (key in object) {
|
|
561
|
+
next.value = key;
|
|
562
|
+
next.done = false;
|
|
563
|
+
return next;
|
|
564
|
+
}
|
|
565
|
+
} // To avoid creating an additional object, we just hang the .value
|
|
566
|
+
// and .done properties off the next function object itself. This
|
|
567
|
+
// also ensures that the minifier will not anonymize the function.
|
|
568
|
+
|
|
569
|
+
|
|
570
|
+
next.done = true;
|
|
571
|
+
return next;
|
|
572
|
+
};
|
|
573
|
+
};
|
|
574
|
+
|
|
575
|
+
function values(iterable) {
|
|
576
|
+
if (iterable) {
|
|
577
|
+
var iteratorMethod = iterable[iteratorSymbol];
|
|
578
|
+
|
|
579
|
+
if (iteratorMethod) {
|
|
580
|
+
return iteratorMethod.call(iterable);
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
if (typeof iterable.next === "function") {
|
|
584
|
+
return iterable;
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
if (!isNaN(iterable.length)) {
|
|
588
|
+
var i = -1,
|
|
589
|
+
next = function next() {
|
|
590
|
+
while (++i < iterable.length) {
|
|
591
|
+
if (hasOwn.call(iterable, i)) {
|
|
592
|
+
next.value = iterable[i];
|
|
593
|
+
next.done = false;
|
|
594
|
+
return next;
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
next.value = undefined$1;
|
|
599
|
+
next.done = true;
|
|
600
|
+
return next;
|
|
601
|
+
};
|
|
602
|
+
|
|
603
|
+
return next.next = next;
|
|
604
|
+
}
|
|
605
|
+
} // Return an iterator with no values.
|
|
606
|
+
|
|
607
|
+
|
|
608
|
+
return {
|
|
609
|
+
next: doneResult
|
|
610
|
+
};
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
exports.values = values;
|
|
614
|
+
|
|
615
|
+
function doneResult() {
|
|
616
|
+
return {
|
|
617
|
+
value: undefined$1,
|
|
618
|
+
done: true
|
|
619
|
+
};
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
Context.prototype = {
|
|
623
|
+
constructor: Context,
|
|
624
|
+
reset: function reset(skipTempReset) {
|
|
625
|
+
this.prev = 0;
|
|
626
|
+
this.next = 0; // Resetting context._sent for legacy support of Babel's
|
|
627
|
+
// function.sent implementation.
|
|
628
|
+
|
|
629
|
+
this.sent = this._sent = undefined$1;
|
|
630
|
+
this.done = false;
|
|
631
|
+
this.delegate = null;
|
|
632
|
+
this.method = "next";
|
|
633
|
+
this.arg = undefined$1;
|
|
634
|
+
this.tryEntries.forEach(resetTryEntry);
|
|
635
|
+
|
|
636
|
+
if (!skipTempReset) {
|
|
637
|
+
for (var name in this) {
|
|
638
|
+
// Not sure about the optimal order of these conditions:
|
|
639
|
+
if (name.charAt(0) === "t" && hasOwn.call(this, name) && !isNaN(+name.slice(1))) {
|
|
640
|
+
this[name] = undefined$1;
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
},
|
|
645
|
+
stop: function stop() {
|
|
646
|
+
this.done = true;
|
|
647
|
+
var rootEntry = this.tryEntries[0];
|
|
648
|
+
var rootRecord = rootEntry.completion;
|
|
649
|
+
|
|
650
|
+
if (rootRecord.type === "throw") {
|
|
651
|
+
throw rootRecord.arg;
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
return this.rval;
|
|
655
|
+
},
|
|
656
|
+
dispatchException: function dispatchException(exception) {
|
|
657
|
+
if (this.done) {
|
|
658
|
+
throw exception;
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
var context = this;
|
|
662
|
+
|
|
663
|
+
function handle(loc, caught) {
|
|
664
|
+
record.type = "throw";
|
|
665
|
+
record.arg = exception;
|
|
666
|
+
context.next = loc;
|
|
667
|
+
|
|
668
|
+
if (caught) {
|
|
669
|
+
// If the dispatched exception was caught by a catch block,
|
|
670
|
+
// then let that catch block handle the exception normally.
|
|
671
|
+
context.method = "next";
|
|
672
|
+
context.arg = undefined$1;
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
return !!caught;
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
679
|
+
var entry = this.tryEntries[i];
|
|
680
|
+
var record = entry.completion;
|
|
681
|
+
|
|
682
|
+
if (entry.tryLoc === "root") {
|
|
683
|
+
// Exception thrown outside of any try block that could handle
|
|
684
|
+
// it, so set the completion value of the entire function to
|
|
685
|
+
// throw the exception.
|
|
686
|
+
return handle("end");
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
if (entry.tryLoc <= this.prev) {
|
|
690
|
+
var hasCatch = hasOwn.call(entry, "catchLoc");
|
|
691
|
+
var hasFinally = hasOwn.call(entry, "finallyLoc");
|
|
692
|
+
|
|
693
|
+
if (hasCatch && hasFinally) {
|
|
694
|
+
if (this.prev < entry.catchLoc) {
|
|
695
|
+
return handle(entry.catchLoc, true);
|
|
696
|
+
} else if (this.prev < entry.finallyLoc) {
|
|
697
|
+
return handle(entry.finallyLoc);
|
|
698
|
+
}
|
|
699
|
+
} else if (hasCatch) {
|
|
700
|
+
if (this.prev < entry.catchLoc) {
|
|
701
|
+
return handle(entry.catchLoc, true);
|
|
702
|
+
}
|
|
703
|
+
} else if (hasFinally) {
|
|
704
|
+
if (this.prev < entry.finallyLoc) {
|
|
705
|
+
return handle(entry.finallyLoc);
|
|
706
|
+
}
|
|
707
|
+
} else {
|
|
708
|
+
throw new Error("try statement without catch or finally");
|
|
709
|
+
}
|
|
710
|
+
}
|
|
711
|
+
}
|
|
712
|
+
},
|
|
713
|
+
abrupt: function abrupt(type, arg) {
|
|
714
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
715
|
+
var entry = this.tryEntries[i];
|
|
716
|
+
|
|
717
|
+
if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
|
|
718
|
+
var finallyEntry = entry;
|
|
719
|
+
break;
|
|
720
|
+
}
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
if (finallyEntry && (type === "break" || type === "continue") && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc) {
|
|
724
|
+
// Ignore the finally entry if control is not jumping to a
|
|
725
|
+
// location outside the try/catch block.
|
|
726
|
+
finallyEntry = null;
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
var record = finallyEntry ? finallyEntry.completion : {};
|
|
730
|
+
record.type = type;
|
|
731
|
+
record.arg = arg;
|
|
732
|
+
|
|
733
|
+
if (finallyEntry) {
|
|
734
|
+
this.method = "next";
|
|
735
|
+
this.next = finallyEntry.finallyLoc;
|
|
736
|
+
return ContinueSentinel;
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
return this.complete(record);
|
|
740
|
+
},
|
|
741
|
+
complete: function complete(record, afterLoc) {
|
|
742
|
+
if (record.type === "throw") {
|
|
743
|
+
throw record.arg;
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
if (record.type === "break" || record.type === "continue") {
|
|
747
|
+
this.next = record.arg;
|
|
748
|
+
} else if (record.type === "return") {
|
|
749
|
+
this.rval = this.arg = record.arg;
|
|
750
|
+
this.method = "return";
|
|
751
|
+
this.next = "end";
|
|
752
|
+
} else if (record.type === "normal" && afterLoc) {
|
|
753
|
+
this.next = afterLoc;
|
|
754
|
+
}
|
|
755
|
+
|
|
756
|
+
return ContinueSentinel;
|
|
757
|
+
},
|
|
758
|
+
finish: function finish(finallyLoc) {
|
|
759
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
760
|
+
var entry = this.tryEntries[i];
|
|
761
|
+
|
|
762
|
+
if (entry.finallyLoc === finallyLoc) {
|
|
763
|
+
this.complete(entry.completion, entry.afterLoc);
|
|
764
|
+
resetTryEntry(entry);
|
|
765
|
+
return ContinueSentinel;
|
|
766
|
+
}
|
|
767
|
+
}
|
|
768
|
+
},
|
|
769
|
+
"catch": function _catch(tryLoc) {
|
|
770
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
771
|
+
var entry = this.tryEntries[i];
|
|
772
|
+
|
|
773
|
+
if (entry.tryLoc === tryLoc) {
|
|
774
|
+
var record = entry.completion;
|
|
775
|
+
|
|
776
|
+
if (record.type === "throw") {
|
|
777
|
+
var thrown = record.arg;
|
|
778
|
+
resetTryEntry(entry);
|
|
779
|
+
}
|
|
780
|
+
|
|
781
|
+
return thrown;
|
|
782
|
+
}
|
|
783
|
+
} // The context.catch method must only be called with a location
|
|
784
|
+
// argument that corresponds to a known catch block.
|
|
785
|
+
|
|
786
|
+
|
|
787
|
+
throw new Error("illegal catch attempt");
|
|
788
|
+
},
|
|
789
|
+
delegateYield: function delegateYield(iterable, resultName, nextLoc) {
|
|
790
|
+
this.delegate = {
|
|
791
|
+
iterator: values(iterable),
|
|
792
|
+
resultName: resultName,
|
|
793
|
+
nextLoc: nextLoc
|
|
794
|
+
};
|
|
795
|
+
|
|
796
|
+
if (this.method === "next") {
|
|
797
|
+
// Deliberately forget the last sent value so that we don't
|
|
798
|
+
// accidentally pass it on to the delegate.
|
|
799
|
+
this.arg = undefined$1;
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
return ContinueSentinel;
|
|
803
|
+
}
|
|
804
|
+
}; // Regardless of whether this script is executing as a CommonJS module
|
|
805
|
+
// or not, return the runtime object so that we can declare the variable
|
|
806
|
+
// regeneratorRuntime in the outer scope, which allows this module to be
|
|
807
|
+
// injected easily by `bin/regenerator --include-runtime script.js`.
|
|
808
|
+
|
|
809
|
+
return exports;
|
|
810
|
+
}( // If this script is executing as a CommonJS module, use module.exports
|
|
811
|
+
// as the regeneratorRuntime namespace. Otherwise create a new empty
|
|
812
|
+
// object. Either way, the resulting object will be used to initialize
|
|
813
|
+
// the regeneratorRuntime variable at the top of this file.
|
|
814
|
+
module.exports );
|
|
815
|
+
|
|
816
|
+
try {
|
|
817
|
+
regeneratorRuntime = runtime;
|
|
818
|
+
} catch (accidentalStrictMode) {
|
|
819
|
+
// This module should not be running in strict mode, so the above
|
|
820
|
+
// assignment should always work unless something is misconfigured. Just
|
|
821
|
+
// in case runtime.js accidentally runs in strict mode, we can escape
|
|
822
|
+
// strict mode using a global Function call. This could conceivably fail
|
|
823
|
+
// if a Content Security Policy forbids using Function, but in that case
|
|
824
|
+
// the proper solution is to fix the accidental strict mode problem. If
|
|
825
|
+
// you've misconfigured your bundler to force strict mode and applied a
|
|
826
|
+
// CSP to forbid Function, and you're not willing to fix either of those
|
|
827
|
+
// problems, please detail your unique predicament in a GitHub issue.
|
|
828
|
+
Function("r", "regeneratorRuntime = r")(runtime);
|
|
829
|
+
}
|
|
830
|
+
});
|
|
831
|
+
|
|
832
|
+
var fetchAPI = /*#__PURE__*/function () {
|
|
833
|
+
var _ref = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(info, init) {
|
|
834
|
+
var response, text;
|
|
835
|
+
return runtime_1.wrap(function _callee$(_context) {
|
|
836
|
+
while (1) {
|
|
837
|
+
switch (_context.prev = _context.next) {
|
|
838
|
+
case 0:
|
|
839
|
+
_context.next = 2;
|
|
840
|
+
return fetch(info, init);
|
|
841
|
+
|
|
842
|
+
case 2:
|
|
843
|
+
response = _context.sent;
|
|
844
|
+
|
|
845
|
+
if (!response.ok) {
|
|
846
|
+
_context.next = 5;
|
|
847
|
+
break;
|
|
848
|
+
}
|
|
849
|
+
|
|
850
|
+
return _context.abrupt("return", response.json());
|
|
851
|
+
|
|
852
|
+
case 5:
|
|
853
|
+
_context.next = 7;
|
|
854
|
+
return response.text();
|
|
855
|
+
|
|
856
|
+
case 7:
|
|
857
|
+
text = _context.sent;
|
|
858
|
+
throw new Error(text);
|
|
859
|
+
|
|
860
|
+
case 9:
|
|
861
|
+
case "end":
|
|
862
|
+
return _context.stop();
|
|
863
|
+
}
|
|
864
|
+
}
|
|
865
|
+
}, _callee);
|
|
866
|
+
}));
|
|
867
|
+
|
|
868
|
+
return function fetchAPI(_x, _x2) {
|
|
869
|
+
return _ref.apply(this, arguments);
|
|
870
|
+
};
|
|
871
|
+
}();
|
|
872
|
+
|
|
873
|
+
var BASE_INIT = {
|
|
874
|
+
method: 'POST',
|
|
875
|
+
headers: {
|
|
876
|
+
'content-type': 'application/json'
|
|
877
|
+
}
|
|
878
|
+
};
|
|
879
|
+
|
|
880
|
+
var getBase = function getBase(_ref) {
|
|
881
|
+
var account = _ref.account,
|
|
882
|
+
environment = _ref.environment;
|
|
883
|
+
return "http://" + account + "." + environment + ".com.br";
|
|
884
|
+
};
|
|
885
|
+
|
|
886
|
+
var VtexCommerce = function VtexCommerce(options) {
|
|
887
|
+
var channel = options.channel;
|
|
888
|
+
var base = getBase(options);
|
|
889
|
+
return {
|
|
890
|
+
catalog: {
|
|
891
|
+
brand: {
|
|
892
|
+
list: function list() {
|
|
893
|
+
return fetchAPI(base + "/api/catalog_system/pub/brand/list");
|
|
894
|
+
}
|
|
895
|
+
},
|
|
896
|
+
category: {
|
|
897
|
+
tree: function tree(depth) {
|
|
898
|
+
if (depth === void 0) {
|
|
899
|
+
depth = 3;
|
|
900
|
+
}
|
|
901
|
+
|
|
902
|
+
return fetchAPI(base + "/api/catalog_system/pub/category/tree/" + depth);
|
|
903
|
+
}
|
|
904
|
+
}
|
|
905
|
+
},
|
|
906
|
+
checkout: {
|
|
907
|
+
simulation: function simulation(args, _temp) {
|
|
908
|
+
var _ref2 = _temp === void 0 ? {
|
|
909
|
+
salesChannel: channel
|
|
910
|
+
} : _temp,
|
|
911
|
+
salesChannel = _ref2.salesChannel;
|
|
912
|
+
|
|
913
|
+
var params = new URLSearchParams({
|
|
914
|
+
sc: salesChannel
|
|
915
|
+
});
|
|
916
|
+
return fetchAPI(base + "/api/checkout/pub/orderForms/simulation?" + params.toString(), _extends({}, BASE_INIT, {
|
|
917
|
+
body: JSON.stringify(args)
|
|
918
|
+
}));
|
|
919
|
+
},
|
|
920
|
+
orderForm: function orderForm(_ref3) {
|
|
921
|
+
var id = _ref3.id,
|
|
922
|
+
_ref3$refreshOutdated = _ref3.refreshOutdatedData,
|
|
923
|
+
refreshOutdatedData = _ref3$refreshOutdated === void 0 ? true : _ref3$refreshOutdated,
|
|
924
|
+
_ref3$salesChannel = _ref3.salesChannel,
|
|
925
|
+
salesChannel = _ref3$salesChannel === void 0 ? channel : _ref3$salesChannel;
|
|
926
|
+
var params = new URLSearchParams({
|
|
927
|
+
refreshOutdatedData: refreshOutdatedData.toString(),
|
|
928
|
+
sc: salesChannel
|
|
929
|
+
});
|
|
930
|
+
return fetchAPI(base + "/api/checkout/pub/orderForm/" + id + "?" + params.toString(), BASE_INIT);
|
|
931
|
+
},
|
|
932
|
+
updateOrderFormItems: function updateOrderFormItems(_ref4) {
|
|
933
|
+
var id = _ref4.id,
|
|
934
|
+
orderItems = _ref4.orderItems,
|
|
935
|
+
_ref4$allowOutdatedDa = _ref4.allowOutdatedData,
|
|
936
|
+
allowOutdatedData = _ref4$allowOutdatedDa === void 0 ? 'paymentData' : _ref4$allowOutdatedDa,
|
|
937
|
+
_ref4$salesChannel = _ref4.salesChannel,
|
|
938
|
+
salesChannel = _ref4$salesChannel === void 0 ? channel : _ref4$salesChannel;
|
|
939
|
+
var params = new URLSearchParams({
|
|
940
|
+
allowOutdatedData: allowOutdatedData,
|
|
941
|
+
sc: salesChannel
|
|
942
|
+
});
|
|
943
|
+
return fetchAPI(base + "/api/checkout/pub/orderForm/" + id + "/items?" + params, _extends({}, BASE_INIT, {
|
|
944
|
+
body: JSON.stringify({
|
|
945
|
+
orderItems: orderItems
|
|
946
|
+
}),
|
|
947
|
+
method: 'PATCH'
|
|
948
|
+
}));
|
|
949
|
+
}
|
|
950
|
+
}
|
|
951
|
+
};
|
|
952
|
+
};
|
|
953
|
+
|
|
954
|
+
var IntelligentSearch = function IntelligentSearch(opts) {
|
|
955
|
+
var channel = opts.channel;
|
|
956
|
+
var base = "http://search.biggylabs.com.br/search-api/v1/" + opts.account;
|
|
957
|
+
|
|
958
|
+
var addDefaultFacets = function addDefaultFacets(facets) {
|
|
959
|
+
var facetsObj = Object.fromEntries(facets.map(function (_ref) {
|
|
960
|
+
var key = _ref.key,
|
|
961
|
+
value = _ref.value;
|
|
962
|
+
return [key, value];
|
|
963
|
+
}));
|
|
964
|
+
return Object.entries(_extends({
|
|
965
|
+
'trade-policy': channel
|
|
966
|
+
}, facetsObj)).map(function (_ref2) {
|
|
967
|
+
var key = _ref2[0],
|
|
968
|
+
value = _ref2[1];
|
|
969
|
+
return {
|
|
970
|
+
key: key,
|
|
971
|
+
value: value
|
|
972
|
+
};
|
|
973
|
+
});
|
|
974
|
+
};
|
|
975
|
+
|
|
976
|
+
var search = function search(_ref3) {
|
|
977
|
+
var _ref3$query = _ref3.query,
|
|
978
|
+
query = _ref3$query === void 0 ? '' : _ref3$query,
|
|
979
|
+
page = _ref3.page,
|
|
980
|
+
count = _ref3.count,
|
|
981
|
+
_ref3$sort = _ref3.sort,
|
|
982
|
+
sort = _ref3$sort === void 0 ? '' : _ref3$sort,
|
|
983
|
+
_ref3$selectedFacets = _ref3.selectedFacets,
|
|
984
|
+
selectedFacets = _ref3$selectedFacets === void 0 ? [] : _ref3$selectedFacets,
|
|
985
|
+
type = _ref3.type,
|
|
986
|
+
_ref3$fuzzy = _ref3.fuzzy,
|
|
987
|
+
fuzzy = _ref3$fuzzy === void 0 ? '0' : _ref3$fuzzy;
|
|
988
|
+
var params = new URLSearchParams({
|
|
989
|
+
page: (page + 1).toString(),
|
|
990
|
+
count: count.toString(),
|
|
991
|
+
query: query,
|
|
992
|
+
sort: sort,
|
|
993
|
+
fuzzy: fuzzy
|
|
994
|
+
});
|
|
995
|
+
var pathname = addDefaultFacets(selectedFacets).map(function (_ref4) {
|
|
996
|
+
var key = _ref4.key,
|
|
997
|
+
value = _ref4.value;
|
|
998
|
+
return key + "/" + value;
|
|
999
|
+
}).join('/');
|
|
1000
|
+
return fetchAPI(base + "/api/split/" + type + "/" + pathname + "?" + params.toString());
|
|
1001
|
+
};
|
|
1002
|
+
|
|
1003
|
+
var products = function products(args) {
|
|
1004
|
+
return search(_extends({}, args, {
|
|
1005
|
+
type: 'product_search'
|
|
1006
|
+
}));
|
|
1007
|
+
};
|
|
1008
|
+
|
|
1009
|
+
var facets = function facets(args) {
|
|
1010
|
+
return search(_extends({}, args, {
|
|
1011
|
+
type: 'attribute_search'
|
|
1012
|
+
}));
|
|
1013
|
+
};
|
|
1014
|
+
|
|
1015
|
+
return {
|
|
1016
|
+
facets: facets,
|
|
1017
|
+
products: products
|
|
1018
|
+
};
|
|
1019
|
+
};
|
|
1020
|
+
|
|
1021
|
+
var getClients = function getClients(options) {
|
|
1022
|
+
var search = IntelligentSearch(options);
|
|
1023
|
+
var commerce = VtexCommerce(options);
|
|
1024
|
+
return {
|
|
1025
|
+
search: search,
|
|
1026
|
+
commerce: commerce
|
|
1027
|
+
};
|
|
1028
|
+
};
|
|
1029
|
+
|
|
1030
|
+
var getSimulationLoader = function getSimulationLoader(_, clients) {
|
|
1031
|
+
var loader = /*#__PURE__*/function () {
|
|
1032
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(items) {
|
|
1033
|
+
var simulated, itemsIndices, askedItems, returnedItems;
|
|
1034
|
+
return runtime_1.wrap(function _callee$(_context) {
|
|
1035
|
+
while (1) {
|
|
1036
|
+
switch (_context.prev = _context.next) {
|
|
1037
|
+
case 0:
|
|
1038
|
+
_context.next = 2;
|
|
1039
|
+
return clients.commerce.checkout.simulation({
|
|
1040
|
+
items: [].concat(items.flat())
|
|
1041
|
+
});
|
|
1042
|
+
|
|
1043
|
+
case 2:
|
|
1044
|
+
simulated = _context.sent;
|
|
1045
|
+
itemsIndices = items.reduce(function (acc, curr) {
|
|
1046
|
+
return [].concat(acc, [curr.length + acc[acc.length - 1]]);
|
|
1047
|
+
}, [0]);
|
|
1048
|
+
|
|
1049
|
+
if (!(simulated.items.length !== itemsIndices[itemsIndices.length - 1])) {
|
|
1050
|
+
_context.next = 8;
|
|
1051
|
+
break;
|
|
1052
|
+
}
|
|
1053
|
+
|
|
1054
|
+
askedItems = itemsIndices[itemsIndices.length - 1];
|
|
1055
|
+
returnedItems = simulated.items.length;
|
|
1056
|
+
throw new Error("Simulation asked for " + askedItems + ", but received " + returnedItems + " items");
|
|
1057
|
+
|
|
1058
|
+
case 8:
|
|
1059
|
+
return _context.abrupt("return", items.map(function (__, index) {
|
|
1060
|
+
return _extends({}, simulated, {
|
|
1061
|
+
items: simulated.items.slice(itemsIndices[index], itemsIndices[index + 1])
|
|
1062
|
+
});
|
|
1063
|
+
}));
|
|
1064
|
+
|
|
1065
|
+
case 9:
|
|
1066
|
+
case "end":
|
|
1067
|
+
return _context.stop();
|
|
1068
|
+
}
|
|
1069
|
+
}
|
|
1070
|
+
}, _callee);
|
|
1071
|
+
}));
|
|
1072
|
+
|
|
1073
|
+
return function loader(_x) {
|
|
1074
|
+
return _ref.apply(this, arguments);
|
|
1075
|
+
};
|
|
1076
|
+
}();
|
|
1077
|
+
|
|
1078
|
+
return new DataLoader(loader, {
|
|
1079
|
+
maxBatchSize: 20
|
|
1080
|
+
});
|
|
1081
|
+
};
|
|
1082
|
+
|
|
1083
|
+
var enhanceSku = function enhanceSku(sku, product) {
|
|
1084
|
+
return _extends({}, sku, {
|
|
1085
|
+
isVariantOf: product
|
|
1086
|
+
});
|
|
1087
|
+
};
|
|
1088
|
+
|
|
1089
|
+
var getSkuLoader = function getSkuLoader(_, clients) {
|
|
1090
|
+
var loader = /*#__PURE__*/function () {
|
|
1091
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(facetsList) {
|
|
1092
|
+
var skuIds, indexById, _yield$clients$search, products, sorted, _iterator, _step, product, sku, index;
|
|
1093
|
+
|
|
1094
|
+
return runtime_1.wrap(function _callee$(_context) {
|
|
1095
|
+
while (1) {
|
|
1096
|
+
switch (_context.prev = _context.next) {
|
|
1097
|
+
case 0:
|
|
1098
|
+
skuIds = facetsList.map(function (facets) {
|
|
1099
|
+
var maybeFacet = facets.find(function (_ref2) {
|
|
1100
|
+
var key = _ref2.key;
|
|
1101
|
+
return key === 'id';
|
|
1102
|
+
});
|
|
1103
|
+
|
|
1104
|
+
if (!maybeFacet) {
|
|
1105
|
+
throw new Error('Error while loading SKU. Needs to pass an id to selected facets');
|
|
1106
|
+
}
|
|
1107
|
+
|
|
1108
|
+
return maybeFacet.value;
|
|
1109
|
+
});
|
|
1110
|
+
indexById = skuIds.reduce(function (acc, id, index) {
|
|
1111
|
+
var _extends2;
|
|
1112
|
+
|
|
1113
|
+
return _extends({}, acc, (_extends2 = {}, _extends2[id] = index, _extends2));
|
|
1114
|
+
}, {});
|
|
1115
|
+
_context.next = 4;
|
|
1116
|
+
return clients.search.products({
|
|
1117
|
+
query: "sku:" + skuIds.join(';'),
|
|
1118
|
+
page: 0,
|
|
1119
|
+
count: skuIds.length
|
|
1120
|
+
});
|
|
1121
|
+
|
|
1122
|
+
case 4:
|
|
1123
|
+
_yield$clients$search = _context.sent;
|
|
1124
|
+
products = _yield$clients$search.products;
|
|
1125
|
+
|
|
1126
|
+
if (!(products.length !== skuIds.length)) {
|
|
1127
|
+
_context.next = 8;
|
|
1128
|
+
break;
|
|
1129
|
+
}
|
|
1130
|
+
|
|
1131
|
+
throw new Error("Sku batching went wrong. Asked for " + skuIds.length + " sku(s) but search api returned " + products.length + " sku(s)");
|
|
1132
|
+
|
|
1133
|
+
case 8:
|
|
1134
|
+
sorted = new Array(products.length); // O(n*m) sort, where n = skuIds.length and m is the number of skus per product
|
|
1135
|
+
|
|
1136
|
+
_iterator = _createForOfIteratorHelperLoose(products);
|
|
1137
|
+
|
|
1138
|
+
case 10:
|
|
1139
|
+
if ((_step = _iterator()).done) {
|
|
1140
|
+
_context.next = 19;
|
|
1141
|
+
break;
|
|
1142
|
+
}
|
|
1143
|
+
|
|
1144
|
+
product = _step.value;
|
|
1145
|
+
sku = product.skus.find(function (item) {
|
|
1146
|
+
return indexById[item.id] != null;
|
|
1147
|
+
});
|
|
1148
|
+
|
|
1149
|
+
if (!(sku == null)) {
|
|
1150
|
+
_context.next = 15;
|
|
1151
|
+
break;
|
|
1152
|
+
}
|
|
1153
|
+
|
|
1154
|
+
throw new Error("Could not find sku for product " + product.id);
|
|
1155
|
+
|
|
1156
|
+
case 15:
|
|
1157
|
+
index = indexById[sku.id];
|
|
1158
|
+
sorted[index] = enhanceSku(sku, product);
|
|
1159
|
+
|
|
1160
|
+
case 17:
|
|
1161
|
+
_context.next = 10;
|
|
1162
|
+
break;
|
|
1163
|
+
|
|
1164
|
+
case 19:
|
|
1165
|
+
return _context.abrupt("return", sorted);
|
|
1166
|
+
|
|
1167
|
+
case 20:
|
|
1168
|
+
case "end":
|
|
1169
|
+
return _context.stop();
|
|
1170
|
+
}
|
|
1171
|
+
}
|
|
1172
|
+
}, _callee);
|
|
1173
|
+
}));
|
|
1174
|
+
|
|
1175
|
+
return function loader(_x) {
|
|
1176
|
+
return _ref.apply(this, arguments);
|
|
1177
|
+
};
|
|
1178
|
+
}();
|
|
1179
|
+
|
|
1180
|
+
return new DataLoader(loader, {
|
|
1181
|
+
maxBatchSize: 99
|
|
1182
|
+
});
|
|
1183
|
+
};
|
|
1184
|
+
|
|
1185
|
+
var getLoaders = function getLoaders(options, clients) {
|
|
1186
|
+
var skuLoader = getSkuLoader(options, clients);
|
|
1187
|
+
var simulationLoader = getSimulationLoader(options, clients);
|
|
1188
|
+
return {
|
|
1189
|
+
skuLoader: skuLoader,
|
|
1190
|
+
simulationLoader: simulationLoader
|
|
1191
|
+
};
|
|
1192
|
+
};
|
|
1193
|
+
|
|
1194
|
+
var StoreAggregateOffer = {
|
|
1195
|
+
highPrice: function highPrice(_ref) {
|
|
1196
|
+
var _items$0$sellingPrice, _items$;
|
|
1197
|
+
|
|
1198
|
+
var items = _ref.items;
|
|
1199
|
+
return items.reduce(function (acc, curr) {
|
|
1200
|
+
return acc > curr.sellingPrice ? acc : curr.sellingPrice;
|
|
1201
|
+
}, (_items$0$sellingPrice = (_items$ = items[0]) == null ? void 0 : _items$.sellingPrice) != null ? _items$0$sellingPrice : 0) / 1e2;
|
|
1202
|
+
},
|
|
1203
|
+
lowPrice: function lowPrice(_ref2) {
|
|
1204
|
+
var _items$0$sellingPrice2, _items$2;
|
|
1205
|
+
|
|
1206
|
+
var items = _ref2.items;
|
|
1207
|
+
return items.reduce(function (acc, curr) {
|
|
1208
|
+
return acc < curr.sellingPrice ? acc : curr.sellingPrice;
|
|
1209
|
+
}, (_items$0$sellingPrice2 = (_items$2 = items[0]) == null ? void 0 : _items$2.sellingPrice) != null ? _items$0$sellingPrice2 : 0) / 1e2;
|
|
1210
|
+
},
|
|
1211
|
+
offerCount: function offerCount(_ref3) {
|
|
1212
|
+
var items = _ref3.items;
|
|
1213
|
+
return items.length;
|
|
1214
|
+
},
|
|
1215
|
+
priceCurrency: function priceCurrency() {
|
|
1216
|
+
return '';
|
|
1217
|
+
},
|
|
1218
|
+
offers: function offers(_ref4) {
|
|
1219
|
+
var items = _ref4.items,
|
|
1220
|
+
product = _ref4.product;
|
|
1221
|
+
return items.map(function (item) {
|
|
1222
|
+
return _extends({}, item, {
|
|
1223
|
+
product: product
|
|
1224
|
+
});
|
|
1225
|
+
});
|
|
1226
|
+
}
|
|
1227
|
+
};
|
|
1228
|
+
|
|
1229
|
+
// TODO: Add a review system integration
|
|
1230
|
+
var StoreAggregateRating = {
|
|
1231
|
+
ratingValue: function ratingValue() {
|
|
1232
|
+
return 5;
|
|
1233
|
+
},
|
|
1234
|
+
reviewCount: function reviewCount() {
|
|
1235
|
+
return 0;
|
|
1236
|
+
}
|
|
1237
|
+
};
|
|
1238
|
+
|
|
1239
|
+
var slugify = function slugify(path) {
|
|
1240
|
+
return rawSlugify(path, {
|
|
1241
|
+
replacement: '-',
|
|
1242
|
+
lower: true
|
|
1243
|
+
});
|
|
1244
|
+
};
|
|
1245
|
+
|
|
1246
|
+
var isBrand = function isBrand(x) {
|
|
1247
|
+
return x.type === 'brand';
|
|
1248
|
+
};
|
|
1249
|
+
|
|
1250
|
+
var StoreCollection = {
|
|
1251
|
+
id: function id(_ref) {
|
|
1252
|
+
var _id = _ref.id;
|
|
1253
|
+
return _id.toString();
|
|
1254
|
+
},
|
|
1255
|
+
slug: function slug(_ref2) {
|
|
1256
|
+
var name = _ref2.name;
|
|
1257
|
+
return slugify(name);
|
|
1258
|
+
},
|
|
1259
|
+
seo: function seo(root) {
|
|
1260
|
+
return isBrand(root) ? {
|
|
1261
|
+
title: root.title,
|
|
1262
|
+
description: root.metaTagDescription
|
|
1263
|
+
} : {
|
|
1264
|
+
title: root.Title,
|
|
1265
|
+
description: root.MetaTagDescription
|
|
1266
|
+
};
|
|
1267
|
+
},
|
|
1268
|
+
type: function type(root) {
|
|
1269
|
+
return isBrand(root) ? 'Brand' : root.level === 0 ? 'Department' : 'Category';
|
|
1270
|
+
},
|
|
1271
|
+
meta: function meta(root) {
|
|
1272
|
+
return isBrand(root) ? {
|
|
1273
|
+
selectedFacets: [{
|
|
1274
|
+
key: 'brand',
|
|
1275
|
+
value: slugify(root.name)
|
|
1276
|
+
}]
|
|
1277
|
+
} : {
|
|
1278
|
+
selectedFacets: new URL(root.url).pathname.slice(1).split('/').map(function (segment, index) {
|
|
1279
|
+
return {
|
|
1280
|
+
key: "category-" + (index + 1),
|
|
1281
|
+
value: slugify(segment)
|
|
1282
|
+
};
|
|
1283
|
+
})
|
|
1284
|
+
};
|
|
1285
|
+
},
|
|
1286
|
+
breadcrumbList: function breadcrumbList() {
|
|
1287
|
+
return {
|
|
1288
|
+
itemListElement: [],
|
|
1289
|
+
numberOfItems: 0
|
|
1290
|
+
};
|
|
1291
|
+
}
|
|
1292
|
+
};
|
|
1293
|
+
|
|
1294
|
+
var StoreFacet = {
|
|
1295
|
+
key: function key(_ref) {
|
|
1296
|
+
var _key = _ref.key;
|
|
1297
|
+
return _key;
|
|
1298
|
+
},
|
|
1299
|
+
label: function label(_ref2) {
|
|
1300
|
+
var _label = _ref2.label;
|
|
1301
|
+
return _label;
|
|
1302
|
+
},
|
|
1303
|
+
values: function values(_ref3) {
|
|
1304
|
+
var _values = _ref3.values;
|
|
1305
|
+
return _values;
|
|
1306
|
+
},
|
|
1307
|
+
type: function type(_ref4) {
|
|
1308
|
+
var _type = _ref4.type;
|
|
1309
|
+
return _type === 'text' ? 'BOOLEAN' : 'RANGE';
|
|
1310
|
+
}
|
|
1311
|
+
};
|
|
1312
|
+
|
|
1313
|
+
var StoreFacetValue = {
|
|
1314
|
+
value: function value(_ref) {
|
|
1315
|
+
var key = _ref.key,
|
|
1316
|
+
from = _ref.from,
|
|
1317
|
+
to = _ref.to;
|
|
1318
|
+
return key != null ? key : from + "-to-" + to;
|
|
1319
|
+
},
|
|
1320
|
+
label: function label(_ref2) {
|
|
1321
|
+
var _label = _ref2.label;
|
|
1322
|
+
return _label != null ? _label : 'unknown';
|
|
1323
|
+
},
|
|
1324
|
+
selected: function selected(_ref3) {
|
|
1325
|
+
var active = _ref3.active;
|
|
1326
|
+
return active;
|
|
1327
|
+
},
|
|
1328
|
+
quantity: function quantity(_ref4) {
|
|
1329
|
+
var count = _ref4.count;
|
|
1330
|
+
return count;
|
|
1331
|
+
}
|
|
1332
|
+
};
|
|
1333
|
+
|
|
1334
|
+
var getId = function getId(item) {
|
|
1335
|
+
return [item.itemOffered.sku, item.seller.identifier, item.price].join('::');
|
|
1336
|
+
};
|
|
1337
|
+
|
|
1338
|
+
var orderFormItemToOffer = function orderFormItemToOffer(item, index) {
|
|
1339
|
+
return {
|
|
1340
|
+
listPrice: item.listPrice / 100,
|
|
1341
|
+
price: item.sellingPrice / 100,
|
|
1342
|
+
quantity: item.quantity,
|
|
1343
|
+
seller: {
|
|
1344
|
+
identifier: item.seller
|
|
1345
|
+
},
|
|
1346
|
+
itemOffered: {
|
|
1347
|
+
sku: item.id,
|
|
1348
|
+
image: [],
|
|
1349
|
+
name: item.name
|
|
1350
|
+
},
|
|
1351
|
+
index: index
|
|
1352
|
+
};
|
|
1353
|
+
};
|
|
1354
|
+
|
|
1355
|
+
var offerToOrderItemInput = function offerToOrderItemInput(offer) {
|
|
1356
|
+
return {
|
|
1357
|
+
quantity: offer.quantity,
|
|
1358
|
+
seller: offer.seller.identifier,
|
|
1359
|
+
id: offer.itemOffered.sku,
|
|
1360
|
+
index: offer.index
|
|
1361
|
+
};
|
|
1362
|
+
};
|
|
1363
|
+
|
|
1364
|
+
var groupById = function groupById(offers) {
|
|
1365
|
+
return offers.reduce(function (acc, item) {
|
|
1366
|
+
var _acc$get;
|
|
1367
|
+
|
|
1368
|
+
var id = getId(item);
|
|
1369
|
+
acc.set(id, (_acc$get = acc.get(id)) != null ? _acc$get : item);
|
|
1370
|
+
return acc;
|
|
1371
|
+
}, new Map());
|
|
1372
|
+
};
|
|
1373
|
+
|
|
1374
|
+
var equals = function equals(of1, of2) {
|
|
1375
|
+
var pick = function pick(_ref) {
|
|
1376
|
+
var orderFormId = _ref.orderFormId,
|
|
1377
|
+
messages = _ref.messages,
|
|
1378
|
+
items = _ref.items,
|
|
1379
|
+
salesChannel = _ref.salesChannel;
|
|
1380
|
+
return {
|
|
1381
|
+
orderFormId: orderFormId,
|
|
1382
|
+
messages: messages,
|
|
1383
|
+
salesChannel: salesChannel,
|
|
1384
|
+
items: items.map(function (_ref2) {
|
|
1385
|
+
var uniqueId = _ref2.uniqueId,
|
|
1386
|
+
quantity = _ref2.quantity,
|
|
1387
|
+
seller = _ref2.seller,
|
|
1388
|
+
sellingPrice = _ref2.sellingPrice,
|
|
1389
|
+
availability = _ref2.availability;
|
|
1390
|
+
return {
|
|
1391
|
+
uniqueId: uniqueId,
|
|
1392
|
+
quantity: quantity,
|
|
1393
|
+
seller: seller,
|
|
1394
|
+
sellingPrice: sellingPrice,
|
|
1395
|
+
availability: availability
|
|
1396
|
+
};
|
|
1397
|
+
})
|
|
1398
|
+
};
|
|
1399
|
+
};
|
|
1400
|
+
|
|
1401
|
+
return deepEquals(pick(of1), pick(of2));
|
|
1402
|
+
};
|
|
1403
|
+
/**
|
|
1404
|
+
* This resolver implements the optimistic cart behavior. The main idea in here
|
|
1405
|
+
* is that we receive a cart from the UI (as query params) and we validate it with
|
|
1406
|
+
* the commerce platform. If the cart is valid, we return null, if the cart is
|
|
1407
|
+
* invalid according to the commerce platform, we return the new cart the UI should use
|
|
1408
|
+
* instead
|
|
1409
|
+
*
|
|
1410
|
+
* The algoritm is something like:
|
|
1411
|
+
* 1. Fetch orderForm from VTEX
|
|
1412
|
+
* 2. Compute delta changes between the orderForm and the UI's cart
|
|
1413
|
+
* 3. Update the orderForm in VTEX platform accordingly
|
|
1414
|
+
* 4. If any chages were made, send to the UI the new cart. Null otherwise
|
|
1415
|
+
*/
|
|
1416
|
+
|
|
1417
|
+
|
|
1418
|
+
var validateCart = /*#__PURE__*/function () {
|
|
1419
|
+
var _ref4 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(_, _ref3, ctx) {
|
|
1420
|
+
var _ref3$cart$order, orderNumber, acceptedOffer, commerce, skuLoader, orderForm, browserItemsById, originItemsById, browserItems, originItems, _browserItems$reduce, itemsToAdd, itemsToUpdate, itemsToDelete, changes, updatedOrderForm;
|
|
1421
|
+
|
|
1422
|
+
return runtime_1.wrap(function _callee$(_context) {
|
|
1423
|
+
while (1) {
|
|
1424
|
+
switch (_context.prev = _context.next) {
|
|
1425
|
+
case 0:
|
|
1426
|
+
_ref3$cart$order = _ref3.cart.order, orderNumber = _ref3$cart$order.orderNumber, acceptedOffer = _ref3$cart$order.acceptedOffer;
|
|
1427
|
+
commerce = ctx.clients.commerce, skuLoader = ctx.loaders.skuLoader; // Step1: Get OrderForm from VTEX Commerce
|
|
1428
|
+
|
|
1429
|
+
_context.next = 4;
|
|
1430
|
+
return commerce.checkout.orderForm({
|
|
1431
|
+
id: orderNumber
|
|
1432
|
+
});
|
|
1433
|
+
|
|
1434
|
+
case 4:
|
|
1435
|
+
orderForm = _context.sent;
|
|
1436
|
+
// Step2: Process items from both browser and checkout so they have the same shape
|
|
1437
|
+
browserItemsById = groupById(acceptedOffer);
|
|
1438
|
+
originItemsById = groupById(orderForm.items.map(orderFormItemToOffer));
|
|
1439
|
+
browserItems = Array.from(browserItemsById.values()); // items on the user's browser
|
|
1440
|
+
|
|
1441
|
+
originItems = Array.from(originItemsById.values()); // items on the VTEX platform backend
|
|
1442
|
+
// Step3: Compute delta changes
|
|
1443
|
+
|
|
1444
|
+
_browserItems$reduce = browserItems.reduce(function (acc, item) {
|
|
1445
|
+
var maybeOriginItem = originItemsById.get(getId(item));
|
|
1446
|
+
|
|
1447
|
+
if (!maybeOriginItem) {
|
|
1448
|
+
acc.itemsToAdd.push(item);
|
|
1449
|
+
} else {
|
|
1450
|
+
acc.itemsToUpdate.push(_extends({}, maybeOriginItem, {
|
|
1451
|
+
quantity: item.quantity
|
|
1452
|
+
}));
|
|
1453
|
+
}
|
|
1454
|
+
|
|
1455
|
+
return acc;
|
|
1456
|
+
}, {
|
|
1457
|
+
itemsToAdd: [],
|
|
1458
|
+
itemsToUpdate: []
|
|
1459
|
+
}), itemsToAdd = _browserItems$reduce.itemsToAdd, itemsToUpdate = _browserItems$reduce.itemsToUpdate;
|
|
1460
|
+
itemsToDelete = originItems.filter(function (item) {
|
|
1461
|
+
return !browserItemsById.has(getId(item));
|
|
1462
|
+
}).map(function (item) {
|
|
1463
|
+
return _extends({}, item, {
|
|
1464
|
+
quantity: 0
|
|
1465
|
+
});
|
|
1466
|
+
});
|
|
1467
|
+
changes = [].concat(itemsToAdd, itemsToUpdate, itemsToDelete).map(offerToOrderItemInput);
|
|
1468
|
+
|
|
1469
|
+
if (!(changes.length === 0)) {
|
|
1470
|
+
_context.next = 14;
|
|
1471
|
+
break;
|
|
1472
|
+
}
|
|
1473
|
+
|
|
1474
|
+
return _context.abrupt("return", null);
|
|
1475
|
+
|
|
1476
|
+
case 14:
|
|
1477
|
+
_context.next = 16;
|
|
1478
|
+
return commerce.checkout.updateOrderFormItems({
|
|
1479
|
+
id: orderForm.orderFormId,
|
|
1480
|
+
orderItems: changes
|
|
1481
|
+
});
|
|
1482
|
+
|
|
1483
|
+
case 16:
|
|
1484
|
+
updatedOrderForm = _context.sent;
|
|
1485
|
+
|
|
1486
|
+
if (!equals(orderForm, updatedOrderForm)) {
|
|
1487
|
+
_context.next = 19;
|
|
1488
|
+
break;
|
|
1489
|
+
}
|
|
1490
|
+
|
|
1491
|
+
return _context.abrupt("return", null);
|
|
1492
|
+
|
|
1493
|
+
case 19:
|
|
1494
|
+
return _context.abrupt("return", {
|
|
1495
|
+
order: {
|
|
1496
|
+
orderNumber: updatedOrderForm.orderFormId,
|
|
1497
|
+
acceptedOffer: updatedOrderForm.items.map(function (item) {
|
|
1498
|
+
return _extends({}, item, {
|
|
1499
|
+
product: skuLoader.load([{
|
|
1500
|
+
key: 'id',
|
|
1501
|
+
value: item.id
|
|
1502
|
+
}])
|
|
1503
|
+
});
|
|
1504
|
+
})
|
|
1505
|
+
},
|
|
1506
|
+
messages: updatedOrderForm.messages.map(function (_ref5) {
|
|
1507
|
+
var text = _ref5.text,
|
|
1508
|
+
status = _ref5.status;
|
|
1509
|
+
return {
|
|
1510
|
+
text: text,
|
|
1511
|
+
status: status.toUpperCase()
|
|
1512
|
+
};
|
|
1513
|
+
})
|
|
1514
|
+
});
|
|
1515
|
+
|
|
1516
|
+
case 20:
|
|
1517
|
+
case "end":
|
|
1518
|
+
return _context.stop();
|
|
1519
|
+
}
|
|
1520
|
+
}
|
|
1521
|
+
}, _callee);
|
|
1522
|
+
}));
|
|
1523
|
+
|
|
1524
|
+
return function validateCart(_x, _x2, _x3) {
|
|
1525
|
+
return _ref4.apply(this, arguments);
|
|
1526
|
+
};
|
|
1527
|
+
}();
|
|
1528
|
+
|
|
1529
|
+
var Mutation = {
|
|
1530
|
+
validateCart: validateCart
|
|
1531
|
+
};
|
|
1532
|
+
|
|
1533
|
+
var StoreOffer = {
|
|
1534
|
+
priceCurrency: function priceCurrency() {
|
|
1535
|
+
return '';
|
|
1536
|
+
},
|
|
1537
|
+
priceValidUntil: function priceValidUntil(_ref) {
|
|
1538
|
+
var _priceValidUntil = _ref.priceValidUntil;
|
|
1539
|
+
return _priceValidUntil != null ? _priceValidUntil : '';
|
|
1540
|
+
},
|
|
1541
|
+
itemCondition: function itemCondition() {
|
|
1542
|
+
return 'https://schema.org/NewCondition';
|
|
1543
|
+
},
|
|
1544
|
+
availability: function availability(_ref2) {
|
|
1545
|
+
var _availability = _ref2.availability;
|
|
1546
|
+
return _availability === 'available' ? 'https://schema.org/InStock' : 'https://schema.org/OutOfStock';
|
|
1547
|
+
},
|
|
1548
|
+
seller: function seller(_ref3) {
|
|
1549
|
+
var _seller = _ref3.seller;
|
|
1550
|
+
return {
|
|
1551
|
+
identifier: _seller
|
|
1552
|
+
};
|
|
1553
|
+
},
|
|
1554
|
+
price: function price(_ref4) {
|
|
1555
|
+
var sellingPrice = _ref4.sellingPrice;
|
|
1556
|
+
return sellingPrice / 1e2;
|
|
1557
|
+
},
|
|
1558
|
+
sellingPrice: function sellingPrice(_ref5) {
|
|
1559
|
+
var _sellingPrice = _ref5.sellingPrice;
|
|
1560
|
+
return _sellingPrice / 1e2;
|
|
1561
|
+
},
|
|
1562
|
+
listPrice: function listPrice(_ref6) {
|
|
1563
|
+
var _listPrice = _ref6.listPrice;
|
|
1564
|
+
return _listPrice / 1e2;
|
|
1565
|
+
},
|
|
1566
|
+
itemOffered: function itemOffered(_ref7) {
|
|
1567
|
+
var product = _ref7.product;
|
|
1568
|
+
return product;
|
|
1569
|
+
},
|
|
1570
|
+
quantity: function quantity(_ref8) {
|
|
1571
|
+
var _quantity = _ref8.quantity;
|
|
1572
|
+
return _quantity;
|
|
1573
|
+
}
|
|
1574
|
+
};
|
|
1575
|
+
|
|
1576
|
+
var DEFAULT_IMAGE = {
|
|
1577
|
+
name: 'image',
|
|
1578
|
+
value: 'https://storecomponents.vtexassets.com/assets/faststore/images/image___117a6d3e229a96ad0e0d0876352566e2.svg'
|
|
1579
|
+
};
|
|
1580
|
+
|
|
1581
|
+
var getSlug = function getSlug(link, id) {
|
|
1582
|
+
return link + "-" + id;
|
|
1583
|
+
};
|
|
1584
|
+
|
|
1585
|
+
var getPath = function getPath(link, id) {
|
|
1586
|
+
return "/" + getSlug(link, id) + "/p";
|
|
1587
|
+
};
|
|
1588
|
+
|
|
1589
|
+
var StoreProduct = {
|
|
1590
|
+
productID: function productID(_ref) {
|
|
1591
|
+
var id = _ref.id;
|
|
1592
|
+
return id;
|
|
1593
|
+
},
|
|
1594
|
+
name: function name(_ref2) {
|
|
1595
|
+
var isVariantOf = _ref2.isVariantOf,
|
|
1596
|
+
_name = _ref2.name;
|
|
1597
|
+
return _name != null ? _name : isVariantOf.name;
|
|
1598
|
+
},
|
|
1599
|
+
slug: function slug(_ref3) {
|
|
1600
|
+
var link = _ref3.isVariantOf.link,
|
|
1601
|
+
id = _ref3.id;
|
|
1602
|
+
return getSlug(link, id);
|
|
1603
|
+
},
|
|
1604
|
+
description: function description(_ref4) {
|
|
1605
|
+
var _description = _ref4.isVariantOf.description;
|
|
1606
|
+
return _description;
|
|
1607
|
+
},
|
|
1608
|
+
seo: function seo(_ref5) {
|
|
1609
|
+
var _ref5$isVariantOf = _ref5.isVariantOf,
|
|
1610
|
+
name = _ref5$isVariantOf.name,
|
|
1611
|
+
description = _ref5$isVariantOf.description;
|
|
1612
|
+
return {
|
|
1613
|
+
title: name,
|
|
1614
|
+
description: description
|
|
1615
|
+
};
|
|
1616
|
+
},
|
|
1617
|
+
brand: function brand(_ref6) {
|
|
1618
|
+
var _brand = _ref6.isVariantOf.brand;
|
|
1619
|
+
return {
|
|
1620
|
+
name: _brand
|
|
1621
|
+
};
|
|
1622
|
+
},
|
|
1623
|
+
breadcrumbList: function breadcrumbList(_ref7) {
|
|
1624
|
+
var _ref7$isVariantOf = _ref7.isVariantOf,
|
|
1625
|
+
categoryTrees = _ref7$isVariantOf.categoryTrees,
|
|
1626
|
+
name = _ref7$isVariantOf.name,
|
|
1627
|
+
link = _ref7$isVariantOf.link,
|
|
1628
|
+
id = _ref7.id;
|
|
1629
|
+
return {
|
|
1630
|
+
itemListElement: [].concat(categoryTrees.map(function (_ref8, index) {
|
|
1631
|
+
var categoryNames = _ref8.categoryNames;
|
|
1632
|
+
return {
|
|
1633
|
+
name: categoryNames[categoryNames.length - 1],
|
|
1634
|
+
item: "/" + categoryNames.join('/').toLowerCase(),
|
|
1635
|
+
position: index + 1
|
|
1636
|
+
};
|
|
1637
|
+
}), [{
|
|
1638
|
+
name: name,
|
|
1639
|
+
item: getPath(link, id),
|
|
1640
|
+
position: categoryTrees.length + 1
|
|
1641
|
+
}]),
|
|
1642
|
+
numberOfItems: categoryTrees.length
|
|
1643
|
+
};
|
|
1644
|
+
},
|
|
1645
|
+
image: function image(_ref9) {
|
|
1646
|
+
var _ref10;
|
|
1647
|
+
|
|
1648
|
+
var isVariantOf = _ref9.isVariantOf,
|
|
1649
|
+
images = _ref9.images;
|
|
1650
|
+
return ((_ref10 = images != null ? images : isVariantOf.images) != null ? _ref10 : [DEFAULT_IMAGE]).map(function (_ref11) {
|
|
1651
|
+
var name = _ref11.name,
|
|
1652
|
+
value = _ref11.value;
|
|
1653
|
+
return {
|
|
1654
|
+
alternateName: name != null ? name : '',
|
|
1655
|
+
url: value.replace('vteximg.com.br', 'vtexassets.com')
|
|
1656
|
+
};
|
|
1657
|
+
});
|
|
1658
|
+
},
|
|
1659
|
+
sku: function sku(_ref12) {
|
|
1660
|
+
var _ref12$isVariantOf$sk = _ref12.isVariantOf.skus,
|
|
1661
|
+
_sku = _ref12$isVariantOf$sk[0];
|
|
1662
|
+
return _sku.id;
|
|
1663
|
+
},
|
|
1664
|
+
gtin: function gtin(_ref13) {
|
|
1665
|
+
var reference = _ref13.reference;
|
|
1666
|
+
return reference != null ? reference : '';
|
|
1667
|
+
},
|
|
1668
|
+
review: function review() {
|
|
1669
|
+
return [];
|
|
1670
|
+
},
|
|
1671
|
+
aggregateRating: function aggregateRating() {
|
|
1672
|
+
return {};
|
|
1673
|
+
},
|
|
1674
|
+
offers: /*#__PURE__*/function () {
|
|
1675
|
+
var _offers = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(product, _, ctx) {
|
|
1676
|
+
var simulationLoader, sellers, id, sellerIds, items, simulation;
|
|
1677
|
+
return runtime_1.wrap(function _callee$(_context) {
|
|
1678
|
+
while (1) {
|
|
1679
|
+
switch (_context.prev = _context.next) {
|
|
1680
|
+
case 0:
|
|
1681
|
+
simulationLoader = ctx.loaders.simulationLoader;
|
|
1682
|
+
sellers = product.sellers, id = product.id; // Unique seller ids
|
|
1683
|
+
|
|
1684
|
+
sellerIds = sellers.map(function (seller) {
|
|
1685
|
+
return seller.id;
|
|
1686
|
+
});
|
|
1687
|
+
items = Array.from(new Set(sellerIds)).map(function (seller) {
|
|
1688
|
+
return {
|
|
1689
|
+
quantity: 1,
|
|
1690
|
+
seller: seller,
|
|
1691
|
+
id: id
|
|
1692
|
+
};
|
|
1693
|
+
});
|
|
1694
|
+
_context.next = 6;
|
|
1695
|
+
return simulationLoader.load(items);
|
|
1696
|
+
|
|
1697
|
+
case 6:
|
|
1698
|
+
simulation = _context.sent;
|
|
1699
|
+
return _context.abrupt("return", _extends({}, simulation, {
|
|
1700
|
+
product: product
|
|
1701
|
+
}));
|
|
1702
|
+
|
|
1703
|
+
case 8:
|
|
1704
|
+
case "end":
|
|
1705
|
+
return _context.stop();
|
|
1706
|
+
}
|
|
1707
|
+
}
|
|
1708
|
+
}, _callee);
|
|
1709
|
+
}));
|
|
1710
|
+
|
|
1711
|
+
function offers(_x, _x2, _x3) {
|
|
1712
|
+
return _offers.apply(this, arguments);
|
|
1713
|
+
}
|
|
1714
|
+
|
|
1715
|
+
return offers;
|
|
1716
|
+
}(),
|
|
1717
|
+
isVariantOf: function isVariantOf(_ref14) {
|
|
1718
|
+
var _isVariantOf = _ref14.isVariantOf;
|
|
1719
|
+
return _isVariantOf;
|
|
1720
|
+
}
|
|
1721
|
+
};
|
|
1722
|
+
|
|
1723
|
+
var StoreProductGroup = {
|
|
1724
|
+
hasVariant: function hasVariant(root) {
|
|
1725
|
+
return root.skus.map(function (sku) {
|
|
1726
|
+
return enhanceSku(sku, root);
|
|
1727
|
+
});
|
|
1728
|
+
},
|
|
1729
|
+
productGroupID: function productGroupID(_ref) {
|
|
1730
|
+
var product = _ref.product;
|
|
1731
|
+
return product;
|
|
1732
|
+
},
|
|
1733
|
+
name: function name(_ref2) {
|
|
1734
|
+
var _name = _ref2.name;
|
|
1735
|
+
return _name;
|
|
1736
|
+
}
|
|
1737
|
+
};
|
|
1738
|
+
|
|
1739
|
+
var getIdFromSlug = function getIdFromSlug(slug) {
|
|
1740
|
+
var id = slug.split('-').pop();
|
|
1741
|
+
|
|
1742
|
+
if (id == null) {
|
|
1743
|
+
throw new Error('Error while extracting sku id from product slug');
|
|
1744
|
+
}
|
|
1745
|
+
|
|
1746
|
+
return id;
|
|
1747
|
+
};
|
|
1748
|
+
/**
|
|
1749
|
+
* Transform facets from the store to VTEX platform facets.
|
|
1750
|
+
* For instance, the channel in Store becames trade-policy in VTEX's realm
|
|
1751
|
+
* */
|
|
1752
|
+
|
|
1753
|
+
|
|
1754
|
+
var transformSelectedFacet = function transformSelectedFacet(_ref) {
|
|
1755
|
+
var key = _ref.key,
|
|
1756
|
+
value = _ref.value;
|
|
1757
|
+
|
|
1758
|
+
switch (key) {
|
|
1759
|
+
case 'channel':
|
|
1760
|
+
return {
|
|
1761
|
+
key: 'trade-policy',
|
|
1762
|
+
value: value
|
|
1763
|
+
};
|
|
1764
|
+
|
|
1765
|
+
case 'slug':
|
|
1766
|
+
return {
|
|
1767
|
+
key: 'id',
|
|
1768
|
+
value: getIdFromSlug(value)
|
|
1769
|
+
};
|
|
1770
|
+
|
|
1771
|
+
default:
|
|
1772
|
+
return {
|
|
1773
|
+
key: key,
|
|
1774
|
+
value: value
|
|
1775
|
+
};
|
|
1776
|
+
}
|
|
1777
|
+
};
|
|
1778
|
+
|
|
1779
|
+
var SORT_MAP = {
|
|
1780
|
+
price_desc: 'price:desc',
|
|
1781
|
+
price_asc: 'price:asc',
|
|
1782
|
+
orders_desc: 'orders:desc',
|
|
1783
|
+
name_desc: 'name:desc',
|
|
1784
|
+
name_asc: 'name:asc',
|
|
1785
|
+
release_desc: 'release:desc',
|
|
1786
|
+
discount_desc: 'discount:desc',
|
|
1787
|
+
score_desc: ''
|
|
1788
|
+
};
|
|
1789
|
+
|
|
1790
|
+
var Query = {
|
|
1791
|
+
product: /*#__PURE__*/function () {
|
|
1792
|
+
var _product = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(_, _ref, ctx) {
|
|
1793
|
+
var locator, skuLoader;
|
|
1794
|
+
return runtime_1.wrap(function _callee$(_context) {
|
|
1795
|
+
while (1) {
|
|
1796
|
+
switch (_context.prev = _context.next) {
|
|
1797
|
+
case 0:
|
|
1798
|
+
locator = _ref.locator;
|
|
1799
|
+
skuLoader = ctx.loaders.skuLoader;
|
|
1800
|
+
return _context.abrupt("return", skuLoader.load(locator.map(transformSelectedFacet)));
|
|
1801
|
+
|
|
1802
|
+
case 3:
|
|
1803
|
+
case "end":
|
|
1804
|
+
return _context.stop();
|
|
1805
|
+
}
|
|
1806
|
+
}
|
|
1807
|
+
}, _callee);
|
|
1808
|
+
}));
|
|
1809
|
+
|
|
1810
|
+
function product(_x, _x2, _x3) {
|
|
1811
|
+
return _product.apply(this, arguments);
|
|
1812
|
+
}
|
|
1813
|
+
|
|
1814
|
+
return product;
|
|
1815
|
+
}(),
|
|
1816
|
+
search: /*#__PURE__*/function () {
|
|
1817
|
+
var _search = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(_, _ref2) {
|
|
1818
|
+
var _selectedFacets$map;
|
|
1819
|
+
|
|
1820
|
+
var first, maybeAfter, sort, term, selectedFacets, after, searchArgs;
|
|
1821
|
+
return runtime_1.wrap(function _callee2$(_context2) {
|
|
1822
|
+
while (1) {
|
|
1823
|
+
switch (_context2.prev = _context2.next) {
|
|
1824
|
+
case 0:
|
|
1825
|
+
first = _ref2.first, maybeAfter = _ref2.after, sort = _ref2.sort, term = _ref2.term, selectedFacets = _ref2.selectedFacets;
|
|
1826
|
+
after = maybeAfter ? Number(maybeAfter) : 0;
|
|
1827
|
+
searchArgs = {
|
|
1828
|
+
page: Math.ceil(after / first),
|
|
1829
|
+
count: first,
|
|
1830
|
+
query: term,
|
|
1831
|
+
sort: SORT_MAP[sort != null ? sort : 'score_desc'],
|
|
1832
|
+
selectedFacets: (_selectedFacets$map = selectedFacets == null ? void 0 : selectedFacets.map(transformSelectedFacet)) != null ? _selectedFacets$map : []
|
|
1833
|
+
};
|
|
1834
|
+
return _context2.abrupt("return", searchArgs);
|
|
1835
|
+
|
|
1836
|
+
case 4:
|
|
1837
|
+
case "end":
|
|
1838
|
+
return _context2.stop();
|
|
1839
|
+
}
|
|
1840
|
+
}
|
|
1841
|
+
}, _callee2);
|
|
1842
|
+
}));
|
|
1843
|
+
|
|
1844
|
+
function search(_x4, _x5) {
|
|
1845
|
+
return _search.apply(this, arguments);
|
|
1846
|
+
}
|
|
1847
|
+
|
|
1848
|
+
return search;
|
|
1849
|
+
}(),
|
|
1850
|
+
allProducts: /*#__PURE__*/function () {
|
|
1851
|
+
var _allProducts = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3(_, _ref3, ctx) {
|
|
1852
|
+
var first, maybeAfter, search, after, products, skus;
|
|
1853
|
+
return runtime_1.wrap(function _callee3$(_context3) {
|
|
1854
|
+
while (1) {
|
|
1855
|
+
switch (_context3.prev = _context3.next) {
|
|
1856
|
+
case 0:
|
|
1857
|
+
first = _ref3.first, maybeAfter = _ref3.after;
|
|
1858
|
+
search = ctx.clients.search;
|
|
1859
|
+
after = maybeAfter ? Number(maybeAfter) : 0;
|
|
1860
|
+
_context3.next = 5;
|
|
1861
|
+
return search.products({
|
|
1862
|
+
page: Math.ceil(after / first),
|
|
1863
|
+
count: first
|
|
1864
|
+
});
|
|
1865
|
+
|
|
1866
|
+
case 5:
|
|
1867
|
+
products = _context3.sent;
|
|
1868
|
+
skus = products.products.map(function (product) {
|
|
1869
|
+
return product.skus.map(function (sku) {
|
|
1870
|
+
return enhanceSku(sku, product);
|
|
1871
|
+
});
|
|
1872
|
+
}).flat().filter(function (sku) {
|
|
1873
|
+
return sku.sellers.length > 0;
|
|
1874
|
+
});
|
|
1875
|
+
return _context3.abrupt("return", {
|
|
1876
|
+
pageInfo: {
|
|
1877
|
+
hasNextPage: products.pagination.after.length > 0,
|
|
1878
|
+
hasPreviousPage: products.pagination.before.length > 0,
|
|
1879
|
+
startCursor: '0',
|
|
1880
|
+
endCursor: products.total.toString(),
|
|
1881
|
+
totalCount: products.total
|
|
1882
|
+
},
|
|
1883
|
+
edges: skus.map(function (sku, index) {
|
|
1884
|
+
return {
|
|
1885
|
+
node: sku,
|
|
1886
|
+
cursor: (after + index).toString()
|
|
1887
|
+
};
|
|
1888
|
+
})
|
|
1889
|
+
});
|
|
1890
|
+
|
|
1891
|
+
case 8:
|
|
1892
|
+
case "end":
|
|
1893
|
+
return _context3.stop();
|
|
1894
|
+
}
|
|
1895
|
+
}
|
|
1896
|
+
}, _callee3);
|
|
1897
|
+
}));
|
|
1898
|
+
|
|
1899
|
+
function allProducts(_x6, _x7, _x8) {
|
|
1900
|
+
return _allProducts.apply(this, arguments);
|
|
1901
|
+
}
|
|
1902
|
+
|
|
1903
|
+
return allProducts;
|
|
1904
|
+
}(),
|
|
1905
|
+
allCollections: /*#__PURE__*/function () {
|
|
1906
|
+
var _allCollections = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee4(_, __, ctx) {
|
|
1907
|
+
var commerce, _yield$Promise$all, brands, tree, categories, dfs, _iterator2, _step2, node, collections;
|
|
1908
|
+
|
|
1909
|
+
return runtime_1.wrap(function _callee4$(_context4) {
|
|
1910
|
+
while (1) {
|
|
1911
|
+
switch (_context4.prev = _context4.next) {
|
|
1912
|
+
case 0:
|
|
1913
|
+
commerce = ctx.clients.commerce;
|
|
1914
|
+
_context4.next = 3;
|
|
1915
|
+
return Promise.all([commerce.catalog.brand.list(), commerce.catalog.category.tree()]);
|
|
1916
|
+
|
|
1917
|
+
case 3:
|
|
1918
|
+
_yield$Promise$all = _context4.sent;
|
|
1919
|
+
brands = _yield$Promise$all[0];
|
|
1920
|
+
tree = _yield$Promise$all[1];
|
|
1921
|
+
categories = [];
|
|
1922
|
+
|
|
1923
|
+
dfs = function dfs(node, level) {
|
|
1924
|
+
categories.push(_extends({}, node, {
|
|
1925
|
+
level: level
|
|
1926
|
+
}));
|
|
1927
|
+
|
|
1928
|
+
for (var _iterator = _createForOfIteratorHelperLoose(node.children), _step; !(_step = _iterator()).done;) {
|
|
1929
|
+
var child = _step.value;
|
|
1930
|
+
dfs(child, level + 1);
|
|
1931
|
+
}
|
|
1932
|
+
};
|
|
1933
|
+
|
|
1934
|
+
for (_iterator2 = _createForOfIteratorHelperLoose(tree); !(_step2 = _iterator2()).done;) {
|
|
1935
|
+
node = _step2.value;
|
|
1936
|
+
dfs(node, 0);
|
|
1937
|
+
}
|
|
1938
|
+
|
|
1939
|
+
collections = [].concat(brands.map(function (x) {
|
|
1940
|
+
return _extends({}, x, {
|
|
1941
|
+
type: 'brand'
|
|
1942
|
+
});
|
|
1943
|
+
}), categories);
|
|
1944
|
+
return _context4.abrupt("return", {
|
|
1945
|
+
pageInfo: {
|
|
1946
|
+
hasNextPage: false,
|
|
1947
|
+
hasPreviousPage: false,
|
|
1948
|
+
startCursor: '0',
|
|
1949
|
+
endCursor: '0'
|
|
1950
|
+
},
|
|
1951
|
+
edges: collections.map(function (node, index) {
|
|
1952
|
+
return {
|
|
1953
|
+
node: node,
|
|
1954
|
+
cursor: index.toString()
|
|
1955
|
+
};
|
|
1956
|
+
})
|
|
1957
|
+
});
|
|
1958
|
+
|
|
1959
|
+
case 11:
|
|
1960
|
+
case "end":
|
|
1961
|
+
return _context4.stop();
|
|
1962
|
+
}
|
|
1963
|
+
}
|
|
1964
|
+
}, _callee4);
|
|
1965
|
+
}));
|
|
1966
|
+
|
|
1967
|
+
function allCollections(_x9, _x10, _x11) {
|
|
1968
|
+
return _allCollections.apply(this, arguments);
|
|
1969
|
+
}
|
|
1970
|
+
|
|
1971
|
+
return allCollections;
|
|
1972
|
+
}()
|
|
1973
|
+
};
|
|
1974
|
+
|
|
1975
|
+
var StoreReview = {
|
|
1976
|
+
reviewRating: function reviewRating() {
|
|
1977
|
+
return {
|
|
1978
|
+
ratingValue: 5,
|
|
1979
|
+
bestRating: 5
|
|
1980
|
+
};
|
|
1981
|
+
},
|
|
1982
|
+
author: function author() {
|
|
1983
|
+
return {
|
|
1984
|
+
name: ''
|
|
1985
|
+
};
|
|
1986
|
+
}
|
|
1987
|
+
};
|
|
1988
|
+
|
|
1989
|
+
var StoreSearchResult = {
|
|
1990
|
+
products: /*#__PURE__*/function () {
|
|
1991
|
+
var _products = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(searchArgs, _, ctx) {
|
|
1992
|
+
var search, products, skus;
|
|
1993
|
+
return runtime_1.wrap(function _callee$(_context) {
|
|
1994
|
+
while (1) {
|
|
1995
|
+
switch (_context.prev = _context.next) {
|
|
1996
|
+
case 0:
|
|
1997
|
+
search = ctx.clients.search;
|
|
1998
|
+
_context.next = 3;
|
|
1999
|
+
return search.products(searchArgs);
|
|
2000
|
+
|
|
2001
|
+
case 3:
|
|
2002
|
+
products = _context.sent;
|
|
2003
|
+
skus = products.products.map(function (product) {
|
|
2004
|
+
var maybeSku = product.skus.find(function (x) {
|
|
2005
|
+
return x.sellers.length > 0;
|
|
2006
|
+
});
|
|
2007
|
+
return maybeSku && enhanceSku(maybeSku, product);
|
|
2008
|
+
}).filter(function (sku) {
|
|
2009
|
+
return !!sku;
|
|
2010
|
+
});
|
|
2011
|
+
return _context.abrupt("return", {
|
|
2012
|
+
pageInfo: {
|
|
2013
|
+
hasNextPage: products.pagination.after.length > 0,
|
|
2014
|
+
hasPreviousPage: products.pagination.before.length > 0,
|
|
2015
|
+
startCursor: '0',
|
|
2016
|
+
endCursor: products.total.toString(),
|
|
2017
|
+
totalCount: products.total
|
|
2018
|
+
},
|
|
2019
|
+
edges: skus.map(function (sku, index) {
|
|
2020
|
+
return {
|
|
2021
|
+
node: sku,
|
|
2022
|
+
cursor: index.toString()
|
|
2023
|
+
};
|
|
2024
|
+
})
|
|
2025
|
+
});
|
|
2026
|
+
|
|
2027
|
+
case 6:
|
|
2028
|
+
case "end":
|
|
2029
|
+
return _context.stop();
|
|
2030
|
+
}
|
|
2031
|
+
}
|
|
2032
|
+
}, _callee);
|
|
2033
|
+
}));
|
|
2034
|
+
|
|
2035
|
+
function products(_x, _x2, _x3) {
|
|
2036
|
+
return _products.apply(this, arguments);
|
|
2037
|
+
}
|
|
2038
|
+
|
|
2039
|
+
return products;
|
|
2040
|
+
}(),
|
|
2041
|
+
facets: /*#__PURE__*/function () {
|
|
2042
|
+
var _facets = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(searchArgs, _, ctx) {
|
|
2043
|
+
var is, facets;
|
|
2044
|
+
return runtime_1.wrap(function _callee2$(_context2) {
|
|
2045
|
+
while (1) {
|
|
2046
|
+
switch (_context2.prev = _context2.next) {
|
|
2047
|
+
case 0:
|
|
2048
|
+
is = ctx.clients.search;
|
|
2049
|
+
_context2.next = 3;
|
|
2050
|
+
return is.facets(searchArgs);
|
|
2051
|
+
|
|
2052
|
+
case 3:
|
|
2053
|
+
facets = _context2.sent;
|
|
2054
|
+
return _context2.abrupt("return", facets.attributes);
|
|
2055
|
+
|
|
2056
|
+
case 5:
|
|
2057
|
+
case "end":
|
|
2058
|
+
return _context2.stop();
|
|
2059
|
+
}
|
|
2060
|
+
}
|
|
2061
|
+
}, _callee2);
|
|
2062
|
+
}));
|
|
2063
|
+
|
|
2064
|
+
function facets(_x4, _x5, _x6) {
|
|
2065
|
+
return _facets.apply(this, arguments);
|
|
2066
|
+
}
|
|
2067
|
+
|
|
2068
|
+
return facets;
|
|
2069
|
+
}()
|
|
2070
|
+
};
|
|
2071
|
+
|
|
2072
|
+
var StoreSeo = {
|
|
2073
|
+
title: function title(_ref) {
|
|
2074
|
+
var _title = _ref.title;
|
|
2075
|
+
return _title != null ? _title : '';
|
|
2076
|
+
},
|
|
2077
|
+
description: function description(_ref2) {
|
|
2078
|
+
var _description = _ref2.description;
|
|
2079
|
+
return _description != null ? _description : '';
|
|
2080
|
+
},
|
|
2081
|
+
titleTemplate: function titleTemplate() {
|
|
2082
|
+
return '';
|
|
2083
|
+
},
|
|
2084
|
+
canonical: function canonical() {
|
|
2085
|
+
return '';
|
|
2086
|
+
}
|
|
2087
|
+
};
|
|
2088
|
+
|
|
2089
|
+
var Resolvers = {
|
|
2090
|
+
StoreCollection: StoreCollection,
|
|
2091
|
+
StoreAggregateOffer: StoreAggregateOffer,
|
|
2092
|
+
StoreProduct: StoreProduct,
|
|
2093
|
+
StoreSeo: StoreSeo,
|
|
2094
|
+
StoreFacet: StoreFacet,
|
|
2095
|
+
StoreFacetValue: StoreFacetValue,
|
|
2096
|
+
StoreOffer: StoreOffer,
|
|
2097
|
+
StoreAggregateRating: StoreAggregateRating,
|
|
2098
|
+
StoreReview: StoreReview,
|
|
2099
|
+
StoreProductGroup: StoreProductGroup,
|
|
2100
|
+
StoreSearchResult: StoreSearchResult,
|
|
2101
|
+
Query: Query,
|
|
2102
|
+
Mutation: Mutation
|
|
2103
|
+
};
|
|
2104
|
+
var getContextFactory = function getContextFactory(options) {
|
|
2105
|
+
return function (ctx) {
|
|
2106
|
+
ctx.clients = getClients(options);
|
|
2107
|
+
ctx.loaders = getLoaders(options, ctx.clients);
|
|
2108
|
+
return ctx;
|
|
2109
|
+
};
|
|
2110
|
+
};
|
|
2111
|
+
var getResolvers = function getResolvers(_) {
|
|
2112
|
+
return Resolvers;
|
|
2113
|
+
};
|
|
2114
|
+
|
|
2115
|
+
var doc = {"kind":"Document","definitions":[{"kind":"ObjectTypeDefinition","name":{"kind":"Name","value":"StoreAggregateOffer"},"interfaces":[],"directives":[],"fields":[{"kind":"FieldDefinition","name":{"kind":"Name","value":"highPrice"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Float"}}},"directives":[]},{"kind":"FieldDefinition","name":{"kind":"Name","value":"lowPrice"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Float"}}},"directives":[]},{"kind":"FieldDefinition","name":{"kind":"Name","value":"offerCount"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Int"}}},"directives":[]},{"kind":"FieldDefinition","name":{"kind":"Name","value":"priceCurrency"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}},"directives":[]},{"kind":"FieldDefinition","name":{"kind":"Name","value":"offers"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"ListType","type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"StoreOffer"}}}}},"directives":[]}]}],"loc":{"start":0,"end":261}};
|
|
2116
|
+
doc.loc.source = {"body":"type StoreAggregateOffer {\n # Highest spot price amongst all sellers\n highPrice: Float!\n # Lowest spot price amongst all sellers\n lowPrice: Float!\n # Number of sellers selling this sku\n offerCount: Int!\n priceCurrency: String!\n offers: [StoreOffer!]!\n}\n","name":"GraphQL request","locationOffset":{"line":1,"column":1}};
|
|
2117
|
+
|
|
2118
|
+
var doc$1 = {"kind":"Document","definitions":[{"kind":"ObjectTypeDefinition","name":{"kind":"Name","value":"StoreAggregateRating"},"interfaces":[],"directives":[],"fields":[{"kind":"FieldDefinition","name":{"kind":"Name","value":"ratingValue"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Float"}}},"directives":[]},{"kind":"FieldDefinition","name":{"kind":"Name","value":"reviewCount"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Int"}}},"directives":[]}]}],"loc":{"start":0,"end":72}};
|
|
2119
|
+
doc$1.loc.source = {"body":"type StoreAggregateRating {\n ratingValue: Float!\n reviewCount: Int!\n}\n","name":"GraphQL request","locationOffset":{"line":1,"column":1}};
|
|
2120
|
+
|
|
2121
|
+
var doc$2 = {"kind":"Document","definitions":[{"kind":"ObjectTypeDefinition","name":{"kind":"Name","value":"StoreAuthor"},"interfaces":[],"directives":[],"fields":[{"kind":"FieldDefinition","name":{"kind":"Name","value":"name"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}},"directives":[]}]}],"loc":{"start":0,"end":37}};
|
|
2122
|
+
doc$2.loc.source = {"body":"type StoreAuthor {\n name: String!\n}\n","name":"GraphQL request","locationOffset":{"line":1,"column":1}};
|
|
2123
|
+
|
|
2124
|
+
var doc$3 = {"kind":"Document","definitions":[{"kind":"ObjectTypeDefinition","name":{"kind":"Name","value":"StoreBrand"},"interfaces":[],"directives":[],"fields":[{"kind":"FieldDefinition","name":{"kind":"Name","value":"name"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}},"directives":[]}]}],"loc":{"start":0,"end":36}};
|
|
2125
|
+
doc$3.loc.source = {"body":"type StoreBrand {\n name: String!\n}\n","name":"GraphQL request","locationOffset":{"line":1,"column":1}};
|
|
2126
|
+
|
|
2127
|
+
var doc$4 = {"kind":"Document","definitions":[{"kind":"ObjectTypeDefinition","name":{"kind":"Name","value":"StoreListItem"},"interfaces":[],"directives":[],"fields":[{"kind":"FieldDefinition","name":{"kind":"Name","value":"item"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}},"directives":[]},{"kind":"FieldDefinition","name":{"kind":"Name","value":"name"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}},"directives":[]},{"kind":"FieldDefinition","name":{"kind":"Name","value":"position"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Int"}}},"directives":[]}]},{"kind":"ObjectTypeDefinition","name":{"kind":"Name","value":"StoreBreadcrumbList"},"interfaces":[],"directives":[],"fields":[{"kind":"FieldDefinition","name":{"kind":"Name","value":"itemListElement"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"ListType","type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"StoreListItem"}}}}},"directives":[]},{"kind":"FieldDefinition","name":{"kind":"Name","value":"numberOfItems"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Int"}}},"directives":[]}]}],"loc":{"start":0,"end":161}};
|
|
2128
|
+
doc$4.loc.source = {"body":"type StoreListItem {\n item: String!\n name: String!\n position: Int!\n}\n\ntype StoreBreadcrumbList {\n itemListElement: [StoreListItem!]!\n numberOfItems: Int!\n}\n","name":"GraphQL request","locationOffset":{"line":1,"column":1}};
|
|
2129
|
+
|
|
2130
|
+
var doc$5 = {"kind":"Document","definitions":[{"kind":"EnumTypeDefinition","name":{"kind":"Name","value":"StoreCollectionType"},"directives":[],"values":[{"kind":"EnumValueDefinition","name":{"kind":"Name","value":"Department"},"directives":[]},{"kind":"EnumValueDefinition","name":{"kind":"Name","value":"Category"},"directives":[]},{"kind":"EnumValueDefinition","name":{"kind":"Name","value":"Brand"},"directives":[]},{"kind":"EnumValueDefinition","name":{"kind":"Name","value":"Cluster"},"directives":[]}]},{"kind":"ObjectTypeDefinition","name":{"kind":"Name","value":"StoreCollectionFacet"},"interfaces":[],"directives":[],"fields":[{"kind":"FieldDefinition","name":{"kind":"Name","value":"key"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}},"directives":[]},{"kind":"FieldDefinition","name":{"kind":"Name","value":"value"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}},"directives":[]}]},{"kind":"ObjectTypeDefinition","name":{"kind":"Name","value":"StoreCollectionMeta"},"interfaces":[],"directives":[],"fields":[{"kind":"FieldDefinition","name":{"kind":"Name","value":"selectedFacets"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"ListType","type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"StoreCollectionFacet"}}}}},"directives":[]}]},{"kind":"ObjectTypeDefinition","name":{"kind":"Name","value":"StoreCollection"},"interfaces":[],"directives":[],"fields":[{"kind":"FieldDefinition","name":{"kind":"Name","value":"seo"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"StoreSeo"}}},"directives":[]},{"kind":"FieldDefinition","name":{"kind":"Name","value":"breadcrumbList"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"StoreBreadcrumbList"}}},"directives":[]},{"kind":"FieldDefinition","name":{"kind":"Name","value":"meta"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"StoreCollectionMeta"}}},"directives":[]},{"kind":"FieldDefinition","name":{"kind":"Name","value":"id"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"ID"}}},"directives":[]},{"kind":"FieldDefinition","name":{"kind":"Name","value":"slug"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}},"directives":[]},{"kind":"FieldDefinition","name":{"kind":"Name","value":"type"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"StoreCollectionType"}}},"directives":[]}]}],"loc":{"start":0,"end":424}};
|
|
2131
|
+
doc$5.loc.source = {"body":"enum StoreCollectionType {\n Department\n Category\n Brand\n Cluster\n}\n\ntype StoreCollectionFacet {\n key: String!\n value: String!\n}\n\ntype StoreCollectionMeta {\n selectedFacets: [StoreCollectionFacet!]!\n}\n\ntype StoreCollection {\n # Meta tag data\n seo: StoreSeo!\n # location for structured data\n breadcrumbList: StoreBreadcrumbList!\n meta: StoreCollectionMeta!\n id: ID!\n slug: String!\n type: StoreCollectionType!\n}\n","name":"GraphQL request","locationOffset":{"line":1,"column":1}};
|
|
2132
|
+
|
|
2133
|
+
var doc$6 = {"kind":"Document","definitions":[{"kind":"ObjectTypeDefinition","name":{"kind":"Name","value":"StoreFacet"},"interfaces":[],"directives":[],"fields":[{"kind":"FieldDefinition","name":{"kind":"Name","value":"key"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}},"directives":[]},{"kind":"FieldDefinition","name":{"kind":"Name","value":"label"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}},"directives":[]},{"kind":"FieldDefinition","name":{"kind":"Name","value":"values"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"ListType","type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"StoreFacetValue"}}}}},"directives":[]},{"kind":"FieldDefinition","name":{"kind":"Name","value":"type"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"StoreFacetType"}}},"directives":[]}]},{"kind":"ObjectTypeDefinition","name":{"kind":"Name","value":"StoreFacetValue"},"interfaces":[],"directives":[],"fields":[{"kind":"FieldDefinition","name":{"kind":"Name","value":"value"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}},"directives":[]},{"kind":"FieldDefinition","name":{"kind":"Name","value":"label"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}},"directives":[]},{"kind":"FieldDefinition","name":{"kind":"Name","value":"selected"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Boolean"}}},"directives":[]},{"kind":"FieldDefinition","name":{"kind":"Name","value":"quantity"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Int"}}},"directives":[]}]}],"loc":{"start":0,"end":240}};
|
|
2134
|
+
doc$6.loc.source = {"body":"type StoreFacet {\n key: String!\n label: String!\n values: [StoreFacetValue!]!\n type: StoreFacetType!\n}\n\ntype StoreFacetValue {\n value: String!\n label: String!\n selected: Boolean!\n # Number of items with this facet\n quantity: Int!\n}\n","name":"GraphQL request","locationOffset":{"line":1,"column":1}};
|
|
2135
|
+
|
|
2136
|
+
var doc$7 = {"kind":"Document","definitions":[{"kind":"ObjectTypeDefinition","name":{"kind":"Name","value":"StoreImage"},"interfaces":[],"directives":[],"fields":[{"kind":"FieldDefinition","name":{"kind":"Name","value":"url"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}},"directives":[]},{"kind":"FieldDefinition","name":{"kind":"Name","value":"alternateName"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}},"directives":[]}]},{"kind":"InputObjectTypeDefinition","name":{"kind":"Name","value":"IStoreImage"},"directives":[],"fields":[{"kind":"InputValueDefinition","name":{"kind":"Name","value":"url"},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}},"directives":[]},{"kind":"InputValueDefinition","name":{"kind":"Name","value":"alternateName"},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}},"directives":[]}]}],"loc":{"start":0,"end":123}};
|
|
2137
|
+
doc$7.loc.source = {"body":"type StoreImage {\n url: String!\n alternateName: String!\n}\n\ninput IStoreImage {\n url: String!\n alternateName: String!\n}\n","name":"GraphQL request","locationOffset":{"line":1,"column":1}};
|
|
2138
|
+
|
|
2139
|
+
var doc$8 = {"kind":"Document","definitions":[{"kind":"ObjectTypeDefinition","name":{"kind":"Name","value":"Mutation"},"interfaces":[],"directives":[],"fields":[{"kind":"FieldDefinition","name":{"kind":"Name","value":"validateCart"},"arguments":[{"kind":"InputValueDefinition","name":{"kind":"Name","value":"cart"},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"IStoreCart"}}},"directives":[]}],"type":{"kind":"NamedType","name":{"kind":"Name","value":"StoreCart"}},"directives":[]}]}],"loc":{"start":0,"end":148}};
|
|
2140
|
+
doc$8.loc.source = {"body":"type Mutation {\n # Returns the order if anything changed with the order. Null if the order is valid\n validateCart(cart: IStoreCart!): StoreCart\n}\n","name":"GraphQL request","locationOffset":{"line":1,"column":1}};
|
|
2141
|
+
|
|
2142
|
+
var doc$9 = {"kind":"Document","definitions":[{"kind":"ObjectTypeDefinition","name":{"kind":"Name","value":"StoreOffer"},"interfaces":[],"directives":[],"fields":[{"kind":"FieldDefinition","name":{"kind":"Name","value":"listPrice"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Float"}}},"directives":[]},{"kind":"FieldDefinition","name":{"kind":"Name","value":"sellingPrice"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Float"}}},"directives":[]},{"kind":"FieldDefinition","name":{"kind":"Name","value":"priceCurrency"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}},"directives":[]},{"kind":"FieldDefinition","name":{"kind":"Name","value":"price"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Float"}}},"directives":[]},{"kind":"FieldDefinition","name":{"kind":"Name","value":"priceValidUntil"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}},"directives":[]},{"kind":"FieldDefinition","name":{"kind":"Name","value":"itemCondition"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}},"directives":[]},{"kind":"FieldDefinition","name":{"kind":"Name","value":"availability"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}},"directives":[]},{"kind":"FieldDefinition","name":{"kind":"Name","value":"seller"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"StoreOrganization"}}},"directives":[]},{"kind":"FieldDefinition","name":{"kind":"Name","value":"itemOffered"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"StoreProduct"}}},"directives":[]},{"kind":"FieldDefinition","name":{"kind":"Name","value":"quantity"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Int"}}},"directives":[]}]},{"kind":"InputObjectTypeDefinition","name":{"kind":"Name","value":"IStoreOffer"},"directives":[],"fields":[{"kind":"InputValueDefinition","name":{"kind":"Name","value":"price"},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Float"}}},"directives":[]},{"kind":"InputValueDefinition","name":{"kind":"Name","value":"listPrice"},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Float"}}},"directives":[]},{"kind":"InputValueDefinition","name":{"kind":"Name","value":"seller"},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"IStoreOrganization"}}},"directives":[]},{"kind":"InputValueDefinition","name":{"kind":"Name","value":"itemOffered"},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"IStoreProduct"}}},"directives":[]},{"kind":"InputValueDefinition","name":{"kind":"Name","value":"quantity"},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Int"}}},"directives":[]}]}],"loc":{"start":0,"end":419}};
|
|
2143
|
+
doc$9.loc.source = {"body":"type StoreOffer {\n listPrice: Float!\n sellingPrice: Float!\n priceCurrency: String!\n # Also known as spotPrice\n price: Float!\n priceValidUntil: String!\n itemCondition: String!\n availability: String!\n seller: StoreOrganization!\n itemOffered: StoreProduct!\n quantity: Int!\n}\n\ninput IStoreOffer {\n price: Float!\n listPrice: Float!\n seller: IStoreOrganization!\n itemOffered: IStoreProduct!\n quantity: Int!\n}\n","name":"GraphQL request","locationOffset":{"line":1,"column":1}};
|
|
2144
|
+
|
|
2145
|
+
var doc$a = {"kind":"Document","definitions":[{"kind":"ObjectTypeDefinition","name":{"kind":"Name","value":"StoreOrder"},"interfaces":[],"directives":[],"fields":[{"kind":"FieldDefinition","name":{"kind":"Name","value":"orderNumber"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}},"directives":[]},{"kind":"FieldDefinition","name":{"kind":"Name","value":"acceptedOffer"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"ListType","type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"StoreOffer"}}}}},"directives":[]}]},{"kind":"InputObjectTypeDefinition","name":{"kind":"Name","value":"IStoreOrder"},"directives":[],"fields":[{"kind":"InputValueDefinition","name":{"kind":"Name","value":"orderNumber"},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}},"directives":[]},{"kind":"InputValueDefinition","name":{"kind":"Name","value":"acceptedOffer"},"type":{"kind":"NonNullType","type":{"kind":"ListType","type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"IStoreOffer"}}}}},"directives":[]}]}],"loc":{"start":0,"end":154}};
|
|
2146
|
+
doc$a.loc.source = {"body":"type StoreOrder {\n orderNumber: String!\n acceptedOffer: [StoreOffer!]!\n}\n\ninput IStoreOrder {\n orderNumber: String!\n acceptedOffer: [IStoreOffer!]!\n}\n","name":"GraphQL request","locationOffset":{"line":1,"column":1}};
|
|
2147
|
+
|
|
2148
|
+
var doc$b = {"kind":"Document","definitions":[{"kind":"ObjectTypeDefinition","name":{"kind":"Name","value":"StoreOrganization"},"interfaces":[],"directives":[],"fields":[{"kind":"FieldDefinition","name":{"kind":"Name","value":"identifier"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}},"directives":[]}]},{"kind":"InputObjectTypeDefinition","name":{"kind":"Name","value":"IStoreOrganization"},"directives":[],"fields":[{"kind":"InputValueDefinition","name":{"kind":"Name","value":"identifier"},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}},"directives":[]}]}],"loc":{"start":0,"end":101}};
|
|
2149
|
+
doc$b.loc.source = {"body":"type StoreOrganization {\n identifier: String!\n}\n\ninput IStoreOrganization {\n identifier: String!\n}\n","name":"GraphQL request","locationOffset":{"line":1,"column":1}};
|
|
2150
|
+
|
|
2151
|
+
var doc$c = {"kind":"Document","definitions":[{"kind":"ObjectTypeDefinition","name":{"kind":"Name","value":"StorePageInfo"},"interfaces":[],"directives":[],"fields":[{"kind":"FieldDefinition","name":{"kind":"Name","value":"hasNextPage"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Boolean"}}},"directives":[]},{"kind":"FieldDefinition","name":{"kind":"Name","value":"hasPreviousPage"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Boolean"}}},"directives":[]},{"kind":"FieldDefinition","name":{"kind":"Name","value":"startCursor"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}},"directives":[]},{"kind":"FieldDefinition","name":{"kind":"Name","value":"endCursor"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}},"directives":[]},{"kind":"FieldDefinition","name":{"kind":"Name","value":"totalCount"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Int"}}},"directives":[]}]}],"loc":{"start":0,"end":197}};
|
|
2152
|
+
doc$c.loc.source = {"body":"type StorePageInfo {\n hasNextPage: Boolean!\n hasPreviousPage: Boolean!\n startCursor: String!\n endCursor: String!\n # Total number of items(products/collections), not pages\n totalCount: Int!\n}\n","name":"GraphQL request","locationOffset":{"line":1,"column":1}};
|
|
2153
|
+
|
|
2154
|
+
var doc$d = {"kind":"Document","definitions":[{"kind":"ObjectTypeDefinition","name":{"kind":"Name","value":"StoreProduct"},"interfaces":[],"directives":[],"fields":[{"kind":"FieldDefinition","name":{"kind":"Name","value":"seo"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"StoreSeo"}}},"directives":[]},{"kind":"FieldDefinition","name":{"kind":"Name","value":"breadcrumbList"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"StoreBreadcrumbList"}}},"directives":[]},{"kind":"FieldDefinition","name":{"kind":"Name","value":"slug"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}},"directives":[]},{"kind":"FieldDefinition","name":{"kind":"Name","value":"name"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}},"directives":[]},{"kind":"FieldDefinition","name":{"kind":"Name","value":"productID"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}},"directives":[]},{"kind":"FieldDefinition","name":{"kind":"Name","value":"brand"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"StoreBrand"}}},"directives":[]},{"kind":"FieldDefinition","name":{"kind":"Name","value":"description"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}},"directives":[]},{"kind":"FieldDefinition","name":{"kind":"Name","value":"image"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"ListType","type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"StoreImage"}}}}},"directives":[]},{"kind":"FieldDefinition","name":{"kind":"Name","value":"offers"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"StoreAggregateOffer"}}},"directives":[]},{"kind":"FieldDefinition","name":{"kind":"Name","value":"sku"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}},"directives":[]},{"kind":"FieldDefinition","name":{"kind":"Name","value":"gtin"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}},"directives":[]},{"kind":"FieldDefinition","name":{"kind":"Name","value":"review"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"ListType","type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"StoreReview"}}}}},"directives":[]},{"kind":"FieldDefinition","name":{"kind":"Name","value":"aggregateRating"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"StoreAggregateRating"}}},"directives":[]},{"kind":"FieldDefinition","name":{"kind":"Name","value":"isVariantOf"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"StoreProductGroup"}}},"directives":[]}]},{"kind":"InputObjectTypeDefinition","name":{"kind":"Name","value":"IStoreProduct"},"directives":[],"fields":[{"kind":"InputValueDefinition","name":{"kind":"Name","value":"sku"},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}},"directives":[]},{"kind":"InputValueDefinition","name":{"kind":"Name","value":"name"},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}},"directives":[]},{"kind":"InputValueDefinition","name":{"kind":"Name","value":"image"},"type":{"kind":"NonNullType","type":{"kind":"ListType","type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"IStoreImage"}}}}},"directives":[]}]}],"loc":{"start":0,"end":528}};
|
|
2155
|
+
doc$d.loc.source = {"body":"type StoreProduct {\n # Meta tag data\n seo: StoreSeo!\n # Location for structured data\n breadcrumbList: StoreBreadcrumbList!\n # Where to retrieve this entity\n slug: String!\n name: String!\n productID: String!\n brand: StoreBrand!\n description: String!\n image: [StoreImage!]!\n offers: StoreAggregateOffer!\n sku: String!\n gtin: String!\n review: [StoreReview!]!\n aggregateRating: StoreAggregateRating!\n isVariantOf: StoreProductGroup!\n}\n\ninput IStoreProduct {\n sku: String!\n name: String!\n image: [IStoreImage!]!\n}\n","name":"GraphQL request","locationOffset":{"line":1,"column":1}};
|
|
2156
|
+
|
|
2157
|
+
var doc$e = {"kind":"Document","definitions":[{"kind":"ObjectTypeDefinition","name":{"kind":"Name","value":"StoreProductGroup"},"interfaces":[],"directives":[],"fields":[{"kind":"FieldDefinition","name":{"kind":"Name","value":"hasVariant"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"ListType","type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"StoreProduct"}}}}},"directives":[]},{"kind":"FieldDefinition","name":{"kind":"Name","value":"productGroupID"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}},"directives":[]},{"kind":"FieldDefinition","name":{"kind":"Name","value":"name"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}},"directives":[]}]}],"loc":{"start":0,"end":100}};
|
|
2158
|
+
doc$e.loc.source = {"body":"type StoreProductGroup {\n hasVariant: [StoreProduct!]!\n productGroupID: String!\n name: String!\n}\n","name":"GraphQL request","locationOffset":{"line":1,"column":1}};
|
|
2159
|
+
|
|
2160
|
+
var doc$f = {"kind":"Document","definitions":[{"kind":"ObjectTypeDefinition","name":{"kind":"Name","value":"StoreProductEdge"},"interfaces":[],"directives":[],"fields":[{"kind":"FieldDefinition","name":{"kind":"Name","value":"node"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"StoreProduct"}}},"directives":[]},{"kind":"FieldDefinition","name":{"kind":"Name","value":"cursor"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}},"directives":[]}]},{"kind":"ObjectTypeDefinition","name":{"kind":"Name","value":"StoreProductConnection"},"interfaces":[],"directives":[],"fields":[{"kind":"FieldDefinition","name":{"kind":"Name","value":"pageInfo"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"StorePageInfo"}}},"directives":[]},{"kind":"FieldDefinition","name":{"kind":"Name","value":"edges"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"ListType","type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"StoreProductEdge"}}}}},"directives":[]}]},{"kind":"ObjectTypeDefinition","name":{"kind":"Name","value":"StoreCollectionEdge"},"interfaces":[],"directives":[],"fields":[{"kind":"FieldDefinition","name":{"kind":"Name","value":"node"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"StoreCollection"}}},"directives":[]},{"kind":"FieldDefinition","name":{"kind":"Name","value":"cursor"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}},"directives":[]}]},{"kind":"ObjectTypeDefinition","name":{"kind":"Name","value":"StoreCollectionConnection"},"interfaces":[],"directives":[],"fields":[{"kind":"FieldDefinition","name":{"kind":"Name","value":"pageInfo"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"StorePageInfo"}}},"directives":[]},{"kind":"FieldDefinition","name":{"kind":"Name","value":"edges"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"ListType","type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"StoreCollectionEdge"}}}}},"directives":[]}]},{"kind":"EnumTypeDefinition","name":{"kind":"Name","value":"StoreSort"},"directives":[],"values":[{"kind":"EnumValueDefinition","name":{"kind":"Name","value":"price_desc"},"directives":[]},{"kind":"EnumValueDefinition","name":{"kind":"Name","value":"price_asc"},"directives":[]},{"kind":"EnumValueDefinition","name":{"kind":"Name","value":"orders_desc"},"directives":[]},{"kind":"EnumValueDefinition","name":{"kind":"Name","value":"name_desc"},"directives":[]},{"kind":"EnumValueDefinition","name":{"kind":"Name","value":"name_asc"},"directives":[]},{"kind":"EnumValueDefinition","name":{"kind":"Name","value":"release_desc"},"directives":[]},{"kind":"EnumValueDefinition","name":{"kind":"Name","value":"discount_desc"},"directives":[]},{"kind":"EnumValueDefinition","name":{"kind":"Name","value":"score_desc"},"directives":[]}]},{"kind":"InputObjectTypeDefinition","name":{"kind":"Name","value":"IStoreSelectedFacet"},"directives":[],"fields":[{"kind":"InputValueDefinition","name":{"kind":"Name","value":"key"},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}},"directives":[]},{"kind":"InputValueDefinition","name":{"kind":"Name","value":"value"},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}},"directives":[]}]},{"kind":"EnumTypeDefinition","name":{"kind":"Name","value":"StoreFacetType"},"directives":[],"values":[{"kind":"EnumValueDefinition","name":{"kind":"Name","value":"BOOLEAN"},"directives":[]},{"kind":"EnumValueDefinition","name":{"kind":"Name","value":"RANGE"},"directives":[]}]},{"kind":"ObjectTypeDefinition","name":{"kind":"Name","value":"StoreSearchResult"},"interfaces":[],"directives":[],"fields":[{"kind":"FieldDefinition","name":{"kind":"Name","value":"products"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"StoreProductConnection"}}},"directives":[]},{"kind":"FieldDefinition","name":{"kind":"Name","value":"facets"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"ListType","type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"StoreFacet"}}}}},"directives":[]}]},{"kind":"ObjectTypeDefinition","name":{"kind":"Name","value":"Query"},"interfaces":[],"directives":[],"fields":[{"kind":"FieldDefinition","name":{"kind":"Name","value":"product"},"arguments":[{"kind":"InputValueDefinition","name":{"kind":"Name","value":"locator"},"type":{"kind":"NonNullType","type":{"kind":"ListType","type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"IStoreSelectedFacet"}}}}},"directives":[]}],"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"StoreProduct"}}},"directives":[]},{"kind":"FieldDefinition","name":{"kind":"Name","value":"search"},"arguments":[{"kind":"InputValueDefinition","name":{"kind":"Name","value":"first"},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Int"}}},"directives":[]},{"kind":"InputValueDefinition","name":{"kind":"Name","value":"after"},"type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}},"directives":[]},{"kind":"InputValueDefinition","name":{"kind":"Name","value":"sort"},"type":{"kind":"NamedType","name":{"kind":"Name","value":"StoreSort"}},"defaultValue":{"kind":"EnumValue","value":"score_desc"},"directives":[]},{"kind":"InputValueDefinition","name":{"kind":"Name","value":"term"},"type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}},"defaultValue":{"kind":"StringValue","value":"","block":false},"directives":[]},{"kind":"InputValueDefinition","name":{"kind":"Name","value":"selectedFacets"},"type":{"kind":"ListType","type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"IStoreSelectedFacet"}}}},"directives":[]}],"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"StoreSearchResult"}}},"directives":[]},{"kind":"FieldDefinition","name":{"kind":"Name","value":"allProducts"},"arguments":[{"kind":"InputValueDefinition","name":{"kind":"Name","value":"first"},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Int"}}},"directives":[]},{"kind":"InputValueDefinition","name":{"kind":"Name","value":"after"},"type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}},"directives":[]}],"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"StoreProductConnection"}}},"directives":[]},{"kind":"FieldDefinition","name":{"kind":"Name","value":"allCollections"},"arguments":[{"kind":"InputValueDefinition","name":{"kind":"Name","value":"first"},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Int"}}},"directives":[]},{"kind":"InputValueDefinition","name":{"kind":"Name","value":"after"},"type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}},"directives":[]}],"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"StoreCollectionConnection"}}},"directives":[]}]}],"loc":{"start":0,"end":1214}};
|
|
2161
|
+
doc$f.loc.source = {"body":"type StoreProductEdge {\n node: StoreProduct!\n cursor: String!\n}\n\ntype StoreProductConnection {\n pageInfo: StorePageInfo!\n edges: [StoreProductEdge!]!\n}\n\n\ntype StoreCollectionEdge {\n node: StoreCollection!\n cursor: String!\n}\n\ntype StoreCollectionConnection {\n pageInfo: StorePageInfo!\n edges: [StoreCollectionEdge!]!\n}\n\nenum StoreSort {\n price_desc\n price_asc\n orders_desc\n name_desc\n name_asc\n release_desc\n discount_desc\n score_desc\n}\n\ninput IStoreSelectedFacet {\n key: String!\n value: String!\n}\n\nenum StoreFacetType {\n BOOLEAN\n RANGE\n}\n\ntype StoreSearchResult {\n products: StoreProductConnection!\n facets: [StoreFacet!]!\n}\n\ntype Query {\n product(locator: [IStoreSelectedFacet!]!): StoreProduct!\n\n search(\n # Relay style pagination args. To know more: https://relay.dev/graphql/connections.htm\n first: Int!\n # Relay style pagination args. To know more: https://relay.dev/graphql/connections.htm\n after: String\n sort: StoreSort = score_desc\n term: String = \"\"\n selectedFacets: [IStoreSelectedFacet!]\n ): StoreSearchResult!\n\n allProducts(first: Int!, after: String): StoreProductConnection!\n\n allCollections(first: Int!, after: String): StoreCollectionConnection!\n}\n","name":"GraphQL request","locationOffset":{"line":1,"column":1}};
|
|
2162
|
+
|
|
2163
|
+
var doc$g = {"kind":"Document","definitions":[{"kind":"ObjectTypeDefinition","name":{"kind":"Name","value":"StoreReviewRating"},"interfaces":[],"directives":[],"fields":[{"kind":"FieldDefinition","name":{"kind":"Name","value":"ratingValue"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Float"}}},"directives":[]},{"kind":"FieldDefinition","name":{"kind":"Name","value":"bestRating"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Float"}}},"directives":[]}]},{"kind":"ObjectTypeDefinition","name":{"kind":"Name","value":"StoreReview"},"interfaces":[],"directives":[],"fields":[{"kind":"FieldDefinition","name":{"kind":"Name","value":"reviewRating"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"StoreReviewRating"}}},"directives":[]},{"kind":"FieldDefinition","name":{"kind":"Name","value":"author"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"StoreAuthor"}}},"directives":[]}]}],"loc":{"start":0,"end":150}};
|
|
2164
|
+
doc$g.loc.source = {"body":"type StoreReviewRating {\n ratingValue: Float!\n bestRating: Float!\n}\n\ntype StoreReview {\n reviewRating: StoreReviewRating!\n author: StoreAuthor!\n}\n","name":"GraphQL request","locationOffset":{"line":1,"column":1}};
|
|
2165
|
+
|
|
2166
|
+
var doc$h = {"kind":"Document","definitions":[{"kind":"ObjectTypeDefinition","name":{"kind":"Name","value":"StoreSeo"},"interfaces":[],"directives":[],"fields":[{"kind":"FieldDefinition","name":{"kind":"Name","value":"title"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}},"directives":[]},{"kind":"FieldDefinition","name":{"kind":"Name","value":"titleTemplate"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}},"directives":[]},{"kind":"FieldDefinition","name":{"kind":"Name","value":"description"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}},"directives":[]},{"kind":"FieldDefinition","name":{"kind":"Name","value":"canonical"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}},"directives":[]}]}],"loc":{"start":0,"end":104}};
|
|
2167
|
+
doc$h.loc.source = {"body":"type StoreSeo {\n title: String!\n titleTemplate: String!\n description: String!\n canonical: String!\n}\n","name":"GraphQL request","locationOffset":{"line":1,"column":1}};
|
|
2168
|
+
|
|
2169
|
+
var doc$i = {"kind":"Document","definitions":[{"kind":"ObjectTypeDefinition","name":{"kind":"Name","value":"StoreCartMessage"},"interfaces":[],"directives":[],"fields":[{"kind":"FieldDefinition","name":{"kind":"Name","value":"text"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}},"directives":[]},{"kind":"FieldDefinition","name":{"kind":"Name","value":"status"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"StoreStatus"}}},"directives":[]}]},{"kind":"ObjectTypeDefinition","name":{"kind":"Name","value":"StoreCart"},"interfaces":[],"directives":[],"fields":[{"kind":"FieldDefinition","name":{"kind":"Name","value":"order"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"StoreOrder"}}},"directives":[]},{"kind":"FieldDefinition","name":{"kind":"Name","value":"messages"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"ListType","type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"StoreCartMessage"}}}}},"directives":[]}]},{"kind":"InputObjectTypeDefinition","name":{"kind":"Name","value":"IStoreCart"},"directives":[],"fields":[{"kind":"InputValueDefinition","name":{"kind":"Name","value":"order"},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"IStoreOrder"}}},"directives":[]}]}],"loc":{"start":0,"end":183}};
|
|
2170
|
+
doc$i.loc.source = {"body":"type StoreCartMessage {\n text: String!\n status: StoreStatus!\n}\n\ntype StoreCart {\n order: StoreOrder!\n messages: [StoreCartMessage!]!\n}\n\ninput IStoreCart {\n order: IStoreOrder!\n}\n","name":"GraphQL request","locationOffset":{"line":1,"column":1}};
|
|
2171
|
+
|
|
2172
|
+
var doc$j = {"kind":"Document","definitions":[{"kind":"EnumTypeDefinition","name":{"kind":"Name","value":"StoreStatus"},"directives":[],"values":[{"kind":"EnumValueDefinition","name":{"kind":"Name","value":"INFO"},"directives":[]},{"kind":"EnumValueDefinition","name":{"kind":"Name","value":"WARNING"},"directives":[]},{"kind":"EnumValueDefinition","name":{"kind":"Name","value":"ERROR"},"directives":[]}]}],"loc":{"start":0,"end":46}};
|
|
2173
|
+
doc$j.loc.source = {"body":"enum StoreStatus {\n INFO\n WARNING\n ERROR\n}\n","name":"GraphQL request","locationOffset":{"line":1,"column":1}};
|
|
2174
|
+
|
|
2175
|
+
var typeDefs = /*#__PURE__*/[doc$f, doc$8, doc$3, doc$4, doc$5, doc$6, doc$7, doc$c, doc$d, doc$h, doc$9, doc$1, doc$g, doc$2, doc$e, doc$b, doc, doc$a, doc$i, doc$j].map(print).join('\n');
|
|
2176
|
+
|
|
2177
|
+
var platforms = {
|
|
2178
|
+
vtex: {
|
|
2179
|
+
getResolvers: getResolvers,
|
|
2180
|
+
getContextFactory: getContextFactory
|
|
2181
|
+
}
|
|
2182
|
+
};
|
|
2183
|
+
var getTypeDefs = function getTypeDefs() {
|
|
2184
|
+
return typeDefs;
|
|
2185
|
+
};
|
|
2186
|
+
var getResolvers$1 = function getResolvers(options) {
|
|
2187
|
+
return platforms[options.platform].getResolvers(options);
|
|
2188
|
+
};
|
|
2189
|
+
var getContextFactory$1 = function getContextFactory(options) {
|
|
2190
|
+
return platforms[options.platform].getContextFactory(options);
|
|
2191
|
+
};
|
|
2192
|
+
var getSchema = /*#__PURE__*/function () {
|
|
2193
|
+
var _ref = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(options) {
|
|
2194
|
+
return runtime_1.wrap(function _callee$(_context) {
|
|
2195
|
+
while (1) {
|
|
2196
|
+
switch (_context.prev = _context.next) {
|
|
2197
|
+
case 0:
|
|
2198
|
+
return _context.abrupt("return", makeExecutableSchema({
|
|
2199
|
+
resolvers: getResolvers$1(options),
|
|
2200
|
+
typeDefs: getTypeDefs()
|
|
2201
|
+
}));
|
|
2202
|
+
|
|
2203
|
+
case 1:
|
|
2204
|
+
case "end":
|
|
2205
|
+
return _context.stop();
|
|
2206
|
+
}
|
|
2207
|
+
}
|
|
2208
|
+
}, _callee);
|
|
2209
|
+
}));
|
|
2210
|
+
|
|
2211
|
+
return function getSchema(_x) {
|
|
2212
|
+
return _ref.apply(this, arguments);
|
|
2213
|
+
};
|
|
2214
|
+
}();
|
|
2215
|
+
|
|
2216
|
+
export { getContextFactory$1 as getContextFactory, getResolvers$1 as getResolvers, getSchema, getTypeDefs };
|
|
2217
|
+
//# sourceMappingURL=api.esm.js.map
|