@infrab4a/connect 3.3.3-beta.1 → 3.4.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundles/infrab4a-connect.umd.js +299 -611
- package/bundles/infrab4a-connect.umd.js.map +1 -1
- package/domain/catalog/models/category.d.ts +2 -3
- package/domain/catalog/models/filter-option.d.ts +1 -1
- package/domain/catalog/models/filter.d.ts +1 -2
- package/domain/catalog/models/index.d.ts +0 -1
- package/domain/catalog/models/product.d.ts +0 -1
- package/domain/catalog/models/types/category-filter.type.d.ts +4 -0
- package/domain/catalog/models/types/index.d.ts +1 -0
- package/domain/catalog/repositories/index.d.ts +0 -1
- package/domain/catalog/repositories/product.repository.d.ts +0 -1
- package/domain/generic/repository/find.repository.d.ts +0 -3
- package/domain/shopping/models/index.d.ts +4 -5
- package/domain/shopping/repositories/index.d.ts +2 -4
- package/esm2015/domain/catalog/models/category.js +1 -8
- package/esm2015/domain/catalog/models/filter-option.js +1 -1
- package/esm2015/domain/catalog/models/filter.js +1 -1
- package/esm2015/domain/catalog/models/index.js +1 -2
- package/esm2015/domain/catalog/models/product.js +1 -1
- package/esm2015/domain/catalog/models/types/category-filter.type.js +2 -0
- package/esm2015/domain/catalog/models/types/index.js +2 -1
- package/esm2015/domain/catalog/repositories/index.js +1 -2
- package/esm2015/domain/catalog/repositories/product.repository.js +1 -1
- package/esm2015/domain/generic/repository/find.repository.js +1 -1
- package/esm2015/domain/shopping/models/index.js +5 -6
- package/esm2015/domain/shopping/repositories/index.js +3 -5
- package/esm2015/infra/elasticsearch/indexes/products-index.js +2 -3
- package/esm2015/infra/firebase/firestore/mixins/with-find-firestore.mixin.js +3 -5
- package/esm2015/infra/firebase/firestore/repositories/catalog/product-firestore.repository.js +1 -4
- package/esm2015/infra/firebase/firestore/repositories/shopping/index.js +4 -6
- package/esm2015/infra/hasura-graphql/mixins/helpers/attribute-option.helper.js +2 -2
- package/esm2015/infra/hasura-graphql/mixins/with-find-hasura-graphql.mixin.js +12 -17
- package/esm2015/infra/hasura-graphql/mixins/with-hasura-graphql.mixin.js +5 -5
- package/esm2015/infra/hasura-graphql/models/filter-hasura-graphql.js +4 -0
- package/esm2015/infra/hasura-graphql/models/filter-option-hasura-graphql.js +4 -0
- package/esm2015/infra/hasura-graphql/models/index.js +3 -1
- package/esm2015/infra/hasura-graphql/repositories/catalog/category-hasura-graphql.repository.js +12 -92
- package/esm2015/infra/hasura-graphql/repositories/catalog/filter-hasura-graphql.repository.js +48 -67
- package/esm2015/infra/hasura-graphql/repositories/catalog/filter-option-hasura-graphql.repository.js +31 -11
- package/esm2015/infra/hasura-graphql/repositories/catalog/index.js +1 -2
- package/esm2015/infra/hasura-graphql/repositories/catalog/product-hasura-graphql.repository.js +4 -23
- package/esm2015/infra/hasura-graphql/repositories/catalog/variant-hasura-graphql.repository.js +2 -2
- package/esm2015/infra/hasura-graphql/types/hasura-graphql-fields.type.js +1 -1
- package/esm2015/utils/index.js +6 -6
- package/fesm2015/infrab4a-connect.js +171 -339
- package/fesm2015/infrab4a-connect.js.map +1 -1
- package/infra/firebase/firestore/mixins/with-find-firestore.mixin.d.ts +2 -2
- package/infra/firebase/firestore/repositories/catalog/product-firestore.repository.d.ts +0 -1
- package/infra/firebase/firestore/repositories/shopping/index.d.ts +3 -5
- package/infra/hasura-graphql/mixins/with-find-hasura-graphql.mixin.d.ts +9 -4
- package/infra/hasura-graphql/models/filter-hasura-graphql.d.ts +3 -0
- package/infra/hasura-graphql/models/filter-option-hasura-graphql.d.ts +3 -0
- package/infra/hasura-graphql/models/index.d.ts +2 -0
- package/infra/hasura-graphql/repositories/catalog/category-hasura-graphql.repository.d.ts +1 -4
- package/infra/hasura-graphql/repositories/catalog/filter-hasura-graphql.repository.d.ts +12 -12
- package/infra/hasura-graphql/repositories/catalog/filter-option-hasura-graphql.repository.d.ts +10 -5
- package/infra/hasura-graphql/repositories/catalog/index.d.ts +0 -1
- package/infra/hasura-graphql/repositories/catalog/product-hasura-graphql.repository.d.ts +0 -1
- package/infra/hasura-graphql/types/hasura-graphql-fields.type.d.ts +1 -1
- package/package.json +2 -2
- package/utils/index.d.ts +5 -5
- package/domain/catalog/models/category-filter.d.ts +0 -9
- package/domain/catalog/repositories/category-filter.repository.d.ts +0 -5
- package/domain/shopping/models/campaign-dashboard.d.ts +0 -15
- package/domain/shopping/models/campaign-hashtag.d.ts +0 -18
- package/domain/shopping/repositories/campaign-dashboard.repository.d.ts +0 -4
- package/domain/shopping/repositories/campaign-hashtag.repository.d.ts +0 -4
- package/esm2015/domain/catalog/models/category-filter.js +0 -10
- package/esm2015/domain/catalog/repositories/category-filter.repository.js +0 -2
- package/esm2015/domain/shopping/models/campaign-dashboard.js +0 -7
- package/esm2015/domain/shopping/models/campaign-hashtag.js +0 -7
- package/esm2015/domain/shopping/repositories/campaign-dashboard.repository.js +0 -2
- package/esm2015/domain/shopping/repositories/campaign-hashtag.repository.js +0 -2
- package/esm2015/infra/firebase/firestore/repositories/shopping/campaign-dashboard-firestore.repository.js +0 -12
- package/esm2015/infra/firebase/firestore/repositories/shopping/campaign-hashtag-firestore.repository.js +0 -12
- package/esm2015/infra/hasura-graphql/repositories/catalog/category-filter-hasura-graphql.repository.js +0 -24
- package/infra/firebase/firestore/repositories/shopping/campaign-dashboard-firestore.repository.d.ts +0 -9
- package/infra/firebase/firestore/repositories/shopping/campaign-hashtag-firestore.repository.d.ts +0 -9
- package/infra/hasura-graphql/repositories/catalog/category-filter-hasura-graphql.repository.d.ts +0 -11
|
@@ -4,11 +4,12 @@ import { __decorate, __metadata, __awaiter, __rest } from 'tslib';
|
|
|
4
4
|
import { parseISO } from 'date-fns';
|
|
5
5
|
export { add, addBusinessDays, addDays, addMonths, addYears, endOfDay, format, formatISO9075, parseISO, startOfDay, sub } from 'date-fns';
|
|
6
6
|
import { isString, isNil, isNumber, isDate, set, isObject, isEmpty, chunk, isBoolean, isInteger, isNaN as isNaN$1, omit } from 'lodash';
|
|
7
|
-
export { chunk, isBoolean, isDate, isEmpty, isInteger, isNaN, isNil, isNumber, isObject, isString, now, omit, pick, set } from 'lodash';
|
|
7
|
+
export { chunk, difference, isBoolean, isDate, isEmpty, isInteger, isNaN, isNil, isNumber, isObject, isString, now, omit, pick, set } from 'lodash';
|
|
8
8
|
import { CustomError } from 'ts-custom-error';
|
|
9
9
|
import axios from 'axios';
|
|
10
10
|
import firebase from 'firebase';
|
|
11
11
|
import { mutation, query } from 'gql-query-builder';
|
|
12
|
+
import fetch from 'node-fetch';
|
|
12
13
|
|
|
13
14
|
class BaseModel {
|
|
14
15
|
get identifier() {
|
|
@@ -465,14 +466,14 @@ class Address extends BaseModel {
|
|
|
465
466
|
}
|
|
466
467
|
}
|
|
467
468
|
|
|
469
|
+
const isUUID = (value) => isString(value) && /[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}/.test(value);
|
|
470
|
+
|
|
468
471
|
class Base {
|
|
469
472
|
constructor(...args) {
|
|
470
473
|
Object.assign(this, ...args);
|
|
471
474
|
}
|
|
472
475
|
}
|
|
473
476
|
|
|
474
|
-
const isUUID = (value) => isString(value) && /[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}/.test(value);
|
|
475
|
-
|
|
476
477
|
const parseDateTime = (value) => {
|
|
477
478
|
if (!isString(value))
|
|
478
479
|
return value;
|
|
@@ -750,15 +751,6 @@ class RecoveryPassword {
|
|
|
750
751
|
}
|
|
751
752
|
}
|
|
752
753
|
|
|
753
|
-
class Filter extends BaseModel {
|
|
754
|
-
identifierFields() {
|
|
755
|
-
return ['id'];
|
|
756
|
-
}
|
|
757
|
-
static get identifiersFields() {
|
|
758
|
-
return ['id'];
|
|
759
|
-
}
|
|
760
|
-
}
|
|
761
|
-
|
|
762
754
|
class Category extends BaseModel {
|
|
763
755
|
identifierFields() {
|
|
764
756
|
return ['id'];
|
|
@@ -766,19 +758,6 @@ class Category extends BaseModel {
|
|
|
766
758
|
static get identifiersFields() {
|
|
767
759
|
return ['id'];
|
|
768
760
|
}
|
|
769
|
-
}
|
|
770
|
-
__decorate([
|
|
771
|
-
Type(() => Filter),
|
|
772
|
-
__metadata("design:type", Array)
|
|
773
|
-
], Category.prototype, "filters", void 0);
|
|
774
|
-
|
|
775
|
-
class CategoryFilter extends BaseModel {
|
|
776
|
-
// identifierFields(): NonFunctionPropertyNames<CategoryFilter>[] {
|
|
777
|
-
// return ['id']
|
|
778
|
-
// }
|
|
779
|
-
static get identifiersFields() {
|
|
780
|
-
return ['id', 'filterId', 'categoryId'];
|
|
781
|
-
}
|
|
782
761
|
}
|
|
783
762
|
|
|
784
763
|
var GenderDestination;
|
|
@@ -796,6 +775,15 @@ var Shops;
|
|
|
796
775
|
Shops["ALL"] = "ALL";
|
|
797
776
|
})(Shops || (Shops = {}));
|
|
798
777
|
|
|
778
|
+
class Filter extends BaseModel {
|
|
779
|
+
identifierFields() {
|
|
780
|
+
return ['id'];
|
|
781
|
+
}
|
|
782
|
+
static get identifiersFields() {
|
|
783
|
+
return ['id'];
|
|
784
|
+
}
|
|
785
|
+
}
|
|
786
|
+
|
|
799
787
|
class FilterOption extends BaseModel {
|
|
800
788
|
identifierFields() {
|
|
801
789
|
return ['id'];
|
|
@@ -841,27 +829,17 @@ class Variant extends BaseModel {
|
|
|
841
829
|
}
|
|
842
830
|
}
|
|
843
831
|
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
]
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
static get identifiersFields() {
|
|
856
|
-
return ['id'];
|
|
857
|
-
}
|
|
858
|
-
}
|
|
859
|
-
|
|
860
|
-
class CampaignHashtag extends BaseModel {
|
|
861
|
-
static get identifiersFields() {
|
|
862
|
-
return ['id'];
|
|
863
|
-
}
|
|
864
|
-
}
|
|
832
|
+
var OrderStatus;
|
|
833
|
+
(function (OrderStatus) {
|
|
834
|
+
OrderStatus["AGUARDANDO_PAGAMENTO"] = "Aguardando pagamento";
|
|
835
|
+
OrderStatus["EM_PREPARO"] = "Preparando pedido";
|
|
836
|
+
OrderStatus["NF_EMITIDA"] = "Nota Fiscal Emitida";
|
|
837
|
+
OrderStatus["AGUARDANDO_ENVIO"] = "Aguardando Transaportadora";
|
|
838
|
+
OrderStatus["ENVIADO"] = "Enviado";
|
|
839
|
+
OrderStatus["ENTREGUE"] = "Entregue";
|
|
840
|
+
OrderStatus["CANCELADO"] = "Cancelado";
|
|
841
|
+
OrderStatus["CREDIT_CARD"] = "credit_card";
|
|
842
|
+
})(OrderStatus || (OrderStatus = {}));
|
|
865
843
|
|
|
866
844
|
class LineItem extends Product {
|
|
867
845
|
}
|
|
@@ -902,18 +880,6 @@ __decorate([
|
|
|
902
880
|
__metadata("design:type", Coupon)
|
|
903
881
|
], Checkout.prototype, "coupon", void 0);
|
|
904
882
|
|
|
905
|
-
var OrderStatus;
|
|
906
|
-
(function (OrderStatus) {
|
|
907
|
-
OrderStatus["AGUARDANDO_PAGAMENTO"] = "Aguardando pagamento";
|
|
908
|
-
OrderStatus["EM_PREPARO"] = "Preparando pedido";
|
|
909
|
-
OrderStatus["NF_EMITIDA"] = "Nota Fiscal Emitida";
|
|
910
|
-
OrderStatus["AGUARDANDO_ENVIO"] = "Aguardando Transaportadora";
|
|
911
|
-
OrderStatus["ENVIADO"] = "Enviado";
|
|
912
|
-
OrderStatus["ENTREGUE"] = "Entregue";
|
|
913
|
-
OrderStatus["CANCELADO"] = "Cancelado";
|
|
914
|
-
OrderStatus["CREDIT_CARD"] = "credit_card";
|
|
915
|
-
})(OrderStatus || (OrderStatus = {}));
|
|
916
|
-
|
|
917
883
|
class Order extends Checkout {
|
|
918
884
|
}
|
|
919
885
|
__decorate([
|
|
@@ -943,6 +909,16 @@ __decorate([
|
|
|
943
909
|
__metadata("design:type", Coupon)
|
|
944
910
|
], CheckoutSubscription.prototype, "coupon", void 0);
|
|
945
911
|
|
|
912
|
+
class Buy2Win extends BaseModel {
|
|
913
|
+
static get identifiersFields() {
|
|
914
|
+
return ['id'];
|
|
915
|
+
}
|
|
916
|
+
}
|
|
917
|
+
__decorate([
|
|
918
|
+
Type(() => Category),
|
|
919
|
+
__metadata("design:type", Array)
|
|
920
|
+
], Buy2Win.prototype, "categories", void 0);
|
|
921
|
+
|
|
946
922
|
var FilterType;
|
|
947
923
|
(function (FilterType) {
|
|
948
924
|
FilterType["ACCESSORY_IMPORTANCE"] = "accessoryImportance";
|
|
@@ -1152,9 +1128,8 @@ class ProductsIndex {
|
|
|
1152
1128
|
'stock',
|
|
1153
1129
|
'weight',
|
|
1154
1130
|
'tags',
|
|
1155
|
-
'filters',
|
|
1156
1131
|
'hasVariants',
|
|
1157
|
-
'type'
|
|
1132
|
+
'type'
|
|
1158
1133
|
];
|
|
1159
1134
|
const { hits } = yield this.adapter.query('products/_search', Object.assign({ _source: fields, query: {
|
|
1160
1135
|
bool: {
|
|
@@ -1352,11 +1327,9 @@ const withFindFirestore = (MixinBase) => {
|
|
|
1352
1327
|
return queryReference.where(firestoreFieldName, (options === null || options === void 0 ? void 0 : options.operator) || '==', (options === null || options === void 0 ? void 0 : options.value) || options);
|
|
1353
1328
|
};
|
|
1354
1329
|
}
|
|
1355
|
-
find({ filters, limits, orderBy,
|
|
1356
|
-
var _a;
|
|
1330
|
+
find({ filters, limits, orderBy, } = {}) {
|
|
1357
1331
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1358
1332
|
const orderByKeys = Object.keys(orderBy || {});
|
|
1359
|
-
const enableCount = (_a = options === null || options === void 0 ? void 0 : options.enableCount) !== null && _a !== void 0 ? _a : true;
|
|
1360
1333
|
let query = this.collection(this.buildCollectionPathForFind(filters || {}));
|
|
1361
1334
|
query = this.makeFirestoreWhere(query, filters || {});
|
|
1362
1335
|
if (orderByKeys.length) {
|
|
@@ -1370,7 +1343,7 @@ const withFindFirestore = (MixinBase) => {
|
|
|
1370
1343
|
const data = docs.docs.map((doc) => doc.data());
|
|
1371
1344
|
return {
|
|
1372
1345
|
data,
|
|
1373
|
-
count:
|
|
1346
|
+
count: this.calculateCount(data, limits),
|
|
1374
1347
|
};
|
|
1375
1348
|
});
|
|
1376
1349
|
}
|
|
@@ -1758,9 +1731,6 @@ class ProductFirestoreRepository extends withCrudFirestore(withHelpers(withFires
|
|
|
1758
1731
|
return this.reviews[status];
|
|
1759
1732
|
});
|
|
1760
1733
|
}
|
|
1761
|
-
cleanShoppingCountFromIds(ids) {
|
|
1762
|
-
return;
|
|
1763
|
-
}
|
|
1764
1734
|
}
|
|
1765
1735
|
|
|
1766
1736
|
class ProductVariantFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), Product) {
|
|
@@ -1783,33 +1753,6 @@ class SubscriptionProductFirestoreRepository extends withCrudFirestore(withHelpe
|
|
|
1783
1753
|
}
|
|
1784
1754
|
}
|
|
1785
1755
|
|
|
1786
|
-
class Buy2WinFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1787
|
-
constructor(firestore) {
|
|
1788
|
-
super();
|
|
1789
|
-
this.firestore = firestore;
|
|
1790
|
-
this.collectionName = 'buy2win';
|
|
1791
|
-
this.model = Buy2Win;
|
|
1792
|
-
}
|
|
1793
|
-
}
|
|
1794
|
-
|
|
1795
|
-
class CampaignDashboardFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1796
|
-
constructor(firestore) {
|
|
1797
|
-
super();
|
|
1798
|
-
this.firestore = firestore;
|
|
1799
|
-
this.collectionName = 'dashboardCampaignsAuto';
|
|
1800
|
-
this.model = CampaignDashboard;
|
|
1801
|
-
}
|
|
1802
|
-
}
|
|
1803
|
-
|
|
1804
|
-
class CampaignHashtagFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1805
|
-
constructor(firestore) {
|
|
1806
|
-
super();
|
|
1807
|
-
this.firestore = firestore;
|
|
1808
|
-
this.collectionName = 'hashtagCampaignsAuto';
|
|
1809
|
-
this.model = CampaignHashtag;
|
|
1810
|
-
}
|
|
1811
|
-
}
|
|
1812
|
-
|
|
1813
1756
|
class CheckoutFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1814
1757
|
constructor(firestore) {
|
|
1815
1758
|
super();
|
|
@@ -1819,15 +1762,6 @@ class CheckoutFirestoreRepository extends withCrudFirestore(withHelpers(withFire
|
|
|
1819
1762
|
}
|
|
1820
1763
|
}
|
|
1821
1764
|
|
|
1822
|
-
class CheckoutSubscriptionFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1823
|
-
constructor(firestore) {
|
|
1824
|
-
super();
|
|
1825
|
-
this.firestore = firestore;
|
|
1826
|
-
this.collectionName = 'checkoutsSubscription';
|
|
1827
|
-
this.model = CheckoutSubscription;
|
|
1828
|
-
}
|
|
1829
|
-
}
|
|
1830
|
-
|
|
1831
1765
|
class CouponFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1832
1766
|
constructor(firestore) {
|
|
1833
1767
|
super();
|
|
@@ -1890,20 +1824,21 @@ class OrderFirestoreRepository extends withCrudFirestore(withHelpers(withFiresto
|
|
|
1890
1824
|
}
|
|
1891
1825
|
}
|
|
1892
1826
|
|
|
1893
|
-
class
|
|
1827
|
+
class PaymentFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1894
1828
|
constructor(firestore) {
|
|
1895
|
-
super(
|
|
1829
|
+
super();
|
|
1896
1830
|
this.firestore = firestore;
|
|
1897
|
-
this.collectionName = '
|
|
1831
|
+
this.collectionName = 'payments';
|
|
1832
|
+
this.model = Payment;
|
|
1898
1833
|
}
|
|
1899
1834
|
}
|
|
1900
1835
|
|
|
1901
|
-
class
|
|
1836
|
+
class CheckoutSubscriptionFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1902
1837
|
constructor(firestore) {
|
|
1903
1838
|
super();
|
|
1904
1839
|
this.firestore = firestore;
|
|
1905
|
-
this.collectionName = '
|
|
1906
|
-
this.model =
|
|
1840
|
+
this.collectionName = 'checkoutsSubscription';
|
|
1841
|
+
this.model = CheckoutSubscription;
|
|
1907
1842
|
}
|
|
1908
1843
|
}
|
|
1909
1844
|
|
|
@@ -1916,6 +1851,23 @@ class SubscriptionPlanFirestoreRepository extends withCrudFirestore(withHelpers(
|
|
|
1916
1851
|
}
|
|
1917
1852
|
}
|
|
1918
1853
|
|
|
1854
|
+
class Buy2WinFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1855
|
+
constructor(firestore) {
|
|
1856
|
+
super();
|
|
1857
|
+
this.firestore = firestore;
|
|
1858
|
+
this.collectionName = 'buy2win';
|
|
1859
|
+
this.model = Buy2Win;
|
|
1860
|
+
}
|
|
1861
|
+
}
|
|
1862
|
+
|
|
1863
|
+
class LegacyOrderFirestoreRepository extends OrderFirestoreRepository {
|
|
1864
|
+
constructor(firestore) {
|
|
1865
|
+
super(firestore);
|
|
1866
|
+
this.firestore = firestore;
|
|
1867
|
+
this.collectionName = 'legacyOrders';
|
|
1868
|
+
}
|
|
1869
|
+
}
|
|
1870
|
+
|
|
1919
1871
|
class HomeFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1920
1872
|
constructor(firestore) {
|
|
1921
1873
|
super();
|
|
@@ -2055,7 +2007,7 @@ class AttributeOptionHelper {
|
|
|
2055
2007
|
}
|
|
2056
2008
|
AttributeOptionHelper.FindByAttribute = (attributeName, fields) => {
|
|
2057
2009
|
if (fields.includes(attributeName))
|
|
2058
|
-
return { columnName: attributeName.toString(), attributeName
|
|
2010
|
+
return { columnName: attributeName.toString(), attributeName };
|
|
2059
2011
|
const field = fields.find((columnOption) => isObject(columnOption) && Object.keys(columnOption).includes(attributeName.toString()));
|
|
2060
2012
|
const fieldOption = field === null || field === void 0 ? void 0 : field[attributeName.toString()];
|
|
2061
2013
|
if (isNil(fieldOption))
|
|
@@ -2373,12 +2325,12 @@ const withHasuraGraphQL = (MixinBase) => {
|
|
|
2373
2325
|
fetch(params) {
|
|
2374
2326
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2375
2327
|
const headers = this.headers;
|
|
2376
|
-
const
|
|
2377
|
-
url: `${this.endpoint}`,
|
|
2328
|
+
const response = yield fetch(`${this.endpoint}`, {
|
|
2378
2329
|
method: 'POST',
|
|
2379
|
-
|
|
2330
|
+
body: JSON.stringify(params),
|
|
2380
2331
|
headers,
|
|
2381
2332
|
});
|
|
2333
|
+
const result = yield response.json();
|
|
2382
2334
|
if (!isNil(result.errors))
|
|
2383
2335
|
throw new Error(JSON.stringify(result.errors));
|
|
2384
2336
|
return result.data;
|
|
@@ -2502,11 +2454,9 @@ const withGetHasuraGraphQL = (MixinBase) => {
|
|
|
2502
2454
|
|
|
2503
2455
|
const withFindHasuraGraphQL = (MixinBase) => {
|
|
2504
2456
|
return class FindHasuraGraphQLMixin extends MixinBase {
|
|
2505
|
-
find(
|
|
2506
|
-
var _a;
|
|
2457
|
+
find(options) {
|
|
2507
2458
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2508
|
-
const { filters, limits, orderBy
|
|
2509
|
-
const enableCount = (_a = options === null || options === void 0 ? void 0 : options.enableCount) !== null && _a !== void 0 ? _a : true;
|
|
2459
|
+
const { filters, limits, orderBy } = options || {};
|
|
2510
2460
|
const variablesCount = Object.assign(Object.assign({}, (isNil(orderBy) ? {} : { order_by: { type: `${this.tableName}_order_by!`, list: true, value: orderBy } })), (isNil(filters)
|
|
2511
2461
|
? {}
|
|
2512
2462
|
: {
|
|
@@ -2520,8 +2470,8 @@ const withFindHasuraGraphQL = (MixinBase) => {
|
|
|
2520
2470
|
const result = yield this.query([
|
|
2521
2471
|
{
|
|
2522
2472
|
operation: this.tableName,
|
|
2523
|
-
fields:
|
|
2524
|
-
?
|
|
2473
|
+
fields: options.fields
|
|
2474
|
+
? options.fields
|
|
2525
2475
|
.map((fieldName) => {
|
|
2526
2476
|
var _a;
|
|
2527
2477
|
return (_a = this.fields.find((fieldOption) => fieldOption === fieldName)) !== null && _a !== void 0 ? _a : this.fields.find((fieldOption) => Object.keys(fieldOption).shift() === fieldName);
|
|
@@ -2530,18 +2480,15 @@ const withFindHasuraGraphQL = (MixinBase) => {
|
|
|
2530
2480
|
: this.fields,
|
|
2531
2481
|
variables,
|
|
2532
2482
|
},
|
|
2533
|
-
|
|
2534
|
-
|
|
2535
|
-
|
|
2536
|
-
|
|
2537
|
-
|
|
2538
|
-
variables: variablesCount,
|
|
2539
|
-
},
|
|
2540
|
-
]
|
|
2541
|
-
: []),
|
|
2483
|
+
{
|
|
2484
|
+
operation: `${this.tableName}_aggregate`,
|
|
2485
|
+
fields: [{ aggregate: ['count'] }],
|
|
2486
|
+
variables: variablesCount,
|
|
2487
|
+
},
|
|
2542
2488
|
]);
|
|
2543
2489
|
const data = result[this.tableName].map((row) => this.convertDataFromHasura(row));
|
|
2544
|
-
|
|
2490
|
+
const count = result[`${this.tableName}_aggregate`].aggregate.count;
|
|
2491
|
+
return { count, data };
|
|
2545
2492
|
});
|
|
2546
2493
|
}
|
|
2547
2494
|
};
|
|
@@ -2555,6 +2502,12 @@ const withCrudHasuraGraphQL = (MixinBase) => {
|
|
|
2555
2502
|
class CategoryHasuraGraphQL extends Category {
|
|
2556
2503
|
}
|
|
2557
2504
|
|
|
2505
|
+
class FilterHasuraGraphQL extends Filter {
|
|
2506
|
+
}
|
|
2507
|
+
|
|
2508
|
+
class FilterOptionHasuraGraphQL extends FilterOption {
|
|
2509
|
+
}
|
|
2510
|
+
|
|
2558
2511
|
class ProductHasuraGraphQL extends Product {
|
|
2559
2512
|
}
|
|
2560
2513
|
__decorate([
|
|
@@ -2581,29 +2534,8 @@ class VariantHasuraGraphQL extends Variant {
|
|
|
2581
2534
|
}
|
|
2582
2535
|
}
|
|
2583
2536
|
|
|
2584
|
-
class CategoryFilterHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
2585
|
-
constructor(endpoint, authOptions) {
|
|
2586
|
-
super({
|
|
2587
|
-
tableName: 'category_filter',
|
|
2588
|
-
model: CategoryFilter,
|
|
2589
|
-
endpoint,
|
|
2590
|
-
authOptions,
|
|
2591
|
-
fields: ['id', { filterId: { columnName: 'filter_id' } }, { categoryId: { columnName: 'category_id' } }],
|
|
2592
|
-
});
|
|
2593
|
-
}
|
|
2594
|
-
deleteByCategoryAndFilter(categoryId, filterId) {
|
|
2595
|
-
return this.mutation('delete_category_filter', ['affected_rows'], {
|
|
2596
|
-
where: {
|
|
2597
|
-
type: 'category_filter_bool_exp',
|
|
2598
|
-
required: true,
|
|
2599
|
-
value: { category_id: { _eq: categoryId }, filter_id: { _eq: filterId } },
|
|
2600
|
-
},
|
|
2601
|
-
});
|
|
2602
|
-
}
|
|
2603
|
-
}
|
|
2604
|
-
|
|
2605
2537
|
class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
2606
|
-
constructor(endpoint, authOptions, productRepository
|
|
2538
|
+
constructor(endpoint, authOptions, productRepository) {
|
|
2607
2539
|
super({
|
|
2608
2540
|
tableName: 'category',
|
|
2609
2541
|
model: Category,
|
|
@@ -2639,17 +2571,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
2639
2571
|
},
|
|
2640
2572
|
},
|
|
2641
2573
|
},
|
|
2642
|
-
|
|
2643
|
-
filters: {
|
|
2644
|
-
columnName: 'filters',
|
|
2645
|
-
foreignKeyColumn: { filter_id: 'id' },
|
|
2646
|
-
fields: [{ filter: ['id', 'description', 'slug', 'enabled'] }],
|
|
2647
|
-
bindPersistData: (value) => ({
|
|
2648
|
-
filters: { data: value.map((filter) => ({ filter_id: filter.id })) },
|
|
2649
|
-
}),
|
|
2650
|
-
from: (filters) => (filters === null || filters === void 0 ? void 0 : filters.map((filter) => filter === null || filter === void 0 ? void 0 : filter.filter)) || [],
|
|
2651
|
-
},
|
|
2652
|
-
},
|
|
2574
|
+
'filters',
|
|
2653
2575
|
{ createdAt: { columnName: 'created_at' } },
|
|
2654
2576
|
{ updatedAt: { columnName: 'updated_at' } },
|
|
2655
2577
|
{
|
|
@@ -2674,7 +2596,6 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
2674
2596
|
],
|
|
2675
2597
|
});
|
|
2676
2598
|
this.productRepository = productRepository;
|
|
2677
|
-
this.categoryFilterRepository = categoryFilterRepository;
|
|
2678
2599
|
}
|
|
2679
2600
|
create(params) {
|
|
2680
2601
|
const _super = Object.create(null, {
|
|
@@ -2692,7 +2613,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
2692
2613
|
var _a;
|
|
2693
2614
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2694
2615
|
return Number.isNaN(+identifiers.id)
|
|
2695
|
-
? (_a = (yield this.find({ filters: { firestoreId: identifiers.id }
|
|
2616
|
+
? (_a = (yield this.find({ filters: { firestoreId: identifiers.id } })).data) === null || _a === void 0 ? void 0 : _a[0]
|
|
2696
2617
|
: _super.get.call(this, identifiers);
|
|
2697
2618
|
});
|
|
2698
2619
|
}
|
|
@@ -2701,13 +2622,12 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
2701
2622
|
update: { get: () => super.update }
|
|
2702
2623
|
});
|
|
2703
2624
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2704
|
-
const { products, id: checkId, metadata
|
|
2625
|
+
const { products, id: checkId, metadata } = params, data = __rest(params, ["products", "id", "metadata"]);
|
|
2705
2626
|
const plainData = this.paramsToPlain({ id: checkId });
|
|
2706
2627
|
const id = yield this.getId(plainData.id);
|
|
2707
2628
|
const category = yield _super.update.call(this, Object.assign({ id }, data));
|
|
2708
2629
|
category.products = products && (yield this.updateProducts(+id, { products }));
|
|
2709
2630
|
category.metadata = metadata && (yield this.updateMetadata(+id, { metadata }));
|
|
2710
|
-
category.filters = filters && (yield this.updateFilters(+id, { filters }));
|
|
2711
2631
|
return category;
|
|
2712
2632
|
});
|
|
2713
2633
|
}
|
|
@@ -2715,11 +2635,11 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
2715
2635
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2716
2636
|
if (!slug)
|
|
2717
2637
|
return;
|
|
2718
|
-
const { data } = yield this.find({ filters: { slug, shop, published: true }
|
|
2719
|
-
if (
|
|
2720
|
-
throw new NotFoundError(`Category with slug ${slug} not found`);
|
|
2721
|
-
if (data.length > 1)
|
|
2638
|
+
const { data, count } = yield this.find({ filters: { slug, shop, published: true } });
|
|
2639
|
+
if (count > 1)
|
|
2722
2640
|
throw new DuplicatedResultsError('Query returned duplicated values');
|
|
2641
|
+
if (!count)
|
|
2642
|
+
throw new NotFoundError(`Category with slug ${slug} not found`);
|
|
2723
2643
|
return data.shift();
|
|
2724
2644
|
});
|
|
2725
2645
|
}
|
|
@@ -2755,7 +2675,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
2755
2675
|
if (!((_a = category === null || category === void 0 ? void 0 : category.products) === null || _a === void 0 ? void 0 : _a.length))
|
|
2756
2676
|
return [];
|
|
2757
2677
|
const products = [];
|
|
2758
|
-
const { data: productsData } = yield this.productRepository.find(Object.assign(
|
|
2678
|
+
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: [
|
|
2759
2679
|
'id',
|
|
2760
2680
|
'name',
|
|
2761
2681
|
'slug',
|
|
@@ -2779,7 +2699,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
2779
2699
|
'tags',
|
|
2780
2700
|
'type',
|
|
2781
2701
|
'shoppingCount',
|
|
2782
|
-
] }, ((options === null || options === void 0 ? void 0 : options.limit) ? { limits: { limit: options === null || options === void 0 ? void 0 : options.limit } } : {}))
|
|
2702
|
+
] }, ((options === null || options === void 0 ? void 0 : options.limit) ? { limits: { limit: options === null || options === void 0 ? void 0 : options.limit } } : {})));
|
|
2783
2703
|
products.push(...productsData);
|
|
2784
2704
|
return products;
|
|
2785
2705
|
});
|
|
@@ -2789,7 +2709,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
2789
2709
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2790
2710
|
if (!Number.isNaN(+id))
|
|
2791
2711
|
return id;
|
|
2792
|
-
const { data } = yield this.find({ filters: { firestoreId: id }
|
|
2712
|
+
const { data } = yield this.find({ filters: { firestoreId: id } });
|
|
2793
2713
|
if ((_a = data === null || data === void 0 ? void 0 : data[0]) === null || _a === void 0 ? void 0 : _a.id)
|
|
2794
2714
|
return (_b = data === null || data === void 0 ? void 0 : data[0]) === null || _b === void 0 ? void 0 : _b.id;
|
|
2795
2715
|
throw new NotFoundError(`Category with id ${id} not found`);
|
|
@@ -2847,90 +2767,21 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
2847
2767
|
return plainData.metadata;
|
|
2848
2768
|
});
|
|
2849
2769
|
}
|
|
2850
|
-
updateFilters(categoryId, { filters }) {
|
|
2851
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
2852
|
-
if ('action' in filters && filters.action === 'remove' && filters.value.length) {
|
|
2853
|
-
for (let i = 0; i < filters.value.length; i++) {
|
|
2854
|
-
yield this.categoryFilterRepository.deleteByCategoryAndFilter(categoryId, filters.value[i].id);
|
|
2855
|
-
}
|
|
2856
|
-
return [];
|
|
2857
|
-
}
|
|
2858
|
-
if ('action' in filters && filters.action === 'merge' && filters.value.length) {
|
|
2859
|
-
let filtersList = [];
|
|
2860
|
-
for (let i = 0; i < filters.value.length; i++) {
|
|
2861
|
-
try {
|
|
2862
|
-
const hasFilter = yield this.categoryFilterRepository
|
|
2863
|
-
.find({
|
|
2864
|
-
filters: {
|
|
2865
|
-
categoryId,
|
|
2866
|
-
filterId: filters.value[i].id,
|
|
2867
|
-
},
|
|
2868
|
-
})
|
|
2869
|
-
.then((data) => data.data.shift());
|
|
2870
|
-
if (hasFilter) {
|
|
2871
|
-
filtersList.push(hasFilter);
|
|
2872
|
-
}
|
|
2873
|
-
else {
|
|
2874
|
-
const newCategoryFilter = yield this.categoryFilterRepository.create({
|
|
2875
|
-
filterId: filters.value[i].id,
|
|
2876
|
-
categoryId,
|
|
2877
|
-
});
|
|
2878
|
-
filtersList.push(newCategoryFilter);
|
|
2879
|
-
}
|
|
2880
|
-
}
|
|
2881
|
-
catch (error) {
|
|
2882
|
-
console.log('catch error: ', error);
|
|
2883
|
-
}
|
|
2884
|
-
}
|
|
2885
|
-
return filtersList;
|
|
2886
|
-
}
|
|
2887
|
-
if (Array.isArray(filters) && filters.length) {
|
|
2888
|
-
let filtersList = [];
|
|
2889
|
-
for (let i = 0; i < filters.length; i++) {
|
|
2890
|
-
try {
|
|
2891
|
-
const hasFilter = yield this.categoryFilterRepository
|
|
2892
|
-
.find({
|
|
2893
|
-
filters: {
|
|
2894
|
-
categoryId,
|
|
2895
|
-
filterId: filters[i].id,
|
|
2896
|
-
},
|
|
2897
|
-
})
|
|
2898
|
-
.then((data) => data.data.shift());
|
|
2899
|
-
if (hasFilter) {
|
|
2900
|
-
filtersList.push(hasFilter);
|
|
2901
|
-
}
|
|
2902
|
-
else {
|
|
2903
|
-
const newCategoryFilter = yield this.categoryFilterRepository.create({
|
|
2904
|
-
filterId: filters[i].id,
|
|
2905
|
-
categoryId,
|
|
2906
|
-
});
|
|
2907
|
-
filtersList.push(newCategoryFilter);
|
|
2908
|
-
}
|
|
2909
|
-
}
|
|
2910
|
-
catch (error) {
|
|
2911
|
-
console.log('catch error: ', error);
|
|
2912
|
-
}
|
|
2913
|
-
}
|
|
2914
|
-
return filtersList;
|
|
2915
|
-
}
|
|
2916
|
-
});
|
|
2917
|
-
}
|
|
2918
2770
|
}
|
|
2919
2771
|
|
|
2920
2772
|
class FilterHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
2921
|
-
constructor(endpoint, authOptions, filterOptionRepository
|
|
2773
|
+
constructor(endpoint, authOptions, filterOptionRepository) {
|
|
2922
2774
|
super({
|
|
2923
2775
|
tableName: 'filter',
|
|
2924
|
-
model:
|
|
2776
|
+
model: FilterHasuraGraphQL,
|
|
2925
2777
|
endpoint,
|
|
2926
2778
|
authOptions,
|
|
2927
2779
|
fields: [
|
|
2928
2780
|
'id',
|
|
2929
2781
|
'description',
|
|
2930
|
-
'slug',
|
|
2931
2782
|
'enabled',
|
|
2932
|
-
|
|
2933
|
-
|
|
2783
|
+
'createdAt',
|
|
2784
|
+
'updatedAt',
|
|
2934
2785
|
{
|
|
2935
2786
|
options: {
|
|
2936
2787
|
columnName: 'options',
|
|
@@ -2939,15 +2790,43 @@ class FilterHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGrap
|
|
|
2939
2790
|
'id',
|
|
2940
2791
|
{ filterId: { columnName: 'filter_id' } },
|
|
2941
2792
|
'description',
|
|
2942
|
-
|
|
2943
|
-
|
|
2793
|
+
'createdAt',
|
|
2794
|
+
'updatedAt'
|
|
2944
2795
|
],
|
|
2945
2796
|
},
|
|
2946
|
-
}
|
|
2797
|
+
}
|
|
2947
2798
|
],
|
|
2948
2799
|
});
|
|
2949
2800
|
this.filterOptionRepository = filterOptionRepository;
|
|
2950
|
-
|
|
2801
|
+
}
|
|
2802
|
+
get(identifiers) {
|
|
2803
|
+
const _super = Object.create(null, {
|
|
2804
|
+
get: { get: () => super.get }
|
|
2805
|
+
});
|
|
2806
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2807
|
+
const filter = yield _super.get.call(this, identifiers);
|
|
2808
|
+
if (!filter)
|
|
2809
|
+
throw new NotFoundError('Filter not found');
|
|
2810
|
+
return filter;
|
|
2811
|
+
});
|
|
2812
|
+
}
|
|
2813
|
+
find(options) {
|
|
2814
|
+
const _super = Object.create(null, {
|
|
2815
|
+
find: { get: () => super.find }
|
|
2816
|
+
});
|
|
2817
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2818
|
+
const filter = yield _super.find.call(this, options);
|
|
2819
|
+
return filter;
|
|
2820
|
+
});
|
|
2821
|
+
}
|
|
2822
|
+
create(params) {
|
|
2823
|
+
const _super = Object.create(null, {
|
|
2824
|
+
create: { get: () => super.create }
|
|
2825
|
+
});
|
|
2826
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2827
|
+
const filter = yield _super.create.call(this, params);
|
|
2828
|
+
return filter;
|
|
2829
|
+
});
|
|
2951
2830
|
}
|
|
2952
2831
|
update(params) {
|
|
2953
2832
|
const _super = Object.create(null, {
|
|
@@ -2960,77 +2839,30 @@ class FilterHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGrap
|
|
|
2960
2839
|
return filter;
|
|
2961
2840
|
});
|
|
2962
2841
|
}
|
|
2842
|
+
;
|
|
2963
2843
|
updateOptions(filterId, { options }) {
|
|
2964
2844
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2965
2845
|
if (!options)
|
|
2966
2846
|
return [];
|
|
2967
|
-
if ('action' in options && options.action === 'remove'
|
|
2847
|
+
if ('action' in options && options.action === 'remove') {
|
|
2968
2848
|
for (let i = 0; i < options.value.length; i++) {
|
|
2969
2849
|
yield this.filterOptionRepository.delete({ id: options.value[i].id });
|
|
2970
2850
|
}
|
|
2971
2851
|
return [];
|
|
2972
2852
|
}
|
|
2973
|
-
if ('action' in options && options.action === '
|
|
2853
|
+
if ('action' in options && options.action === 'update') {
|
|
2974
2854
|
let filterOptions = [];
|
|
2975
2855
|
for (let i = 0; i < options.value.length; i++) {
|
|
2976
|
-
|
|
2977
|
-
|
|
2978
|
-
|
|
2979
|
-
filterOptions.push(hasFilter);
|
|
2980
|
-
}
|
|
2981
|
-
catch (error) {
|
|
2982
|
-
const newOption = yield this.filterOptionRepository.create(Object.assign(Object.assign({}, options.value[i]), { filterId }));
|
|
2856
|
+
const hasFilter = yield this.filterOptionRepository.get({ id: options.value[i].id });
|
|
2857
|
+
if (!hasFilter) {
|
|
2858
|
+
const newOption = yield this.filterOptionRepository.create(options.value[i]);
|
|
2983
2859
|
filterOptions.push(newOption);
|
|
2984
2860
|
}
|
|
2985
|
-
|
|
2986
|
-
|
|
2987
|
-
}
|
|
2988
|
-
if (Array.isArray(options) && options.length) {
|
|
2989
|
-
let filterOptions = [];
|
|
2990
|
-
for (let i = 0; i < options.length; i++) {
|
|
2991
|
-
try {
|
|
2992
|
-
const hasFilter = yield this.filterOptionRepository.get({ id: options[i].id });
|
|
2993
|
-
if (hasFilter)
|
|
2994
|
-
filterOptions.push(hasFilter);
|
|
2861
|
+
else {
|
|
2862
|
+
filterOptions.push(hasFilter);
|
|
2995
2863
|
}
|
|
2996
|
-
catch (error) {
|
|
2997
|
-
const newOption = yield this.filterOptionRepository.create(Object.assign(Object.assign({}, options[i]), { filterId }));
|
|
2998
|
-
filterOptions.push(newOption);
|
|
2999
|
-
}
|
|
3000
|
-
}
|
|
3001
|
-
}
|
|
3002
|
-
return [];
|
|
3003
|
-
});
|
|
3004
|
-
}
|
|
3005
|
-
delete(params) {
|
|
3006
|
-
const _super = Object.create(null, {
|
|
3007
|
-
delete: { get: () => super.delete }
|
|
3008
|
-
});
|
|
3009
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
3010
|
-
const { options } = params, data = __rest(params, ["options"]);
|
|
3011
|
-
const categoryFilters = yield this.categoryFilterRepository
|
|
3012
|
-
.find({
|
|
3013
|
-
filters: {
|
|
3014
|
-
filterId: +data.id,
|
|
3015
|
-
},
|
|
3016
|
-
})
|
|
3017
|
-
.then((result) => result.data);
|
|
3018
|
-
if (categoryFilters.length)
|
|
3019
|
-
throw new Error('Erro: o filtro está associado a uma ou mais categoria(s)');
|
|
3020
|
-
yield this.deleteOptions(options);
|
|
3021
|
-
yield _super.delete.call(this, { id: +data.id });
|
|
3022
|
-
return;
|
|
3023
|
-
});
|
|
3024
|
-
}
|
|
3025
|
-
deleteOptions(options) {
|
|
3026
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
3027
|
-
for (let i = 0; i < options.length; i++) {
|
|
3028
|
-
try {
|
|
3029
|
-
yield this.filterOptionRepository.delete({ id: options[i].id });
|
|
3030
|
-
}
|
|
3031
|
-
catch (error) {
|
|
3032
|
-
console.log(error);
|
|
3033
2864
|
}
|
|
2865
|
+
return filterOptions;
|
|
3034
2866
|
}
|
|
3035
2867
|
});
|
|
3036
2868
|
}
|
|
@@ -3039,17 +2871,36 @@ class FilterHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGrap
|
|
|
3039
2871
|
class FilterOptionHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
3040
2872
|
constructor(endpoint, authOptions) {
|
|
3041
2873
|
super({
|
|
3042
|
-
tableName: '
|
|
3043
|
-
model:
|
|
2874
|
+
tableName: 'filter-option',
|
|
2875
|
+
model: FilterOptionHasuraGraphQL,
|
|
3044
2876
|
endpoint,
|
|
3045
2877
|
authOptions,
|
|
3046
|
-
fields: [
|
|
3047
|
-
|
|
3048
|
-
|
|
3049
|
-
|
|
3050
|
-
|
|
3051
|
-
|
|
3052
|
-
|
|
2878
|
+
fields: [],
|
|
2879
|
+
});
|
|
2880
|
+
}
|
|
2881
|
+
create(params) {
|
|
2882
|
+
return super.create(params);
|
|
2883
|
+
}
|
|
2884
|
+
find(options) {
|
|
2885
|
+
const _super = Object.create(null, {
|
|
2886
|
+
find: { get: () => super.find }
|
|
2887
|
+
});
|
|
2888
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2889
|
+
const filterOptions = yield _super.find.call(this, options);
|
|
2890
|
+
return filterOptions;
|
|
2891
|
+
});
|
|
2892
|
+
}
|
|
2893
|
+
delete(identifiers) {
|
|
2894
|
+
return super.delete(identifiers);
|
|
2895
|
+
}
|
|
2896
|
+
findByFilter(filterId) {
|
|
2897
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2898
|
+
const options = yield this.find({
|
|
2899
|
+
filters: {
|
|
2900
|
+
filterId,
|
|
2901
|
+
},
|
|
2902
|
+
});
|
|
2903
|
+
return options;
|
|
3053
2904
|
});
|
|
3054
2905
|
}
|
|
3055
2906
|
}
|
|
@@ -3157,7 +3008,6 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
3157
3008
|
'weight',
|
|
3158
3009
|
'gender',
|
|
3159
3010
|
{ tags: { columnName: 'tags', type: HasuraGraphQLColumnType.Jsonb } },
|
|
3160
|
-
{ filters: { columnName: 'filters', type: HasuraGraphQLColumnType.Jsonb } },
|
|
3161
3011
|
{ isKit: { columnName: 'is_kit' } },
|
|
3162
3012
|
{ createdAt: { columnName: 'created_at' } },
|
|
3163
3013
|
{ updatedAt: { columnName: 'updated_at' } },
|
|
@@ -3259,7 +3109,7 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
3259
3109
|
var _a;
|
|
3260
3110
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3261
3111
|
const product = Number.isNaN(+identifiers.id)
|
|
3262
|
-
? (_a = (yield this.find({ filters: { firestoreId: identifiers.id }
|
|
3112
|
+
? (_a = (yield this.find({ filters: { firestoreId: identifiers.id } })).data) === null || _a === void 0 ? void 0 : _a[0]
|
|
3263
3113
|
: yield _super.get.call(this, identifiers);
|
|
3264
3114
|
if (product.productId)
|
|
3265
3115
|
throw new NotFoundError('Product not found, it is a variant');
|
|
@@ -3287,12 +3137,9 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
3287
3137
|
filters: {
|
|
3288
3138
|
slug,
|
|
3289
3139
|
},
|
|
3290
|
-
fields: this.fields.map((field) => typeof field === 'string' ? field : Object.keys(field).shift()),
|
|
3291
|
-
options: {
|
|
3292
|
-
enableCount: false,
|
|
3293
|
-
},
|
|
3294
3140
|
});
|
|
3295
3141
|
const product = (_a = result === null || result === void 0 ? void 0 : result.data) === null || _a === void 0 ? void 0 : _a.shift();
|
|
3142
|
+
product.reviews = yield this.findReviewsByProduct(+product.id);
|
|
3296
3143
|
return product;
|
|
3297
3144
|
});
|
|
3298
3145
|
}
|
|
@@ -3455,7 +3302,7 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
3455
3302
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3456
3303
|
if (!Number.isNaN(+id))
|
|
3457
3304
|
return id;
|
|
3458
|
-
const { data } = yield this.find({ filters: { firestoreId: id }
|
|
3305
|
+
const { data } = yield this.find({ filters: { firestoreId: id } });
|
|
3459
3306
|
if ((_a = data === null || data === void 0 ? void 0 : data[0]) === null || _a === void 0 ? void 0 : _a.id)
|
|
3460
3307
|
return (_b = data === null || data === void 0 ? void 0 : data[0]) === null || _b === void 0 ? void 0 : _b.id;
|
|
3461
3308
|
throw new NotFoundError(`Product with id ${id} not found`);
|
|
@@ -3511,21 +3358,6 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
3511
3358
|
return data && data[0] && this.bindReviewToModel(data[0]);
|
|
3512
3359
|
});
|
|
3513
3360
|
}
|
|
3514
|
-
cleanShoppingCountFromIds(ids) {
|
|
3515
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
3516
|
-
return yield this.mutation('update_product', ['affected_rows'], {
|
|
3517
|
-
where: {
|
|
3518
|
-
value: { id: { _nin: ids } },
|
|
3519
|
-
type: 'product_bool_exp',
|
|
3520
|
-
required: true,
|
|
3521
|
-
},
|
|
3522
|
-
_set: {
|
|
3523
|
-
value: { shopping_count: 0 },
|
|
3524
|
-
type: 'product_set_input',
|
|
3525
|
-
},
|
|
3526
|
-
});
|
|
3527
|
-
});
|
|
3528
|
-
}
|
|
3529
3361
|
}
|
|
3530
3362
|
|
|
3531
3363
|
class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
@@ -3629,7 +3461,7 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
3629
3461
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3630
3462
|
if (!Number.isNaN(+id))
|
|
3631
3463
|
return id;
|
|
3632
|
-
const { data } = yield this.find({ filters: { firestoreId: id }
|
|
3464
|
+
const { data } = yield this.find({ filters: { firestoreId: id } });
|
|
3633
3465
|
if ((_a = data === null || data === void 0 ? void 0 : data[0]) === null || _a === void 0 ? void 0 : _a.id)
|
|
3634
3466
|
return (_b = data === null || data === void 0 ? void 0 : data[0]) === null || _b === void 0 ? void 0 : _b.id;
|
|
3635
3467
|
throw new NotFoundError(`Product with id ${id} not found`);
|
|
@@ -3641,5 +3473,5 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
3641
3473
|
* Generated bundle index. Do not edit.
|
|
3642
3474
|
*/
|
|
3643
3475
|
|
|
3644
|
-
export { AccessoryImportances, Address, Area, Authentication, AuthenticationFirebaseAuthService, AxiosAdapter, Base, BaseModel, BeardProblems, BeardSizes, BeautyProductImportances, BeautyProfile, BeautyQuestionsHelper, BillingStatus, BodyProblems, BodyShapes, BodyTattoos, Buy2Win, Buy2WinFirestoreRepository,
|
|
3476
|
+
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, Filter, FilterHasuraGraphQL, FilterHasuraGraphQLRepository, FilterOption, FilterOptionHasuraGraphQL, 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, Shops, SignInMethods, SignOut, Status, Subscription, SubscriptionEditionFirestoreRepository, SubscriptionFirestoreRepository, SubscriptionPayment, SubscriptionPaymentFirestoreRepository, SubscriptionPlan, SubscriptionPlanFirestoreRepository, SubscriptionProductFirestoreRepository, UnauthorizedError, UpdateOptionActions, User, UserAddress, UserAddressFirestoreRepository, UserAlreadyRegisteredError, UserBeautyProfileFirestoreRepository, UserFirestoreRepository, UserPaymentMethod, UserPaymentMethodFirestoreRepository, UserType, Variant, VariantHasuraGraphQL, VariantHasuraGraphQLRepository, WeakPasswordError, Where, isUUID, parseDateTime, withCreateFirestore, withCreateHasuraGraphQL, withCrudFirestore, withCrudHasuraGraphQL, withDeleteFirestore, withDeleteHasuraGraphQL, withFindFirestore, withFindHasuraGraphQL, withFirestore, withGetFirestore, withGetHasuraGraphQL, withHasuraGraphQL, withHelpers, withSubCollection, withUpdateFirestore, withUpdateHasuraGraphQL };
|
|
3645
3477
|
//# sourceMappingURL=infrab4a-connect.js.map
|