@infrab4a/connect 3.3.3-beta.1 → 3.4.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundles/infrab4a-connect.umd.js +280 -610
- 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/repositories/catalog/category-hasura-graphql.repository.js +12 -92
- package/esm2015/infra/hasura-graphql/repositories/catalog/filter-hasura-graphql.repository.js +46 -65
- package/esm2015/infra/hasura-graphql/repositories/catalog/filter-option-hasura-graphql.repository.js +29 -9
- 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 +163 -337
- 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/repositories/catalog/category-hasura-graphql.repository.d.ts +1 -4
- package/infra/hasura-graphql/repositories/catalog/filter-hasura-graphql.repository.d.ts +6 -7
- package/infra/hasura-graphql/repositories/catalog/filter-option-hasura-graphql.repository.d.ts +6 -2
- 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
|
};
|
|
@@ -2581,29 +2528,8 @@ class VariantHasuraGraphQL extends Variant {
|
|
|
2581
2528
|
}
|
|
2582
2529
|
}
|
|
2583
2530
|
|
|
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
2531
|
class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
2606
|
-
constructor(endpoint, authOptions, productRepository
|
|
2532
|
+
constructor(endpoint, authOptions, productRepository) {
|
|
2607
2533
|
super({
|
|
2608
2534
|
tableName: 'category',
|
|
2609
2535
|
model: Category,
|
|
@@ -2639,17 +2565,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
2639
2565
|
},
|
|
2640
2566
|
},
|
|
2641
2567
|
},
|
|
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
|
-
},
|
|
2568
|
+
'filters',
|
|
2653
2569
|
{ createdAt: { columnName: 'created_at' } },
|
|
2654
2570
|
{ updatedAt: { columnName: 'updated_at' } },
|
|
2655
2571
|
{
|
|
@@ -2674,7 +2590,6 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
2674
2590
|
],
|
|
2675
2591
|
});
|
|
2676
2592
|
this.productRepository = productRepository;
|
|
2677
|
-
this.categoryFilterRepository = categoryFilterRepository;
|
|
2678
2593
|
}
|
|
2679
2594
|
create(params) {
|
|
2680
2595
|
const _super = Object.create(null, {
|
|
@@ -2692,7 +2607,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
2692
2607
|
var _a;
|
|
2693
2608
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2694
2609
|
return Number.isNaN(+identifiers.id)
|
|
2695
|
-
? (_a = (yield this.find({ filters: { firestoreId: identifiers.id }
|
|
2610
|
+
? (_a = (yield this.find({ filters: { firestoreId: identifiers.id } })).data) === null || _a === void 0 ? void 0 : _a[0]
|
|
2696
2611
|
: _super.get.call(this, identifiers);
|
|
2697
2612
|
});
|
|
2698
2613
|
}
|
|
@@ -2701,13 +2616,12 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
2701
2616
|
update: { get: () => super.update }
|
|
2702
2617
|
});
|
|
2703
2618
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2704
|
-
const { products, id: checkId, metadata
|
|
2619
|
+
const { products, id: checkId, metadata } = params, data = __rest(params, ["products", "id", "metadata"]);
|
|
2705
2620
|
const plainData = this.paramsToPlain({ id: checkId });
|
|
2706
2621
|
const id = yield this.getId(plainData.id);
|
|
2707
2622
|
const category = yield _super.update.call(this, Object.assign({ id }, data));
|
|
2708
2623
|
category.products = products && (yield this.updateProducts(+id, { products }));
|
|
2709
2624
|
category.metadata = metadata && (yield this.updateMetadata(+id, { metadata }));
|
|
2710
|
-
category.filters = filters && (yield this.updateFilters(+id, { filters }));
|
|
2711
2625
|
return category;
|
|
2712
2626
|
});
|
|
2713
2627
|
}
|
|
@@ -2715,11 +2629,11 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
2715
2629
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2716
2630
|
if (!slug)
|
|
2717
2631
|
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)
|
|
2632
|
+
const { data, count } = yield this.find({ filters: { slug, shop, published: true } });
|
|
2633
|
+
if (count > 1)
|
|
2722
2634
|
throw new DuplicatedResultsError('Query returned duplicated values');
|
|
2635
|
+
if (!count)
|
|
2636
|
+
throw new NotFoundError(`Category with slug ${slug} not found`);
|
|
2723
2637
|
return data.shift();
|
|
2724
2638
|
});
|
|
2725
2639
|
}
|
|
@@ -2755,7 +2669,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
2755
2669
|
if (!((_a = category === null || category === void 0 ? void 0 : category.products) === null || _a === void 0 ? void 0 : _a.length))
|
|
2756
2670
|
return [];
|
|
2757
2671
|
const products = [];
|
|
2758
|
-
const { data: productsData } = yield this.productRepository.find(Object.assign(
|
|
2672
|
+
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
2673
|
'id',
|
|
2760
2674
|
'name',
|
|
2761
2675
|
'slug',
|
|
@@ -2779,7 +2693,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
2779
2693
|
'tags',
|
|
2780
2694
|
'type',
|
|
2781
2695
|
'shoppingCount',
|
|
2782
|
-
] }, ((options === null || options === void 0 ? void 0 : options.limit) ? { limits: { limit: options === null || options === void 0 ? void 0 : options.limit } } : {}))
|
|
2696
|
+
] }, ((options === null || options === void 0 ? void 0 : options.limit) ? { limits: { limit: options === null || options === void 0 ? void 0 : options.limit } } : {})));
|
|
2783
2697
|
products.push(...productsData);
|
|
2784
2698
|
return products;
|
|
2785
2699
|
});
|
|
@@ -2789,7 +2703,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
2789
2703
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2790
2704
|
if (!Number.isNaN(+id))
|
|
2791
2705
|
return id;
|
|
2792
|
-
const { data } = yield this.find({ filters: { firestoreId: id }
|
|
2706
|
+
const { data } = yield this.find({ filters: { firestoreId: id } });
|
|
2793
2707
|
if ((_a = data === null || data === void 0 ? void 0 : data[0]) === null || _a === void 0 ? void 0 : _a.id)
|
|
2794
2708
|
return (_b = data === null || data === void 0 ? void 0 : data[0]) === null || _b === void 0 ? void 0 : _b.id;
|
|
2795
2709
|
throw new NotFoundError(`Category with id ${id} not found`);
|
|
@@ -2847,78 +2761,10 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
2847
2761
|
return plainData.metadata;
|
|
2848
2762
|
});
|
|
2849
2763
|
}
|
|
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
2764
|
}
|
|
2919
2765
|
|
|
2920
2766
|
class FilterHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
2921
|
-
constructor(endpoint, authOptions, filterOptionRepository
|
|
2767
|
+
constructor(endpoint, authOptions, filterOptionRepository) {
|
|
2922
2768
|
super({
|
|
2923
2769
|
tableName: 'filter',
|
|
2924
2770
|
model: Filter,
|
|
@@ -2927,10 +2773,9 @@ class FilterHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGrap
|
|
|
2927
2773
|
fields: [
|
|
2928
2774
|
'id',
|
|
2929
2775
|
'description',
|
|
2930
|
-
'slug',
|
|
2931
2776
|
'enabled',
|
|
2932
|
-
|
|
2933
|
-
|
|
2777
|
+
'createdAt',
|
|
2778
|
+
'updatedAt',
|
|
2934
2779
|
{
|
|
2935
2780
|
options: {
|
|
2936
2781
|
columnName: 'options',
|
|
@@ -2939,15 +2784,43 @@ class FilterHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGrap
|
|
|
2939
2784
|
'id',
|
|
2940
2785
|
{ filterId: { columnName: 'filter_id' } },
|
|
2941
2786
|
'description',
|
|
2942
|
-
|
|
2943
|
-
|
|
2787
|
+
'createdAt',
|
|
2788
|
+
'updatedAt'
|
|
2944
2789
|
],
|
|
2945
2790
|
},
|
|
2946
|
-
}
|
|
2791
|
+
}
|
|
2947
2792
|
],
|
|
2948
2793
|
});
|
|
2949
2794
|
this.filterOptionRepository = filterOptionRepository;
|
|
2950
|
-
|
|
2795
|
+
}
|
|
2796
|
+
get(identifiers) {
|
|
2797
|
+
const _super = Object.create(null, {
|
|
2798
|
+
get: { get: () => super.get }
|
|
2799
|
+
});
|
|
2800
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2801
|
+
const filter = yield _super.get.call(this, identifiers);
|
|
2802
|
+
if (!filter)
|
|
2803
|
+
throw new NotFoundError('Filter not found');
|
|
2804
|
+
return filter;
|
|
2805
|
+
});
|
|
2806
|
+
}
|
|
2807
|
+
find(options) {
|
|
2808
|
+
const _super = Object.create(null, {
|
|
2809
|
+
find: { get: () => super.find }
|
|
2810
|
+
});
|
|
2811
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2812
|
+
const filter = yield _super.find.call(this, options);
|
|
2813
|
+
return filter;
|
|
2814
|
+
});
|
|
2815
|
+
}
|
|
2816
|
+
create(params) {
|
|
2817
|
+
const _super = Object.create(null, {
|
|
2818
|
+
create: { get: () => super.create }
|
|
2819
|
+
});
|
|
2820
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2821
|
+
const filter = yield _super.create.call(this, params);
|
|
2822
|
+
return filter;
|
|
2823
|
+
});
|
|
2951
2824
|
}
|
|
2952
2825
|
update(params) {
|
|
2953
2826
|
const _super = Object.create(null, {
|
|
@@ -2960,77 +2833,30 @@ class FilterHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGrap
|
|
|
2960
2833
|
return filter;
|
|
2961
2834
|
});
|
|
2962
2835
|
}
|
|
2836
|
+
;
|
|
2963
2837
|
updateOptions(filterId, { options }) {
|
|
2964
2838
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2965
2839
|
if (!options)
|
|
2966
2840
|
return [];
|
|
2967
|
-
if ('action' in options && options.action === 'remove'
|
|
2841
|
+
if ('action' in options && options.action === 'remove') {
|
|
2968
2842
|
for (let i = 0; i < options.value.length; i++) {
|
|
2969
2843
|
yield this.filterOptionRepository.delete({ id: options.value[i].id });
|
|
2970
2844
|
}
|
|
2971
2845
|
return [];
|
|
2972
2846
|
}
|
|
2973
|
-
if ('action' in options && options.action === '
|
|
2847
|
+
if ('action' in options && options.action === 'update') {
|
|
2974
2848
|
let filterOptions = [];
|
|
2975
2849
|
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 }));
|
|
2850
|
+
const hasFilter = yield this.filterOptionRepository.get({ id: options.value[i].id });
|
|
2851
|
+
if (!hasFilter) {
|
|
2852
|
+
const newOption = yield this.filterOptionRepository.create(options.value[i]);
|
|
2983
2853
|
filterOptions.push(newOption);
|
|
2984
2854
|
}
|
|
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);
|
|
2995
|
-
}
|
|
2996
|
-
catch (error) {
|
|
2997
|
-
const newOption = yield this.filterOptionRepository.create(Object.assign(Object.assign({}, options[i]), { filterId }));
|
|
2998
|
-
filterOptions.push(newOption);
|
|
2855
|
+
else {
|
|
2856
|
+
filterOptions.push(hasFilter);
|
|
2999
2857
|
}
|
|
3000
2858
|
}
|
|
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
|
-
}
|
|
2859
|
+
return filterOptions;
|
|
3034
2860
|
}
|
|
3035
2861
|
});
|
|
3036
2862
|
}
|
|
@@ -3039,17 +2865,36 @@ class FilterHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGrap
|
|
|
3039
2865
|
class FilterOptionHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
3040
2866
|
constructor(endpoint, authOptions) {
|
|
3041
2867
|
super({
|
|
3042
|
-
tableName: '
|
|
2868
|
+
tableName: 'filter-option',
|
|
3043
2869
|
model: FilterOption,
|
|
3044
2870
|
endpoint,
|
|
3045
2871
|
authOptions,
|
|
3046
|
-
fields: [
|
|
3047
|
-
|
|
3048
|
-
|
|
3049
|
-
|
|
3050
|
-
|
|
3051
|
-
|
|
3052
|
-
|
|
2872
|
+
fields: [],
|
|
2873
|
+
});
|
|
2874
|
+
}
|
|
2875
|
+
create(params) {
|
|
2876
|
+
return super.create(params);
|
|
2877
|
+
}
|
|
2878
|
+
find(options) {
|
|
2879
|
+
const _super = Object.create(null, {
|
|
2880
|
+
find: { get: () => super.find }
|
|
2881
|
+
});
|
|
2882
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2883
|
+
const filterOptions = yield _super.find.call(this, options);
|
|
2884
|
+
return filterOptions;
|
|
2885
|
+
});
|
|
2886
|
+
}
|
|
2887
|
+
delete(identifiers) {
|
|
2888
|
+
return super.delete(identifiers);
|
|
2889
|
+
}
|
|
2890
|
+
findByFilter(filterId) {
|
|
2891
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2892
|
+
const options = yield this.find({
|
|
2893
|
+
filters: {
|
|
2894
|
+
filterId,
|
|
2895
|
+
},
|
|
2896
|
+
});
|
|
2897
|
+
return options;
|
|
3053
2898
|
});
|
|
3054
2899
|
}
|
|
3055
2900
|
}
|
|
@@ -3157,7 +3002,6 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
3157
3002
|
'weight',
|
|
3158
3003
|
'gender',
|
|
3159
3004
|
{ tags: { columnName: 'tags', type: HasuraGraphQLColumnType.Jsonb } },
|
|
3160
|
-
{ filters: { columnName: 'filters', type: HasuraGraphQLColumnType.Jsonb } },
|
|
3161
3005
|
{ isKit: { columnName: 'is_kit' } },
|
|
3162
3006
|
{ createdAt: { columnName: 'created_at' } },
|
|
3163
3007
|
{ updatedAt: { columnName: 'updated_at' } },
|
|
@@ -3259,7 +3103,7 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
3259
3103
|
var _a;
|
|
3260
3104
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3261
3105
|
const product = Number.isNaN(+identifiers.id)
|
|
3262
|
-
? (_a = (yield this.find({ filters: { firestoreId: identifiers.id }
|
|
3106
|
+
? (_a = (yield this.find({ filters: { firestoreId: identifiers.id } })).data) === null || _a === void 0 ? void 0 : _a[0]
|
|
3263
3107
|
: yield _super.get.call(this, identifiers);
|
|
3264
3108
|
if (product.productId)
|
|
3265
3109
|
throw new NotFoundError('Product not found, it is a variant');
|
|
@@ -3287,12 +3131,9 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
3287
3131
|
filters: {
|
|
3288
3132
|
slug,
|
|
3289
3133
|
},
|
|
3290
|
-
fields: this.fields.map((field) => typeof field === 'string' ? field : Object.keys(field).shift()),
|
|
3291
|
-
options: {
|
|
3292
|
-
enableCount: false,
|
|
3293
|
-
},
|
|
3294
3134
|
});
|
|
3295
3135
|
const product = (_a = result === null || result === void 0 ? void 0 : result.data) === null || _a === void 0 ? void 0 : _a.shift();
|
|
3136
|
+
product.reviews = yield this.findReviewsByProduct(+product.id);
|
|
3296
3137
|
return product;
|
|
3297
3138
|
});
|
|
3298
3139
|
}
|
|
@@ -3455,7 +3296,7 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
3455
3296
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3456
3297
|
if (!Number.isNaN(+id))
|
|
3457
3298
|
return id;
|
|
3458
|
-
const { data } = yield this.find({ filters: { firestoreId: id }
|
|
3299
|
+
const { data } = yield this.find({ filters: { firestoreId: id } });
|
|
3459
3300
|
if ((_a = data === null || data === void 0 ? void 0 : data[0]) === null || _a === void 0 ? void 0 : _a.id)
|
|
3460
3301
|
return (_b = data === null || data === void 0 ? void 0 : data[0]) === null || _b === void 0 ? void 0 : _b.id;
|
|
3461
3302
|
throw new NotFoundError(`Product with id ${id} not found`);
|
|
@@ -3511,21 +3352,6 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
3511
3352
|
return data && data[0] && this.bindReviewToModel(data[0]);
|
|
3512
3353
|
});
|
|
3513
3354
|
}
|
|
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
3355
|
}
|
|
3530
3356
|
|
|
3531
3357
|
class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
@@ -3629,7 +3455,7 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
3629
3455
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3630
3456
|
if (!Number.isNaN(+id))
|
|
3631
3457
|
return id;
|
|
3632
|
-
const { data } = yield this.find({ filters: { firestoreId: id }
|
|
3458
|
+
const { data } = yield this.find({ filters: { firestoreId: id } });
|
|
3633
3459
|
if ((_a = data === null || data === void 0 ? void 0 : data[0]) === null || _a === void 0 ? void 0 : _a.id)
|
|
3634
3460
|
return (_b = data === null || data === void 0 ? void 0 : data[0]) === null || _b === void 0 ? void 0 : _b.id;
|
|
3635
3461
|
throw new NotFoundError(`Product with id ${id} not found`);
|
|
@@ -3641,5 +3467,5 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
3641
3467
|
* Generated bundle index. Do not edit.
|
|
3642
3468
|
*/
|
|
3643
3469
|
|
|
3644
|
-
export { AccessoryImportances, Address, Area, Authentication, AuthenticationFirebaseAuthService, AxiosAdapter, Base, BaseModel, BeardProblems, BeardSizes, BeautyProductImportances, BeautyProfile, BeautyQuestionsHelper, BillingStatus, BodyProblems, BodyShapes, BodyTattoos, Buy2Win, Buy2WinFirestoreRepository,
|
|
3470
|
+
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, 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, 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
3471
|
//# sourceMappingURL=infrab4a-connect.js.map
|