@infrab4a/connect 3.4.0-beta.8 → 3.4.0-beta.9
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 +186 -47
- package/bundles/infrab4a-connect.umd.js.map +1 -1
- package/domain/catalog/models/category.d.ts +1 -1
- package/domain/catalog/repositories/category-filter.repository.d.ts +4 -0
- package/domain/catalog/repositories/index.d.ts +1 -0
- package/esm2015/domain/catalog/models/category.js +8 -1
- package/esm2015/domain/catalog/repositories/category-filter.repository.js +2 -0
- package/esm2015/domain/catalog/repositories/index.js +2 -1
- package/esm2015/infra/hasura-graphql/repositories/catalog/category-filter-hasura-graphql.repository.js +15 -0
- package/esm2015/infra/hasura-graphql/repositories/catalog/category-hasura-graphql.repository.js +76 -8
- package/esm2015/infra/hasura-graphql/repositories/catalog/filter-hasura-graphql.repository.js +13 -8
- package/esm2015/infra/hasura-graphql/repositories/catalog/index.js +2 -1
- package/esm2015/infra/hasura-graphql/types/hasura-graphql-fields.type.js +1 -1
- package/fesm2015/infrab4a-connect.js +114 -25
- package/fesm2015/infrab4a-connect.js.map +1 -1
- package/infra/hasura-graphql/repositories/catalog/category-filter-hasura-graphql.repository.d.ts +10 -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 +3 -1
- package/infra/hasura-graphql/repositories/catalog/index.d.ts +1 -0
- package/infra/hasura-graphql/types/hasura-graphql-fields.type.d.ts +1 -1
- package/package.json +1 -1
|
@@ -751,7 +751,7 @@ class RecoveryPassword {
|
|
|
751
751
|
}
|
|
752
752
|
}
|
|
753
753
|
|
|
754
|
-
class
|
|
754
|
+
class Filter extends BaseModel {
|
|
755
755
|
identifierFields() {
|
|
756
756
|
return ['id'];
|
|
757
757
|
}
|
|
@@ -760,6 +760,19 @@ class Category extends BaseModel {
|
|
|
760
760
|
}
|
|
761
761
|
}
|
|
762
762
|
|
|
763
|
+
class Category extends BaseModel {
|
|
764
|
+
identifierFields() {
|
|
765
|
+
return ['id'];
|
|
766
|
+
}
|
|
767
|
+
static get identifiersFields() {
|
|
768
|
+
return ['id'];
|
|
769
|
+
}
|
|
770
|
+
}
|
|
771
|
+
__decorate([
|
|
772
|
+
Type(() => Filter),
|
|
773
|
+
__metadata("design:type", Array)
|
|
774
|
+
], Category.prototype, "filters", void 0);
|
|
775
|
+
|
|
763
776
|
class CategoryFilter extends BaseModel {
|
|
764
777
|
identifierFields() {
|
|
765
778
|
return ['id'];
|
|
@@ -784,15 +797,6 @@ var Shops;
|
|
|
784
797
|
Shops["ALL"] = "ALL";
|
|
785
798
|
})(Shops || (Shops = {}));
|
|
786
799
|
|
|
787
|
-
class Filter extends BaseModel {
|
|
788
|
-
identifierFields() {
|
|
789
|
-
return ['id'];
|
|
790
|
-
}
|
|
791
|
-
static get identifiersFields() {
|
|
792
|
-
return ['id'];
|
|
793
|
-
}
|
|
794
|
-
}
|
|
795
|
-
|
|
796
800
|
class FilterOption extends BaseModel {
|
|
797
801
|
identifierFields() {
|
|
798
802
|
return ['id'];
|
|
@@ -2537,8 +2541,20 @@ class VariantHasuraGraphQL extends Variant {
|
|
|
2537
2541
|
}
|
|
2538
2542
|
}
|
|
2539
2543
|
|
|
2544
|
+
class CategoryFilterHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
2545
|
+
constructor(endpoint, authOptions) {
|
|
2546
|
+
super({
|
|
2547
|
+
tableName: 'category_filter',
|
|
2548
|
+
model: CategoryFilter,
|
|
2549
|
+
endpoint,
|
|
2550
|
+
authOptions,
|
|
2551
|
+
fields: ['id', { filterId: { columnName: 'filter_id' } }, { categoryId: { columnName: 'category_id' } }],
|
|
2552
|
+
});
|
|
2553
|
+
}
|
|
2554
|
+
}
|
|
2555
|
+
|
|
2540
2556
|
class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
2541
|
-
constructor(endpoint, authOptions, productRepository) {
|
|
2557
|
+
constructor(endpoint, authOptions, productRepository, categoryFilterRepository) {
|
|
2542
2558
|
super({
|
|
2543
2559
|
tableName: 'category',
|
|
2544
2560
|
model: Category,
|
|
@@ -2574,11 +2590,17 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
2574
2590
|
},
|
|
2575
2591
|
},
|
|
2576
2592
|
},
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
|
|
2593
|
+
{
|
|
2594
|
+
filters: {
|
|
2595
|
+
columnName: 'filters',
|
|
2596
|
+
foreignKeyColumn: { filter_id: 'id' },
|
|
2597
|
+
fields: [{ filter: ['id', 'description', 'slug', 'enabled'] }],
|
|
2598
|
+
bindPersistData: (value) => ({
|
|
2599
|
+
filters: { data: value.map((filter) => ({ filter_id: filter.id })) },
|
|
2600
|
+
}),
|
|
2601
|
+
from: (filters) => (filters === null || filters === void 0 ? void 0 : filters.map((filter) => filter === null || filter === void 0 ? void 0 : filter.filter)) || [],
|
|
2602
|
+
},
|
|
2603
|
+
},
|
|
2582
2604
|
{ createdAt: { columnName: 'created_at' } },
|
|
2583
2605
|
{ updatedAt: { columnName: 'updated_at' } },
|
|
2584
2606
|
{
|
|
@@ -2603,6 +2625,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
2603
2625
|
],
|
|
2604
2626
|
});
|
|
2605
2627
|
this.productRepository = productRepository;
|
|
2628
|
+
this.categoryFilterRepository = categoryFilterRepository;
|
|
2606
2629
|
}
|
|
2607
2630
|
create(params) {
|
|
2608
2631
|
const _super = Object.create(null, {
|
|
@@ -2629,12 +2652,13 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
2629
2652
|
update: { get: () => super.update }
|
|
2630
2653
|
});
|
|
2631
2654
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2632
|
-
const { products, id: checkId, metadata } = params, data = __rest(params, ["products", "id", "metadata"]);
|
|
2655
|
+
const { products, id: checkId, metadata, filters } = params, data = __rest(params, ["products", "id", "metadata", "filters"]);
|
|
2633
2656
|
const plainData = this.paramsToPlain({ id: checkId });
|
|
2634
2657
|
const id = yield this.getId(plainData.id);
|
|
2635
2658
|
const category = yield _super.update.call(this, Object.assign({ id }, data));
|
|
2636
2659
|
category.products = products && (yield this.updateProducts(+id, { products }));
|
|
2637
2660
|
category.metadata = metadata && (yield this.updateMetadata(+id, { metadata }));
|
|
2661
|
+
category.filters = filters && (yield this.updateFilters(+id, { filters }));
|
|
2638
2662
|
return category;
|
|
2639
2663
|
});
|
|
2640
2664
|
}
|
|
@@ -2774,10 +2798,70 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
2774
2798
|
return plainData.metadata;
|
|
2775
2799
|
});
|
|
2776
2800
|
}
|
|
2801
|
+
updateFilters(categoryId, { filters }) {
|
|
2802
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2803
|
+
if ('action' in filters && filters.action === 'remove' && filters.value.length) {
|
|
2804
|
+
for (let i = 0; i < filters.value.length; i++) {
|
|
2805
|
+
yield this.categoryFilterRepository.delete({ id: filters.value[i].id });
|
|
2806
|
+
}
|
|
2807
|
+
return [];
|
|
2808
|
+
}
|
|
2809
|
+
if ('action' in filters && filters.action === 'merge' && filters.value.length) {
|
|
2810
|
+
let filtersList = [];
|
|
2811
|
+
for (let i = 0; i < filters.value.length; i++) {
|
|
2812
|
+
try {
|
|
2813
|
+
const hasFilter = yield this.categoryFilterRepository
|
|
2814
|
+
.find({
|
|
2815
|
+
filters: {
|
|
2816
|
+
categoryId,
|
|
2817
|
+
filterId: filters[i].id,
|
|
2818
|
+
},
|
|
2819
|
+
})
|
|
2820
|
+
.then((data) => data.data.shift());
|
|
2821
|
+
if (hasFilter)
|
|
2822
|
+
filtersList.push(hasFilter);
|
|
2823
|
+
}
|
|
2824
|
+
catch (error) {
|
|
2825
|
+
const newCategoryFilter = yield this.categoryFilterRepository.create({
|
|
2826
|
+
filterId: filters.value[i].id,
|
|
2827
|
+
categoryId,
|
|
2828
|
+
});
|
|
2829
|
+
filtersList.push(newCategoryFilter);
|
|
2830
|
+
}
|
|
2831
|
+
}
|
|
2832
|
+
return filtersList;
|
|
2833
|
+
}
|
|
2834
|
+
if (Array.isArray(filters) && filters.length) {
|
|
2835
|
+
let filtersList = [];
|
|
2836
|
+
for (let i = 0; i < filters.length; i++) {
|
|
2837
|
+
try {
|
|
2838
|
+
const hasFilter = yield this.categoryFilterRepository
|
|
2839
|
+
.find({
|
|
2840
|
+
filters: {
|
|
2841
|
+
categoryId,
|
|
2842
|
+
filterId: filters[i].id,
|
|
2843
|
+
},
|
|
2844
|
+
})
|
|
2845
|
+
.then((data) => data.data.shift());
|
|
2846
|
+
if (hasFilter)
|
|
2847
|
+
filtersList.push(hasFilter);
|
|
2848
|
+
}
|
|
2849
|
+
catch (error) {
|
|
2850
|
+
const newCategoryFilter = yield this.categoryFilterRepository.create({
|
|
2851
|
+
filterId: filters[i].id,
|
|
2852
|
+
categoryId,
|
|
2853
|
+
});
|
|
2854
|
+
filtersList.push(newCategoryFilter);
|
|
2855
|
+
}
|
|
2856
|
+
}
|
|
2857
|
+
return filtersList;
|
|
2858
|
+
}
|
|
2859
|
+
});
|
|
2860
|
+
}
|
|
2777
2861
|
}
|
|
2778
2862
|
|
|
2779
2863
|
class FilterHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
2780
|
-
constructor(endpoint, authOptions, filterOptionRepository) {
|
|
2864
|
+
constructor(endpoint, authOptions, filterOptionRepository, categoryFilterRepository) {
|
|
2781
2865
|
super({
|
|
2782
2866
|
tableName: 'filter',
|
|
2783
2867
|
model: Filter,
|
|
@@ -2806,6 +2890,7 @@ class FilterHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGrap
|
|
|
2806
2890
|
],
|
|
2807
2891
|
});
|
|
2808
2892
|
this.filterOptionRepository = filterOptionRepository;
|
|
2893
|
+
this.categoryFilterRepository = categoryFilterRepository;
|
|
2809
2894
|
}
|
|
2810
2895
|
update(params) {
|
|
2811
2896
|
const _super = Object.create(null, {
|
|
@@ -2865,12 +2950,16 @@ class FilterHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGrap
|
|
|
2865
2950
|
delete: { get: () => super.delete }
|
|
2866
2951
|
});
|
|
2867
2952
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2868
|
-
const { options } = params, data = __rest(params
|
|
2869
|
-
|
|
2870
|
-
|
|
2871
|
-
|
|
2872
|
-
|
|
2873
|
-
|
|
2953
|
+
const { options } = params, data = __rest(params, ["options"]);
|
|
2954
|
+
const categoryFilters = yield this.categoryFilterRepository
|
|
2955
|
+
.find({
|
|
2956
|
+
filters: {
|
|
2957
|
+
filterId: +data.id,
|
|
2958
|
+
},
|
|
2959
|
+
})
|
|
2960
|
+
.then((result) => result.data);
|
|
2961
|
+
if (categoryFilters.length)
|
|
2962
|
+
throw new Error('Erro: o filtro está associado a uma ou mais categoria(s)');
|
|
2874
2963
|
yield this.deleteOptions(options);
|
|
2875
2964
|
yield _super.delete.call(this, { id: +data.id });
|
|
2876
2965
|
return;
|
|
@@ -3476,5 +3565,5 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
3476
3565
|
* Generated bundle index. Do not edit.
|
|
3477
3566
|
*/
|
|
3478
3567
|
|
|
3479
|
-
export { AccessoryImportances, Address, Area, Authentication, AuthenticationFirebaseAuthService, AxiosAdapter, Base, BaseModel, BeardProblems, BeardSizes, BeautyProductImportances, BeautyProfile, BeautyQuestionsHelper, BillingStatus, BodyProblems, BodyShapes, BodyTattoos, Buy2Win, Buy2WinFirestoreRepository, Category, CategoryFilter, 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 };
|
|
3568
|
+
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, 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 };
|
|
3480
3569
|
//# sourceMappingURL=infrab4a-connect.js.map
|