@infrab4a/connect 4.0.0-beta.14 → 4.0.0-beta.17
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/mixins/with-get-firestore.mixin.mjs +4 -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/with-find-hasura-graphql.mixin.mjs +16 -12
- package/esm2020/infra/hasura-graphql/mixins/with-hasura-graphql.mixin.mjs +12 -7
- 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 +481 -89
- package/fesm2015/infrab4a-connect.mjs.map +1 -1
- package/fesm2020/infrab4a-connect.mjs +460 -86
- 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
|
@@ -754,6 +754,15 @@ class RecoveryPassword {
|
|
|
754
754
|
}
|
|
755
755
|
}
|
|
756
756
|
|
|
757
|
+
class Filter extends BaseModel {
|
|
758
|
+
identifierFields() {
|
|
759
|
+
return ['id'];
|
|
760
|
+
}
|
|
761
|
+
static get identifiersFields() {
|
|
762
|
+
return ['id'];
|
|
763
|
+
}
|
|
764
|
+
}
|
|
765
|
+
|
|
757
766
|
class Category extends BaseModel {
|
|
758
767
|
identifierFields() {
|
|
759
768
|
return ['id'];
|
|
@@ -762,6 +771,20 @@ class Category extends BaseModel {
|
|
|
762
771
|
return ['id'];
|
|
763
772
|
}
|
|
764
773
|
}
|
|
774
|
+
__decorate([
|
|
775
|
+
Type(() => Filter),
|
|
776
|
+
__metadata("design:type", Array)
|
|
777
|
+
], Category.prototype, "filters", void 0);
|
|
778
|
+
|
|
779
|
+
class CategoryFilter extends BaseModel {
|
|
780
|
+
static get identifiersFields() {
|
|
781
|
+
return ['id'];
|
|
782
|
+
}
|
|
783
|
+
}
|
|
784
|
+
__decorate([
|
|
785
|
+
Type(() => Filter),
|
|
786
|
+
__metadata("design:type", Filter)
|
|
787
|
+
], CategoryFilter.prototype, "filter", void 0);
|
|
765
788
|
|
|
766
789
|
var GenderDestination;
|
|
767
790
|
(function (GenderDestination) {
|
|
@@ -778,6 +801,15 @@ var Shops;
|
|
|
778
801
|
Shops["ALL"] = "ALL";
|
|
779
802
|
})(Shops || (Shops = {}));
|
|
780
803
|
|
|
804
|
+
class FilterOption extends BaseModel {
|
|
805
|
+
identifierFields() {
|
|
806
|
+
return ['id'];
|
|
807
|
+
}
|
|
808
|
+
static get identifiersFields() {
|
|
809
|
+
return ['id'];
|
|
810
|
+
}
|
|
811
|
+
}
|
|
812
|
+
|
|
781
813
|
class Product extends BaseModel {
|
|
782
814
|
identifierFields() {
|
|
783
815
|
return ['id'];
|
|
@@ -814,17 +846,27 @@ class Variant extends BaseModel {
|
|
|
814
846
|
}
|
|
815
847
|
}
|
|
816
848
|
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
849
|
+
class Buy2Win extends BaseModel {
|
|
850
|
+
static get identifiersFields() {
|
|
851
|
+
return ['id'];
|
|
852
|
+
}
|
|
853
|
+
}
|
|
854
|
+
__decorate([
|
|
855
|
+
Type(() => Category),
|
|
856
|
+
__metadata("design:type", Array)
|
|
857
|
+
], Buy2Win.prototype, "categories", void 0);
|
|
858
|
+
|
|
859
|
+
class CampaignDashboard extends BaseModel {
|
|
860
|
+
static get identifiersFields() {
|
|
861
|
+
return ['id'];
|
|
862
|
+
}
|
|
863
|
+
}
|
|
864
|
+
|
|
865
|
+
class CampaignHashtag extends BaseModel {
|
|
866
|
+
static get identifiersFields() {
|
|
867
|
+
return ['id'];
|
|
868
|
+
}
|
|
869
|
+
}
|
|
828
870
|
|
|
829
871
|
class LineItem extends Product {
|
|
830
872
|
}
|
|
@@ -865,6 +907,18 @@ __decorate([
|
|
|
865
907
|
__metadata("design:type", Coupon)
|
|
866
908
|
], Checkout.prototype, "coupon", void 0);
|
|
867
909
|
|
|
910
|
+
var OrderStatus;
|
|
911
|
+
(function (OrderStatus) {
|
|
912
|
+
OrderStatus["AGUARDANDO_PAGAMENTO"] = "Aguardando pagamento";
|
|
913
|
+
OrderStatus["EM_PREPARO"] = "Preparando pedido";
|
|
914
|
+
OrderStatus["NF_EMITIDA"] = "Nota Fiscal Emitida";
|
|
915
|
+
OrderStatus["AGUARDANDO_ENVIO"] = "Aguardando Transaportadora";
|
|
916
|
+
OrderStatus["ENVIADO"] = "Enviado";
|
|
917
|
+
OrderStatus["ENTREGUE"] = "Entregue";
|
|
918
|
+
OrderStatus["CANCELADO"] = "Cancelado";
|
|
919
|
+
OrderStatus["CREDIT_CARD"] = "credit_card";
|
|
920
|
+
})(OrderStatus || (OrderStatus = {}));
|
|
921
|
+
|
|
868
922
|
class Order extends Checkout {
|
|
869
923
|
}
|
|
870
924
|
__decorate([
|
|
@@ -894,16 +948,6 @@ __decorate([
|
|
|
894
948
|
__metadata("design:type", Coupon)
|
|
895
949
|
], CheckoutSubscription.prototype, "coupon", void 0);
|
|
896
950
|
|
|
897
|
-
class Buy2Win extends BaseModel {
|
|
898
|
-
static get identifiersFields() {
|
|
899
|
-
return ['id'];
|
|
900
|
-
}
|
|
901
|
-
}
|
|
902
|
-
__decorate([
|
|
903
|
-
Type(() => Category),
|
|
904
|
-
__metadata("design:type", Array)
|
|
905
|
-
], Buy2Win.prototype, "categories", void 0);
|
|
906
|
-
|
|
907
951
|
var FilterType;
|
|
908
952
|
(function (FilterType) {
|
|
909
953
|
FilterType["ACCESSORY_IMPORTANCE"] = "accessoryImportance";
|
|
@@ -1003,6 +1047,12 @@ class ShopMenu extends BaseModel {
|
|
|
1003
1047
|
}
|
|
1004
1048
|
}
|
|
1005
1049
|
|
|
1050
|
+
class ShopSettings extends BaseModel {
|
|
1051
|
+
static get identifiersFields() {
|
|
1052
|
+
return ['id'];
|
|
1053
|
+
}
|
|
1054
|
+
}
|
|
1055
|
+
|
|
1006
1056
|
class InvalidArgumentError extends CustomError {
|
|
1007
1057
|
constructor(message) {
|
|
1008
1058
|
super(message);
|
|
@@ -1113,6 +1163,7 @@ class ProductsIndex {
|
|
|
1113
1163
|
'stock',
|
|
1114
1164
|
'weight',
|
|
1115
1165
|
'tags',
|
|
1166
|
+
'filters',
|
|
1116
1167
|
'hasVariants',
|
|
1117
1168
|
'type',
|
|
1118
1169
|
];
|
|
@@ -1206,6 +1257,8 @@ const withFirestore = (MixinBase) => {
|
|
|
1206
1257
|
constructor(...params) {
|
|
1207
1258
|
const options = params[0];
|
|
1208
1259
|
super(...params);
|
|
1260
|
+
this.fields = {};
|
|
1261
|
+
this.interceptors = {};
|
|
1209
1262
|
this.collectionName = '';
|
|
1210
1263
|
this.firestore = options.firestore;
|
|
1211
1264
|
this.collectionName = options.collectionName;
|
|
@@ -1260,6 +1313,9 @@ const withGetFirestore = (MixinBase) => {
|
|
|
1260
1313
|
get(identifiers) {
|
|
1261
1314
|
var _a, _b, _c, _d;
|
|
1262
1315
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1316
|
+
console.log(this.buildCollectionPathForGet(identifiers));
|
|
1317
|
+
console.log(this.firestore);
|
|
1318
|
+
console.log(this.collection(this.buildCollectionPathForGet(identifiers)));
|
|
1263
1319
|
const instance = this.model.toInstance(this.model.identifiersFields.reduce((acc, field) => (Object.assign(Object.assign({}, acc), { [field]: identifiers[field] })), {}));
|
|
1264
1320
|
const intercepted = yield ((_b = (_a = this.interceptors) === null || _a === void 0 ? void 0 : _a.request) === null || _b === void 0 ? void 0 : _b.call(_a, { instance }));
|
|
1265
1321
|
const builded = (intercepted === null || intercepted === void 0 ? void 0 : intercepted.instance) || instance;
|
|
@@ -1347,10 +1403,11 @@ const withFindFirestore = (MixinBase) => {
|
|
|
1347
1403
|
};
|
|
1348
1404
|
}
|
|
1349
1405
|
find(find = {}) {
|
|
1350
|
-
var _a, _b, _c, _d;
|
|
1406
|
+
var _a, _b, _c, _d, _e, _f;
|
|
1351
1407
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1352
1408
|
const collection = this.collection(this.buildCollectionPathForFind(find.filters));
|
|
1353
|
-
const
|
|
1409
|
+
const enableCount = (_b = (_a = find === null || find === void 0 ? void 0 : find.options) === null || _a === void 0 ? void 0 : _a.enableCount) !== null && _b !== void 0 ? _b : true;
|
|
1410
|
+
const intercepted = yield ((_d = (_c = this.interceptors) === null || _c === void 0 ? void 0 : _c.request) === null || _d === void 0 ? void 0 : _d.call(_c, { find }));
|
|
1354
1411
|
const { filters, limits, orderBy } = intercepted.find || find;
|
|
1355
1412
|
const queries = this.makeFirestoreWhere(filters || {});
|
|
1356
1413
|
const ordination = this.makeFirestoreOrderBy(filters, orderBy);
|
|
@@ -1359,8 +1416,8 @@ const withFindFirestore = (MixinBase) => {
|
|
|
1359
1416
|
const docs = yield getDocs(query(collection, ...queryArgumments));
|
|
1360
1417
|
const data = docs.docs.map((doc) => doc.data());
|
|
1361
1418
|
return {
|
|
1362
|
-
data: (yield ((
|
|
1363
|
-
count: this.calculateCount(data, limits),
|
|
1419
|
+
data: (yield ((_f = (_e = this.interceptors) === null || _e === void 0 ? void 0 : _e.response) === null || _f === void 0 ? void 0 : _f.call(_e, data, intercepted))) || data,
|
|
1420
|
+
count: enableCount ? this.calculateCount(data, limits) : Infinity,
|
|
1364
1421
|
};
|
|
1365
1422
|
});
|
|
1366
1423
|
}
|
|
@@ -1683,7 +1740,7 @@ class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFire
|
|
|
1683
1740
|
return categoryDocs.docs[0].data();
|
|
1684
1741
|
});
|
|
1685
1742
|
}
|
|
1686
|
-
getCategoriesForHome(categoryIds, limit = 4) {
|
|
1743
|
+
getCategoriesForHome(categoryIds, limit = 4, gender) {
|
|
1687
1744
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1688
1745
|
const categorySnap = yield getDocs(query(this.collection(this.collectionName), where('id', 'in', categoryIds.filter(Boolean)), where('published', '==', true)));
|
|
1689
1746
|
if (categorySnap.empty)
|
|
@@ -1692,7 +1749,7 @@ class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFire
|
|
|
1692
1749
|
const homeSections = yield Promise.all(categories.map((category) => __awaiter(this, void 0, void 0, function* () {
|
|
1693
1750
|
return ({
|
|
1694
1751
|
category,
|
|
1695
|
-
products: yield this.mountCategory(category, { limit, hasStock: true }),
|
|
1752
|
+
products: yield this.mountCategory(category, { limit, hasStock: true, gender }),
|
|
1696
1753
|
});
|
|
1697
1754
|
})));
|
|
1698
1755
|
return homeSections;
|
|
@@ -1711,6 +1768,8 @@ class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFire
|
|
|
1711
1768
|
wheres.push(where('published', '==', true), where('id', 'in', productIds));
|
|
1712
1769
|
if (options === null || options === void 0 ? void 0 : options.hasStock)
|
|
1713
1770
|
wheres.push(where('stock.quantity', '>', 0));
|
|
1771
|
+
if (options === null || options === void 0 ? void 0 : options.gender)
|
|
1772
|
+
wheres.push(where('tags', 'array-contains', options === null || options === void 0 ? void 0 : options.gender));
|
|
1714
1773
|
if (options === null || options === void 0 ? void 0 : options.limit)
|
|
1715
1774
|
wheres.push(limit(options === null || options === void 0 ? void 0 : options.limit));
|
|
1716
1775
|
const productSnap = yield getDocs(query(this.collection('productsErpVitrine'), ...wheres));
|
|
@@ -1772,6 +1831,9 @@ class ProductFirestoreRepository extends withCrudFirestore(withHelpers(withFires
|
|
|
1772
1831
|
return this.reviews[status];
|
|
1773
1832
|
});
|
|
1774
1833
|
}
|
|
1834
|
+
cleanShoppingCountFromIds() {
|
|
1835
|
+
return;
|
|
1836
|
+
}
|
|
1775
1837
|
}
|
|
1776
1838
|
|
|
1777
1839
|
class ProductVariantFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), Product) {
|
|
@@ -1798,6 +1860,39 @@ class SubscriptionProductFirestoreRepository extends withCrudFirestore(withHelpe
|
|
|
1798
1860
|
}
|
|
1799
1861
|
}
|
|
1800
1862
|
|
|
1863
|
+
class Buy2WinFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1864
|
+
constructor({ firestore, interceptors }) {
|
|
1865
|
+
super({
|
|
1866
|
+
firestore,
|
|
1867
|
+
collectionName: 'buy2win',
|
|
1868
|
+
model: Buy2Win,
|
|
1869
|
+
interceptors,
|
|
1870
|
+
});
|
|
1871
|
+
}
|
|
1872
|
+
}
|
|
1873
|
+
|
|
1874
|
+
class CampaignDashboardFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1875
|
+
constructor({ firestore, interceptors, }) {
|
|
1876
|
+
super({
|
|
1877
|
+
firestore,
|
|
1878
|
+
collectionName: 'dashboardCampaignsAuto',
|
|
1879
|
+
model: CampaignDashboard,
|
|
1880
|
+
interceptors,
|
|
1881
|
+
});
|
|
1882
|
+
}
|
|
1883
|
+
}
|
|
1884
|
+
|
|
1885
|
+
class CampaignHashtagFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1886
|
+
constructor({ firestore, interceptors, }) {
|
|
1887
|
+
super({
|
|
1888
|
+
firestore,
|
|
1889
|
+
collectionName: 'hashtagCampaignsAuto',
|
|
1890
|
+
model: CampaignHashtag,
|
|
1891
|
+
interceptors,
|
|
1892
|
+
});
|
|
1893
|
+
}
|
|
1894
|
+
}
|
|
1895
|
+
|
|
1801
1896
|
class CheckoutFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1802
1897
|
constructor({ firestore, interceptors }) {
|
|
1803
1898
|
super({
|
|
@@ -1809,6 +1904,17 @@ class CheckoutFirestoreRepository extends withCrudFirestore(withHelpers(withFire
|
|
|
1809
1904
|
}
|
|
1810
1905
|
}
|
|
1811
1906
|
|
|
1907
|
+
class CheckoutSubscriptionFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1908
|
+
constructor({ firestore, interceptors, }) {
|
|
1909
|
+
super({
|
|
1910
|
+
firestore,
|
|
1911
|
+
collectionName: 'checkoutsSubscription',
|
|
1912
|
+
model: CheckoutSubscription,
|
|
1913
|
+
interceptors,
|
|
1914
|
+
});
|
|
1915
|
+
}
|
|
1916
|
+
}
|
|
1917
|
+
|
|
1812
1918
|
class CouponFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1813
1919
|
constructor({ firestore, interceptors }) {
|
|
1814
1920
|
super({
|
|
@@ -1874,23 +1980,22 @@ class OrderFirestoreRepository extends withCrudFirestore(withHelpers(withFiresto
|
|
|
1874
1980
|
}
|
|
1875
1981
|
}
|
|
1876
1982
|
|
|
1877
|
-
class
|
|
1983
|
+
class LegacyOrderFirestoreRepository extends OrderFirestoreRepository {
|
|
1878
1984
|
constructor({ firestore, interceptors }) {
|
|
1879
1985
|
super({
|
|
1880
1986
|
firestore,
|
|
1881
|
-
collectionName: 'payments',
|
|
1882
|
-
model: Payment,
|
|
1883
1987
|
interceptors,
|
|
1884
1988
|
});
|
|
1989
|
+
this.collectionName = 'legacyOrders';
|
|
1885
1990
|
}
|
|
1886
1991
|
}
|
|
1887
1992
|
|
|
1888
|
-
class
|
|
1889
|
-
constructor({ firestore, interceptors
|
|
1993
|
+
class PaymentFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1994
|
+
constructor({ firestore, interceptors }) {
|
|
1890
1995
|
super({
|
|
1891
1996
|
firestore,
|
|
1892
|
-
collectionName: '
|
|
1893
|
-
model:
|
|
1997
|
+
collectionName: 'payments',
|
|
1998
|
+
model: Payment,
|
|
1894
1999
|
interceptors,
|
|
1895
2000
|
});
|
|
1896
2001
|
}
|
|
@@ -1907,27 +2012,6 @@ class SubscriptionPlanFirestoreRepository extends withCrudFirestore(withHelpers(
|
|
|
1907
2012
|
}
|
|
1908
2013
|
}
|
|
1909
2014
|
|
|
1910
|
-
class Buy2WinFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1911
|
-
constructor({ firestore, interceptors }) {
|
|
1912
|
-
super({
|
|
1913
|
-
firestore,
|
|
1914
|
-
collectionName: 'buy2win',
|
|
1915
|
-
model: Buy2Win,
|
|
1916
|
-
interceptors,
|
|
1917
|
-
});
|
|
1918
|
-
}
|
|
1919
|
-
}
|
|
1920
|
-
|
|
1921
|
-
class LegacyOrderFirestoreRepository extends OrderFirestoreRepository {
|
|
1922
|
-
constructor({ firestore, interceptors }) {
|
|
1923
|
-
super({
|
|
1924
|
-
firestore,
|
|
1925
|
-
interceptors,
|
|
1926
|
-
});
|
|
1927
|
-
this.collectionName = 'legacyOrders';
|
|
1928
|
-
}
|
|
1929
|
-
}
|
|
1930
|
-
|
|
1931
2015
|
class HomeFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1932
2016
|
constructor({ firestore, interceptors }) {
|
|
1933
2017
|
super({
|
|
@@ -1993,6 +2077,17 @@ class ShopMenuFirestoreRepository extends withCrudFirestore(withHelpers(withFire
|
|
|
1993
2077
|
}
|
|
1994
2078
|
}
|
|
1995
2079
|
|
|
2080
|
+
class ShopSettingsFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
2081
|
+
constructor({ firestore, interceptors, }) {
|
|
2082
|
+
super({
|
|
2083
|
+
firestore,
|
|
2084
|
+
collectionName: 'shopSettings',
|
|
2085
|
+
model: ShopSettings,
|
|
2086
|
+
interceptors,
|
|
2087
|
+
});
|
|
2088
|
+
}
|
|
2089
|
+
}
|
|
2090
|
+
|
|
1996
2091
|
class AuthenticationFirebaseAuthService {
|
|
1997
2092
|
constructor(firebaseAuth) {
|
|
1998
2093
|
this.firebaseAuth = firebaseAuth;
|
|
@@ -2079,7 +2174,7 @@ class AttributeOptionHelper {
|
|
|
2079
2174
|
AttributeOptionHelper.FindByAttribute = (attributeName, fields) => {
|
|
2080
2175
|
var _a;
|
|
2081
2176
|
if (fields.includes(attributeName))
|
|
2082
|
-
return { columnName: attributeName.toString(), attributeName };
|
|
2177
|
+
return { columnName: attributeName.toString(), attributeName, to: (value) => value, from: (value) => value };
|
|
2083
2178
|
const field = fields.find((columnOption) => isObject(columnOption) && Object.keys(columnOption).includes(attributeName.toString()));
|
|
2084
2179
|
const fieldOption = (_a = is(field)) === null || _a === void 0 ? void 0 : _a[attributeName];
|
|
2085
2180
|
if (isNil(fieldOption))
|
|
@@ -2380,9 +2475,13 @@ const withHasuraGraphQL = (MixinBase) => {
|
|
|
2380
2475
|
this.fields = options.fields || this.model.identifiersFields;
|
|
2381
2476
|
}
|
|
2382
2477
|
get headers() {
|
|
2383
|
-
|
|
2478
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
2479
|
+
return Object.assign(Object.assign(Object.assign({ 'Content-Type': 'application/json' }, (isNil((_a = this.authOptions) === null || _a === void 0 ? void 0 : _a.authToken) ? {} : { Authorization: (_b = this.authOptions) === null || _b === void 0 ? void 0 : _b.authToken })), (isNil((_c = this.authOptions) === null || _c === void 0 ? void 0 : _c.adminSecret) ? {} : { 'X-Hasura-Admin-Secret': (_d = this.authOptions) === null || _d === void 0 ? void 0 : _d.adminSecret })), (isNil((_e = this.authOptions) === null || _e === void 0 ? void 0 : _e.authRole)
|
|
2384
2480
|
? {}
|
|
2385
|
-
: {
|
|
2481
|
+
: {
|
|
2482
|
+
'X-Hasura-Role': this.authOptions.authRole.role,
|
|
2483
|
+
'X-Hasura-User-Id': (_g = (_f = this.authOptions) === null || _f === void 0 ? void 0 : _f.authRole) === null || _g === void 0 ? void 0 : _g.userId,
|
|
2484
|
+
}));
|
|
2386
2485
|
}
|
|
2387
2486
|
mutation(operation, fields, variables) {
|
|
2388
2487
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -2407,10 +2506,12 @@ const withHasuraGraphQL = (MixinBase) => {
|
|
|
2407
2506
|
fetch(params) {
|
|
2408
2507
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2409
2508
|
const headers = this.headers;
|
|
2410
|
-
const
|
|
2509
|
+
const { data: result } = yield axios({
|
|
2510
|
+
url: `${this.endpoint}`,
|
|
2511
|
+
method: 'POST',
|
|
2512
|
+
data: params,
|
|
2411
2513
|
headers,
|
|
2412
2514
|
});
|
|
2413
|
-
const result = yield response.data;
|
|
2414
2515
|
if (!isNil(result.errors))
|
|
2415
2516
|
throw new Error(JSON.stringify(result.errors));
|
|
2416
2517
|
return result.data;
|
|
@@ -2550,9 +2651,11 @@ const withGetHasuraGraphQL = (MixinBase) => {
|
|
|
2550
2651
|
|
|
2551
2652
|
const withFindHasuraGraphQL = (MixinBase) => {
|
|
2552
2653
|
return class FindHasuraGraphQLMixin extends MixinBase {
|
|
2553
|
-
find(
|
|
2654
|
+
find(params) {
|
|
2655
|
+
var _a;
|
|
2554
2656
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2555
|
-
const { filters, limits, orderBy } =
|
|
2657
|
+
const { filters, limits, orderBy, options } = params || {};
|
|
2658
|
+
const enableCount = (_a = options === null || options === void 0 ? void 0 : options.enableCount) !== null && _a !== void 0 ? _a : true;
|
|
2556
2659
|
const variablesCount = Object.assign(Object.assign({}, (isNil(orderBy) ? {} : { order_by: { type: `${this.tableName}_order_by!`, list: true, value: orderBy } })), (isNil(filters)
|
|
2557
2660
|
? {}
|
|
2558
2661
|
: {
|
|
@@ -2566,8 +2669,8 @@ const withFindHasuraGraphQL = (MixinBase) => {
|
|
|
2566
2669
|
const result = yield this.query([
|
|
2567
2670
|
{
|
|
2568
2671
|
operation: this.tableName,
|
|
2569
|
-
fields:
|
|
2570
|
-
?
|
|
2672
|
+
fields: params.fields
|
|
2673
|
+
? params.fields
|
|
2571
2674
|
.map((fieldName) => {
|
|
2572
2675
|
var _a;
|
|
2573
2676
|
return (_a = this.fields.find((fieldOption) => fieldOption === fieldName)) !== null && _a !== void 0 ? _a : this.fields.find((fieldOption) => Object.keys(fieldOption).shift() === fieldName);
|
|
@@ -2576,15 +2679,18 @@ const withFindHasuraGraphQL = (MixinBase) => {
|
|
|
2576
2679
|
: this.fields,
|
|
2577
2680
|
variables,
|
|
2578
2681
|
},
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
|
|
2583
|
-
|
|
2682
|
+
...(enableCount
|
|
2683
|
+
? [
|
|
2684
|
+
{
|
|
2685
|
+
operation: `${this.tableName}_aggregate`,
|
|
2686
|
+
fields: [{ aggregate: ['count'] }],
|
|
2687
|
+
variables: variablesCount,
|
|
2688
|
+
},
|
|
2689
|
+
]
|
|
2690
|
+
: []),
|
|
2584
2691
|
]);
|
|
2585
2692
|
const data = result[this.tableName].map((row) => this.convertDataFromHasura(row));
|
|
2586
|
-
|
|
2587
|
-
return { count, data };
|
|
2693
|
+
return { data, count: enableCount ? result[`${this.tableName}_aggregate`].aggregate.count : Infinity };
|
|
2588
2694
|
});
|
|
2589
2695
|
}
|
|
2590
2696
|
};
|
|
@@ -2624,8 +2730,60 @@ class VariantHasuraGraphQL extends Variant {
|
|
|
2624
2730
|
}
|
|
2625
2731
|
}
|
|
2626
2732
|
|
|
2733
|
+
class CategoryFilterHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
2734
|
+
constructor({ endpoint, authOptions, interceptors, }) {
|
|
2735
|
+
super({
|
|
2736
|
+
tableName: 'category_filter',
|
|
2737
|
+
model: CategoryFilter,
|
|
2738
|
+
endpoint,
|
|
2739
|
+
authOptions,
|
|
2740
|
+
fields: [
|
|
2741
|
+
'id',
|
|
2742
|
+
{ filterId: { columnName: 'filter_id' } },
|
|
2743
|
+
{ categoryId: { columnName: 'category_id' } },
|
|
2744
|
+
{
|
|
2745
|
+
filter: {
|
|
2746
|
+
columnName: 'filter',
|
|
2747
|
+
foreignKeyColumn: { id: 'filterId' },
|
|
2748
|
+
fields: [
|
|
2749
|
+
'id',
|
|
2750
|
+
'description',
|
|
2751
|
+
'slug',
|
|
2752
|
+
'enabled',
|
|
2753
|
+
{ createdAt: { columnName: 'created_at' } },
|
|
2754
|
+
{ updatedAt: { columnName: 'updated_at' } },
|
|
2755
|
+
{
|
|
2756
|
+
options: {
|
|
2757
|
+
columnName: 'options',
|
|
2758
|
+
foreignKeyColumn: { filterId: 'id' },
|
|
2759
|
+
fields: [
|
|
2760
|
+
'id',
|
|
2761
|
+
{ filterId: { columnName: 'filter_id' } },
|
|
2762
|
+
'description',
|
|
2763
|
+
{ createdAt: { columnName: 'created_at' } },
|
|
2764
|
+
{ updatedAt: { columnName: 'updated_at' } },
|
|
2765
|
+
],
|
|
2766
|
+
},
|
|
2767
|
+
},
|
|
2768
|
+
],
|
|
2769
|
+
},
|
|
2770
|
+
},
|
|
2771
|
+
],
|
|
2772
|
+
});
|
|
2773
|
+
}
|
|
2774
|
+
deleteByCategoryAndFilter(categoryId, filterId) {
|
|
2775
|
+
return this.mutation('delete_category_filter', ['affected_rows'], {
|
|
2776
|
+
where: {
|
|
2777
|
+
type: 'category_filter_bool_exp',
|
|
2778
|
+
required: true,
|
|
2779
|
+
value: { category_id: { _eq: categoryId }, filter_id: { _eq: filterId } },
|
|
2780
|
+
},
|
|
2781
|
+
});
|
|
2782
|
+
}
|
|
2783
|
+
}
|
|
2784
|
+
|
|
2627
2785
|
class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
2628
|
-
constructor({ endpoint, authOptions, interceptors, }, productRepository) {
|
|
2786
|
+
constructor({ endpoint, authOptions, interceptors, }, productRepository, categoryFilterRepository) {
|
|
2629
2787
|
super({
|
|
2630
2788
|
tableName: 'category',
|
|
2631
2789
|
model: Category,
|
|
@@ -2665,7 +2823,17 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
2665
2823
|
},
|
|
2666
2824
|
},
|
|
2667
2825
|
},
|
|
2668
|
-
|
|
2826
|
+
{
|
|
2827
|
+
filters: {
|
|
2828
|
+
columnName: 'filters',
|
|
2829
|
+
foreignKeyColumn: { filter_id: 'id' },
|
|
2830
|
+
fields: [{ filter: ['id', 'description', 'slug', 'enabled'] }],
|
|
2831
|
+
bindPersistData: (value) => ({
|
|
2832
|
+
filters: { data: value.map((filter) => ({ filter_id: filter.id })) },
|
|
2833
|
+
}),
|
|
2834
|
+
from: (filters) => (filters === null || filters === void 0 ? void 0 : filters.map((filter) => filter === null || filter === void 0 ? void 0 : filter.filter)) || [],
|
|
2835
|
+
},
|
|
2836
|
+
},
|
|
2669
2837
|
{ createdAt: { columnName: 'created_at' } },
|
|
2670
2838
|
{ updatedAt: { columnName: 'updated_at' } },
|
|
2671
2839
|
{
|
|
@@ -2690,6 +2858,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
2690
2858
|
],
|
|
2691
2859
|
});
|
|
2692
2860
|
this.productRepository = productRepository;
|
|
2861
|
+
this.categoryFilterRepository = categoryFilterRepository;
|
|
2693
2862
|
}
|
|
2694
2863
|
create(params) {
|
|
2695
2864
|
const _super = Object.create(null, {
|
|
@@ -2707,7 +2876,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
2707
2876
|
var _a;
|
|
2708
2877
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2709
2878
|
return Number.isNaN(+identifiers.id)
|
|
2710
|
-
? (_a = (yield this.find({ filters: { firestoreId: identifiers.id } })).data) === null || _a === void 0 ? void 0 : _a[0]
|
|
2879
|
+
? (_a = (yield this.find({ filters: { firestoreId: identifiers.id }, options: { enableCount: false } })).data) === null || _a === void 0 ? void 0 : _a[0]
|
|
2711
2880
|
: _super.get.call(this, identifiers);
|
|
2712
2881
|
});
|
|
2713
2882
|
}
|
|
@@ -2716,12 +2885,13 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
2716
2885
|
update: { get: () => super.update }
|
|
2717
2886
|
});
|
|
2718
2887
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2719
|
-
const { products, id: checkId, metadata } = params, data = __rest(params, ["products", "id", "metadata"]);
|
|
2888
|
+
const { products, id: checkId, metadata, filters } = params, data = __rest(params, ["products", "id", "metadata", "filters"]);
|
|
2720
2889
|
const plainData = this.paramsToPlain({ id: checkId });
|
|
2721
2890
|
const id = yield this.getId(plainData.id);
|
|
2722
2891
|
const category = yield _super.update.call(this, Object.assign({ id }, data));
|
|
2723
2892
|
category.products = products && (yield this.updateProducts(+id, { products }));
|
|
2724
2893
|
category.metadata = metadata && (yield this.updateMetadata(+id, { metadata }));
|
|
2894
|
+
category.filters = filters && (yield this.updateFilters(+id, { filters }));
|
|
2725
2895
|
return category;
|
|
2726
2896
|
});
|
|
2727
2897
|
}
|
|
@@ -2729,15 +2899,15 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
2729
2899
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2730
2900
|
if (!slug)
|
|
2731
2901
|
return null;
|
|
2732
|
-
const { data
|
|
2733
|
-
if (
|
|
2734
|
-
throw new DuplicatedResultsError('Query returned duplicated values');
|
|
2735
|
-
if (!count)
|
|
2902
|
+
const { data } = yield this.find({ filters: { slug, shop, published: true }, options: { enableCount: false } });
|
|
2903
|
+
if (!data.length)
|
|
2736
2904
|
throw new NotFoundError(`Category with slug ${slug} not found`);
|
|
2905
|
+
if (data.length > 1)
|
|
2906
|
+
throw new DuplicatedResultsError('Query returned duplicated values');
|
|
2737
2907
|
return data.shift();
|
|
2738
2908
|
});
|
|
2739
2909
|
}
|
|
2740
|
-
getCategoriesForHome(categoryIds, limit = 4) {
|
|
2910
|
+
getCategoriesForHome(categoryIds, limit = 4, gender) {
|
|
2741
2911
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2742
2912
|
if (!(categoryIds === null || categoryIds === void 0 ? void 0 : categoryIds.length))
|
|
2743
2913
|
return [];
|
|
@@ -2757,7 +2927,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
2757
2927
|
const homeSections = yield Promise.all(categories.map((category) => __awaiter(this, void 0, void 0, function* () {
|
|
2758
2928
|
return ({
|
|
2759
2929
|
category,
|
|
2760
|
-
products: yield this.mountCategory(category, { limit, hasStock: true }),
|
|
2930
|
+
products: yield this.mountCategory(category, { limit, hasStock: true, gender }),
|
|
2761
2931
|
});
|
|
2762
2932
|
})));
|
|
2763
2933
|
return homeSections;
|
|
@@ -2769,7 +2939,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
2769
2939
|
if (!((_a = category === null || category === void 0 ? void 0 : category.products) === null || _a === void 0 ? void 0 : _a.length))
|
|
2770
2940
|
return [];
|
|
2771
2941
|
const products = [];
|
|
2772
|
-
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: [
|
|
2942
|
+
const { data: productsData } = yield this.productRepository.find(Object.assign(Object.assign({ filters: Object.assign(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 } } } : {})), ((options === null || options === void 0 ? void 0 : options.gender) ? { tags: { operator: Where.IN, value: [options === null || options === void 0 ? void 0 : options.gender] } } : {})), fields: [
|
|
2773
2943
|
'id',
|
|
2774
2944
|
'name',
|
|
2775
2945
|
'slug',
|
|
@@ -2793,7 +2963,8 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
2793
2963
|
'tags',
|
|
2794
2964
|
'type',
|
|
2795
2965
|
'shoppingCount',
|
|
2796
|
-
|
|
2966
|
+
'gender',
|
|
2967
|
+
] }, ((options === null || options === void 0 ? void 0 : options.limit) ? { limits: { limit: options === null || options === void 0 ? void 0 : options.limit } } : {})), { options: { enableCount: false } }));
|
|
2797
2968
|
products.push(...productsData);
|
|
2798
2969
|
return products;
|
|
2799
2970
|
});
|
|
@@ -2803,7 +2974,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
2803
2974
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2804
2975
|
if (!Number.isNaN(+id))
|
|
2805
2976
|
return id;
|
|
2806
|
-
const { data } = yield this.find({ filters: { firestoreId: id } });
|
|
2977
|
+
const { data } = yield this.find({ filters: { firestoreId: id }, options: { enableCount: false } });
|
|
2807
2978
|
if ((_a = data === null || data === void 0 ? void 0 : data[0]) === null || _a === void 0 ? void 0 : _a.id)
|
|
2808
2979
|
return (_b = data === null || data === void 0 ? void 0 : data[0]) === null || _b === void 0 ? void 0 : _b.id;
|
|
2809
2980
|
throw new NotFoundError(`Category with id ${id} not found`);
|
|
@@ -2861,6 +3032,208 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
2861
3032
|
return plainData.metadata;
|
|
2862
3033
|
});
|
|
2863
3034
|
}
|
|
3035
|
+
updateFilters(categoryId, { filters }) {
|
|
3036
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
3037
|
+
if ('action' in filters && filters.action === 'remove' && filters.value.length) {
|
|
3038
|
+
for (let i = 0; i < filters.value.length; i++) {
|
|
3039
|
+
yield this.categoryFilterRepository.deleteByCategoryAndFilter(categoryId, filters.value[i].id);
|
|
3040
|
+
}
|
|
3041
|
+
return [];
|
|
3042
|
+
}
|
|
3043
|
+
if ('action' in filters && filters.action === 'merge' && filters.value.length) {
|
|
3044
|
+
let filtersList = [];
|
|
3045
|
+
for (let i = 0; i < filters.value.length; i++) {
|
|
3046
|
+
try {
|
|
3047
|
+
const hasFilter = yield this.categoryFilterRepository
|
|
3048
|
+
.find({
|
|
3049
|
+
filters: {
|
|
3050
|
+
categoryId,
|
|
3051
|
+
filterId: filters.value[i].id,
|
|
3052
|
+
},
|
|
3053
|
+
})
|
|
3054
|
+
.then((data) => { var _a; return (_a = data.data.shift()) === null || _a === void 0 ? void 0 : _a.filter; });
|
|
3055
|
+
if (hasFilter) {
|
|
3056
|
+
filtersList.push(hasFilter);
|
|
3057
|
+
}
|
|
3058
|
+
else {
|
|
3059
|
+
yield this.categoryFilterRepository.create({
|
|
3060
|
+
filterId: filters.value[i].id,
|
|
3061
|
+
categoryId,
|
|
3062
|
+
});
|
|
3063
|
+
filtersList.push(filters.value[i]);
|
|
3064
|
+
}
|
|
3065
|
+
}
|
|
3066
|
+
catch (error) {
|
|
3067
|
+
console.log('catch error: ', error);
|
|
3068
|
+
}
|
|
3069
|
+
}
|
|
3070
|
+
return filtersList;
|
|
3071
|
+
}
|
|
3072
|
+
if (Array.isArray(filters) && filters.length) {
|
|
3073
|
+
let filtersList = [];
|
|
3074
|
+
for (let i = 0; i < filters.length; i++) {
|
|
3075
|
+
try {
|
|
3076
|
+
const hasFilter = yield this.categoryFilterRepository
|
|
3077
|
+
.find({
|
|
3078
|
+
filters: {
|
|
3079
|
+
categoryId,
|
|
3080
|
+
filterId: filters[i].id,
|
|
3081
|
+
},
|
|
3082
|
+
})
|
|
3083
|
+
.then((data) => { var _a; return (_a = data.data.shift()) === null || _a === void 0 ? void 0 : _a.filter; });
|
|
3084
|
+
if (hasFilter) {
|
|
3085
|
+
filtersList.push(hasFilter);
|
|
3086
|
+
}
|
|
3087
|
+
else {
|
|
3088
|
+
yield this.categoryFilterRepository.create({
|
|
3089
|
+
filterId: filters[i].id,
|
|
3090
|
+
categoryId,
|
|
3091
|
+
});
|
|
3092
|
+
filtersList.push(filters[i]);
|
|
3093
|
+
}
|
|
3094
|
+
}
|
|
3095
|
+
catch (error) {
|
|
3096
|
+
console.log('catch error: ', error);
|
|
3097
|
+
}
|
|
3098
|
+
}
|
|
3099
|
+
return filtersList;
|
|
3100
|
+
}
|
|
3101
|
+
return [];
|
|
3102
|
+
});
|
|
3103
|
+
}
|
|
3104
|
+
}
|
|
3105
|
+
|
|
3106
|
+
class FilterHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
3107
|
+
constructor({ endpoint, authOptions, interceptors, }, filterOptionRepository, categoryFilterRepository) {
|
|
3108
|
+
super({
|
|
3109
|
+
tableName: 'filter',
|
|
3110
|
+
model: Filter,
|
|
3111
|
+
endpoint,
|
|
3112
|
+
authOptions,
|
|
3113
|
+
fields: [
|
|
3114
|
+
'id',
|
|
3115
|
+
'description',
|
|
3116
|
+
'slug',
|
|
3117
|
+
'enabled',
|
|
3118
|
+
{ createdAt: { columnName: 'created_at' } },
|
|
3119
|
+
{ updatedAt: { columnName: 'updated_at' } },
|
|
3120
|
+
{
|
|
3121
|
+
options: {
|
|
3122
|
+
columnName: 'options',
|
|
3123
|
+
foreignKeyColumn: { filterId: 'id' },
|
|
3124
|
+
fields: [
|
|
3125
|
+
'id',
|
|
3126
|
+
{ filterId: { columnName: 'filter_id' } },
|
|
3127
|
+
'description',
|
|
3128
|
+
{ createdAt: { columnName: 'created_at' } },
|
|
3129
|
+
{ updatedAt: { columnName: 'updated_at' } },
|
|
3130
|
+
],
|
|
3131
|
+
},
|
|
3132
|
+
},
|
|
3133
|
+
],
|
|
3134
|
+
});
|
|
3135
|
+
this.filterOptionRepository = filterOptionRepository;
|
|
3136
|
+
this.categoryFilterRepository = categoryFilterRepository;
|
|
3137
|
+
}
|
|
3138
|
+
update(params) {
|
|
3139
|
+
const _super = Object.create(null, {
|
|
3140
|
+
update: { get: () => super.update }
|
|
3141
|
+
});
|
|
3142
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
3143
|
+
const { options } = params, data = __rest(params, ["options"]);
|
|
3144
|
+
const filter = yield _super.update.call(this, data);
|
|
3145
|
+
filter.options = yield this.updateOptions(+data.id, { options });
|
|
3146
|
+
return filter;
|
|
3147
|
+
});
|
|
3148
|
+
}
|
|
3149
|
+
updateOptions(filterId, { options }) {
|
|
3150
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
3151
|
+
if (!options)
|
|
3152
|
+
return [];
|
|
3153
|
+
if ('action' in options && options.action === 'remove' && options.value.length) {
|
|
3154
|
+
for (let i = 0; i < options.value.length; i++) {
|
|
3155
|
+
yield this.filterOptionRepository.delete({ id: options.value[i].id });
|
|
3156
|
+
}
|
|
3157
|
+
return [];
|
|
3158
|
+
}
|
|
3159
|
+
if ('action' in options && options.action === 'merge' && options.value.length) {
|
|
3160
|
+
let filterOptions = [];
|
|
3161
|
+
for (let i = 0; i < options.value.length; i++) {
|
|
3162
|
+
try {
|
|
3163
|
+
const hasFilter = yield this.filterOptionRepository.get({ id: options.value[i].id });
|
|
3164
|
+
if (hasFilter)
|
|
3165
|
+
filterOptions.push(hasFilter);
|
|
3166
|
+
}
|
|
3167
|
+
catch (error) {
|
|
3168
|
+
const newOption = yield this.filterOptionRepository.create(Object.assign(Object.assign({}, options.value[i]), { filterId }));
|
|
3169
|
+
filterOptions.push(newOption);
|
|
3170
|
+
}
|
|
3171
|
+
}
|
|
3172
|
+
return filterOptions;
|
|
3173
|
+
}
|
|
3174
|
+
if (Array.isArray(options) && options.length) {
|
|
3175
|
+
let filterOptions = [];
|
|
3176
|
+
for (let i = 0; i < options.length; i++) {
|
|
3177
|
+
try {
|
|
3178
|
+
const hasFilter = yield this.filterOptionRepository.get({ id: options[i].id });
|
|
3179
|
+
if (hasFilter)
|
|
3180
|
+
filterOptions.push(hasFilter);
|
|
3181
|
+
}
|
|
3182
|
+
catch (error) {
|
|
3183
|
+
const newOption = yield this.filterOptionRepository.create(Object.assign(Object.assign({}, options[i]), { filterId }));
|
|
3184
|
+
filterOptions.push(newOption);
|
|
3185
|
+
}
|
|
3186
|
+
}
|
|
3187
|
+
}
|
|
3188
|
+
return [];
|
|
3189
|
+
});
|
|
3190
|
+
}
|
|
3191
|
+
delete(params) {
|
|
3192
|
+
const _super = Object.create(null, {
|
|
3193
|
+
delete: { get: () => super.delete }
|
|
3194
|
+
});
|
|
3195
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
3196
|
+
const { data: categoryFilters } = yield this.categoryFilterRepository.find({
|
|
3197
|
+
filters: {
|
|
3198
|
+
filterId: params.id,
|
|
3199
|
+
},
|
|
3200
|
+
});
|
|
3201
|
+
if (categoryFilters.length)
|
|
3202
|
+
throw new Error('Erro: o filtro está associado a uma ou mais categoria(s)');
|
|
3203
|
+
yield this.deleteOptions(+params.id);
|
|
3204
|
+
yield _super.delete.call(this, { id: +params.id });
|
|
3205
|
+
return;
|
|
3206
|
+
});
|
|
3207
|
+
}
|
|
3208
|
+
deleteOptions(filterId) {
|
|
3209
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
3210
|
+
yield this.mutation('delete_filter_option', ['affected_rows'], {
|
|
3211
|
+
where: {
|
|
3212
|
+
type: 'filter_option_bool_exp',
|
|
3213
|
+
required: true,
|
|
3214
|
+
value: { filter_id: { _eq: filterId } },
|
|
3215
|
+
},
|
|
3216
|
+
});
|
|
3217
|
+
});
|
|
3218
|
+
}
|
|
3219
|
+
}
|
|
3220
|
+
|
|
3221
|
+
class FilterOptionHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
3222
|
+
constructor({ endpoint, authOptions, interceptors, }) {
|
|
3223
|
+
super({
|
|
3224
|
+
tableName: 'filter_option',
|
|
3225
|
+
model: FilterOption,
|
|
3226
|
+
endpoint,
|
|
3227
|
+
authOptions,
|
|
3228
|
+
fields: [
|
|
3229
|
+
'id',
|
|
3230
|
+
'description',
|
|
3231
|
+
{ filterId: { columnName: 'filter_id' } },
|
|
3232
|
+
{ createdAt: { columnName: 'created_at' } },
|
|
3233
|
+
{ updatedAt: { columnName: 'updated_at' } },
|
|
3234
|
+
],
|
|
3235
|
+
});
|
|
3236
|
+
}
|
|
2864
3237
|
}
|
|
2865
3238
|
|
|
2866
3239
|
class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
@@ -2967,6 +3340,7 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
2967
3340
|
'weight',
|
|
2968
3341
|
'gender',
|
|
2969
3342
|
{ tags: { columnName: 'tags', type: HasuraGraphQLColumnType.Jsonb } },
|
|
3343
|
+
{ filters: { columnName: 'filters', type: HasuraGraphQLColumnType.Jsonb } },
|
|
2970
3344
|
{ isKit: { columnName: 'is_kit' } },
|
|
2971
3345
|
{ createdAt: { columnName: 'created_at' } },
|
|
2972
3346
|
{ updatedAt: { columnName: 'updated_at' } },
|
|
@@ -3068,7 +3442,7 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
3068
3442
|
var _a;
|
|
3069
3443
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3070
3444
|
const product = Number.isNaN(+identifiers.id)
|
|
3071
|
-
? (_a = (yield this.find({ filters: { firestoreId: identifiers.id } })).data) === null || _a === void 0 ? void 0 : _a[0]
|
|
3445
|
+
? (_a = (yield this.find({ filters: { firestoreId: identifiers.id }, options: { enableCount: false } })).data) === null || _a === void 0 ? void 0 : _a[0]
|
|
3072
3446
|
: yield _super.get.call(this, identifiers);
|
|
3073
3447
|
if (product.productId)
|
|
3074
3448
|
throw new NotFoundError('Product not found, it is a variant');
|
|
@@ -3096,9 +3470,12 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
3096
3470
|
filters: {
|
|
3097
3471
|
slug,
|
|
3098
3472
|
},
|
|
3473
|
+
fields: this.fields.map((field) => typeof field === 'string' ? field : Object.keys(field).shift()),
|
|
3474
|
+
options: {
|
|
3475
|
+
enableCount: false,
|
|
3476
|
+
},
|
|
3099
3477
|
});
|
|
3100
3478
|
const product = (_a = result === null || result === void 0 ? void 0 : result.data) === null || _a === void 0 ? void 0 : _a.shift();
|
|
3101
|
-
product.reviews = yield this.findReviewsByProduct(+product.id);
|
|
3102
3479
|
return product;
|
|
3103
3480
|
});
|
|
3104
3481
|
}
|
|
@@ -3261,7 +3638,7 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
3261
3638
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3262
3639
|
if (!Number.isNaN(+id))
|
|
3263
3640
|
return id;
|
|
3264
|
-
const { data } = yield this.find({ filters: { firestoreId: id } });
|
|
3641
|
+
const { data } = yield this.find({ filters: { firestoreId: id }, options: { enableCount: false } });
|
|
3265
3642
|
if ((_a = data === null || data === void 0 ? void 0 : data[0]) === null || _a === void 0 ? void 0 : _a.id)
|
|
3266
3643
|
return (_b = data === null || data === void 0 ? void 0 : data[0]) === null || _b === void 0 ? void 0 : _b.id;
|
|
3267
3644
|
throw new NotFoundError(`Product with id ${id} not found`);
|
|
@@ -3317,6 +3694,21 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
3317
3694
|
return data && data[0] && this.bindReviewToModel(data[0]);
|
|
3318
3695
|
});
|
|
3319
3696
|
}
|
|
3697
|
+
cleanShoppingCountFromIds(ids) {
|
|
3698
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
3699
|
+
return yield this.mutation('update_product', ['affected_rows'], {
|
|
3700
|
+
where: {
|
|
3701
|
+
value: { id: { _nin: ids } },
|
|
3702
|
+
type: 'product_bool_exp',
|
|
3703
|
+
required: true,
|
|
3704
|
+
},
|
|
3705
|
+
_set: {
|
|
3706
|
+
value: { shopping_count: 0 },
|
|
3707
|
+
type: 'product_set_input',
|
|
3708
|
+
},
|
|
3709
|
+
});
|
|
3710
|
+
});
|
|
3711
|
+
}
|
|
3320
3712
|
}
|
|
3321
3713
|
|
|
3322
3714
|
class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
@@ -3427,7 +3819,7 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
3427
3819
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3428
3820
|
if (!Number.isNaN(+id))
|
|
3429
3821
|
return id;
|
|
3430
|
-
const { data } = yield this.find({ filters: { firestoreId: id } });
|
|
3822
|
+
const { data } = yield this.find({ filters: { firestoreId: id }, options: { enableCount: false } });
|
|
3431
3823
|
if ((_a = data === null || data === void 0 ? void 0 : data[0]) === null || _a === void 0 ? void 0 : _a.id)
|
|
3432
3824
|
return (_b = data === null || data === void 0 ? void 0 : data[0]) === null || _b === void 0 ? void 0 : _b.id;
|
|
3433
3825
|
throw new NotFoundError(`Product with id ${id} not found`);
|
|
@@ -3439,5 +3831,5 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
3439
3831
|
* Generated bundle index. Do not edit.
|
|
3440
3832
|
*/
|
|
3441
3833
|
|
|
3442
|
-
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 };
|
|
3834
|
+
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 };
|
|
3443
3835
|
//# sourceMappingURL=infrab4a-connect.mjs.map
|