@infrab4a/connect 4.0.0-beta.13 → 4.0.0-beta.15
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/domain/catalog/models/category-filter.d.ts +11 -0
- package/domain/catalog/models/category.d.ts +3 -2
- package/domain/catalog/models/filter-option.d.ts +10 -0
- package/domain/catalog/models/filter.d.ts +13 -0
- package/domain/catalog/models/index.d.ts +3 -0
- package/domain/catalog/models/product.d.ts +1 -0
- package/domain/catalog/models/types/index.d.ts +0 -1
- package/domain/catalog/repositories/category-filter.repository.d.ts +5 -0
- package/domain/catalog/repositories/category.repository.d.ts +3 -3
- package/domain/catalog/repositories/filter-option.repository.d.ts +4 -0
- package/domain/catalog/repositories/filter.repository.d.ts +4 -0
- package/domain/catalog/repositories/index.d.ts +3 -0
- package/domain/catalog/repositories/product.repository.d.ts +1 -0
- package/domain/generic/repository/find.repository.d.ts +3 -0
- package/domain/shop-settings/models/index.d.ts +1 -0
- package/domain/shop-settings/models/shop-settings.d.ts +9 -0
- package/domain/shop-settings/models/types/index.d.ts +6 -1
- package/domain/shop-settings/models/types/shop-banner.type.d.ts +12 -0
- package/domain/shop-settings/models/types/shop-brands.type.d.ts +10 -0
- package/domain/shop-settings/models/types/shop-carousel.type.d.ts +5 -0
- package/domain/shop-settings/models/types/shop-collection.type.d.ts +9 -0
- package/domain/shop-settings/models/types/shop-section.type.d.ts +9 -0
- package/domain/shop-settings/repositories/index.d.ts +1 -0
- package/domain/shop-settings/repositories/shop-settings.repository.d.ts +4 -0
- package/domain/shopping/models/buy-2-win.d.ts +3 -1
- package/domain/shopping/models/campaign-dashboard.d.ts +15 -0
- package/domain/shopping/models/campaign-hashtag.d.ts +18 -0
- package/domain/shopping/models/index.d.ts +5 -4
- package/domain/shopping/repositories/campaign-dashboard.repository.d.ts +4 -0
- package/domain/shopping/repositories/campaign-hashtag.repository.d.ts +4 -0
- package/domain/shopping/repositories/index.d.ts +4 -2
- package/esm2020/domain/catalog/models/category-filter.mjs +14 -0
- package/esm2020/domain/catalog/models/category.mjs +8 -1
- package/esm2020/domain/catalog/models/filter-option.mjs +10 -0
- package/esm2020/domain/catalog/models/filter.mjs +10 -0
- package/esm2020/domain/catalog/models/index.mjs +4 -1
- package/esm2020/domain/catalog/models/product.mjs +1 -1
- package/esm2020/domain/catalog/models/types/index.mjs +1 -2
- package/esm2020/domain/catalog/repositories/category-filter.repository.mjs +2 -0
- package/esm2020/domain/catalog/repositories/category.repository.mjs +1 -1
- package/esm2020/domain/catalog/repositories/filter-option.repository.mjs +2 -0
- package/esm2020/domain/catalog/repositories/filter.repository.mjs +2 -0
- package/esm2020/domain/catalog/repositories/index.mjs +4 -1
- package/esm2020/domain/catalog/repositories/product.repository.mjs +1 -1
- package/esm2020/domain/generic/repository/find.repository.mjs +1 -1
- package/esm2020/domain/shop-settings/models/index.mjs +2 -1
- package/esm2020/domain/shop-settings/models/shop-settings.mjs +7 -0
- package/esm2020/domain/shop-settings/models/types/index.mjs +7 -2
- package/esm2020/domain/shop-settings/models/types/shop-banner.type.mjs +2 -0
- package/esm2020/domain/shop-settings/models/types/shop-brands.type.mjs +2 -0
- package/esm2020/domain/shop-settings/models/types/shop-carousel.type.mjs +2 -0
- package/esm2020/domain/shop-settings/models/types/shop-collection.type.mjs +2 -0
- package/esm2020/domain/shop-settings/models/types/shop-section.type.mjs +2 -0
- package/esm2020/domain/shop-settings/repositories/index.mjs +2 -1
- package/esm2020/domain/shop-settings/repositories/shop-settings.repository.mjs +2 -0
- package/esm2020/domain/shopping/models/buy-2-win.mjs +2 -2
- package/esm2020/domain/shopping/models/campaign-dashboard.mjs +7 -0
- package/esm2020/domain/shopping/models/campaign-hashtag.mjs +7 -0
- package/esm2020/domain/shopping/models/index.mjs +6 -5
- package/esm2020/domain/shopping/repositories/campaign-dashboard.repository.mjs +2 -0
- package/esm2020/domain/shopping/repositories/campaign-hashtag.repository.mjs +2 -0
- package/esm2020/domain/shopping/repositories/index.mjs +5 -3
- package/esm2020/infra/elasticsearch/indexes/products-index.mjs +2 -1
- package/esm2020/infra/firebase/firestore/mixins/with-find-firestore.mixin.mjs +3 -2
- package/esm2020/infra/firebase/firestore/mixins/with-firestore.mixin.mjs +3 -1
- package/esm2020/infra/firebase/firestore/repositories/catalog/category-firestore.repository.mjs +5 -3
- package/esm2020/infra/firebase/firestore/repositories/catalog/product-firestore.repository.mjs +4 -1
- package/esm2020/infra/firebase/firestore/repositories/shop-settings/index.mjs +2 -1
- package/esm2020/infra/firebase/firestore/repositories/shop-settings/shop-settings-firestore.repository.mjs +14 -0
- package/esm2020/infra/firebase/firestore/repositories/shopping/campaign-dashboard-firestore.repository.mjs +14 -0
- package/esm2020/infra/firebase/firestore/repositories/shopping/campaign-hashtag-firestore.repository.mjs +14 -0
- package/esm2020/infra/firebase/firestore/repositories/shopping/index.mjs +6 -4
- package/esm2020/infra/hasura-graphql/mixins/helpers/attribute-option.helper.mjs +2 -2
- package/esm2020/infra/hasura-graphql/mixins/helpers/graphql-field.helper.mjs +5 -2
- package/esm2020/infra/hasura-graphql/mixins/with-find-hasura-graphql.mixin.mjs +16 -12
- package/esm2020/infra/hasura-graphql/mixins/with-hasura-graphql.mixin.mjs +5 -3
- package/esm2020/infra/hasura-graphql/repositories/catalog/category-filter-hasura-graphql.repository.mjs +55 -0
- package/esm2020/infra/hasura-graphql/repositories/catalog/category-hasura-graphql.repository.mjs +94 -12
- package/esm2020/infra/hasura-graphql/repositories/catalog/filter-hasura-graphql.repository.mjs +104 -0
- package/esm2020/infra/hasura-graphql/repositories/catalog/filter-option-hasura-graphql.repository.mjs +21 -0
- package/esm2020/infra/hasura-graphql/repositories/catalog/index.mjs +4 -1
- package/esm2020/infra/hasura-graphql/repositories/catalog/product-hasura-graphql.repository.mjs +21 -4
- package/esm2020/infra/hasura-graphql/repositories/catalog/variant-hasura-graphql.repository.mjs +2 -2
- package/esm2020/infra/hasura-graphql/types/hasura-graphql-fields.type.mjs +1 -1
- package/fesm2015/infrab4a-connect.mjs +473 -89
- package/fesm2015/infrab4a-connect.mjs.map +1 -1
- package/fesm2020/infrab4a-connect.mjs +454 -83
- package/fesm2020/infrab4a-connect.mjs.map +1 -1
- package/infra/firebase/firestore/repositories/catalog/category-firestore.repository.d.ts +2 -1
- package/infra/firebase/firestore/repositories/catalog/product-firestore.repository.d.ts +1 -0
- package/infra/firebase/firestore/repositories/shop-settings/index.d.ts +1 -0
- package/infra/firebase/firestore/repositories/shop-settings/shop-settings-firestore.repository.d.ts +7 -0
- package/infra/firebase/firestore/repositories/shopping/campaign-dashboard-firestore.repository.d.ts +8 -0
- package/infra/firebase/firestore/repositories/shopping/campaign-hashtag-firestore.repository.d.ts +8 -0
- package/infra/firebase/firestore/repositories/shopping/index.d.ts +5 -3
- package/infra/hasura-graphql/mixins/with-find-hasura-graphql.mixin.d.ts +4 -9
- package/infra/hasura-graphql/repositories/catalog/category-filter-hasura-graphql.repository.d.ts +11 -0
- package/infra/hasura-graphql/repositories/catalog/category-hasura-graphql.repository.d.ts +6 -2
- package/infra/hasura-graphql/repositories/catalog/filter-hasura-graphql.repository.d.ts +18 -0
- package/infra/hasura-graphql/repositories/catalog/filter-option-hasura-graphql.repository.d.ts +10 -0
- package/infra/hasura-graphql/repositories/catalog/index.d.ts +3 -0
- package/infra/hasura-graphql/repositories/catalog/product-hasura-graphql.repository.d.ts +1 -0
- package/infra/hasura-graphql/types/hasura-graphql-fields.type.d.ts +1 -1
- package/package.json +1 -1
- package/domain/catalog/models/types/category-filter.type.d.ts +0 -4
- package/esm2020/domain/catalog/models/types/category-filter.type.mjs +0 -2
|
@@ -759,6 +759,15 @@ class RecoveryPassword {
|
|
|
759
759
|
}
|
|
760
760
|
}
|
|
761
761
|
|
|
762
|
+
class Filter extends BaseModel {
|
|
763
|
+
identifierFields() {
|
|
764
|
+
return ['id'];
|
|
765
|
+
}
|
|
766
|
+
static get identifiersFields() {
|
|
767
|
+
return ['id'];
|
|
768
|
+
}
|
|
769
|
+
}
|
|
770
|
+
|
|
762
771
|
class Category extends BaseModel {
|
|
763
772
|
identifierFields() {
|
|
764
773
|
return ['id'];
|
|
@@ -767,6 +776,20 @@ class Category extends BaseModel {
|
|
|
767
776
|
return ['id'];
|
|
768
777
|
}
|
|
769
778
|
}
|
|
779
|
+
__decorate([
|
|
780
|
+
Type(() => Filter),
|
|
781
|
+
__metadata("design:type", Array)
|
|
782
|
+
], Category.prototype, "filters", void 0);
|
|
783
|
+
|
|
784
|
+
class CategoryFilter extends BaseModel {
|
|
785
|
+
static get identifiersFields() {
|
|
786
|
+
return ['id'];
|
|
787
|
+
}
|
|
788
|
+
}
|
|
789
|
+
__decorate([
|
|
790
|
+
Type(() => Filter),
|
|
791
|
+
__metadata("design:type", Filter)
|
|
792
|
+
], CategoryFilter.prototype, "filter", void 0);
|
|
770
793
|
|
|
771
794
|
var GenderDestination;
|
|
772
795
|
(function (GenderDestination) {
|
|
@@ -783,6 +806,15 @@ var Shops;
|
|
|
783
806
|
Shops["ALL"] = "ALL";
|
|
784
807
|
})(Shops || (Shops = {}));
|
|
785
808
|
|
|
809
|
+
class FilterOption extends BaseModel {
|
|
810
|
+
identifierFields() {
|
|
811
|
+
return ['id'];
|
|
812
|
+
}
|
|
813
|
+
static get identifiersFields() {
|
|
814
|
+
return ['id'];
|
|
815
|
+
}
|
|
816
|
+
}
|
|
817
|
+
|
|
786
818
|
class Product extends BaseModel {
|
|
787
819
|
identifierFields() {
|
|
788
820
|
return ['id'];
|
|
@@ -819,17 +851,27 @@ class Variant extends BaseModel {
|
|
|
819
851
|
}
|
|
820
852
|
}
|
|
821
853
|
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
854
|
+
class Buy2Win extends BaseModel {
|
|
855
|
+
static get identifiersFields() {
|
|
856
|
+
return ['id'];
|
|
857
|
+
}
|
|
858
|
+
}
|
|
859
|
+
__decorate([
|
|
860
|
+
Type(() => Category),
|
|
861
|
+
__metadata("design:type", Array)
|
|
862
|
+
], Buy2Win.prototype, "categories", void 0);
|
|
863
|
+
|
|
864
|
+
class CampaignDashboard extends BaseModel {
|
|
865
|
+
static get identifiersFields() {
|
|
866
|
+
return ['id'];
|
|
867
|
+
}
|
|
868
|
+
}
|
|
869
|
+
|
|
870
|
+
class CampaignHashtag extends BaseModel {
|
|
871
|
+
static get identifiersFields() {
|
|
872
|
+
return ['id'];
|
|
873
|
+
}
|
|
874
|
+
}
|
|
833
875
|
|
|
834
876
|
class LineItem extends Product {
|
|
835
877
|
}
|
|
@@ -870,6 +912,18 @@ __decorate([
|
|
|
870
912
|
__metadata("design:type", Coupon)
|
|
871
913
|
], Checkout.prototype, "coupon", void 0);
|
|
872
914
|
|
|
915
|
+
var OrderStatus;
|
|
916
|
+
(function (OrderStatus) {
|
|
917
|
+
OrderStatus["AGUARDANDO_PAGAMENTO"] = "Aguardando pagamento";
|
|
918
|
+
OrderStatus["EM_PREPARO"] = "Preparando pedido";
|
|
919
|
+
OrderStatus["NF_EMITIDA"] = "Nota Fiscal Emitida";
|
|
920
|
+
OrderStatus["AGUARDANDO_ENVIO"] = "Aguardando Transaportadora";
|
|
921
|
+
OrderStatus["ENVIADO"] = "Enviado";
|
|
922
|
+
OrderStatus["ENTREGUE"] = "Entregue";
|
|
923
|
+
OrderStatus["CANCELADO"] = "Cancelado";
|
|
924
|
+
OrderStatus["CREDIT_CARD"] = "credit_card";
|
|
925
|
+
})(OrderStatus || (OrderStatus = {}));
|
|
926
|
+
|
|
873
927
|
class Order extends Checkout {
|
|
874
928
|
}
|
|
875
929
|
__decorate([
|
|
@@ -899,16 +953,6 @@ __decorate([
|
|
|
899
953
|
__metadata("design:type", Coupon)
|
|
900
954
|
], CheckoutSubscription.prototype, "coupon", void 0);
|
|
901
955
|
|
|
902
|
-
class Buy2Win extends BaseModel {
|
|
903
|
-
static get identifiersFields() {
|
|
904
|
-
return ['id'];
|
|
905
|
-
}
|
|
906
|
-
}
|
|
907
|
-
__decorate([
|
|
908
|
-
Type(() => Category),
|
|
909
|
-
__metadata("design:type", Array)
|
|
910
|
-
], Buy2Win.prototype, "categories", void 0);
|
|
911
|
-
|
|
912
956
|
var FilterType;
|
|
913
957
|
(function (FilterType) {
|
|
914
958
|
FilterType["ACCESSORY_IMPORTANCE"] = "accessoryImportance";
|
|
@@ -1008,6 +1052,12 @@ class ShopMenu extends BaseModel {
|
|
|
1008
1052
|
}
|
|
1009
1053
|
}
|
|
1010
1054
|
|
|
1055
|
+
class ShopSettings extends BaseModel {
|
|
1056
|
+
static get identifiersFields() {
|
|
1057
|
+
return ['id'];
|
|
1058
|
+
}
|
|
1059
|
+
}
|
|
1060
|
+
|
|
1011
1061
|
class InvalidArgumentError extends CustomError {
|
|
1012
1062
|
constructor(message) {
|
|
1013
1063
|
super(message);
|
|
@@ -1107,6 +1157,7 @@ class ProductsIndex {
|
|
|
1107
1157
|
'stock',
|
|
1108
1158
|
'weight',
|
|
1109
1159
|
'tags',
|
|
1160
|
+
'filters',
|
|
1110
1161
|
'hasVariants',
|
|
1111
1162
|
'type',
|
|
1112
1163
|
];
|
|
@@ -1202,6 +1253,8 @@ const withFirestore = (MixinBase) => {
|
|
|
1202
1253
|
constructor(...params) {
|
|
1203
1254
|
const options = params[0];
|
|
1204
1255
|
super(...params);
|
|
1256
|
+
this.fields = {};
|
|
1257
|
+
this.interceptors = {};
|
|
1205
1258
|
this.collectionName = '';
|
|
1206
1259
|
this.firestore = options.firestore;
|
|
1207
1260
|
this.collectionName = options.collectionName;
|
|
@@ -1344,6 +1397,7 @@ const withFindFirestore = (MixinBase) => {
|
|
|
1344
1397
|
}
|
|
1345
1398
|
async find(find = {}) {
|
|
1346
1399
|
const collection = this.collection(this.buildCollectionPathForFind(find.filters));
|
|
1400
|
+
const enableCount = find?.options?.enableCount ?? true;
|
|
1347
1401
|
const intercepted = await this.interceptors?.request?.({ find });
|
|
1348
1402
|
const { filters, limits, orderBy } = intercepted.find || find;
|
|
1349
1403
|
const queries = this.makeFirestoreWhere(filters || {});
|
|
@@ -1354,7 +1408,7 @@ const withFindFirestore = (MixinBase) => {
|
|
|
1354
1408
|
const data = docs.docs.map((doc) => doc.data());
|
|
1355
1409
|
return {
|
|
1356
1410
|
data: (await this.interceptors?.response?.(data, intercepted)) || data,
|
|
1357
|
-
count: this.calculateCount(data, limits),
|
|
1411
|
+
count: enableCount ? this.calculateCount(data, limits) : Infinity,
|
|
1358
1412
|
};
|
|
1359
1413
|
}
|
|
1360
1414
|
buildCollectionPathForFind(filters) {
|
|
@@ -1648,14 +1702,14 @@ class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFire
|
|
|
1648
1702
|
throw new NotFoundError(`Document with slug ${slug} not found`);
|
|
1649
1703
|
return categoryDocs.docs[0].data();
|
|
1650
1704
|
}
|
|
1651
|
-
async getCategoriesForHome(categoryIds, limit = 4) {
|
|
1705
|
+
async getCategoriesForHome(categoryIds, limit = 4, gender) {
|
|
1652
1706
|
const categorySnap = await getDocs(query(this.collection(this.collectionName), where('id', 'in', categoryIds.filter(Boolean)), where('published', '==', true)));
|
|
1653
1707
|
if (categorySnap.empty)
|
|
1654
1708
|
throw new NotFoundError('Categories not found');
|
|
1655
1709
|
const categories = categorySnap.docs.map((doc) => doc.data());
|
|
1656
1710
|
const homeSections = await Promise.all(categories.map(async (category) => ({
|
|
1657
1711
|
category,
|
|
1658
|
-
products: await this.mountCategory(category, { limit, hasStock: true }),
|
|
1712
|
+
products: await this.mountCategory(category, { limit, hasStock: true, gender }),
|
|
1659
1713
|
})));
|
|
1660
1714
|
return homeSections;
|
|
1661
1715
|
}
|
|
@@ -1671,6 +1725,8 @@ class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFire
|
|
|
1671
1725
|
wheres.push(where('published', '==', true), where('id', 'in', productIds));
|
|
1672
1726
|
if (options?.hasStock)
|
|
1673
1727
|
wheres.push(where('stock.quantity', '>', 0));
|
|
1728
|
+
if (options?.gender)
|
|
1729
|
+
wheres.push(where('tags', 'array-contains', options?.gender));
|
|
1674
1730
|
if (options?.limit)
|
|
1675
1731
|
wheres.push(limit(options?.limit));
|
|
1676
1732
|
const productSnap = await getDocs(query(this.collection('productsErpVitrine'), ...wheres));
|
|
@@ -1725,6 +1781,9 @@ class ProductFirestoreRepository extends withCrudFirestore(withHelpers(withFires
|
|
|
1725
1781
|
});
|
|
1726
1782
|
return this.reviews[status];
|
|
1727
1783
|
}
|
|
1784
|
+
cleanShoppingCountFromIds() {
|
|
1785
|
+
return;
|
|
1786
|
+
}
|
|
1728
1787
|
}
|
|
1729
1788
|
|
|
1730
1789
|
class ProductVariantFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), Product) {
|
|
@@ -1751,6 +1810,39 @@ class SubscriptionProductFirestoreRepository extends withCrudFirestore(withHelpe
|
|
|
1751
1810
|
}
|
|
1752
1811
|
}
|
|
1753
1812
|
|
|
1813
|
+
class Buy2WinFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1814
|
+
constructor({ firestore, interceptors }) {
|
|
1815
|
+
super({
|
|
1816
|
+
firestore,
|
|
1817
|
+
collectionName: 'buy2win',
|
|
1818
|
+
model: Buy2Win,
|
|
1819
|
+
interceptors,
|
|
1820
|
+
});
|
|
1821
|
+
}
|
|
1822
|
+
}
|
|
1823
|
+
|
|
1824
|
+
class CampaignDashboardFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1825
|
+
constructor({ firestore, interceptors, }) {
|
|
1826
|
+
super({
|
|
1827
|
+
firestore,
|
|
1828
|
+
collectionName: 'dashboardCampaignsAuto',
|
|
1829
|
+
model: CampaignDashboard,
|
|
1830
|
+
interceptors,
|
|
1831
|
+
});
|
|
1832
|
+
}
|
|
1833
|
+
}
|
|
1834
|
+
|
|
1835
|
+
class CampaignHashtagFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1836
|
+
constructor({ firestore, interceptors, }) {
|
|
1837
|
+
super({
|
|
1838
|
+
firestore,
|
|
1839
|
+
collectionName: 'hashtagCampaignsAuto',
|
|
1840
|
+
model: CampaignHashtag,
|
|
1841
|
+
interceptors,
|
|
1842
|
+
});
|
|
1843
|
+
}
|
|
1844
|
+
}
|
|
1845
|
+
|
|
1754
1846
|
class CheckoutFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1755
1847
|
constructor({ firestore, interceptors }) {
|
|
1756
1848
|
super({
|
|
@@ -1762,6 +1854,17 @@ class CheckoutFirestoreRepository extends withCrudFirestore(withHelpers(withFire
|
|
|
1762
1854
|
}
|
|
1763
1855
|
}
|
|
1764
1856
|
|
|
1857
|
+
class CheckoutSubscriptionFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1858
|
+
constructor({ firestore, interceptors, }) {
|
|
1859
|
+
super({
|
|
1860
|
+
firestore,
|
|
1861
|
+
collectionName: 'checkoutsSubscription',
|
|
1862
|
+
model: CheckoutSubscription,
|
|
1863
|
+
interceptors,
|
|
1864
|
+
});
|
|
1865
|
+
}
|
|
1866
|
+
}
|
|
1867
|
+
|
|
1765
1868
|
class CouponFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1766
1869
|
constructor({ firestore, interceptors }) {
|
|
1767
1870
|
super({
|
|
@@ -1826,23 +1929,22 @@ class OrderFirestoreRepository extends withCrudFirestore(withHelpers(withFiresto
|
|
|
1826
1929
|
}
|
|
1827
1930
|
}
|
|
1828
1931
|
|
|
1829
|
-
class
|
|
1932
|
+
class LegacyOrderFirestoreRepository extends OrderFirestoreRepository {
|
|
1830
1933
|
constructor({ firestore, interceptors }) {
|
|
1831
1934
|
super({
|
|
1832
1935
|
firestore,
|
|
1833
|
-
collectionName: 'payments',
|
|
1834
|
-
model: Payment,
|
|
1835
1936
|
interceptors,
|
|
1836
1937
|
});
|
|
1938
|
+
this.collectionName = 'legacyOrders';
|
|
1837
1939
|
}
|
|
1838
1940
|
}
|
|
1839
1941
|
|
|
1840
|
-
class
|
|
1841
|
-
constructor({ firestore, interceptors
|
|
1942
|
+
class PaymentFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1943
|
+
constructor({ firestore, interceptors }) {
|
|
1842
1944
|
super({
|
|
1843
1945
|
firestore,
|
|
1844
|
-
collectionName: '
|
|
1845
|
-
model:
|
|
1946
|
+
collectionName: 'payments',
|
|
1947
|
+
model: Payment,
|
|
1846
1948
|
interceptors,
|
|
1847
1949
|
});
|
|
1848
1950
|
}
|
|
@@ -1859,27 +1961,6 @@ class SubscriptionPlanFirestoreRepository extends withCrudFirestore(withHelpers(
|
|
|
1859
1961
|
}
|
|
1860
1962
|
}
|
|
1861
1963
|
|
|
1862
|
-
class Buy2WinFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1863
|
-
constructor({ firestore, interceptors }) {
|
|
1864
|
-
super({
|
|
1865
|
-
firestore,
|
|
1866
|
-
collectionName: 'buy2win',
|
|
1867
|
-
model: Buy2Win,
|
|
1868
|
-
interceptors,
|
|
1869
|
-
});
|
|
1870
|
-
}
|
|
1871
|
-
}
|
|
1872
|
-
|
|
1873
|
-
class LegacyOrderFirestoreRepository extends OrderFirestoreRepository {
|
|
1874
|
-
constructor({ firestore, interceptors }) {
|
|
1875
|
-
super({
|
|
1876
|
-
firestore,
|
|
1877
|
-
interceptors,
|
|
1878
|
-
});
|
|
1879
|
-
this.collectionName = 'legacyOrders';
|
|
1880
|
-
}
|
|
1881
|
-
}
|
|
1882
|
-
|
|
1883
1964
|
class HomeFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1884
1965
|
constructor({ firestore, interceptors }) {
|
|
1885
1966
|
super({
|
|
@@ -1943,6 +2024,17 @@ class ShopMenuFirestoreRepository extends withCrudFirestore(withHelpers(withFire
|
|
|
1943
2024
|
}
|
|
1944
2025
|
}
|
|
1945
2026
|
|
|
2027
|
+
class ShopSettingsFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
2028
|
+
constructor({ firestore, interceptors, }) {
|
|
2029
|
+
super({
|
|
2030
|
+
firestore,
|
|
2031
|
+
collectionName: 'shopSettings',
|
|
2032
|
+
model: ShopSettings,
|
|
2033
|
+
interceptors,
|
|
2034
|
+
});
|
|
2035
|
+
}
|
|
2036
|
+
}
|
|
2037
|
+
|
|
1946
2038
|
class AuthenticationFirebaseAuthService {
|
|
1947
2039
|
constructor(firebaseAuth) {
|
|
1948
2040
|
this.firebaseAuth = firebaseAuth;
|
|
@@ -2016,7 +2108,7 @@ class AttributeOptionHelper {
|
|
|
2016
2108
|
}
|
|
2017
2109
|
AttributeOptionHelper.FindByAttribute = (attributeName, fields) => {
|
|
2018
2110
|
if (fields.includes(attributeName))
|
|
2019
|
-
return { columnName: attributeName.toString(), attributeName };
|
|
2111
|
+
return { columnName: attributeName.toString(), attributeName, to: (value) => value, from: (value) => value };
|
|
2020
2112
|
const field = fields.find((columnOption) => isObject(columnOption) && Object.keys(columnOption).includes(attributeName.toString()));
|
|
2021
2113
|
const fieldOption = is(field)?.[attributeName];
|
|
2022
2114
|
if (isNil(fieldOption))
|
|
@@ -2218,7 +2310,10 @@ GraphQLFieldHelper.ConvertFieldValueFrom = (data, fields) => Object.keys(data).r
|
|
|
2218
2310
|
}
|
|
2219
2311
|
if (!!from)
|
|
2220
2312
|
return { ...result, [attributeName]: from(data[columnName], data) };
|
|
2221
|
-
return {
|
|
2313
|
+
return {
|
|
2314
|
+
...result,
|
|
2315
|
+
[attributeName]: isString(data[columnName]) ? parseDateTime(data[columnName].toString()) : data[columnName],
|
|
2316
|
+
};
|
|
2222
2317
|
}, {});
|
|
2223
2318
|
GraphQLFieldHelper.ConvertFieldValueTo = (instance, fields, update = false) => {
|
|
2224
2319
|
const data = instance.toPlain?.() || instance;
|
|
@@ -2372,10 +2467,12 @@ const withHasuraGraphQL = (MixinBase) => {
|
|
|
2372
2467
|
}
|
|
2373
2468
|
async fetch(params) {
|
|
2374
2469
|
const headers = this.headers;
|
|
2375
|
-
const
|
|
2470
|
+
const { data: result } = await axios({
|
|
2471
|
+
url: `${this.endpoint}`,
|
|
2472
|
+
method: 'POST',
|
|
2473
|
+
data: params,
|
|
2376
2474
|
headers,
|
|
2377
2475
|
});
|
|
2378
|
-
const result = await response.data;
|
|
2379
2476
|
if (!isNil(result.errors))
|
|
2380
2477
|
throw new Error(JSON.stringify(result.errors));
|
|
2381
2478
|
return result.data;
|
|
@@ -2517,8 +2614,9 @@ const withGetHasuraGraphQL = (MixinBase) => {
|
|
|
2517
2614
|
|
|
2518
2615
|
const withFindHasuraGraphQL = (MixinBase) => {
|
|
2519
2616
|
return class FindHasuraGraphQLMixin extends MixinBase {
|
|
2520
|
-
async find(
|
|
2521
|
-
const { filters, limits, orderBy } =
|
|
2617
|
+
async find(params) {
|
|
2618
|
+
const { filters, limits, orderBy, options } = params || {};
|
|
2619
|
+
const enableCount = options?.enableCount ?? true;
|
|
2522
2620
|
const variablesCount = {
|
|
2523
2621
|
...(isNil(orderBy) ? {} : { order_by: { type: `${this.tableName}_order_by!`, list: true, value: orderBy } }),
|
|
2524
2622
|
...(isNil(filters)
|
|
@@ -2538,23 +2636,26 @@ const withFindHasuraGraphQL = (MixinBase) => {
|
|
|
2538
2636
|
const result = await this.query([
|
|
2539
2637
|
{
|
|
2540
2638
|
operation: this.tableName,
|
|
2541
|
-
fields:
|
|
2542
|
-
?
|
|
2639
|
+
fields: params.fields
|
|
2640
|
+
? params.fields
|
|
2543
2641
|
.map((fieldName) => this.fields.find((fieldOption) => fieldOption === fieldName) ??
|
|
2544
2642
|
this.fields.find((fieldOption) => Object.keys(fieldOption).shift() === fieldName))
|
|
2545
2643
|
.filter(Boolean)
|
|
2546
2644
|
: this.fields,
|
|
2547
2645
|
variables,
|
|
2548
2646
|
},
|
|
2549
|
-
|
|
2550
|
-
|
|
2551
|
-
|
|
2552
|
-
|
|
2553
|
-
|
|
2647
|
+
...(enableCount
|
|
2648
|
+
? [
|
|
2649
|
+
{
|
|
2650
|
+
operation: `${this.tableName}_aggregate`,
|
|
2651
|
+
fields: [{ aggregate: ['count'] }],
|
|
2652
|
+
variables: variablesCount,
|
|
2653
|
+
},
|
|
2654
|
+
]
|
|
2655
|
+
: []),
|
|
2554
2656
|
]);
|
|
2555
2657
|
const data = result[this.tableName].map((row) => this.convertDataFromHasura(row));
|
|
2556
|
-
|
|
2557
|
-
return { count, data };
|
|
2658
|
+
return { data, count: enableCount ? result[`${this.tableName}_aggregate`].aggregate.count : Infinity };
|
|
2558
2659
|
}
|
|
2559
2660
|
};
|
|
2560
2661
|
};
|
|
@@ -2593,8 +2694,60 @@ class VariantHasuraGraphQL extends Variant {
|
|
|
2593
2694
|
}
|
|
2594
2695
|
}
|
|
2595
2696
|
|
|
2697
|
+
class CategoryFilterHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
2698
|
+
constructor(endpoint, authOptions) {
|
|
2699
|
+
super({
|
|
2700
|
+
tableName: 'category_filter',
|
|
2701
|
+
model: CategoryFilter,
|
|
2702
|
+
endpoint,
|
|
2703
|
+
authOptions,
|
|
2704
|
+
fields: [
|
|
2705
|
+
'id',
|
|
2706
|
+
{ filterId: { columnName: 'filter_id' } },
|
|
2707
|
+
{ categoryId: { columnName: 'category_id' } },
|
|
2708
|
+
{
|
|
2709
|
+
filter: {
|
|
2710
|
+
columnName: 'filter',
|
|
2711
|
+
foreignKeyColumn: { id: 'filterId' },
|
|
2712
|
+
fields: [
|
|
2713
|
+
'id',
|
|
2714
|
+
'description',
|
|
2715
|
+
'slug',
|
|
2716
|
+
'enabled',
|
|
2717
|
+
{ createdAt: { columnName: 'created_at' } },
|
|
2718
|
+
{ updatedAt: { columnName: 'updated_at' } },
|
|
2719
|
+
{
|
|
2720
|
+
options: {
|
|
2721
|
+
columnName: 'options',
|
|
2722
|
+
foreignKeyColumn: { filterId: 'id' },
|
|
2723
|
+
fields: [
|
|
2724
|
+
'id',
|
|
2725
|
+
{ filterId: { columnName: 'filter_id' } },
|
|
2726
|
+
'description',
|
|
2727
|
+
{ createdAt: { columnName: 'created_at' } },
|
|
2728
|
+
{ updatedAt: { columnName: 'updated_at' } },
|
|
2729
|
+
],
|
|
2730
|
+
},
|
|
2731
|
+
},
|
|
2732
|
+
],
|
|
2733
|
+
},
|
|
2734
|
+
},
|
|
2735
|
+
],
|
|
2736
|
+
});
|
|
2737
|
+
}
|
|
2738
|
+
deleteByCategoryAndFilter(categoryId, filterId) {
|
|
2739
|
+
return this.mutation('delete_category_filter', ['affected_rows'], {
|
|
2740
|
+
where: {
|
|
2741
|
+
type: 'category_filter_bool_exp',
|
|
2742
|
+
required: true,
|
|
2743
|
+
value: { category_id: { _eq: categoryId }, filter_id: { _eq: filterId } },
|
|
2744
|
+
},
|
|
2745
|
+
});
|
|
2746
|
+
}
|
|
2747
|
+
}
|
|
2748
|
+
|
|
2596
2749
|
class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
2597
|
-
constructor({ endpoint, authOptions, interceptors, }, productRepository) {
|
|
2750
|
+
constructor({ endpoint, authOptions, interceptors, }, productRepository, categoryFilterRepository) {
|
|
2598
2751
|
super({
|
|
2599
2752
|
tableName: 'category',
|
|
2600
2753
|
model: Category,
|
|
@@ -2637,7 +2790,17 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
2637
2790
|
},
|
|
2638
2791
|
},
|
|
2639
2792
|
},
|
|
2640
|
-
|
|
2793
|
+
{
|
|
2794
|
+
filters: {
|
|
2795
|
+
columnName: 'filters',
|
|
2796
|
+
foreignKeyColumn: { filter_id: 'id' },
|
|
2797
|
+
fields: [{ filter: ['id', 'description', 'slug', 'enabled'] }],
|
|
2798
|
+
bindPersistData: (value) => ({
|
|
2799
|
+
filters: { data: value.map((filter) => ({ filter_id: filter.id })) },
|
|
2800
|
+
}),
|
|
2801
|
+
from: (filters) => filters?.map((filter) => filter?.filter) || [],
|
|
2802
|
+
},
|
|
2803
|
+
},
|
|
2641
2804
|
{ createdAt: { columnName: 'created_at' } },
|
|
2642
2805
|
{ updatedAt: { columnName: 'updated_at' } },
|
|
2643
2806
|
{
|
|
@@ -2662,6 +2825,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
2662
2825
|
],
|
|
2663
2826
|
});
|
|
2664
2827
|
this.productRepository = productRepository;
|
|
2828
|
+
this.categoryFilterRepository = categoryFilterRepository;
|
|
2665
2829
|
}
|
|
2666
2830
|
async create(params) {
|
|
2667
2831
|
const { metadata, ...data } = params;
|
|
@@ -2669,29 +2833,30 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
2669
2833
|
}
|
|
2670
2834
|
async get(identifiers) {
|
|
2671
2835
|
return Number.isNaN(+identifiers.id)
|
|
2672
|
-
? (await this.find({ filters: { firestoreId: identifiers.id } })).data?.[0]
|
|
2836
|
+
? (await this.find({ filters: { firestoreId: identifiers.id }, options: { enableCount: false } })).data?.[0]
|
|
2673
2837
|
: super.get(identifiers);
|
|
2674
2838
|
}
|
|
2675
2839
|
async update(params) {
|
|
2676
|
-
const { products, id: checkId, metadata, ...data } = params;
|
|
2840
|
+
const { products, id: checkId, metadata, filters, ...data } = params;
|
|
2677
2841
|
const plainData = this.paramsToPlain({ id: checkId });
|
|
2678
2842
|
const id = await this.getId(plainData.id);
|
|
2679
2843
|
const category = await super.update({ id, ...data });
|
|
2680
2844
|
category.products = products && (await this.updateProducts(+id, { products }));
|
|
2681
2845
|
category.metadata = metadata && (await this.updateMetadata(+id, { metadata }));
|
|
2846
|
+
category.filters = filters && (await this.updateFilters(+id, { filters }));
|
|
2682
2847
|
return category;
|
|
2683
2848
|
}
|
|
2684
2849
|
async getCategoryBySlug(slug, shop) {
|
|
2685
2850
|
if (!slug)
|
|
2686
2851
|
return null;
|
|
2687
|
-
const { data
|
|
2688
|
-
if (
|
|
2689
|
-
throw new DuplicatedResultsError('Query returned duplicated values');
|
|
2690
|
-
if (!count)
|
|
2852
|
+
const { data } = await this.find({ filters: { slug, shop, published: true }, options: { enableCount: false } });
|
|
2853
|
+
if (!data.length)
|
|
2691
2854
|
throw new NotFoundError(`Category with slug ${slug} not found`);
|
|
2855
|
+
if (data.length > 1)
|
|
2856
|
+
throw new DuplicatedResultsError('Query returned duplicated values');
|
|
2692
2857
|
return data.shift();
|
|
2693
2858
|
}
|
|
2694
|
-
async getCategoriesForHome(categoryIds, limit = 4) {
|
|
2859
|
+
async getCategoriesForHome(categoryIds, limit = 4, gender) {
|
|
2695
2860
|
if (!categoryIds?.length)
|
|
2696
2861
|
return [];
|
|
2697
2862
|
const categoriesFirestore = categoryIds.filter((categoryId) => Number.isNaN(+categoryId));
|
|
@@ -2709,7 +2874,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
2709
2874
|
return [];
|
|
2710
2875
|
const homeSections = await Promise.all(categories.map(async (category) => ({
|
|
2711
2876
|
category,
|
|
2712
|
-
products: await this.mountCategory(category, { limit, hasStock: true }),
|
|
2877
|
+
products: await this.mountCategory(category, { limit, hasStock: true, gender }),
|
|
2713
2878
|
})));
|
|
2714
2879
|
return homeSections;
|
|
2715
2880
|
}
|
|
@@ -2722,6 +2887,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
2722
2887
|
id: { operator: Where.IN, value: category.products },
|
|
2723
2888
|
published: true,
|
|
2724
2889
|
...(options?.hasStock ? { stock: { quantity: { operator: Where.GT, value: 0 } } } : {}),
|
|
2890
|
+
...(options?.gender ? { tags: { operator: Where.IN, value: [options?.gender] } } : {}),
|
|
2725
2891
|
},
|
|
2726
2892
|
fields: [
|
|
2727
2893
|
'id',
|
|
@@ -2747,8 +2913,10 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
2747
2913
|
'tags',
|
|
2748
2914
|
'type',
|
|
2749
2915
|
'shoppingCount',
|
|
2916
|
+
'gender',
|
|
2750
2917
|
],
|
|
2751
2918
|
...(options?.limit ? { limits: { limit: options?.limit } } : {}),
|
|
2919
|
+
options: { enableCount: false },
|
|
2752
2920
|
});
|
|
2753
2921
|
products.push(...productsData);
|
|
2754
2922
|
return products;
|
|
@@ -2756,7 +2924,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
2756
2924
|
async getId(id) {
|
|
2757
2925
|
if (!Number.isNaN(+id))
|
|
2758
2926
|
return id;
|
|
2759
|
-
const { data } = await this.find({ filters: { firestoreId: id } });
|
|
2927
|
+
const { data } = await this.find({ filters: { firestoreId: id }, options: { enableCount: false } });
|
|
2760
2928
|
if (data?.[0]?.id)
|
|
2761
2929
|
return data?.[0]?.id;
|
|
2762
2930
|
throw new NotFoundError(`Category with id ${id} not found`);
|
|
@@ -2809,6 +2977,192 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
2809
2977
|
});
|
|
2810
2978
|
return plainData.metadata;
|
|
2811
2979
|
}
|
|
2980
|
+
async updateFilters(categoryId, { filters }) {
|
|
2981
|
+
if ('action' in filters && filters.action === 'remove' && filters.value.length) {
|
|
2982
|
+
for (let i = 0; i < filters.value.length; i++) {
|
|
2983
|
+
await this.categoryFilterRepository.deleteByCategoryAndFilter(categoryId, filters.value[i].id);
|
|
2984
|
+
}
|
|
2985
|
+
return [];
|
|
2986
|
+
}
|
|
2987
|
+
if ('action' in filters && filters.action === 'merge' && filters.value.length) {
|
|
2988
|
+
let filtersList = [];
|
|
2989
|
+
for (let i = 0; i < filters.value.length; i++) {
|
|
2990
|
+
try {
|
|
2991
|
+
const hasFilter = await this.categoryFilterRepository
|
|
2992
|
+
.find({
|
|
2993
|
+
filters: {
|
|
2994
|
+
categoryId,
|
|
2995
|
+
filterId: filters.value[i].id,
|
|
2996
|
+
},
|
|
2997
|
+
})
|
|
2998
|
+
.then((data) => data.data.shift()?.filter);
|
|
2999
|
+
if (hasFilter) {
|
|
3000
|
+
filtersList.push(hasFilter);
|
|
3001
|
+
}
|
|
3002
|
+
else {
|
|
3003
|
+
await this.categoryFilterRepository.create({
|
|
3004
|
+
filterId: filters.value[i].id,
|
|
3005
|
+
categoryId,
|
|
3006
|
+
});
|
|
3007
|
+
filtersList.push(filters.value[i]);
|
|
3008
|
+
}
|
|
3009
|
+
}
|
|
3010
|
+
catch (error) {
|
|
3011
|
+
console.log('catch error: ', error);
|
|
3012
|
+
}
|
|
3013
|
+
}
|
|
3014
|
+
return filtersList;
|
|
3015
|
+
}
|
|
3016
|
+
if (Array.isArray(filters) && filters.length) {
|
|
3017
|
+
let filtersList = [];
|
|
3018
|
+
for (let i = 0; i < filters.length; i++) {
|
|
3019
|
+
try {
|
|
3020
|
+
const hasFilter = await this.categoryFilterRepository
|
|
3021
|
+
.find({
|
|
3022
|
+
filters: {
|
|
3023
|
+
categoryId,
|
|
3024
|
+
filterId: filters[i].id,
|
|
3025
|
+
},
|
|
3026
|
+
})
|
|
3027
|
+
.then((data) => data.data.shift()?.filter);
|
|
3028
|
+
if (hasFilter) {
|
|
3029
|
+
filtersList.push(hasFilter);
|
|
3030
|
+
}
|
|
3031
|
+
else {
|
|
3032
|
+
await this.categoryFilterRepository.create({
|
|
3033
|
+
filterId: filters[i].id,
|
|
3034
|
+
categoryId,
|
|
3035
|
+
});
|
|
3036
|
+
filtersList.push(filters[i]);
|
|
3037
|
+
}
|
|
3038
|
+
}
|
|
3039
|
+
catch (error) {
|
|
3040
|
+
console.log('catch error: ', error);
|
|
3041
|
+
}
|
|
3042
|
+
}
|
|
3043
|
+
return filtersList;
|
|
3044
|
+
}
|
|
3045
|
+
return [];
|
|
3046
|
+
}
|
|
3047
|
+
}
|
|
3048
|
+
|
|
3049
|
+
class FilterHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
3050
|
+
constructor(endpoint, authOptions, filterOptionRepository, categoryFilterRepository) {
|
|
3051
|
+
super({
|
|
3052
|
+
tableName: 'filter',
|
|
3053
|
+
model: Filter,
|
|
3054
|
+
endpoint,
|
|
3055
|
+
authOptions,
|
|
3056
|
+
fields: [
|
|
3057
|
+
'id',
|
|
3058
|
+
'description',
|
|
3059
|
+
'slug',
|
|
3060
|
+
'enabled',
|
|
3061
|
+
{ createdAt: { columnName: 'created_at' } },
|
|
3062
|
+
{ updatedAt: { columnName: 'updated_at' } },
|
|
3063
|
+
{
|
|
3064
|
+
options: {
|
|
3065
|
+
columnName: 'options',
|
|
3066
|
+
foreignKeyColumn: { filterId: 'id' },
|
|
3067
|
+
fields: [
|
|
3068
|
+
'id',
|
|
3069
|
+
{ filterId: { columnName: 'filter_id' } },
|
|
3070
|
+
'description',
|
|
3071
|
+
{ createdAt: { columnName: 'created_at' } },
|
|
3072
|
+
{ updatedAt: { columnName: 'updated_at' } },
|
|
3073
|
+
],
|
|
3074
|
+
},
|
|
3075
|
+
},
|
|
3076
|
+
],
|
|
3077
|
+
});
|
|
3078
|
+
this.filterOptionRepository = filterOptionRepository;
|
|
3079
|
+
this.categoryFilterRepository = categoryFilterRepository;
|
|
3080
|
+
}
|
|
3081
|
+
async update(params) {
|
|
3082
|
+
const { options, ...data } = params;
|
|
3083
|
+
const filter = await super.update(data);
|
|
3084
|
+
filter.options = await this.updateOptions(+data.id, { options });
|
|
3085
|
+
return filter;
|
|
3086
|
+
}
|
|
3087
|
+
async updateOptions(filterId, { options }) {
|
|
3088
|
+
if (!options)
|
|
3089
|
+
return [];
|
|
3090
|
+
if ('action' in options && options.action === 'remove' && options.value.length) {
|
|
3091
|
+
for (let i = 0; i < options.value.length; i++) {
|
|
3092
|
+
await this.filterOptionRepository.delete({ id: options.value[i].id });
|
|
3093
|
+
}
|
|
3094
|
+
return [];
|
|
3095
|
+
}
|
|
3096
|
+
if ('action' in options && options.action === 'merge' && options.value.length) {
|
|
3097
|
+
let filterOptions = [];
|
|
3098
|
+
for (let i = 0; i < options.value.length; i++) {
|
|
3099
|
+
try {
|
|
3100
|
+
const hasFilter = await this.filterOptionRepository.get({ id: options.value[i].id });
|
|
3101
|
+
if (hasFilter)
|
|
3102
|
+
filterOptions.push(hasFilter);
|
|
3103
|
+
}
|
|
3104
|
+
catch (error) {
|
|
3105
|
+
const newOption = await this.filterOptionRepository.create({ ...options.value[i], filterId });
|
|
3106
|
+
filterOptions.push(newOption);
|
|
3107
|
+
}
|
|
3108
|
+
}
|
|
3109
|
+
return filterOptions;
|
|
3110
|
+
}
|
|
3111
|
+
if (Array.isArray(options) && options.length) {
|
|
3112
|
+
let filterOptions = [];
|
|
3113
|
+
for (let i = 0; i < options.length; i++) {
|
|
3114
|
+
try {
|
|
3115
|
+
const hasFilter = await this.filterOptionRepository.get({ id: options[i].id });
|
|
3116
|
+
if (hasFilter)
|
|
3117
|
+
filterOptions.push(hasFilter);
|
|
3118
|
+
}
|
|
3119
|
+
catch (error) {
|
|
3120
|
+
const newOption = await this.filterOptionRepository.create({ ...options[i], filterId });
|
|
3121
|
+
filterOptions.push(newOption);
|
|
3122
|
+
}
|
|
3123
|
+
}
|
|
3124
|
+
}
|
|
3125
|
+
return [];
|
|
3126
|
+
}
|
|
3127
|
+
async delete(params) {
|
|
3128
|
+
const { data: categoryFilters } = await this.categoryFilterRepository.find({
|
|
3129
|
+
filters: {
|
|
3130
|
+
filterId: params.id,
|
|
3131
|
+
},
|
|
3132
|
+
});
|
|
3133
|
+
if (categoryFilters.length)
|
|
3134
|
+
throw new Error('Erro: o filtro está associado a uma ou mais categoria(s)');
|
|
3135
|
+
await this.deleteOptions(+params.id);
|
|
3136
|
+
await super.delete({ id: +params.id });
|
|
3137
|
+
return;
|
|
3138
|
+
}
|
|
3139
|
+
async deleteOptions(filterId) {
|
|
3140
|
+
await this.mutation('delete_filter_option', ['affected_rows'], {
|
|
3141
|
+
where: {
|
|
3142
|
+
type: 'filter_option_bool_exp',
|
|
3143
|
+
required: true,
|
|
3144
|
+
value: { filter_id: { _eq: filterId } },
|
|
3145
|
+
},
|
|
3146
|
+
});
|
|
3147
|
+
}
|
|
3148
|
+
}
|
|
3149
|
+
|
|
3150
|
+
class FilterOptionHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
3151
|
+
constructor(endpoint, authOptions) {
|
|
3152
|
+
super({
|
|
3153
|
+
tableName: 'filter_option',
|
|
3154
|
+
model: FilterOption,
|
|
3155
|
+
endpoint,
|
|
3156
|
+
authOptions,
|
|
3157
|
+
fields: [
|
|
3158
|
+
'id',
|
|
3159
|
+
'description',
|
|
3160
|
+
{ filterId: { columnName: 'filter_id' } },
|
|
3161
|
+
{ createdAt: { columnName: 'created_at' } },
|
|
3162
|
+
{ updatedAt: { columnName: 'updated_at' } },
|
|
3163
|
+
],
|
|
3164
|
+
});
|
|
3165
|
+
}
|
|
2812
3166
|
}
|
|
2813
3167
|
|
|
2814
3168
|
class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
@@ -2947,6 +3301,7 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
2947
3301
|
'weight',
|
|
2948
3302
|
'gender',
|
|
2949
3303
|
{ tags: { columnName: 'tags', type: HasuraGraphQLColumnType.Jsonb } },
|
|
3304
|
+
{ filters: { columnName: 'filters', type: HasuraGraphQLColumnType.Jsonb } },
|
|
2950
3305
|
{ isKit: { columnName: 'is_kit' } },
|
|
2951
3306
|
{ createdAt: { columnName: 'created_at' } },
|
|
2952
3307
|
{ updatedAt: { columnName: 'updated_at' } },
|
|
@@ -3038,7 +3393,7 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
3038
3393
|
}
|
|
3039
3394
|
async get(identifiers) {
|
|
3040
3395
|
const product = Number.isNaN(+identifiers.id)
|
|
3041
|
-
? (await this.find({ filters: { firestoreId: identifiers.id } })).data?.[0]
|
|
3396
|
+
? (await this.find({ filters: { firestoreId: identifiers.id }, options: { enableCount: false } })).data?.[0]
|
|
3042
3397
|
: await super.get(identifiers);
|
|
3043
3398
|
if (product.productId)
|
|
3044
3399
|
throw new NotFoundError('Product not found, it is a variant');
|
|
@@ -3062,9 +3417,12 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
3062
3417
|
filters: {
|
|
3063
3418
|
slug,
|
|
3064
3419
|
},
|
|
3420
|
+
fields: this.fields.map((field) => typeof field === 'string' ? field : Object.keys(field).shift()),
|
|
3421
|
+
options: {
|
|
3422
|
+
enableCount: false,
|
|
3423
|
+
},
|
|
3065
3424
|
});
|
|
3066
3425
|
const product = result?.data?.shift();
|
|
3067
|
-
product.reviews = await this.findReviewsByProduct(+product.id);
|
|
3068
3426
|
return product;
|
|
3069
3427
|
}
|
|
3070
3428
|
async update(params) {
|
|
@@ -3214,7 +3572,7 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
3214
3572
|
async getId(id) {
|
|
3215
3573
|
if (!Number.isNaN(+id))
|
|
3216
3574
|
return id;
|
|
3217
|
-
const { data } = await this.find({ filters: { firestoreId: id } });
|
|
3575
|
+
const { data } = await this.find({ filters: { firestoreId: id }, options: { enableCount: false } });
|
|
3218
3576
|
if (data?.[0]?.id)
|
|
3219
3577
|
return data?.[0]?.id;
|
|
3220
3578
|
throw new NotFoundError(`Product with id ${id} not found`);
|
|
@@ -3270,6 +3628,19 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
3270
3628
|
});
|
|
3271
3629
|
return data && data[0] && this.bindReviewToModel(data[0]);
|
|
3272
3630
|
}
|
|
3631
|
+
async cleanShoppingCountFromIds(ids) {
|
|
3632
|
+
return await this.mutation('update_product', ['affected_rows'], {
|
|
3633
|
+
where: {
|
|
3634
|
+
value: { id: { _nin: ids } },
|
|
3635
|
+
type: 'product_bool_exp',
|
|
3636
|
+
required: true,
|
|
3637
|
+
},
|
|
3638
|
+
_set: {
|
|
3639
|
+
value: { shopping_count: 0 },
|
|
3640
|
+
type: 'product_set_input',
|
|
3641
|
+
},
|
|
3642
|
+
});
|
|
3643
|
+
}
|
|
3273
3644
|
}
|
|
3274
3645
|
|
|
3275
3646
|
class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
@@ -3372,7 +3743,7 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
3372
3743
|
async getId(id) {
|
|
3373
3744
|
if (!Number.isNaN(+id))
|
|
3374
3745
|
return id;
|
|
3375
|
-
const { data } = await this.find({ filters: { firestoreId: id } });
|
|
3746
|
+
const { data } = await this.find({ filters: { firestoreId: id }, options: { enableCount: false } });
|
|
3376
3747
|
if (data?.[0]?.id)
|
|
3377
3748
|
return data?.[0]?.id;
|
|
3378
3749
|
throw new NotFoundError(`Product with id ${id} not found`);
|
|
@@ -3383,5 +3754,5 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
3383
3754
|
* Generated bundle index. Do not edit.
|
|
3384
3755
|
*/
|
|
3385
3756
|
|
|
3386
|
-
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, get, is, isUUID, parseDateTime, withCreateFirestore, withCreateHasuraGraphQL, withCrudFirestore, withCrudHasuraGraphQL, withDeleteFirestore, withDeleteHasuraGraphQL, withFindFirestore, withFindHasuraGraphQL, withFirestore, withGetFirestore, withGetHasuraGraphQL, withHasuraGraphQL, withHelpers, withSubCollection, withUpdateFirestore, withUpdateHasuraGraphQL };
|
|
3757
|
+
export { AccessoryImportances, Address, Area, Authentication, AuthenticationFirebaseAuthService, AxiosAdapter, Base, BaseModel, BeardProblems, BeardSizes, BeautyProductImportances, BeautyProfile, BeautyQuestionsHelper, BillingStatus, BodyProblems, BodyShapes, BodyTattoos, Buy2Win, Buy2WinFirestoreRepository, CampaignDashboard, CampaignDashboardFirestoreRepository, CampaignHashtag, CampaignHashtagFirestoreRepository, Category, CategoryFilter, CategoryFilterHasuraGraphQLRepository, CategoryFirestoreRepository, CategoryHasuraGraphQL, CategoryHasuraGraphQLRepository, Checkout, CheckoutFirestoreRepository, CheckoutSubscription, CheckoutSubscriptionFirestoreRepository, CheckoutTypes, Coupon, CouponFirestoreRepository, CouponSubtypes, CouponTypes, DuplicatedResultsError, Edition, EditionStatus, Exclusivities, FaceSkinOilinesses, FaceSkinProblems, FaceSkinTones, FamilyIncomes, Filter, FilterHasuraGraphQLRepository, FilterOption, FilterOptionHasuraGraphQLRepository, 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, ShopSettings, ShopSettingsFirestoreRepository, 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, get, is, isUUID, parseDateTime, withCreateFirestore, withCreateHasuraGraphQL, withCrudFirestore, withCrudHasuraGraphQL, withDeleteFirestore, withDeleteHasuraGraphQL, withFindFirestore, withFindHasuraGraphQL, withFirestore, withGetFirestore, withGetHasuraGraphQL, withHasuraGraphQL, withHelpers, withSubCollection, withUpdateFirestore, withUpdateHasuraGraphQL };
|
|
3387
3758
|
//# sourceMappingURL=infrab4a-connect.mjs.map
|