@infrab4a/connect 2.0.13-beta.1 → 3.0.0-beta.1
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 +187 -318
- package/bundles/infrab4a-connect.umd.js.map +1 -1
- package/domain/catalog/models/product.d.ts +4 -8
- package/domain/catalog/models/types/index.d.ts +3 -2
- package/domain/catalog/models/types/product-metadata.type.d.ts +4 -0
- package/domain/catalog/models/types/shop-description.type.d.ts +7 -0
- package/domain/catalog/models/types/{shops-price.type.d.ts → shop-price.type.d.ts} +0 -4
- package/domain/catalog/models/variant.d.ts +2 -2
- package/domain/generic/repository/enums/where.enum.d.ts +0 -1
- package/esm2015/domain/catalog/models/product.js +1 -5
- package/esm2015/domain/catalog/models/types/index.js +4 -3
- package/esm2015/domain/catalog/models/types/product-metadata.type.js +2 -0
- package/esm2015/domain/catalog/models/types/shop-description.type.js +2 -0
- package/esm2015/domain/catalog/models/types/shop-price.type.js +2 -0
- package/esm2015/domain/catalog/models/variant.js +1 -1
- package/esm2015/domain/catalog/repositories/product.repository.js +1 -1
- package/esm2015/domain/generic/repository/enums/where.enum.js +1 -2
- package/esm2015/domain/shop-settings/models/home.js +1 -1
- package/esm2015/infra/elasticsearch/indexes/products-index.js +4 -6
- package/esm2015/infra/firebase/firestore/models/user-search.js +7 -0
- package/esm2015/infra/firebase/firestore/repositories/catalog/category-firestore.repository.js +4 -5
- package/esm2015/infra/firebase/firestore/repositories/users/index.js +7 -6
- package/esm2015/infra/firebase/firestore/repositories/users/user-firestore.repository.js +6 -4
- package/esm2015/infra/firebase/firestore/repositories/users/user-search-firestore.repository.js +12 -0
- package/esm2015/infra/hasura-graphql/repositories/catalog/category-hasura-graphql.repository.js +4 -65
- package/esm2015/infra/hasura-graphql/repositories/catalog/product-hasura-graphql.repository.js +28 -55
- package/esm2015/infra/hasura-graphql/repositories/catalog/variant-hasura-graphql.repository.js +11 -14
- package/esm2015/infra/hasura-graphql/types/hasura-graphql-fields.type.js +1 -1
- package/fesm2015/infrab4a-connect.js +103 -186
- package/fesm2015/infrab4a-connect.js.map +1 -1
- package/infra/firebase/firestore/models/user-search.d.ts +9 -0
- package/infra/firebase/firestore/repositories/users/index.d.ts +6 -5
- package/infra/firebase/firestore/repositories/users/user-firestore.repository.d.ts +3 -1
- package/infra/firebase/firestore/repositories/users/user-search-firestore.repository.d.ts +9 -0
- package/infra/hasura-graphql/repositories/catalog/category-hasura-graphql.repository.d.ts +1 -4
- package/infra/hasura-graphql/types/hasura-graphql-fields.type.d.ts +1 -1
- package/package.json +1 -1
- package/domain/catalog/models/types/shops-description.type.d.ts +0 -7
- package/esm2015/domain/catalog/models/types/shops-description.type.js +0 -2
- package/esm2015/domain/catalog/models/types/shops-price.type.js +0 -2
|
@@ -36,7 +36,6 @@ class BaseModel {
|
|
|
36
36
|
var Where;
|
|
37
37
|
(function (Where) {
|
|
38
38
|
Where["EQUALS"] = "==";
|
|
39
|
-
Where["NOTEQUALS"] = "!=";
|
|
40
39
|
Where["GT"] = ">";
|
|
41
40
|
Where["GTE"] = ">=";
|
|
42
41
|
Where["IN"] = "in";
|
|
@@ -779,10 +778,6 @@ class Product extends BaseModel {
|
|
|
779
778
|
identifierFields() {
|
|
780
779
|
return ['id'];
|
|
781
780
|
}
|
|
782
|
-
getInfoByShop(shop) {
|
|
783
|
-
var _a, _b, _c, _d, _e, _f;
|
|
784
|
-
return Object.assign(Object.assign(Object.assign({}, (((_b = (_a = this.description) === null || _a === void 0 ? void 0 : _a[shop]) === null || _b === void 0 ? void 0 : _b.description) ? { description: (_d = (_c = this.description) === null || _c === void 0 ? void 0 : _c[shop]) === null || _d === void 0 ? void 0 : _d.description } : {})), (((_e = this.price) === null || _e === void 0 ? void 0 : _e[shop]) || {})), (((_f = this.stock) === null || _f === void 0 ? void 0 : _f[shop]) || {}));
|
|
785
|
-
}
|
|
786
781
|
static get identifiersFields() {
|
|
787
782
|
return ['id'];
|
|
788
783
|
}
|
|
@@ -1098,7 +1093,6 @@ class ProductsIndex {
|
|
|
1098
1093
|
}
|
|
1099
1094
|
findById(ids, options) {
|
|
1100
1095
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1101
|
-
const publishedField = options.shop === Shops.GLAMSHOP ? 'publishedGlam' : 'published';
|
|
1102
1096
|
const fields = [
|
|
1103
1097
|
'brand',
|
|
1104
1098
|
'id',
|
|
@@ -1116,7 +1110,6 @@ class ProductsIndex {
|
|
|
1116
1110
|
'weight',
|
|
1117
1111
|
'tags',
|
|
1118
1112
|
'hasVariants',
|
|
1119
|
-
'type'
|
|
1120
1113
|
];
|
|
1121
1114
|
const { hits } = yield this.adapter.query('products/_search', Object.assign({ _source: fields, query: {
|
|
1122
1115
|
bool: {
|
|
@@ -1128,7 +1121,7 @@ class ProductsIndex {
|
|
|
1128
1121
|
},
|
|
1129
1122
|
{
|
|
1130
1123
|
term: {
|
|
1131
|
-
|
|
1124
|
+
published: true,
|
|
1132
1125
|
},
|
|
1133
1126
|
},
|
|
1134
1127
|
...(options.hasStock
|
|
@@ -1160,7 +1153,7 @@ class ProductsIndex {
|
|
|
1160
1153
|
yield this.adapter.save(`products/_doc/${product.firestoreId}`, product.toPlain());
|
|
1161
1154
|
}
|
|
1162
1155
|
catch (error) {
|
|
1163
|
-
console.
|
|
1156
|
+
console.info(error.message);
|
|
1164
1157
|
yield this.adapter.save(`products/_doc/${product.id}`, product.toPlain());
|
|
1165
1158
|
}
|
|
1166
1159
|
});
|
|
@@ -1429,26 +1422,6 @@ const withCrudFirestore = (MixinBase) => {
|
|
|
1429
1422
|
};
|
|
1430
1423
|
};
|
|
1431
1424
|
|
|
1432
|
-
class LeadFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1433
|
-
constructor(firestore) {
|
|
1434
|
-
super();
|
|
1435
|
-
this.firestore = firestore;
|
|
1436
|
-
this.collectionName = 'leads';
|
|
1437
|
-
this.model = Lead;
|
|
1438
|
-
}
|
|
1439
|
-
}
|
|
1440
|
-
|
|
1441
|
-
class SubscriptionEditionFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), Subscription) {
|
|
1442
|
-
constructor(firestore, parentRepository) {
|
|
1443
|
-
super();
|
|
1444
|
-
this.firestore = firestore;
|
|
1445
|
-
this.parentRepository = parentRepository;
|
|
1446
|
-
this.collectionName = 'editions';
|
|
1447
|
-
this.parentIdField = 'subscriptionId';
|
|
1448
|
-
this.model = Edition;
|
|
1449
|
-
}
|
|
1450
|
-
}
|
|
1451
|
-
|
|
1452
1425
|
class SubscriptionFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1453
1426
|
constructor(firestore) {
|
|
1454
1427
|
super();
|
|
@@ -1458,43 +1431,26 @@ class SubscriptionFirestoreRepository extends withCrudFirestore(withHelpers(with
|
|
|
1458
1431
|
}
|
|
1459
1432
|
}
|
|
1460
1433
|
|
|
1461
|
-
class
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
this.firestore = firestore;
|
|
1465
|
-
this.parentRepository = parentRepository;
|
|
1466
|
-
this.collectionName = 'payments';
|
|
1467
|
-
this.parentIdField = 'subscriptionId';
|
|
1468
|
-
this.model = SubscriptionPayment;
|
|
1469
|
-
}
|
|
1470
|
-
}
|
|
1471
|
-
|
|
1472
|
-
class UserAddressFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), User) {
|
|
1473
|
-
constructor(firestore, parentRepository) {
|
|
1474
|
-
super();
|
|
1475
|
-
this.firestore = firestore;
|
|
1476
|
-
this.parentRepository = parentRepository;
|
|
1477
|
-
this.collectionName = 'address';
|
|
1478
|
-
this.parentIdField = 'userId';
|
|
1479
|
-
this.model = UserAddress;
|
|
1434
|
+
class UserSearch extends BaseModel {
|
|
1435
|
+
static get identifiersFields() {
|
|
1436
|
+
return ['id'];
|
|
1480
1437
|
}
|
|
1481
1438
|
}
|
|
1482
1439
|
|
|
1483
|
-
class
|
|
1484
|
-
constructor(firestore
|
|
1440
|
+
class UserSearchFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1441
|
+
constructor(firestore) {
|
|
1485
1442
|
super();
|
|
1486
1443
|
this.firestore = firestore;
|
|
1487
|
-
this.
|
|
1488
|
-
this.
|
|
1489
|
-
this.parentIdField = 'userId';
|
|
1490
|
-
this.model = BeautyProfile;
|
|
1444
|
+
this.collectionName = 'userSearch';
|
|
1445
|
+
this.model = UserSearch;
|
|
1491
1446
|
}
|
|
1492
1447
|
}
|
|
1493
1448
|
|
|
1494
1449
|
class UserFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1495
|
-
constructor(firestore) {
|
|
1450
|
+
constructor(firestore, userSearchFirestoreRepository = new UserSearchFirestoreRepository(firestore)) {
|
|
1496
1451
|
super();
|
|
1497
1452
|
this.firestore = firestore;
|
|
1453
|
+
this.userSearchFirestoreRepository = userSearchFirestoreRepository;
|
|
1498
1454
|
this.collectionName = 'users';
|
|
1499
1455
|
this.model = User;
|
|
1500
1456
|
}
|
|
@@ -1511,7 +1467,7 @@ class UserFirestoreRepository extends withCrudFirestore(withHelpers(withFirestor
|
|
|
1511
1467
|
}
|
|
1512
1468
|
checkIfExistsByField(field, value) {
|
|
1513
1469
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1514
|
-
const result = yield this.find({
|
|
1470
|
+
const result = yield this.userSearchFirestoreRepository.find({ [field]: { operator: Where.EQUALS, value } });
|
|
1515
1471
|
return result.count > 0;
|
|
1516
1472
|
});
|
|
1517
1473
|
}
|
|
@@ -1555,6 +1511,39 @@ class UserFirestoreRepository extends withCrudFirestore(withHelpers(withFirestor
|
|
|
1555
1511
|
}
|
|
1556
1512
|
}
|
|
1557
1513
|
|
|
1514
|
+
class SubscriptionEditionFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), Subscription) {
|
|
1515
|
+
constructor(firestore, parentRepository) {
|
|
1516
|
+
super();
|
|
1517
|
+
this.firestore = firestore;
|
|
1518
|
+
this.parentRepository = parentRepository;
|
|
1519
|
+
this.collectionName = 'editions';
|
|
1520
|
+
this.parentIdField = 'subscriptionId';
|
|
1521
|
+
this.model = Edition;
|
|
1522
|
+
}
|
|
1523
|
+
}
|
|
1524
|
+
|
|
1525
|
+
class UserBeautyProfileFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), User) {
|
|
1526
|
+
constructor(firestore, parentRepository) {
|
|
1527
|
+
super();
|
|
1528
|
+
this.firestore = firestore;
|
|
1529
|
+
this.parentRepository = parentRepository;
|
|
1530
|
+
this.collectionName = 'CX';
|
|
1531
|
+
this.parentIdField = 'userId';
|
|
1532
|
+
this.model = BeautyProfile;
|
|
1533
|
+
}
|
|
1534
|
+
}
|
|
1535
|
+
|
|
1536
|
+
class UserAddressFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), User) {
|
|
1537
|
+
constructor(firestore, parentRepository) {
|
|
1538
|
+
super();
|
|
1539
|
+
this.firestore = firestore;
|
|
1540
|
+
this.parentRepository = parentRepository;
|
|
1541
|
+
this.collectionName = 'address';
|
|
1542
|
+
this.parentIdField = 'userId';
|
|
1543
|
+
this.model = UserAddress;
|
|
1544
|
+
}
|
|
1545
|
+
}
|
|
1546
|
+
|
|
1558
1547
|
class UserPaymentMethodFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), User) {
|
|
1559
1548
|
constructor(firestore, parentRepository) {
|
|
1560
1549
|
super();
|
|
@@ -1566,6 +1555,26 @@ class UserPaymentMethodFirestoreRepository extends withSubCollection(withCrudFir
|
|
|
1566
1555
|
}
|
|
1567
1556
|
}
|
|
1568
1557
|
|
|
1558
|
+
class SubscriptionPaymentFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), Subscription) {
|
|
1559
|
+
constructor(firestore, parentRepository) {
|
|
1560
|
+
super();
|
|
1561
|
+
this.firestore = firestore;
|
|
1562
|
+
this.parentRepository = parentRepository;
|
|
1563
|
+
this.collectionName = 'payments';
|
|
1564
|
+
this.parentIdField = 'subscriptionId';
|
|
1565
|
+
this.model = SubscriptionPayment;
|
|
1566
|
+
}
|
|
1567
|
+
}
|
|
1568
|
+
|
|
1569
|
+
class LeadFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1570
|
+
constructor(firestore) {
|
|
1571
|
+
super();
|
|
1572
|
+
this.firestore = firestore;
|
|
1573
|
+
this.collectionName = 'leads';
|
|
1574
|
+
this.model = Lead;
|
|
1575
|
+
}
|
|
1576
|
+
}
|
|
1577
|
+
|
|
1569
1578
|
class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1570
1579
|
constructor(firestore) {
|
|
1571
1580
|
super();
|
|
@@ -1612,12 +1621,11 @@ class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFire
|
|
|
1612
1621
|
throw new RequiredArgumentError(['Category products is empty']);
|
|
1613
1622
|
const chunks = chunk(category.products, 10);
|
|
1614
1623
|
const products = [];
|
|
1615
|
-
const publishedField = category.shop === Shops.GLAMSHOP ? 'publishedGlam' : 'published';
|
|
1616
1624
|
for (const productIds of chunks) {
|
|
1617
1625
|
if ((options === null || options === void 0 ? void 0 : options.limit) && products.length >= (options === null || options === void 0 ? void 0 : options.limit))
|
|
1618
1626
|
break;
|
|
1619
1627
|
let query = yield this.collection('productsErpVitrine')
|
|
1620
|
-
.where(
|
|
1628
|
+
.where('published', '==', true)
|
|
1621
1629
|
.where('id', 'in', productIds);
|
|
1622
1630
|
if (options === null || options === void 0 ? void 0 : options.hasStock)
|
|
1623
1631
|
query = query.where('stock.quantity', '>', 0);
|
|
@@ -2499,19 +2507,6 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
2499
2507
|
: _super.get.call(this, identifiers);
|
|
2500
2508
|
});
|
|
2501
2509
|
}
|
|
2502
|
-
update(params) {
|
|
2503
|
-
const _super = Object.create(null, {
|
|
2504
|
-
update: { get: () => super.update }
|
|
2505
|
-
});
|
|
2506
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
2507
|
-
const { products, id: checkId } = params, data = __rest(params, ["products", "id"]);
|
|
2508
|
-
const plainData = this.paramsToPlain({ id: checkId });
|
|
2509
|
-
const id = yield this.getId(plainData.id);
|
|
2510
|
-
const category = yield _super.update.call(this, Object.assign({ id }, data));
|
|
2511
|
-
category.products = products && (yield this.updateProducts(+id, { products }));
|
|
2512
|
-
return category;
|
|
2513
|
-
});
|
|
2514
|
-
}
|
|
2515
2510
|
getCategoryBySlug(slug, shop) {
|
|
2516
2511
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2517
2512
|
if (!slug)
|
|
@@ -2545,8 +2540,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
2545
2540
|
if (!category.products)
|
|
2546
2541
|
throw new RequiredArgumentError(['Category products is empty']);
|
|
2547
2542
|
const products = [];
|
|
2548
|
-
const
|
|
2549
|
-
const { data: productsData } = yield this.productRepository.find(Object.assign({ filters: Object.assign({ id: { operator: Where.IN, value: category.products }, [publishedField]: true }, ((options === null || options === void 0 ? void 0 : options.hasStock) ? { stock: { quantity: { operator: Where.GT, value: 0 } } } : {})), fields: [
|
|
2543
|
+
const { data: productsData } = yield this.productRepository.find(Object.assign({ filters: Object.assign({ id: { operator: Where.IN, value: category.products }, published: true }, ((options === null || options === void 0 ? void 0 : options.hasStock) ? { stock: { quantity: { operator: Where.GT, value: 0 } } } : {})), fields: [
|
|
2550
2544
|
'id',
|
|
2551
2545
|
'name',
|
|
2552
2546
|
'slug',
|
|
@@ -2558,7 +2552,6 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
2558
2552
|
'subscriberPrice',
|
|
2559
2553
|
'stock',
|
|
2560
2554
|
'published',
|
|
2561
|
-
'publishedGlam',
|
|
2562
2555
|
'CEST',
|
|
2563
2556
|
'EAN',
|
|
2564
2557
|
'NCM',
|
|
@@ -2566,60 +2559,14 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
2566
2559
|
'costPrice',
|
|
2567
2560
|
'hasVariants',
|
|
2568
2561
|
'isKit',
|
|
2569
|
-
'shopAvailability',
|
|
2570
2562
|
'sku',
|
|
2571
2563
|
'rate',
|
|
2572
2564
|
'tags',
|
|
2573
|
-
'type',
|
|
2574
|
-
'shoppingCount',
|
|
2575
2565
|
] }, ((options === null || options === void 0 ? void 0 : options.limit) ? { limits: { limit: options === null || options === void 0 ? void 0 : options.limit } } : {})));
|
|
2576
2566
|
products.push(...productsData);
|
|
2577
2567
|
return products;
|
|
2578
2568
|
});
|
|
2579
2569
|
}
|
|
2580
|
-
getId(id) {
|
|
2581
|
-
var _a, _b;
|
|
2582
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
2583
|
-
if (!Number.isNaN(+id))
|
|
2584
|
-
return id;
|
|
2585
|
-
const { data } = yield this.find({ filters: { firestoreId: id } });
|
|
2586
|
-
if ((_a = data === null || data === void 0 ? void 0 : data[0]) === null || _a === void 0 ? void 0 : _a.id)
|
|
2587
|
-
return (_b = data === null || data === void 0 ? void 0 : data[0]) === null || _b === void 0 ? void 0 : _b.id;
|
|
2588
|
-
throw new NotFoundError(`Category with id ${id} not found`);
|
|
2589
|
-
});
|
|
2590
|
-
}
|
|
2591
|
-
updateProducts(categoryId, { products }) {
|
|
2592
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
2593
|
-
if ('action' in products && products.action === 'remove') {
|
|
2594
|
-
yield this.mutation('delete_category_product', ['affected_rows'], {
|
|
2595
|
-
where: {
|
|
2596
|
-
type: 'category_product_bool_exp',
|
|
2597
|
-
required: true,
|
|
2598
|
-
value: { category_id: { _eq: categoryId } },
|
|
2599
|
-
},
|
|
2600
|
-
});
|
|
2601
|
-
return [];
|
|
2602
|
-
}
|
|
2603
|
-
const plainData = this.paramsToPlain({ products });
|
|
2604
|
-
if (!plainData.products || plainData.products.length <= 0)
|
|
2605
|
-
return [];
|
|
2606
|
-
yield this.mutation('delete_category_product', ['affected_rows'], {
|
|
2607
|
-
where: {
|
|
2608
|
-
type: 'category_product_bool_exp',
|
|
2609
|
-
required: true,
|
|
2610
|
-
value: { category_id: { _eq: categoryId } },
|
|
2611
|
-
},
|
|
2612
|
-
});
|
|
2613
|
-
yield this.mutation('insert_category_product', ['affected_rows'], {
|
|
2614
|
-
objects: {
|
|
2615
|
-
type: '[category_product_insert_input!]',
|
|
2616
|
-
required: true,
|
|
2617
|
-
value: plainData.products.map((productId) => ({ category_id: categoryId, product_id: productId })),
|
|
2618
|
-
},
|
|
2619
|
-
});
|
|
2620
|
-
return plainData.products;
|
|
2621
|
-
});
|
|
2622
|
-
}
|
|
2623
2570
|
}
|
|
2624
2571
|
|
|
2625
2572
|
class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
@@ -2645,8 +2592,8 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
2645
2592
|
{
|
|
2646
2593
|
description: {
|
|
2647
2594
|
columnName: 'description',
|
|
2648
|
-
from: (description) =>
|
|
2649
|
-
to: (value) =>
|
|
2595
|
+
from: (description) => ({ description }),
|
|
2596
|
+
to: (value) => value.description,
|
|
2650
2597
|
},
|
|
2651
2598
|
},
|
|
2652
2599
|
{ hasVariants: { columnName: 'has_variants' } },
|
|
@@ -2656,12 +2603,12 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
2656
2603
|
{
|
|
2657
2604
|
price: {
|
|
2658
2605
|
columnName: 'price',
|
|
2659
|
-
from: (price, data) =>
|
|
2660
|
-
|
|
2661
|
-
|
|
2662
|
-
|
|
2663
|
-
|
|
2664
|
-
|
|
2606
|
+
from: (price, data) => ({
|
|
2607
|
+
price,
|
|
2608
|
+
fullPrice: data.full_price,
|
|
2609
|
+
subscriberDiscountPercentage: data.subscriber_discount_percentage,
|
|
2610
|
+
subscriberPrice: data.subscriber_price,
|
|
2611
|
+
}),
|
|
2665
2612
|
bindFindFilter: (sentence) => {
|
|
2666
2613
|
const filters = Object.values(sentence).shift();
|
|
2667
2614
|
return Object.assign(Object.assign(Object.assign(Object.assign({}, (((filters === null || filters === void 0 ? void 0 : filters.price) || (filters === null || filters === void 0 ? void 0 : filters.price) === 0) && { price: filters.price })), ((filters.fullPrice || filters.fullPrice === 0) && { full_price: filters.fullPrice })), ((filters.subscriberDiscountPercentage || filters.subscriberDiscountPercentage === 0) && {
|
|
@@ -2670,19 +2617,15 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
2670
2617
|
subscriber_price: filters.subscriberPrice,
|
|
2671
2618
|
}));
|
|
2672
2619
|
},
|
|
2673
|
-
bindPersistData: (
|
|
2674
|
-
|
|
2675
|
-
|
|
2676
|
-
subscriber_discount_percentage: priceData.subscriberDiscountPercentage,
|
|
2677
|
-
})), (priceData.subscriberPrice >= 0 && { subscriber_price: priceData.subscriberPrice }));
|
|
2678
|
-
},
|
|
2620
|
+
bindPersistData: (priceData) => (Object.assign(Object.assign(Object.assign(Object.assign({}, ((priceData === null || priceData === void 0 ? void 0 : priceData.price) >= 0 && { price: priceData.price })), (priceData.fullPrice >= 0 && { full_price: priceData.fullPrice })), (priceData.subscriberDiscountPercentage >= 0 && {
|
|
2621
|
+
subscriber_discount_percentage: priceData.subscriberDiscountPercentage,
|
|
2622
|
+
})), (priceData.subscriberPrice >= 0 && { subscriber_price: priceData.subscriberPrice }))),
|
|
2679
2623
|
},
|
|
2680
2624
|
},
|
|
2681
2625
|
{ fullPrice: { columnName: 'full_price' } },
|
|
2682
2626
|
{ subscriberDiscountPercentage: { columnName: 'subscriber_discount_percentage' } },
|
|
2683
2627
|
{ subscriberPrice: { columnName: 'subscriber_price' } },
|
|
2684
2628
|
'published',
|
|
2685
|
-
{ publishedGlam: { columnName: 'published_glam' } },
|
|
2686
2629
|
'sku',
|
|
2687
2630
|
{
|
|
2688
2631
|
stock: {
|
|
@@ -2696,14 +2639,6 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
2696
2639
|
'video',
|
|
2697
2640
|
'weight',
|
|
2698
2641
|
'gender',
|
|
2699
|
-
{
|
|
2700
|
-
shopAvailability: {
|
|
2701
|
-
columnName: 'shop_availabilities',
|
|
2702
|
-
fields: ['shop'],
|
|
2703
|
-
from: (shop) => (Array.isArray(shop) ? shop.map((row) => row.shop) : []),
|
|
2704
|
-
bindPersistData: (shops) => ({ shop_availabilities: { data: shops.map((shop) => ({ shop })) } }),
|
|
2705
|
-
},
|
|
2706
|
-
},
|
|
2707
2642
|
{ tags: { columnName: 'tags', type: HasuraGraphQLColumnType.Jsonb } },
|
|
2708
2643
|
{ isKit: { columnName: 'is_kit' } },
|
|
2709
2644
|
{ createdAt: { columnName: 'created_at' } },
|
|
@@ -2715,7 +2650,6 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
2715
2650
|
from: (value) => value.aggregate.avg.rate,
|
|
2716
2651
|
},
|
|
2717
2652
|
},
|
|
2718
|
-
{ shoppingCount: { columnName: 'shopping_count' } },
|
|
2719
2653
|
];
|
|
2720
2654
|
this.fields = [
|
|
2721
2655
|
...commonFields,
|
|
@@ -2743,10 +2677,12 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
2743
2677
|
},
|
|
2744
2678
|
},
|
|
2745
2679
|
{
|
|
2746
|
-
|
|
2747
|
-
columnName: '
|
|
2748
|
-
|
|
2749
|
-
|
|
2680
|
+
metadata: {
|
|
2681
|
+
columnName: 'metadata',
|
|
2682
|
+
fields: ['title', 'description'],
|
|
2683
|
+
bindPersistData: (value) => ({
|
|
2684
|
+
metadata: { data: value },
|
|
2685
|
+
}),
|
|
2750
2686
|
},
|
|
2751
2687
|
},
|
|
2752
2688
|
];
|
|
@@ -2776,7 +2712,7 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
2776
2712
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2777
2713
|
const product = yield _super.create.call(this, omit(data, ['reviews']));
|
|
2778
2714
|
try {
|
|
2779
|
-
product.reviews =
|
|
2715
|
+
product.reviews = yield this.updateReviews(+product.id, data);
|
|
2780
2716
|
}
|
|
2781
2717
|
catch (error) {
|
|
2782
2718
|
yield this.delete({ id: product.id });
|
|
@@ -2796,7 +2732,7 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
2796
2732
|
: yield _super.get.call(this, identifiers);
|
|
2797
2733
|
if (product.productId)
|
|
2798
2734
|
throw new NotFoundError('Product not found, it is a variant');
|
|
2799
|
-
product.reviews =
|
|
2735
|
+
product.reviews = yield this.findReviewsByProduct(+product.id);
|
|
2800
2736
|
return product;
|
|
2801
2737
|
});
|
|
2802
2738
|
}
|
|
@@ -2805,12 +2741,8 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
2805
2741
|
find: { get: () => super.find }
|
|
2806
2742
|
});
|
|
2807
2743
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2808
|
-
const _a = params || {}, { filters
|
|
2809
|
-
|
|
2810
|
-
this.fields
|
|
2811
|
-
.map((field) => (typeof field === 'string' ? field : Object.keys(field).shift()))
|
|
2812
|
-
.filter((field) => field !== 'reviews');
|
|
2813
|
-
return _super.find.call(this, Object.assign(Object.assign({}, options), { filters: Object.assign(Object.assign({}, filters), { productId: { operator: Where.ISNULL } }), fields: bindFields }));
|
|
2744
|
+
const _a = params || {}, { filters } = _a, options = __rest(_a, ["filters"]);
|
|
2745
|
+
return _super.find.call(this, Object.assign(Object.assign({}, options), { filters: Object.assign(Object.assign({}, filters), { productId: { operator: Where.ISNULL } }) }));
|
|
2814
2746
|
});
|
|
2815
2747
|
}
|
|
2816
2748
|
getBySlug(slug) {
|
|
@@ -2831,7 +2763,7 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
2831
2763
|
update: { get: () => super.update }
|
|
2832
2764
|
});
|
|
2833
2765
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2834
|
-
const { categories, kitProducts, reviews, id: checkId,
|
|
2766
|
+
const { categories, kitProducts, reviews, id: checkId, rate } = params, data = __rest(params, ["categories", "kitProducts", "reviews", "id", "rate"]);
|
|
2835
2767
|
const plainData = this.paramsToPlain({ id: checkId });
|
|
2836
2768
|
const id = yield this.getId(plainData.id);
|
|
2837
2769
|
const product = yield _super.update.call(this, Object.assign({ id }, data));
|
|
@@ -2843,13 +2775,13 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
2843
2775
|
}
|
|
2844
2776
|
fetchReviews(status) {
|
|
2845
2777
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2846
|
-
const
|
|
2778
|
+
const reviews = {
|
|
2847
2779
|
status: status === 'pending'
|
|
2848
2780
|
? { [HasuraGraphQLWhere.ISNULL]: true }
|
|
2849
2781
|
: { [HasuraGraphQLWhere.EQUALS]: status === 'approved' },
|
|
2850
2782
|
};
|
|
2851
2783
|
const { product: data } = yield this.query('product', ['id', 'name', 'sku', { reviews: { columnName: 'reviews', fields: this.reviewsFields } }], {
|
|
2852
|
-
where: { value: { reviews
|
|
2784
|
+
where: { value: { reviews }, type: 'product_bool_exp', required: true },
|
|
2853
2785
|
});
|
|
2854
2786
|
return data.reduce((reviews, product) => [
|
|
2855
2787
|
...reviews,
|
|
@@ -2863,19 +2795,7 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
2863
2795
|
}
|
|
2864
2796
|
updateCategories(productId, { categories }) {
|
|
2865
2797
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2866
|
-
if ('action' in categories && categories.action === 'remove') {
|
|
2867
|
-
yield this.mutation('delete_category_product', ['affected_rows'], {
|
|
2868
|
-
where: {
|
|
2869
|
-
type: 'category_product_bool_exp',
|
|
2870
|
-
required: true,
|
|
2871
|
-
value: { product_id: { _eq: productId } },
|
|
2872
|
-
},
|
|
2873
|
-
});
|
|
2874
|
-
return [];
|
|
2875
|
-
}
|
|
2876
2798
|
const plainData = this.paramsToPlain({ categories });
|
|
2877
|
-
if (!plainData.categories || plainData.categories.length <= 0)
|
|
2878
|
-
return [];
|
|
2879
2799
|
yield this.mutation('delete_category_product', ['affected_rows'], {
|
|
2880
2800
|
where: {
|
|
2881
2801
|
type: 'category_product_bool_exp',
|
|
@@ -2919,6 +2839,8 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
2919
2839
|
}
|
|
2920
2840
|
updateReviews(productId, { reviews }) {
|
|
2921
2841
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2842
|
+
if (!reviews)
|
|
2843
|
+
return [];
|
|
2922
2844
|
if ('action' in reviews && reviews.action === 'remove') {
|
|
2923
2845
|
const reviewIds = yield Promise.all(reviews.value.map((reviewData) => __awaiter(this, void 0, void 0, function* () {
|
|
2924
2846
|
const review = yield this.findReview(reviewData, productId);
|
|
@@ -2930,8 +2852,6 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
2930
2852
|
return reviews.value.map((review, index) => !reviewIds[index] && review).filter(Boolean);
|
|
2931
2853
|
}
|
|
2932
2854
|
const plainData = this.paramsToPlain({ reviews });
|
|
2933
|
-
if (!plainData.reviews || plainData.reviews.length <= 0)
|
|
2934
|
-
return [];
|
|
2935
2855
|
return Promise.all(plainData.reviews.map((reviewData) => __awaiter(this, void 0, void 0, function* () {
|
|
2936
2856
|
const review = yield this.findReview(reviewData, productId);
|
|
2937
2857
|
if (review.id)
|
|
@@ -3043,12 +2963,12 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
3043
2963
|
{
|
|
3044
2964
|
price: {
|
|
3045
2965
|
columnName: 'price',
|
|
3046
|
-
from: (price, data) =>
|
|
3047
|
-
|
|
3048
|
-
|
|
3049
|
-
|
|
3050
|
-
|
|
3051
|
-
|
|
2966
|
+
from: (price, data) => ({
|
|
2967
|
+
price,
|
|
2968
|
+
fullPrice: data.full_price,
|
|
2969
|
+
subscriberDiscountPercentage: data.subscriber_discount_percentage,
|
|
2970
|
+
subscriberPrice: data.subscriber_price,
|
|
2971
|
+
}),
|
|
3052
2972
|
bindFindFilter: (sentence) => {
|
|
3053
2973
|
const filters = Object.values(sentence).shift();
|
|
3054
2974
|
return Object.assign(Object.assign(Object.assign(Object.assign({}, (((filters === null || filters === void 0 ? void 0 : filters.price) || (filters === null || filters === void 0 ? void 0 : filters.price) === 0) && { price: filters.price })), ((filters.fullPrice || filters.fullPrice === 0) && { full_price: filters.fullPrice })), ((filters.subscriberDiscountPercentage || filters.subscriberDiscountPercentage === 0) && {
|
|
@@ -3057,12 +2977,9 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
3057
2977
|
subscriber_price: filters.subscriberPrice,
|
|
3058
2978
|
}));
|
|
3059
2979
|
},
|
|
3060
|
-
bindPersistData: (
|
|
3061
|
-
|
|
3062
|
-
|
|
3063
|
-
subscriber_discount_percentage: priceData.subscriberDiscountPercentage,
|
|
3064
|
-
})), (priceData.subscriberPrice >= 0 && { subscriber_price: priceData.subscriberPrice }));
|
|
3065
|
-
},
|
|
2980
|
+
bindPersistData: (priceData) => (Object.assign(Object.assign(Object.assign(Object.assign({}, ((priceData === null || priceData === void 0 ? void 0 : priceData.price) >= 0 && { price: priceData.price })), (priceData.fullPrice >= 0 && { full_price: priceData.fullPrice })), (priceData.subscriberDiscountPercentage >= 0 && {
|
|
2981
|
+
subscriber_discount_percentage: priceData.subscriberDiscountPercentage,
|
|
2982
|
+
})), (priceData.subscriberPrice >= 0 && { subscriber_price: priceData.subscriberPrice }))),
|
|
3066
2983
|
},
|
|
3067
2984
|
},
|
|
3068
2985
|
{ fullPrice: { columnName: 'full_price' } },
|
|
@@ -3143,5 +3060,5 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
3143
3060
|
* Generated bundle index. Do not edit.
|
|
3144
3061
|
*/
|
|
3145
3062
|
|
|
3146
|
-
export { AccessoryImportances, Address, Area, Authentication, AuthenticationFirebaseAuthService, AxiosAdapter, Base, BaseModel, BeardProblems, BeardSizes, BeautyProductImportances, BeautyProfile, BeautyQuestionsHelper, BillingStatus, BodyProblems, BodyShapes, BodyTattoos, Buy2Win, Buy2WinFirestoreRepository, Category, CategoryFirestoreRepository, CategoryHasuraGraphQL, CategoryHasuraGraphQLRepository, Checkout, CheckoutFirestoreRepository, CheckoutSubscription, CheckoutSubscriptionFirestoreRepository, CheckoutTypes, Coupon, CouponFirestoreRepository, CouponSubtypes, CouponTypes, DuplicatedResultsError, Edition, EditionStatus, Exclusivities, FaceSkinOilinesses, FaceSkinProblems, FaceSkinTones, FamilyIncomes, FilterType, FragranceImportances, GenderDestination, HairColors, HairProblems, HairStrands, HairTypes, Home, HomeFirestoreRepository, InvalidArgumentError, KitProduct, KitProductHasuraGraphQL, Lead, LeadFirestoreRepository, LegacyOrderFirestoreRepository, LineItem, NotFoundError, OfficePosition, Order, OrderFirestoreRepository, OrderStatus, Payment, PaymentFirestoreRepository, PaymentType, Product, ProductFirestoreRepository, ProductHasuraGraphQL, ProductHasuraGraphQLRepository, ProductSpents, ProductVariantFirestoreRepository, ProductsIndex, QuestionsFilters, RecoveryPassword, Register, RegisterFirebaseAuthService, RequiredArgumentError, ShippingMethod, ShopMenu, ShopMenuFirestoreRepository, Shops, SignInMethods, SignOut, Status, Subscription, SubscriptionEditionFirestoreRepository, SubscriptionFirestoreRepository, SubscriptionPayment, SubscriptionPaymentFirestoreRepository, SubscriptionPlan, SubscriptionPlanFirestoreRepository, SubscriptionProductFirestoreRepository, UnauthorizedError, UpdateOptionActions, User, UserAddress, UserAddressFirestoreRepository, UserAlreadyRegisteredError, UserBeautyProfileFirestoreRepository, UserFirestoreRepository, UserPaymentMethod, UserPaymentMethodFirestoreRepository, UserType, Variant, VariantHasuraGraphQL, VariantHasuraGraphQLRepository, WeakPasswordError, Where, isUUID, parseDateTime, withCreateFirestore, withCreateHasuraGraphQL, withCrudFirestore, withCrudHasuraGraphQL, withDeleteFirestore, withDeleteHasuraGraphQL, withFindFirestore, withFindHasuraGraphQL, withFirestore, withGetFirestore, withGetHasuraGraphQL, withHasuraGraphQL, withHelpers, withSubCollection, withUpdateFirestore, withUpdateHasuraGraphQL };
|
|
3063
|
+
export { AccessoryImportances, Address, Area, Authentication, AuthenticationFirebaseAuthService, AxiosAdapter, Base, BaseModel, BeardProblems, BeardSizes, BeautyProductImportances, BeautyProfile, BeautyQuestionsHelper, BillingStatus, BodyProblems, BodyShapes, BodyTattoos, Buy2Win, Buy2WinFirestoreRepository, Category, CategoryFirestoreRepository, CategoryHasuraGraphQL, CategoryHasuraGraphQLRepository, Checkout, CheckoutFirestoreRepository, CheckoutSubscription, CheckoutSubscriptionFirestoreRepository, CheckoutTypes, Coupon, CouponFirestoreRepository, CouponSubtypes, CouponTypes, DuplicatedResultsError, Edition, EditionStatus, Exclusivities, FaceSkinOilinesses, FaceSkinProblems, FaceSkinTones, FamilyIncomes, FilterType, FragranceImportances, GenderDestination, HairColors, HairProblems, HairStrands, HairTypes, Home, HomeFirestoreRepository, InvalidArgumentError, KitProduct, KitProductHasuraGraphQL, Lead, LeadFirestoreRepository, LegacyOrderFirestoreRepository, LineItem, NotFoundError, OfficePosition, Order, OrderFirestoreRepository, OrderStatus, Payment, PaymentFirestoreRepository, PaymentType, Product, ProductFirestoreRepository, ProductHasuraGraphQL, ProductHasuraGraphQLRepository, ProductSpents, ProductVariantFirestoreRepository, ProductsIndex, QuestionsFilters, RecoveryPassword, Register, RegisterFirebaseAuthService, RequiredArgumentError, ShippingMethod, ShopMenu, ShopMenuFirestoreRepository, Shops, SignInMethods, SignOut, Status, Subscription, SubscriptionEditionFirestoreRepository, SubscriptionFirestoreRepository, SubscriptionPayment, SubscriptionPaymentFirestoreRepository, SubscriptionPlan, SubscriptionPlanFirestoreRepository, SubscriptionProductFirestoreRepository, UnauthorizedError, UpdateOptionActions, User, UserAddress, UserAddressFirestoreRepository, UserAlreadyRegisteredError, UserBeautyProfileFirestoreRepository, UserFirestoreRepository, UserPaymentMethod, UserPaymentMethodFirestoreRepository, UserSearchFirestoreRepository, UserType, Variant, VariantHasuraGraphQL, VariantHasuraGraphQLRepository, WeakPasswordError, Where, isUUID, parseDateTime, withCreateFirestore, withCreateHasuraGraphQL, withCrudFirestore, withCrudHasuraGraphQL, withDeleteFirestore, withDeleteHasuraGraphQL, withFindFirestore, withFindHasuraGraphQL, withFirestore, withGetFirestore, withGetHasuraGraphQL, withHasuraGraphQL, withHelpers, withSubCollection, withUpdateFirestore, withUpdateHasuraGraphQL };
|
|
3147
3064
|
//# sourceMappingURL=infrab4a-connect.js.map
|