@infrab4a/connect 0.16.3-beta.1 → 0.16.3
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/bundles/infrab4a-connect.umd.js +50 -8
- package/bundles/infrab4a-connect.umd.js.map +1 -1
- package/domain/users/models/user.d.ts +0 -1
- package/esm2015/domain/users/models/user.js +1 -1
- package/esm2015/infra/firebase/firestore/repositories/catalog/category-firestore.repository.js +20 -7
- package/fesm2015/infrab4a-connect.js +18 -6
- package/fesm2015/infrab4a-connect.js.map +1 -1
- package/package.json +1 -1
|
@@ -2224,14 +2224,56 @@
|
|
|
2224
2224
|
};
|
|
2225
2225
|
CategoryFirestoreRepository.prototype.mountCategory = function (category, options) {
|
|
2226
2226
|
return __awaiter(this, void 0, void 0, function () {
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2227
|
+
var chunks, products, publishedField, chunks_1, chunks_1_1, productIds, query, productSnap, e_1_1;
|
|
2228
|
+
var e_1, _a;
|
|
2229
|
+
return __generator(this, function (_b) {
|
|
2230
|
+
switch (_b.label) {
|
|
2231
|
+
case 0:
|
|
2232
|
+
if (!category.products)
|
|
2233
|
+
throw new RequiredArgumentError(['Category products is empty']);
|
|
2234
|
+
chunks = lodash.chunk(category.products, 10);
|
|
2235
|
+
products = [];
|
|
2236
|
+
publishedField = category.shop === exports.Shops.GLAMSHOP ? 'publishedGlam' : 'published';
|
|
2237
|
+
_b.label = 1;
|
|
2238
|
+
case 1:
|
|
2239
|
+
_b.trys.push([1, 7, 8, 9]);
|
|
2240
|
+
chunks_1 = __values(chunks), chunks_1_1 = chunks_1.next();
|
|
2241
|
+
_b.label = 2;
|
|
2242
|
+
case 2:
|
|
2243
|
+
if (!!chunks_1_1.done) return [3 /*break*/, 6];
|
|
2244
|
+
productIds = chunks_1_1.value;
|
|
2245
|
+
if ((options === null || options === void 0 ? void 0 : options.limit) && products.length >= (options === null || options === void 0 ? void 0 : options.limit))
|
|
2246
|
+
return [3 /*break*/, 6];
|
|
2247
|
+
return [4 /*yield*/, this.collection('products').where(publishedField, '==', true).where('id', 'in', productIds)];
|
|
2248
|
+
case 3:
|
|
2249
|
+
query = _b.sent();
|
|
2250
|
+
if (options === null || options === void 0 ? void 0 : options.hasStock)
|
|
2251
|
+
query = query.where('stock.quantity', '>', 0);
|
|
2252
|
+
if (options === null || options === void 0 ? void 0 : options.limit)
|
|
2253
|
+
query = query.limit(options === null || options === void 0 ? void 0 : options.limit);
|
|
2254
|
+
return [4 /*yield*/, query.get()];
|
|
2255
|
+
case 4:
|
|
2256
|
+
productSnap = _b.sent();
|
|
2257
|
+
if (productSnap.empty)
|
|
2258
|
+
return [3 /*break*/, 5];
|
|
2259
|
+
products.push.apply(products, __spreadArray([], __read(productSnap.docs.map(function (doc) { return doc.data(); }))));
|
|
2260
|
+
_b.label = 5;
|
|
2261
|
+
case 5:
|
|
2262
|
+
chunks_1_1 = chunks_1.next();
|
|
2263
|
+
return [3 /*break*/, 2];
|
|
2264
|
+
case 6: return [3 /*break*/, 9];
|
|
2265
|
+
case 7:
|
|
2266
|
+
e_1_1 = _b.sent();
|
|
2267
|
+
e_1 = { error: e_1_1 };
|
|
2268
|
+
return [3 /*break*/, 9];
|
|
2269
|
+
case 8:
|
|
2270
|
+
try {
|
|
2271
|
+
if (chunks_1_1 && !chunks_1_1.done && (_a = chunks_1.return)) _a.call(chunks_1);
|
|
2272
|
+
}
|
|
2273
|
+
finally { if (e_1) throw e_1.error; }
|
|
2274
|
+
return [7 /*endfinally*/];
|
|
2275
|
+
case 9: return [2 /*return*/, products];
|
|
2276
|
+
}
|
|
2235
2277
|
});
|
|
2236
2278
|
});
|
|
2237
2279
|
};
|