@infrab4a/connect 0.4.8 → 0.5.0
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 +95 -6
- package/bundles/infrab4a-connect.umd.js.map +1 -1
- package/esm2015/lib/domain/catalog/models/product.js +4 -1
- package/esm2015/lib/domain/catalog/repositories/category.repository.js +1 -1
- package/esm2015/lib/domain/shopping/models/line-item.js +1 -1
- package/esm2015/lib/domain/users/models/user.js +1 -1
- package/esm2015/lib/infra/firebase/firestore/repositories/catalog/category-firestore.repository.js +27 -3
- package/esm2015/lib/infra/firebase/firestore/repositories/users/user-firestore.repository.js +23 -1
- package/fesm2015/infrab4a-connect.js +50 -1
- package/fesm2015/infrab4a-connect.js.map +1 -1
- package/lib/domain/catalog/models/product.d.ts +2 -1
- package/lib/domain/catalog/repositories/category.repository.d.ts +1 -0
- package/lib/domain/shopping/models/line-item.d.ts +1 -0
- package/lib/domain/users/models/user.d.ts +1 -0
- package/lib/infra/firebase/firestore/repositories/catalog/category-firestore.repository.d.ts +1 -0
- package/lib/infra/firebase/firestore/repositories/users/user-firestore.repository.d.ts +5 -0
- package/package.json +1 -1
|
@@ -634,6 +634,9 @@
|
|
|
634
634
|
Product.prototype.identifierFields = function () {
|
|
635
635
|
return ['id'];
|
|
636
636
|
};
|
|
637
|
+
Product.prototype.getInfoByShop = function (shop) {
|
|
638
|
+
return Object.assign(Object.assign({ description: this.description[shop].description }, this.price[shop]), this.stock[shop]);
|
|
639
|
+
};
|
|
637
640
|
return Product;
|
|
638
641
|
}(BaseModel));
|
|
639
642
|
|
|
@@ -1346,21 +1349,36 @@
|
|
|
1346
1349
|
get: { get: function () { return _super_1.prototype.get; } }
|
|
1347
1350
|
});
|
|
1348
1351
|
return __awaiter(this, void 0, void 0, function () {
|
|
1349
|
-
var user, _a;
|
|
1350
|
-
return __generator(this, function (
|
|
1351
|
-
switch (
|
|
1352
|
+
var user, _a, _b;
|
|
1353
|
+
return __generator(this, function (_c) {
|
|
1354
|
+
switch (_c.label) {
|
|
1352
1355
|
case 0: return [4 /*yield*/, _super.get.call(this, { id: identifiers.id })];
|
|
1353
1356
|
case 1:
|
|
1354
|
-
user =
|
|
1357
|
+
user = _c.sent();
|
|
1355
1358
|
_a = user;
|
|
1356
1359
|
return [4 /*yield*/, this.getBeautyProfile(user.id)];
|
|
1357
1360
|
case 2:
|
|
1358
|
-
_a.beautyProfile =
|
|
1361
|
+
_a.beautyProfile = _c.sent();
|
|
1362
|
+
_b = user;
|
|
1363
|
+
return [4 /*yield*/, this.checkIfIsSubscriber(user.id)];
|
|
1364
|
+
case 3:
|
|
1365
|
+
_b.isSubscriber = _c.sent();
|
|
1359
1366
|
return [2 /*return*/, user];
|
|
1360
1367
|
}
|
|
1361
1368
|
});
|
|
1362
1369
|
});
|
|
1363
1370
|
};
|
|
1371
|
+
UserFirestoreRepository.prototype.buildModelInstance = function () {
|
|
1372
|
+
var _a = _super_1.prototype.buildModelInstance.call(this), fromFirestore = _a.fromFirestore, toFirestore = _a.toFirestore;
|
|
1373
|
+
return {
|
|
1374
|
+
toFirestore: function (data) {
|
|
1375
|
+
var plain = toFirestore(data);
|
|
1376
|
+
delete plain.isSubscriber;
|
|
1377
|
+
return plain;
|
|
1378
|
+
},
|
|
1379
|
+
fromFirestore: fromFirestore,
|
|
1380
|
+
};
|
|
1381
|
+
};
|
|
1364
1382
|
UserFirestoreRepository.prototype.getBeautyProfile = function (userId) {
|
|
1365
1383
|
return __awaiter(this, void 0, void 0, function () {
|
|
1366
1384
|
var beautyProfile;
|
|
@@ -1379,6 +1397,23 @@
|
|
|
1379
1397
|
});
|
|
1380
1398
|
});
|
|
1381
1399
|
};
|
|
1400
|
+
UserFirestoreRepository.prototype.checkIfIsSubscriber = function (userId) {
|
|
1401
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1402
|
+
var docs;
|
|
1403
|
+
return __generator(this, function (_a) {
|
|
1404
|
+
switch (_a.label) {
|
|
1405
|
+
case 0: return [4 /*yield*/, this.firestore
|
|
1406
|
+
.collection('subscription')
|
|
1407
|
+
.where('user.id', '==', userId)
|
|
1408
|
+
.where('status', '==', 'active')
|
|
1409
|
+
.get()];
|
|
1410
|
+
case 1:
|
|
1411
|
+
docs = _a.sent();
|
|
1412
|
+
return [2 /*return*/, !!docs && !!docs.size];
|
|
1413
|
+
}
|
|
1414
|
+
});
|
|
1415
|
+
});
|
|
1416
|
+
};
|
|
1382
1417
|
UserFirestoreRepository.prototype.buildBeautyProfileModelInstance = function () {
|
|
1383
1418
|
return {
|
|
1384
1419
|
toFirestore: function (data) { return data.toPlain(); },
|
|
@@ -1492,7 +1527,7 @@
|
|
|
1492
1527
|
category = categories_1_1.value;
|
|
1493
1528
|
return [4 /*yield*/, this.collection("products")
|
|
1494
1529
|
.where("categories", "array-contains", category.id)
|
|
1495
|
-
.where("published", "==", true)
|
|
1530
|
+
// .where("published", "==", true)
|
|
1496
1531
|
.where("stock.quantity", ">", 1)
|
|
1497
1532
|
.limit(4)
|
|
1498
1533
|
.get()];
|
|
@@ -1520,6 +1555,60 @@
|
|
|
1520
1555
|
});
|
|
1521
1556
|
});
|
|
1522
1557
|
};
|
|
1558
|
+
CategoryFirestoreRepository.prototype.mountCategory = function (category) {
|
|
1559
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1560
|
+
var chunks, products, chunks_1, chunks_1_1, productIds, productSnap, e_2_1;
|
|
1561
|
+
var e_2, _a;
|
|
1562
|
+
return __generator(this, function (_b) {
|
|
1563
|
+
switch (_b.label) {
|
|
1564
|
+
case 0:
|
|
1565
|
+
if (!category.products)
|
|
1566
|
+
throw new RequiredArgumentError(["Category products is empty"]);
|
|
1567
|
+
chunks = category.products.reduce(function (resultArray, item, index) {
|
|
1568
|
+
var chunkIndex = Math.floor(index / 10);
|
|
1569
|
+
if (!resultArray[chunkIndex])
|
|
1570
|
+
resultArray[chunkIndex] = [];
|
|
1571
|
+
resultArray[chunkIndex].push(item);
|
|
1572
|
+
return resultArray;
|
|
1573
|
+
}, []);
|
|
1574
|
+
products = [];
|
|
1575
|
+
_b.label = 1;
|
|
1576
|
+
case 1:
|
|
1577
|
+
_b.trys.push([1, 6, 7, 8]);
|
|
1578
|
+
chunks_1 = __values(chunks), chunks_1_1 = chunks_1.next();
|
|
1579
|
+
_b.label = 2;
|
|
1580
|
+
case 2:
|
|
1581
|
+
if (!!chunks_1_1.done) return [3 /*break*/, 5];
|
|
1582
|
+
productIds = chunks_1_1.value;
|
|
1583
|
+
return [4 /*yield*/, this.collection("products")
|
|
1584
|
+
.where("id", "in", productIds)
|
|
1585
|
+
// .where("published", "==", true)
|
|
1586
|
+
.get()];
|
|
1587
|
+
case 3:
|
|
1588
|
+
productSnap = _b.sent();
|
|
1589
|
+
if (productSnap.empty)
|
|
1590
|
+
return [3 /*break*/, 4];
|
|
1591
|
+
products.push.apply(products, __spreadArray([], __read(productSnap.docs.map(function (doc) { return doc.data(); }))));
|
|
1592
|
+
_b.label = 4;
|
|
1593
|
+
case 4:
|
|
1594
|
+
chunks_1_1 = chunks_1.next();
|
|
1595
|
+
return [3 /*break*/, 2];
|
|
1596
|
+
case 5: return [3 /*break*/, 8];
|
|
1597
|
+
case 6:
|
|
1598
|
+
e_2_1 = _b.sent();
|
|
1599
|
+
e_2 = { error: e_2_1 };
|
|
1600
|
+
return [3 /*break*/, 8];
|
|
1601
|
+
case 7:
|
|
1602
|
+
try {
|
|
1603
|
+
if (chunks_1_1 && !chunks_1_1.done && (_a = chunks_1.return)) _a.call(chunks_1);
|
|
1604
|
+
}
|
|
1605
|
+
finally { if (e_2) throw e_2.error; }
|
|
1606
|
+
return [7 /*endfinally*/];
|
|
1607
|
+
case 8: return [2 /*return*/, products];
|
|
1608
|
+
}
|
|
1609
|
+
});
|
|
1610
|
+
});
|
|
1611
|
+
};
|
|
1523
1612
|
return CategoryFirestoreRepository;
|
|
1524
1613
|
}(withCrudFirestore(withHelpers(withFirestore(Base)))));
|
|
1525
1614
|
|