@infrab4a/connect 3.5.0-beta.3 → 3.6.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 +622 -153
- package/bundles/infrab4a-connect.umd.js.map +1 -1
- package/domain/catalog/models/category-filter.d.ts +9 -0
- package/domain/catalog/models/category.d.ts +3 -2
- package/domain/catalog/models/filter-option.d.ts +10 -0
- package/domain/catalog/models/filter.d.ts +13 -0
- package/domain/catalog/models/index.d.ts +3 -0
- package/domain/catalog/models/product.d.ts +1 -0
- package/domain/catalog/models/types/index.d.ts +0 -1
- package/domain/catalog/repositories/category-filter.repository.d.ts +5 -0
- package/domain/catalog/repositories/filter-option.repository.d.ts +4 -0
- package/domain/catalog/repositories/filter.repository.d.ts +4 -0
- package/domain/catalog/repositories/index.d.ts +3 -0
- package/domain/shop-settings/models/index.d.ts +1 -0
- package/domain/shop-settings/models/shop-settings.d.ts +9 -0
- package/domain/shop-settings/models/types/index.d.ts +5 -0
- package/domain/shop-settings/models/types/shop-banner.type.d.ts +12 -0
- package/domain/shop-settings/models/types/shop-brands.type.d.ts +10 -0
- package/domain/shop-settings/models/types/shop-carousel.type.d.ts +5 -0
- package/domain/shop-settings/models/types/shop-collection.type.d.ts +9 -0
- package/domain/shop-settings/models/types/shop-section.type.d.ts +9 -0
- package/domain/shop-settings/repositories/index.d.ts +1 -0
- package/domain/shop-settings/repositories/shop-settings.repository.d.ts +4 -0
- package/domain/shopping/models/index.d.ts +4 -5
- package/domain/shopping/repositories/index.d.ts +2 -4
- package/esm2015/domain/catalog/models/category-filter.js +10 -0
- package/esm2015/domain/catalog/models/category.js +8 -1
- package/esm2015/domain/catalog/models/filter-option.js +10 -0
- package/esm2015/domain/catalog/models/filter.js +10 -0
- package/esm2015/domain/catalog/models/index.js +4 -1
- package/esm2015/domain/catalog/models/product.js +1 -1
- package/esm2015/domain/catalog/models/types/index.js +1 -2
- package/esm2015/domain/catalog/repositories/category-filter.repository.js +2 -0
- package/esm2015/domain/catalog/repositories/filter-option.repository.js +2 -0
- package/esm2015/domain/catalog/repositories/filter.repository.js +2 -0
- package/esm2015/domain/catalog/repositories/index.js +4 -1
- package/esm2015/domain/shop-settings/models/index.js +2 -1
- package/esm2015/domain/shop-settings/models/shop-settings.js +7 -0
- package/esm2015/domain/shop-settings/models/types/index.js +6 -1
- package/esm2015/domain/shop-settings/models/types/shop-banner.type.js +2 -0
- package/esm2015/domain/shop-settings/models/types/shop-brands.type.js +2 -0
- package/esm2015/domain/shop-settings/models/types/shop-carousel.type.js +2 -0
- package/esm2015/domain/shop-settings/models/types/shop-collection.type.js +2 -0
- package/esm2015/domain/shop-settings/models/types/shop-section.type.js +2 -0
- package/esm2015/domain/shop-settings/repositories/index.js +2 -1
- package/esm2015/domain/shop-settings/repositories/shop-settings.repository.js +2 -0
- 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 +3 -2
- package/esm2015/infra/firebase/firestore/repositories/shop-settings/index.js +2 -1
- package/esm2015/infra/firebase/firestore/repositories/shop-settings/shop-settings-firestore.repository.js +12 -0
- 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-hasura-graphql.mixin.js +5 -5
- package/esm2015/infra/hasura-graphql/repositories/catalog/category-filter-hasura-graphql.repository.js +24 -0
- package/esm2015/infra/hasura-graphql/repositories/catalog/category-hasura-graphql.repository.js +84 -4
- package/esm2015/infra/hasura-graphql/repositories/catalog/filter-hasura-graphql.repository.js +123 -0
- package/esm2015/infra/hasura-graphql/repositories/catalog/filter-option-hasura-graphql.repository.js +21 -0
- package/esm2015/infra/hasura-graphql/repositories/catalog/index.js +4 -1
- package/esm2015/infra/hasura-graphql/repositories/catalog/product-hasura-graphql.repository.js +2 -1
- package/esm2015/infra/hasura-graphql/types/hasura-graphql-fields.type.js +1 -1
- package/fesm2015/infrab4a-connect.js +340 -85
- package/fesm2015/infrab4a-connect.js.map +1 -1
- package/infra/firebase/firestore/repositories/shop-settings/index.d.ts +1 -0
- package/infra/firebase/firestore/repositories/shop-settings/shop-settings-firestore.repository.d.ts +8 -0
- package/infra/firebase/firestore/repositories/shopping/index.d.ts +3 -5
- package/infra/hasura-graphql/repositories/catalog/category-filter-hasura-graphql.repository.d.ts +11 -0
- package/infra/hasura-graphql/repositories/catalog/category-hasura-graphql.repository.d.ts +4 -1
- package/infra/hasura-graphql/repositories/catalog/filter-hasura-graphql.repository.d.ts +18 -0
- package/infra/hasura-graphql/repositories/catalog/filter-option-hasura-graphql.repository.d.ts +10 -0
- package/infra/hasura-graphql/repositories/catalog/index.d.ts +3 -0
- package/infra/hasura-graphql/types/hasura-graphql-fields.type.d.ts +1 -1
- package/package.json +1 -1
- package/domain/catalog/models/types/category-filter.type.d.ts +0 -4
- package/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/types/category-filter.type.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/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
|
@@ -9,7 +9,6 @@ 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';
|
|
13
12
|
|
|
14
13
|
class BaseModel {
|
|
15
14
|
get identifier() {
|
|
@@ -751,6 +750,15 @@ class RecoveryPassword {
|
|
|
751
750
|
}
|
|
752
751
|
}
|
|
753
752
|
|
|
753
|
+
class Filter extends BaseModel {
|
|
754
|
+
identifierFields() {
|
|
755
|
+
return ['id'];
|
|
756
|
+
}
|
|
757
|
+
static get identifiersFields() {
|
|
758
|
+
return ['id'];
|
|
759
|
+
}
|
|
760
|
+
}
|
|
761
|
+
|
|
754
762
|
class Category extends BaseModel {
|
|
755
763
|
identifierFields() {
|
|
756
764
|
return ['id'];
|
|
@@ -758,6 +766,19 @@ class Category extends BaseModel {
|
|
|
758
766
|
static get identifiersFields() {
|
|
759
767
|
return ['id'];
|
|
760
768
|
}
|
|
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
|
+
}
|
|
761
782
|
}
|
|
762
783
|
|
|
763
784
|
var GenderDestination;
|
|
@@ -775,6 +796,15 @@ var Shops;
|
|
|
775
796
|
Shops["ALL"] = "ALL";
|
|
776
797
|
})(Shops || (Shops = {}));
|
|
777
798
|
|
|
799
|
+
class FilterOption extends BaseModel {
|
|
800
|
+
identifierFields() {
|
|
801
|
+
return ['id'];
|
|
802
|
+
}
|
|
803
|
+
static get identifiersFields() {
|
|
804
|
+
return ['id'];
|
|
805
|
+
}
|
|
806
|
+
}
|
|
807
|
+
|
|
778
808
|
class Product extends BaseModel {
|
|
779
809
|
identifierFields() {
|
|
780
810
|
return ['id'];
|
|
@@ -811,27 +841,17 @@ class Variant extends BaseModel {
|
|
|
811
841
|
}
|
|
812
842
|
}
|
|
813
843
|
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
]
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
static get identifiersFields() {
|
|
826
|
-
return ['id'];
|
|
827
|
-
}
|
|
828
|
-
}
|
|
829
|
-
|
|
830
|
-
class CampaignHashtag extends BaseModel {
|
|
831
|
-
static get identifiersFields() {
|
|
832
|
-
return ['id'];
|
|
833
|
-
}
|
|
834
|
-
}
|
|
844
|
+
var OrderStatus;
|
|
845
|
+
(function (OrderStatus) {
|
|
846
|
+
OrderStatus["AGUARDANDO_PAGAMENTO"] = "Aguardando pagamento";
|
|
847
|
+
OrderStatus["EM_PREPARO"] = "Preparando pedido";
|
|
848
|
+
OrderStatus["NF_EMITIDA"] = "Nota Fiscal Emitida";
|
|
849
|
+
OrderStatus["AGUARDANDO_ENVIO"] = "Aguardando Transaportadora";
|
|
850
|
+
OrderStatus["ENVIADO"] = "Enviado";
|
|
851
|
+
OrderStatus["ENTREGUE"] = "Entregue";
|
|
852
|
+
OrderStatus["CANCELADO"] = "Cancelado";
|
|
853
|
+
OrderStatus["CREDIT_CARD"] = "credit_card";
|
|
854
|
+
})(OrderStatus || (OrderStatus = {}));
|
|
835
855
|
|
|
836
856
|
class LineItem extends Product {
|
|
837
857
|
}
|
|
@@ -872,18 +892,6 @@ __decorate([
|
|
|
872
892
|
__metadata("design:type", Coupon)
|
|
873
893
|
], Checkout.prototype, "coupon", void 0);
|
|
874
894
|
|
|
875
|
-
var OrderStatus;
|
|
876
|
-
(function (OrderStatus) {
|
|
877
|
-
OrderStatus["AGUARDANDO_PAGAMENTO"] = "Aguardando pagamento";
|
|
878
|
-
OrderStatus["EM_PREPARO"] = "Preparando pedido";
|
|
879
|
-
OrderStatus["NF_EMITIDA"] = "Nota Fiscal Emitida";
|
|
880
|
-
OrderStatus["AGUARDANDO_ENVIO"] = "Aguardando Transaportadora";
|
|
881
|
-
OrderStatus["ENVIADO"] = "Enviado";
|
|
882
|
-
OrderStatus["ENTREGUE"] = "Entregue";
|
|
883
|
-
OrderStatus["CANCELADO"] = "Cancelado";
|
|
884
|
-
OrderStatus["CREDIT_CARD"] = "credit_card";
|
|
885
|
-
})(OrderStatus || (OrderStatus = {}));
|
|
886
|
-
|
|
887
895
|
class Order extends Checkout {
|
|
888
896
|
}
|
|
889
897
|
__decorate([
|
|
@@ -913,6 +921,16 @@ __decorate([
|
|
|
913
921
|
__metadata("design:type", Coupon)
|
|
914
922
|
], CheckoutSubscription.prototype, "coupon", void 0);
|
|
915
923
|
|
|
924
|
+
class Buy2Win extends BaseModel {
|
|
925
|
+
static get identifiersFields() {
|
|
926
|
+
return ['id'];
|
|
927
|
+
}
|
|
928
|
+
}
|
|
929
|
+
__decorate([
|
|
930
|
+
Type(() => Category),
|
|
931
|
+
__metadata("design:type", Array)
|
|
932
|
+
], Buy2Win.prototype, "categories", void 0);
|
|
933
|
+
|
|
916
934
|
var FilterType;
|
|
917
935
|
(function (FilterType) {
|
|
918
936
|
FilterType["ACCESSORY_IMPORTANCE"] = "accessoryImportance";
|
|
@@ -1011,6 +1029,12 @@ class ShopMenu extends BaseModel {
|
|
|
1011
1029
|
}
|
|
1012
1030
|
}
|
|
1013
1031
|
|
|
1032
|
+
class ShopSettings extends BaseModel {
|
|
1033
|
+
static get identifiersFields() {
|
|
1034
|
+
return ['id'];
|
|
1035
|
+
}
|
|
1036
|
+
}
|
|
1037
|
+
|
|
1014
1038
|
class InvalidArgumentError extends CustomError {
|
|
1015
1039
|
constructor(message) {
|
|
1016
1040
|
super(message);
|
|
@@ -1122,8 +1146,9 @@ class ProductsIndex {
|
|
|
1122
1146
|
'stock',
|
|
1123
1147
|
'weight',
|
|
1124
1148
|
'tags',
|
|
1149
|
+
'filters',
|
|
1125
1150
|
'hasVariants',
|
|
1126
|
-
'type'
|
|
1151
|
+
'type',
|
|
1127
1152
|
];
|
|
1128
1153
|
const { hits } = yield this.adapter.query('products/_search', Object.assign({ _source: fields, query: {
|
|
1129
1154
|
bool: {
|
|
@@ -1749,33 +1774,6 @@ class SubscriptionProductFirestoreRepository extends withCrudFirestore(withHelpe
|
|
|
1749
1774
|
}
|
|
1750
1775
|
}
|
|
1751
1776
|
|
|
1752
|
-
class Buy2WinFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1753
|
-
constructor(firestore) {
|
|
1754
|
-
super();
|
|
1755
|
-
this.firestore = firestore;
|
|
1756
|
-
this.collectionName = 'buy2win';
|
|
1757
|
-
this.model = Buy2Win;
|
|
1758
|
-
}
|
|
1759
|
-
}
|
|
1760
|
-
|
|
1761
|
-
class CampaignDashboardFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1762
|
-
constructor(firestore) {
|
|
1763
|
-
super();
|
|
1764
|
-
this.firestore = firestore;
|
|
1765
|
-
this.collectionName = 'dashboardCampaignsAuto';
|
|
1766
|
-
this.model = CampaignDashboard;
|
|
1767
|
-
}
|
|
1768
|
-
}
|
|
1769
|
-
|
|
1770
|
-
class CampaignHashtagFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1771
|
-
constructor(firestore) {
|
|
1772
|
-
super();
|
|
1773
|
-
this.firestore = firestore;
|
|
1774
|
-
this.collectionName = 'hashtagCampaignsAuto';
|
|
1775
|
-
this.model = CampaignHashtag;
|
|
1776
|
-
}
|
|
1777
|
-
}
|
|
1778
|
-
|
|
1779
1777
|
class CheckoutFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1780
1778
|
constructor(firestore) {
|
|
1781
1779
|
super();
|
|
@@ -1785,15 +1783,6 @@ class CheckoutFirestoreRepository extends withCrudFirestore(withHelpers(withFire
|
|
|
1785
1783
|
}
|
|
1786
1784
|
}
|
|
1787
1785
|
|
|
1788
|
-
class CheckoutSubscriptionFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1789
|
-
constructor(firestore) {
|
|
1790
|
-
super();
|
|
1791
|
-
this.firestore = firestore;
|
|
1792
|
-
this.collectionName = 'checkoutsSubscription';
|
|
1793
|
-
this.model = CheckoutSubscription;
|
|
1794
|
-
}
|
|
1795
|
-
}
|
|
1796
|
-
|
|
1797
1786
|
class CouponFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1798
1787
|
constructor(firestore) {
|
|
1799
1788
|
super();
|
|
@@ -1856,20 +1845,21 @@ class OrderFirestoreRepository extends withCrudFirestore(withHelpers(withFiresto
|
|
|
1856
1845
|
}
|
|
1857
1846
|
}
|
|
1858
1847
|
|
|
1859
|
-
class
|
|
1848
|
+
class PaymentFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1860
1849
|
constructor(firestore) {
|
|
1861
|
-
super(
|
|
1850
|
+
super();
|
|
1862
1851
|
this.firestore = firestore;
|
|
1863
|
-
this.collectionName = '
|
|
1852
|
+
this.collectionName = 'payments';
|
|
1853
|
+
this.model = Payment;
|
|
1864
1854
|
}
|
|
1865
1855
|
}
|
|
1866
1856
|
|
|
1867
|
-
class
|
|
1857
|
+
class CheckoutSubscriptionFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1868
1858
|
constructor(firestore) {
|
|
1869
1859
|
super();
|
|
1870
1860
|
this.firestore = firestore;
|
|
1871
|
-
this.collectionName = '
|
|
1872
|
-
this.model =
|
|
1861
|
+
this.collectionName = 'checkoutsSubscription';
|
|
1862
|
+
this.model = CheckoutSubscription;
|
|
1873
1863
|
}
|
|
1874
1864
|
}
|
|
1875
1865
|
|
|
@@ -1882,6 +1872,23 @@ class SubscriptionPlanFirestoreRepository extends withCrudFirestore(withHelpers(
|
|
|
1882
1872
|
}
|
|
1883
1873
|
}
|
|
1884
1874
|
|
|
1875
|
+
class Buy2WinFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1876
|
+
constructor(firestore) {
|
|
1877
|
+
super();
|
|
1878
|
+
this.firestore = firestore;
|
|
1879
|
+
this.collectionName = 'buy2win';
|
|
1880
|
+
this.model = Buy2Win;
|
|
1881
|
+
}
|
|
1882
|
+
}
|
|
1883
|
+
|
|
1884
|
+
class LegacyOrderFirestoreRepository extends OrderFirestoreRepository {
|
|
1885
|
+
constructor(firestore) {
|
|
1886
|
+
super(firestore);
|
|
1887
|
+
this.firestore = firestore;
|
|
1888
|
+
this.collectionName = 'legacyOrders';
|
|
1889
|
+
}
|
|
1890
|
+
}
|
|
1891
|
+
|
|
1885
1892
|
class HomeFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1886
1893
|
constructor(firestore) {
|
|
1887
1894
|
super();
|
|
@@ -1943,6 +1950,15 @@ class ShopMenuFirestoreRepository extends withCrudFirestore(withHelpers(withFire
|
|
|
1943
1950
|
}
|
|
1944
1951
|
}
|
|
1945
1952
|
|
|
1953
|
+
class ShopSettingsFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1954
|
+
constructor(firestore) {
|
|
1955
|
+
super();
|
|
1956
|
+
this.firestore = firestore;
|
|
1957
|
+
this.collectionName = 'shopSettings';
|
|
1958
|
+
this.model = ShopSettings;
|
|
1959
|
+
}
|
|
1960
|
+
}
|
|
1961
|
+
|
|
1946
1962
|
class AuthenticationFirebaseAuthService {
|
|
1947
1963
|
constructor(firebaseAuth) {
|
|
1948
1964
|
this.firebaseAuth = firebaseAuth;
|
|
@@ -2021,7 +2037,7 @@ class AttributeOptionHelper {
|
|
|
2021
2037
|
}
|
|
2022
2038
|
AttributeOptionHelper.FindByAttribute = (attributeName, fields) => {
|
|
2023
2039
|
if (fields.includes(attributeName))
|
|
2024
|
-
return { columnName: attributeName.toString(), attributeName };
|
|
2040
|
+
return { columnName: attributeName.toString(), attributeName, to: (value) => value, from: (value) => value };
|
|
2025
2041
|
const field = fields.find((columnOption) => isObject(columnOption) && Object.keys(columnOption).includes(attributeName.toString()));
|
|
2026
2042
|
const fieldOption = field === null || field === void 0 ? void 0 : field[attributeName.toString()];
|
|
2027
2043
|
if (isNil(fieldOption))
|
|
@@ -2339,12 +2355,12 @@ const withHasuraGraphQL = (MixinBase) => {
|
|
|
2339
2355
|
fetch(params) {
|
|
2340
2356
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2341
2357
|
const headers = this.headers;
|
|
2342
|
-
const
|
|
2358
|
+
const { data: result } = yield axios({
|
|
2359
|
+
url: `${this.endpoint}`,
|
|
2343
2360
|
method: 'POST',
|
|
2344
|
-
|
|
2361
|
+
data: params,
|
|
2345
2362
|
headers,
|
|
2346
2363
|
});
|
|
2347
|
-
const result = yield response.json();
|
|
2348
2364
|
if (!isNil(result.errors))
|
|
2349
2365
|
throw new Error(JSON.stringify(result.errors));
|
|
2350
2366
|
return result.data;
|
|
@@ -2547,8 +2563,29 @@ class VariantHasuraGraphQL extends Variant {
|
|
|
2547
2563
|
}
|
|
2548
2564
|
}
|
|
2549
2565
|
|
|
2566
|
+
class CategoryFilterHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
2567
|
+
constructor(endpoint, authOptions) {
|
|
2568
|
+
super({
|
|
2569
|
+
tableName: 'category_filter',
|
|
2570
|
+
model: CategoryFilter,
|
|
2571
|
+
endpoint,
|
|
2572
|
+
authOptions,
|
|
2573
|
+
fields: ['id', { filterId: { columnName: 'filter_id' } }, { categoryId: { columnName: 'category_id' } }],
|
|
2574
|
+
});
|
|
2575
|
+
}
|
|
2576
|
+
deleteByCategoryAndFilter(categoryId, filterId) {
|
|
2577
|
+
return this.mutation('delete_category_filter', ['affected_rows'], {
|
|
2578
|
+
where: {
|
|
2579
|
+
type: 'category_filter_bool_exp',
|
|
2580
|
+
required: true,
|
|
2581
|
+
value: { category_id: { _eq: categoryId }, filter_id: { _eq: filterId } },
|
|
2582
|
+
},
|
|
2583
|
+
});
|
|
2584
|
+
}
|
|
2585
|
+
}
|
|
2586
|
+
|
|
2550
2587
|
class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
2551
|
-
constructor(endpoint, authOptions, productRepository) {
|
|
2588
|
+
constructor(endpoint, authOptions, productRepository, categoryFilterRepository) {
|
|
2552
2589
|
super({
|
|
2553
2590
|
tableName: 'category',
|
|
2554
2591
|
model: Category,
|
|
@@ -2584,7 +2621,17 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
2584
2621
|
},
|
|
2585
2622
|
},
|
|
2586
2623
|
},
|
|
2587
|
-
|
|
2624
|
+
{
|
|
2625
|
+
filters: {
|
|
2626
|
+
columnName: 'filters',
|
|
2627
|
+
foreignKeyColumn: { filter_id: 'id' },
|
|
2628
|
+
fields: [{ filter: ['id', 'description', 'slug', 'enabled'] }],
|
|
2629
|
+
bindPersistData: (value) => ({
|
|
2630
|
+
filters: { data: value.map((filter) => ({ filter_id: filter.id })) },
|
|
2631
|
+
}),
|
|
2632
|
+
from: (filters) => (filters === null || filters === void 0 ? void 0 : filters.map((filter) => filter === null || filter === void 0 ? void 0 : filter.filter)) || [],
|
|
2633
|
+
},
|
|
2634
|
+
},
|
|
2588
2635
|
{ createdAt: { columnName: 'created_at' } },
|
|
2589
2636
|
{ updatedAt: { columnName: 'updated_at' } },
|
|
2590
2637
|
{
|
|
@@ -2609,6 +2656,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
2609
2656
|
],
|
|
2610
2657
|
});
|
|
2611
2658
|
this.productRepository = productRepository;
|
|
2659
|
+
this.categoryFilterRepository = categoryFilterRepository;
|
|
2612
2660
|
}
|
|
2613
2661
|
create(params) {
|
|
2614
2662
|
const _super = Object.create(null, {
|
|
@@ -2635,12 +2683,13 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
2635
2683
|
update: { get: () => super.update }
|
|
2636
2684
|
});
|
|
2637
2685
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2638
|
-
const { products, id: checkId, metadata } = params, data = __rest(params, ["products", "id", "metadata"]);
|
|
2686
|
+
const { products, id: checkId, metadata, filters } = params, data = __rest(params, ["products", "id", "metadata", "filters"]);
|
|
2639
2687
|
const plainData = this.paramsToPlain({ id: checkId });
|
|
2640
2688
|
const id = yield this.getId(plainData.id);
|
|
2641
2689
|
const category = yield _super.update.call(this, Object.assign({ id }, data));
|
|
2642
2690
|
category.products = products && (yield this.updateProducts(+id, { products }));
|
|
2643
2691
|
category.metadata = metadata && (yield this.updateMetadata(+id, { metadata }));
|
|
2692
|
+
category.filters = filters && (yield this.updateFilters(+id, { filters }));
|
|
2644
2693
|
return category;
|
|
2645
2694
|
});
|
|
2646
2695
|
}
|
|
@@ -2780,6 +2829,211 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
2780
2829
|
return plainData.metadata;
|
|
2781
2830
|
});
|
|
2782
2831
|
}
|
|
2832
|
+
updateFilters(categoryId, { filters }) {
|
|
2833
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2834
|
+
if ('action' in filters && filters.action === 'remove' && filters.value.length) {
|
|
2835
|
+
for (let i = 0; i < filters.value.length; i++) {
|
|
2836
|
+
yield this.categoryFilterRepository.deleteByCategoryAndFilter(categoryId, filters.value[i].id);
|
|
2837
|
+
}
|
|
2838
|
+
return [];
|
|
2839
|
+
}
|
|
2840
|
+
if ('action' in filters && filters.action === 'merge' && filters.value.length) {
|
|
2841
|
+
let filtersList = [];
|
|
2842
|
+
for (let i = 0; i < filters.value.length; i++) {
|
|
2843
|
+
try {
|
|
2844
|
+
const hasFilter = yield this.categoryFilterRepository
|
|
2845
|
+
.find({
|
|
2846
|
+
filters: {
|
|
2847
|
+
categoryId,
|
|
2848
|
+
filterId: filters.value[i].id,
|
|
2849
|
+
},
|
|
2850
|
+
})
|
|
2851
|
+
.then((data) => data.data.shift());
|
|
2852
|
+
if (hasFilter) {
|
|
2853
|
+
filtersList.push(hasFilter);
|
|
2854
|
+
}
|
|
2855
|
+
else {
|
|
2856
|
+
const newCategoryFilter = yield this.categoryFilterRepository.create({
|
|
2857
|
+
filterId: filters.value[i].id,
|
|
2858
|
+
categoryId,
|
|
2859
|
+
});
|
|
2860
|
+
filtersList.push(newCategoryFilter);
|
|
2861
|
+
}
|
|
2862
|
+
}
|
|
2863
|
+
catch (error) {
|
|
2864
|
+
console.log('catch error: ', error);
|
|
2865
|
+
}
|
|
2866
|
+
}
|
|
2867
|
+
return filtersList;
|
|
2868
|
+
}
|
|
2869
|
+
if (Array.isArray(filters) && filters.length) {
|
|
2870
|
+
let filtersList = [];
|
|
2871
|
+
for (let i = 0; i < filters.length; i++) {
|
|
2872
|
+
try {
|
|
2873
|
+
const hasFilter = yield this.categoryFilterRepository
|
|
2874
|
+
.find({
|
|
2875
|
+
filters: {
|
|
2876
|
+
categoryId,
|
|
2877
|
+
filterId: filters[i].id,
|
|
2878
|
+
},
|
|
2879
|
+
})
|
|
2880
|
+
.then((data) => data.data.shift());
|
|
2881
|
+
if (hasFilter) {
|
|
2882
|
+
filtersList.push(hasFilter);
|
|
2883
|
+
}
|
|
2884
|
+
else {
|
|
2885
|
+
const newCategoryFilter = yield this.categoryFilterRepository.create({
|
|
2886
|
+
filterId: filters[i].id,
|
|
2887
|
+
categoryId,
|
|
2888
|
+
});
|
|
2889
|
+
filtersList.push(newCategoryFilter);
|
|
2890
|
+
}
|
|
2891
|
+
}
|
|
2892
|
+
catch (error) {
|
|
2893
|
+
console.log('catch error: ', error);
|
|
2894
|
+
}
|
|
2895
|
+
}
|
|
2896
|
+
return filtersList;
|
|
2897
|
+
}
|
|
2898
|
+
});
|
|
2899
|
+
}
|
|
2900
|
+
}
|
|
2901
|
+
|
|
2902
|
+
class FilterHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
2903
|
+
constructor(endpoint, authOptions, filterOptionRepository, categoryFilterRepository) {
|
|
2904
|
+
super({
|
|
2905
|
+
tableName: 'filter',
|
|
2906
|
+
model: Filter,
|
|
2907
|
+
endpoint,
|
|
2908
|
+
authOptions,
|
|
2909
|
+
fields: [
|
|
2910
|
+
'id',
|
|
2911
|
+
'description',
|
|
2912
|
+
'slug',
|
|
2913
|
+
'enabled',
|
|
2914
|
+
{ createdAt: { columnName: 'created_at' } },
|
|
2915
|
+
{ updatedAt: { columnName: 'updated_at' } },
|
|
2916
|
+
{
|
|
2917
|
+
options: {
|
|
2918
|
+
columnName: 'options',
|
|
2919
|
+
foreignKeyColumn: { filterId: 'id' },
|
|
2920
|
+
fields: [
|
|
2921
|
+
'id',
|
|
2922
|
+
{ filterId: { columnName: 'filter_id' } },
|
|
2923
|
+
'description',
|
|
2924
|
+
{ createdAt: { columnName: 'created_at' } },
|
|
2925
|
+
{ updatedAt: { columnName: 'updated_at' } },
|
|
2926
|
+
],
|
|
2927
|
+
},
|
|
2928
|
+
},
|
|
2929
|
+
],
|
|
2930
|
+
});
|
|
2931
|
+
this.filterOptionRepository = filterOptionRepository;
|
|
2932
|
+
this.categoryFilterRepository = categoryFilterRepository;
|
|
2933
|
+
}
|
|
2934
|
+
update(params) {
|
|
2935
|
+
const _super = Object.create(null, {
|
|
2936
|
+
update: { get: () => super.update }
|
|
2937
|
+
});
|
|
2938
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2939
|
+
const { options } = params, data = __rest(params, ["options"]);
|
|
2940
|
+
const filter = yield _super.update.call(this, data);
|
|
2941
|
+
filter.options = yield this.updateOptions(+data.id, { options });
|
|
2942
|
+
return filter;
|
|
2943
|
+
});
|
|
2944
|
+
}
|
|
2945
|
+
updateOptions(filterId, { options }) {
|
|
2946
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2947
|
+
if (!options)
|
|
2948
|
+
return [];
|
|
2949
|
+
if ('action' in options && options.action === 'remove' && options.value.length) {
|
|
2950
|
+
for (let i = 0; i < options.value.length; i++) {
|
|
2951
|
+
yield this.filterOptionRepository.delete({ id: options.value[i].id });
|
|
2952
|
+
}
|
|
2953
|
+
return [];
|
|
2954
|
+
}
|
|
2955
|
+
if ('action' in options && options.action === 'merge' && options.value.length) {
|
|
2956
|
+
let filterOptions = [];
|
|
2957
|
+
for (let i = 0; i < options.value.length; i++) {
|
|
2958
|
+
try {
|
|
2959
|
+
const hasFilter = yield this.filterOptionRepository.get({ id: options.value[i].id });
|
|
2960
|
+
if (hasFilter)
|
|
2961
|
+
filterOptions.push(hasFilter);
|
|
2962
|
+
}
|
|
2963
|
+
catch (error) {
|
|
2964
|
+
const newOption = yield this.filterOptionRepository.create(Object.assign(Object.assign({}, options.value[i]), { filterId }));
|
|
2965
|
+
filterOptions.push(newOption);
|
|
2966
|
+
}
|
|
2967
|
+
}
|
|
2968
|
+
return filterOptions;
|
|
2969
|
+
}
|
|
2970
|
+
if (Array.isArray(options) && options.length) {
|
|
2971
|
+
let filterOptions = [];
|
|
2972
|
+
for (let i = 0; i < options.length; i++) {
|
|
2973
|
+
try {
|
|
2974
|
+
const hasFilter = yield this.filterOptionRepository.get({ id: options[i].id });
|
|
2975
|
+
if (hasFilter)
|
|
2976
|
+
filterOptions.push(hasFilter);
|
|
2977
|
+
}
|
|
2978
|
+
catch (error) {
|
|
2979
|
+
const newOption = yield this.filterOptionRepository.create(Object.assign(Object.assign({}, options[i]), { filterId }));
|
|
2980
|
+
filterOptions.push(newOption);
|
|
2981
|
+
}
|
|
2982
|
+
}
|
|
2983
|
+
}
|
|
2984
|
+
return [];
|
|
2985
|
+
});
|
|
2986
|
+
}
|
|
2987
|
+
delete(params) {
|
|
2988
|
+
const _super = Object.create(null, {
|
|
2989
|
+
delete: { get: () => super.delete }
|
|
2990
|
+
});
|
|
2991
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2992
|
+
const { options } = params, data = __rest(params, ["options"]);
|
|
2993
|
+
const categoryFilters = yield this.categoryFilterRepository
|
|
2994
|
+
.find({
|
|
2995
|
+
filters: {
|
|
2996
|
+
filterId: +data.id,
|
|
2997
|
+
},
|
|
2998
|
+
})
|
|
2999
|
+
.then((result) => result.data);
|
|
3000
|
+
if (categoryFilters.length)
|
|
3001
|
+
throw new Error('Erro: o filtro está associado a uma ou mais categoria(s)');
|
|
3002
|
+
yield this.deleteOptions(options);
|
|
3003
|
+
yield _super.delete.call(this, { id: +data.id });
|
|
3004
|
+
return;
|
|
3005
|
+
});
|
|
3006
|
+
}
|
|
3007
|
+
deleteOptions(options) {
|
|
3008
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
3009
|
+
for (let i = 0; i < options.length; i++) {
|
|
3010
|
+
try {
|
|
3011
|
+
yield this.filterOptionRepository.delete({ id: options[i].id });
|
|
3012
|
+
}
|
|
3013
|
+
catch (error) {
|
|
3014
|
+
console.log(error);
|
|
3015
|
+
}
|
|
3016
|
+
}
|
|
3017
|
+
});
|
|
3018
|
+
}
|
|
3019
|
+
}
|
|
3020
|
+
|
|
3021
|
+
class FilterOptionHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
3022
|
+
constructor(endpoint, authOptions) {
|
|
3023
|
+
super({
|
|
3024
|
+
tableName: 'filter_option',
|
|
3025
|
+
model: FilterOption,
|
|
3026
|
+
endpoint,
|
|
3027
|
+
authOptions,
|
|
3028
|
+
fields: [
|
|
3029
|
+
'id',
|
|
3030
|
+
'description',
|
|
3031
|
+
{ filterId: { columnName: 'filter_id' } },
|
|
3032
|
+
{ createdAt: { columnName: 'created_at' } },
|
|
3033
|
+
{ updatedAt: { columnName: 'updated_at' } },
|
|
3034
|
+
],
|
|
3035
|
+
});
|
|
3036
|
+
}
|
|
2783
3037
|
}
|
|
2784
3038
|
|
|
2785
3039
|
class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
@@ -2885,6 +3139,7 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
2885
3139
|
'weight',
|
|
2886
3140
|
'gender',
|
|
2887
3141
|
{ tags: { columnName: 'tags', type: HasuraGraphQLColumnType.Jsonb } },
|
|
3142
|
+
{ filters: { columnName: 'filters', type: HasuraGraphQLColumnType.Jsonb } },
|
|
2888
3143
|
{ isKit: { columnName: 'is_kit' } },
|
|
2889
3144
|
{ createdAt: { columnName: 'created_at' } },
|
|
2890
3145
|
{ updatedAt: { columnName: 'updated_at' } },
|
|
@@ -3353,5 +3608,5 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
3353
3608
|
* Generated bundle index. Do not edit.
|
|
3354
3609
|
*/
|
|
3355
3610
|
|
|
3356
|
-
export { AccessoryImportances, Address, Area, Authentication, AuthenticationFirebaseAuthService, AxiosAdapter, Base, BaseModel, BeardProblems, BeardSizes, BeautyProductImportances, BeautyProfile, BeautyQuestionsHelper, BillingStatus, BodyProblems, BodyShapes, BodyTattoos, Buy2Win, Buy2WinFirestoreRepository,
|
|
3611
|
+
export { AccessoryImportances, Address, Area, Authentication, AuthenticationFirebaseAuthService, AxiosAdapter, Base, BaseModel, BeardProblems, BeardSizes, BeautyProductImportances, BeautyProfile, BeautyQuestionsHelper, BillingStatus, BodyProblems, BodyShapes, BodyTattoos, Buy2Win, Buy2WinFirestoreRepository, Category, CategoryFilter, CategoryFilterHasuraGraphQLRepository, CategoryFirestoreRepository, CategoryHasuraGraphQL, CategoryHasuraGraphQLRepository, Checkout, CheckoutFirestoreRepository, CheckoutSubscription, CheckoutSubscriptionFirestoreRepository, CheckoutTypes, Coupon, CouponFirestoreRepository, CouponSubtypes, CouponTypes, DuplicatedResultsError, Edition, EditionStatus, Exclusivities, FaceSkinOilinesses, FaceSkinProblems, FaceSkinTones, FamilyIncomes, Filter, FilterHasuraGraphQLRepository, FilterOption, FilterOptionHasuraGraphQLRepository, FilterType, FragranceImportances, GenderDestination, HairColors, HairProblems, HairStrands, HairTypes, Home, HomeFirestoreRepository, InvalidArgumentError, KitProduct, KitProductHasuraGraphQL, Lead, LeadFirestoreRepository, LegacyOrderFirestoreRepository, LineItem, NotFoundError, OfficePosition, Order, OrderFirestoreRepository, OrderStatus, Payment, PaymentFirestoreRepository, PaymentType, Product, ProductFirestoreRepository, ProductHasuraGraphQL, ProductHasuraGraphQLRepository, ProductSpents, ProductVariantFirestoreRepository, ProductsIndex, QuestionsFilters, RecoveryPassword, Register, RegisterFirebaseAuthService, RequiredArgumentError, ShippingMethod, ShopMenu, ShopMenuFirestoreRepository, ShopSettings, ShopSettingsFirestoreRepository, Shops, SignInMethods, SignOut, Status, Subscription, SubscriptionEditionFirestoreRepository, SubscriptionFirestoreRepository, SubscriptionPayment, SubscriptionPaymentFirestoreRepository, SubscriptionPlan, SubscriptionPlanFirestoreRepository, SubscriptionProductFirestoreRepository, UnauthorizedError, UpdateOptionActions, User, UserAddress, UserAddressFirestoreRepository, UserAlreadyRegisteredError, UserBeautyProfileFirestoreRepository, UserFirestoreRepository, UserPaymentMethod, UserPaymentMethodFirestoreRepository, UserType, Variant, VariantHasuraGraphQL, VariantHasuraGraphQLRepository, WeakPasswordError, Where, isUUID, parseDateTime, withCreateFirestore, withCreateHasuraGraphQL, withCrudFirestore, withCrudHasuraGraphQL, withDeleteFirestore, withDeleteHasuraGraphQL, withFindFirestore, withFindHasuraGraphQL, withFirestore, withGetFirestore, withGetHasuraGraphQL, withHasuraGraphQL, withHelpers, withSubCollection, withUpdateFirestore, withUpdateHasuraGraphQL };
|
|
3357
3612
|
//# sourceMappingURL=infrab4a-connect.js.map
|