@infrab4a/connect 3.4.0-beta.0 → 3.4.0-beta.10
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 +316 -163
- package/bundles/infrab4a-connect.umd.js.map +1 -1
- package/domain/catalog/models/category-filter.d.ts +8 -0
- package/domain/catalog/models/category.d.ts +3 -2
- package/domain/catalog/models/filter-option.d.ts +1 -1
- package/domain/catalog/models/filter.d.ts +2 -1
- package/domain/catalog/models/index.d.ts +1 -0
- package/domain/catalog/models/types/index.d.ts +0 -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-filter.js +10 -0
- package/esm2015/domain/catalog/models/category.js +8 -1
- 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 +2 -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/index.js +2 -1
- package/esm2015/infra/hasura-graphql/mixins/helpers/attribute-option.helper.js +2 -2
- package/esm2015/infra/hasura-graphql/models/index.js +1 -3
- 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 +76 -4
- package/esm2015/infra/hasura-graphql/repositories/catalog/filter-hasura-graphql.repository.js +67 -48
- package/esm2015/infra/hasura-graphql/repositories/catalog/filter-option-hasura-graphql.repository.js +11 -31
- 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/esm2015/utils/index.js +6 -6
- package/fesm2015/infrab4a-connect.js +197 -96
- package/fesm2015/infrab4a-connect.js.map +1 -1
- package/infra/hasura-graphql/models/index.d.ts +0 -2
- 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 +12 -12
- package/infra/hasura-graphql/repositories/catalog/filter-option-hasura-graphql.repository.d.ts +5 -10
- 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
- package/utils/index.d.ts +5 -5
- package/domain/catalog/models/types/category-filter.type.d.ts +0 -4
- package/esm2015/domain/catalog/models/types/category-filter.type.js +0 -2
- package/esm2015/infra/hasura-graphql/models/filter-hasura-graphql.js +0 -4
- package/esm2015/infra/hasura-graphql/models/filter-option-hasura-graphql.js +0 -4
- package/infra/hasura-graphql/models/filter-hasura-graphql.d.ts +0 -3
- package/infra/hasura-graphql/models/filter-option-hasura-graphql.d.ts +0 -3
|
@@ -4,7 +4,7 @@ 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,
|
|
7
|
+
export { chunk, 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';
|
|
@@ -466,14 +466,14 @@ class Address extends BaseModel {
|
|
|
466
466
|
}
|
|
467
467
|
}
|
|
468
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
|
-
|
|
471
469
|
class Base {
|
|
472
470
|
constructor(...args) {
|
|
473
471
|
Object.assign(this, ...args);
|
|
474
472
|
}
|
|
475
473
|
}
|
|
476
474
|
|
|
475
|
+
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);
|
|
476
|
+
|
|
477
477
|
const parseDateTime = (value) => {
|
|
478
478
|
if (!isString(value))
|
|
479
479
|
return value;
|
|
@@ -751,6 +751,15 @@ class RecoveryPassword {
|
|
|
751
751
|
}
|
|
752
752
|
}
|
|
753
753
|
|
|
754
|
+
class Filter extends BaseModel {
|
|
755
|
+
identifierFields() {
|
|
756
|
+
return ['id'];
|
|
757
|
+
}
|
|
758
|
+
static get identifiersFields() {
|
|
759
|
+
return ['id'];
|
|
760
|
+
}
|
|
761
|
+
}
|
|
762
|
+
|
|
754
763
|
class Category extends BaseModel {
|
|
755
764
|
identifierFields() {
|
|
756
765
|
return ['id'];
|
|
@@ -758,6 +767,19 @@ class Category extends BaseModel {
|
|
|
758
767
|
static get identifiersFields() {
|
|
759
768
|
return ['id'];
|
|
760
769
|
}
|
|
770
|
+
}
|
|
771
|
+
__decorate([
|
|
772
|
+
Type(() => Filter),
|
|
773
|
+
__metadata("design:type", Array)
|
|
774
|
+
], Category.prototype, "filters", void 0);
|
|
775
|
+
|
|
776
|
+
class CategoryFilter extends BaseModel {
|
|
777
|
+
identifierFields() {
|
|
778
|
+
return ['id'];
|
|
779
|
+
}
|
|
780
|
+
static get identifiersFields() {
|
|
781
|
+
return ['id'];
|
|
782
|
+
}
|
|
761
783
|
}
|
|
762
784
|
|
|
763
785
|
var GenderDestination;
|
|
@@ -775,15 +797,6 @@ var Shops;
|
|
|
775
797
|
Shops["ALL"] = "ALL";
|
|
776
798
|
})(Shops || (Shops = {}));
|
|
777
799
|
|
|
778
|
-
class Filter extends BaseModel {
|
|
779
|
-
identifierFields() {
|
|
780
|
-
return ['id'];
|
|
781
|
-
}
|
|
782
|
-
static get identifiersFields() {
|
|
783
|
-
return ['id'];
|
|
784
|
-
}
|
|
785
|
-
}
|
|
786
|
-
|
|
787
800
|
class FilterOption extends BaseModel {
|
|
788
801
|
identifierFields() {
|
|
789
802
|
return ['id'];
|
|
@@ -2007,7 +2020,7 @@ class AttributeOptionHelper {
|
|
|
2007
2020
|
}
|
|
2008
2021
|
AttributeOptionHelper.FindByAttribute = (attributeName, fields) => {
|
|
2009
2022
|
if (fields.includes(attributeName))
|
|
2010
|
-
return { columnName: attributeName.toString(), attributeName };
|
|
2023
|
+
return { columnName: attributeName.toString(), attributeName, to: (value) => value, from: (value) => value };
|
|
2011
2024
|
const field = fields.find((columnOption) => isObject(columnOption) && Object.keys(columnOption).includes(attributeName.toString()));
|
|
2012
2025
|
const fieldOption = field === null || field === void 0 ? void 0 : field[attributeName.toString()];
|
|
2013
2026
|
if (isNil(fieldOption))
|
|
@@ -2502,12 +2515,6 @@ const withCrudHasuraGraphQL = (MixinBase) => {
|
|
|
2502
2515
|
class CategoryHasuraGraphQL extends Category {
|
|
2503
2516
|
}
|
|
2504
2517
|
|
|
2505
|
-
class FilterHasuraGraphQL extends Filter {
|
|
2506
|
-
}
|
|
2507
|
-
|
|
2508
|
-
class FilterOptionHasuraGraphQL extends FilterOption {
|
|
2509
|
-
}
|
|
2510
|
-
|
|
2511
2518
|
class ProductHasuraGraphQL extends Product {
|
|
2512
2519
|
}
|
|
2513
2520
|
__decorate([
|
|
@@ -2534,8 +2541,29 @@ class VariantHasuraGraphQL extends Variant {
|
|
|
2534
2541
|
}
|
|
2535
2542
|
}
|
|
2536
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
|
+
deleteByCategoryAndFilter(categoryId, filterId) {
|
|
2555
|
+
return this.mutation('delete_category_filter', ['affected_rows'], {
|
|
2556
|
+
where: {
|
|
2557
|
+
type: 'category_filter_bool_exp',
|
|
2558
|
+
required: true,
|
|
2559
|
+
value: { category_id: { _eq: categoryId }, filterId: { _eq: filterId } },
|
|
2560
|
+
},
|
|
2561
|
+
});
|
|
2562
|
+
}
|
|
2563
|
+
}
|
|
2564
|
+
|
|
2537
2565
|
class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
2538
|
-
constructor(endpoint, authOptions, productRepository) {
|
|
2566
|
+
constructor(endpoint, authOptions, productRepository, categoryFilterRepository) {
|
|
2539
2567
|
super({
|
|
2540
2568
|
tableName: 'category',
|
|
2541
2569
|
model: Category,
|
|
@@ -2571,7 +2599,17 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
2571
2599
|
},
|
|
2572
2600
|
},
|
|
2573
2601
|
},
|
|
2574
|
-
|
|
2602
|
+
{
|
|
2603
|
+
filters: {
|
|
2604
|
+
columnName: 'filters',
|
|
2605
|
+
foreignKeyColumn: { filter_id: 'id' },
|
|
2606
|
+
fields: [{ filter: ['id', 'description', 'slug', 'enabled'] }],
|
|
2607
|
+
bindPersistData: (value) => ({
|
|
2608
|
+
filters: { data: value.map((filter) => ({ filter_id: filter.id })) },
|
|
2609
|
+
}),
|
|
2610
|
+
from: (filters) => (filters === null || filters === void 0 ? void 0 : filters.map((filter) => filter === null || filter === void 0 ? void 0 : filter.filter)) || [],
|
|
2611
|
+
},
|
|
2612
|
+
},
|
|
2575
2613
|
{ createdAt: { columnName: 'created_at' } },
|
|
2576
2614
|
{ updatedAt: { columnName: 'updated_at' } },
|
|
2577
2615
|
{
|
|
@@ -2596,6 +2634,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
2596
2634
|
],
|
|
2597
2635
|
});
|
|
2598
2636
|
this.productRepository = productRepository;
|
|
2637
|
+
this.categoryFilterRepository = categoryFilterRepository;
|
|
2599
2638
|
}
|
|
2600
2639
|
create(params) {
|
|
2601
2640
|
const _super = Object.create(null, {
|
|
@@ -2622,12 +2661,13 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
2622
2661
|
update: { get: () => super.update }
|
|
2623
2662
|
});
|
|
2624
2663
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2625
|
-
const { products, id: checkId, metadata } = params, data = __rest(params, ["products", "id", "metadata"]);
|
|
2664
|
+
const { products, id: checkId, metadata, filters } = params, data = __rest(params, ["products", "id", "metadata", "filters"]);
|
|
2626
2665
|
const plainData = this.paramsToPlain({ id: checkId });
|
|
2627
2666
|
const id = yield this.getId(plainData.id);
|
|
2628
2667
|
const category = yield _super.update.call(this, Object.assign({ id }, data));
|
|
2629
2668
|
category.products = products && (yield this.updateProducts(+id, { products }));
|
|
2630
2669
|
category.metadata = metadata && (yield this.updateMetadata(+id, { metadata }));
|
|
2670
|
+
category.filters = filters && (yield this.updateFilters(+id, { filters }));
|
|
2631
2671
|
return category;
|
|
2632
2672
|
});
|
|
2633
2673
|
}
|
|
@@ -2767,21 +2807,82 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
2767
2807
|
return plainData.metadata;
|
|
2768
2808
|
});
|
|
2769
2809
|
}
|
|
2810
|
+
updateFilters(categoryId, { filters }) {
|
|
2811
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2812
|
+
if ('action' in filters && filters.action === 'remove' && filters.value.length) {
|
|
2813
|
+
for (let i = 0; i < filters.value.length; i++) {
|
|
2814
|
+
yield this.categoryFilterRepository.deleteByCategoryAndFilter(categoryId, filters.value[i].id);
|
|
2815
|
+
}
|
|
2816
|
+
return [];
|
|
2817
|
+
}
|
|
2818
|
+
if ('action' in filters && filters.action === 'merge' && filters.value.length) {
|
|
2819
|
+
let filtersList = [];
|
|
2820
|
+
for (let i = 0; i < filters.value.length; i++) {
|
|
2821
|
+
try {
|
|
2822
|
+
const hasFilter = yield this.categoryFilterRepository
|
|
2823
|
+
.find({
|
|
2824
|
+
filters: {
|
|
2825
|
+
categoryId,
|
|
2826
|
+
filterId: filters[i].id,
|
|
2827
|
+
},
|
|
2828
|
+
})
|
|
2829
|
+
.then((data) => data.data.shift());
|
|
2830
|
+
if (hasFilter)
|
|
2831
|
+
filtersList.push(hasFilter);
|
|
2832
|
+
}
|
|
2833
|
+
catch (error) {
|
|
2834
|
+
const newCategoryFilter = yield this.categoryFilterRepository.create({
|
|
2835
|
+
filterId: filters.value[i].id,
|
|
2836
|
+
categoryId,
|
|
2837
|
+
});
|
|
2838
|
+
filtersList.push(newCategoryFilter);
|
|
2839
|
+
}
|
|
2840
|
+
}
|
|
2841
|
+
return filtersList;
|
|
2842
|
+
}
|
|
2843
|
+
if (Array.isArray(filters) && filters.length) {
|
|
2844
|
+
let filtersList = [];
|
|
2845
|
+
for (let i = 0; i < filters.length; i++) {
|
|
2846
|
+
try {
|
|
2847
|
+
const hasFilter = yield this.categoryFilterRepository
|
|
2848
|
+
.find({
|
|
2849
|
+
filters: {
|
|
2850
|
+
categoryId,
|
|
2851
|
+
filterId: filters[i].id,
|
|
2852
|
+
},
|
|
2853
|
+
})
|
|
2854
|
+
.then((data) => data.data.shift());
|
|
2855
|
+
if (hasFilter)
|
|
2856
|
+
filtersList.push(hasFilter);
|
|
2857
|
+
}
|
|
2858
|
+
catch (error) {
|
|
2859
|
+
const newCategoryFilter = yield this.categoryFilterRepository.create({
|
|
2860
|
+
filterId: filters[i].id,
|
|
2861
|
+
categoryId,
|
|
2862
|
+
});
|
|
2863
|
+
filtersList.push(newCategoryFilter);
|
|
2864
|
+
}
|
|
2865
|
+
}
|
|
2866
|
+
return filtersList;
|
|
2867
|
+
}
|
|
2868
|
+
});
|
|
2869
|
+
}
|
|
2770
2870
|
}
|
|
2771
2871
|
|
|
2772
2872
|
class FilterHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
2773
|
-
constructor(endpoint, authOptions, filterOptionRepository) {
|
|
2873
|
+
constructor(endpoint, authOptions, filterOptionRepository, categoryFilterRepository) {
|
|
2774
2874
|
super({
|
|
2775
2875
|
tableName: 'filter',
|
|
2776
|
-
model:
|
|
2876
|
+
model: Filter,
|
|
2777
2877
|
endpoint,
|
|
2778
2878
|
authOptions,
|
|
2779
2879
|
fields: [
|
|
2780
2880
|
'id',
|
|
2781
2881
|
'description',
|
|
2882
|
+
'slug',
|
|
2782
2883
|
'enabled',
|
|
2783
|
-
|
|
2784
|
-
|
|
2884
|
+
{ createdAt: { columnName: 'created_at' } },
|
|
2885
|
+
{ updatedAt: { columnName: 'updated_at' } },
|
|
2785
2886
|
{
|
|
2786
2887
|
options: {
|
|
2787
2888
|
columnName: 'options',
|
|
@@ -2790,43 +2891,15 @@ class FilterHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGrap
|
|
|
2790
2891
|
'id',
|
|
2791
2892
|
{ filterId: { columnName: 'filter_id' } },
|
|
2792
2893
|
'description',
|
|
2793
|
-
|
|
2794
|
-
|
|
2894
|
+
{ createdAt: { columnName: 'created_at' } },
|
|
2895
|
+
{ updatedAt: { columnName: 'updated_at' } },
|
|
2795
2896
|
],
|
|
2796
2897
|
},
|
|
2797
|
-
}
|
|
2898
|
+
},
|
|
2798
2899
|
],
|
|
2799
2900
|
});
|
|
2800
2901
|
this.filterOptionRepository = filterOptionRepository;
|
|
2801
|
-
|
|
2802
|
-
get(identifiers) {
|
|
2803
|
-
const _super = Object.create(null, {
|
|
2804
|
-
get: { get: () => super.get }
|
|
2805
|
-
});
|
|
2806
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
2807
|
-
const filter = yield _super.get.call(this, identifiers);
|
|
2808
|
-
if (!filter)
|
|
2809
|
-
throw new NotFoundError('Filter not found');
|
|
2810
|
-
return filter;
|
|
2811
|
-
});
|
|
2812
|
-
}
|
|
2813
|
-
find(options) {
|
|
2814
|
-
const _super = Object.create(null, {
|
|
2815
|
-
find: { get: () => super.find }
|
|
2816
|
-
});
|
|
2817
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
2818
|
-
const filter = yield _super.find.call(this, options);
|
|
2819
|
-
return filter;
|
|
2820
|
-
});
|
|
2821
|
-
}
|
|
2822
|
-
create(params) {
|
|
2823
|
-
const _super = Object.create(null, {
|
|
2824
|
-
create: { get: () => super.create }
|
|
2825
|
-
});
|
|
2826
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
2827
|
-
const filter = yield _super.create.call(this, params);
|
|
2828
|
-
return filter;
|
|
2829
|
-
});
|
|
2902
|
+
this.categoryFilterRepository = categoryFilterRepository;
|
|
2830
2903
|
}
|
|
2831
2904
|
update(params) {
|
|
2832
2905
|
const _super = Object.create(null, {
|
|
@@ -2839,31 +2912,78 @@ class FilterHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGrap
|
|
|
2839
2912
|
return filter;
|
|
2840
2913
|
});
|
|
2841
2914
|
}
|
|
2842
|
-
;
|
|
2843
2915
|
updateOptions(filterId, { options }) {
|
|
2844
2916
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2845
2917
|
if (!options)
|
|
2846
2918
|
return [];
|
|
2847
|
-
if ('action' in options && options.action === 'remove') {
|
|
2919
|
+
if ('action' in options && options.action === 'remove' && options.value.length) {
|
|
2848
2920
|
for (let i = 0; i < options.value.length; i++) {
|
|
2849
2921
|
yield this.filterOptionRepository.delete({ id: options.value[i].id });
|
|
2850
2922
|
}
|
|
2851
2923
|
return [];
|
|
2852
2924
|
}
|
|
2853
|
-
if ('action' in options && options.action === '
|
|
2925
|
+
if ('action' in options && options.action === 'merge' && options.value.length) {
|
|
2854
2926
|
let filterOptions = [];
|
|
2855
2927
|
for (let i = 0; i < options.value.length; i++) {
|
|
2856
|
-
|
|
2857
|
-
|
|
2858
|
-
|
|
2859
|
-
|
|
2928
|
+
try {
|
|
2929
|
+
const hasFilter = yield this.filterOptionRepository.get({ id: options.value[i].id });
|
|
2930
|
+
if (hasFilter)
|
|
2931
|
+
filterOptions.push(hasFilter);
|
|
2860
2932
|
}
|
|
2861
|
-
|
|
2862
|
-
|
|
2933
|
+
catch (error) {
|
|
2934
|
+
const newOption = yield this.filterOptionRepository.create(Object.assign(Object.assign({}, options.value[i]), { filterId }));
|
|
2935
|
+
filterOptions.push(newOption);
|
|
2863
2936
|
}
|
|
2864
2937
|
}
|
|
2865
2938
|
return filterOptions;
|
|
2866
2939
|
}
|
|
2940
|
+
if (Array.isArray(options) && options.length) {
|
|
2941
|
+
let filterOptions = [];
|
|
2942
|
+
for (let i = 0; i < options.length; i++) {
|
|
2943
|
+
try {
|
|
2944
|
+
const hasFilter = yield this.filterOptionRepository.get({ id: options[i].id });
|
|
2945
|
+
if (hasFilter)
|
|
2946
|
+
filterOptions.push(hasFilter);
|
|
2947
|
+
}
|
|
2948
|
+
catch (error) {
|
|
2949
|
+
const newOption = yield this.filterOptionRepository.create(Object.assign(Object.assign({}, options[i]), { filterId }));
|
|
2950
|
+
filterOptions.push(newOption);
|
|
2951
|
+
}
|
|
2952
|
+
}
|
|
2953
|
+
}
|
|
2954
|
+
return [];
|
|
2955
|
+
});
|
|
2956
|
+
}
|
|
2957
|
+
delete(params) {
|
|
2958
|
+
const _super = Object.create(null, {
|
|
2959
|
+
delete: { get: () => super.delete }
|
|
2960
|
+
});
|
|
2961
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2962
|
+
const { options } = params, data = __rest(params, ["options"]);
|
|
2963
|
+
const categoryFilters = yield this.categoryFilterRepository
|
|
2964
|
+
.find({
|
|
2965
|
+
filters: {
|
|
2966
|
+
filterId: +data.id,
|
|
2967
|
+
},
|
|
2968
|
+
})
|
|
2969
|
+
.then((result) => result.data);
|
|
2970
|
+
if (categoryFilters.length)
|
|
2971
|
+
throw new Error('Erro: o filtro está associado a uma ou mais categoria(s)');
|
|
2972
|
+
yield this.deleteOptions(options);
|
|
2973
|
+
yield _super.delete.call(this, { id: +data.id });
|
|
2974
|
+
return;
|
|
2975
|
+
});
|
|
2976
|
+
}
|
|
2977
|
+
deleteOptions(options) {
|
|
2978
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2979
|
+
for (let i = 0; i < options.length; i++) {
|
|
2980
|
+
try {
|
|
2981
|
+
yield this.filterOptionRepository.delete({ id: options[i].id });
|
|
2982
|
+
}
|
|
2983
|
+
catch (error) {
|
|
2984
|
+
console.log(error);
|
|
2985
|
+
}
|
|
2986
|
+
}
|
|
2867
2987
|
});
|
|
2868
2988
|
}
|
|
2869
2989
|
}
|
|
@@ -2871,36 +2991,17 @@ class FilterHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGrap
|
|
|
2871
2991
|
class FilterOptionHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
2872
2992
|
constructor(endpoint, authOptions) {
|
|
2873
2993
|
super({
|
|
2874
|
-
tableName: '
|
|
2875
|
-
model:
|
|
2994
|
+
tableName: 'filter_option',
|
|
2995
|
+
model: FilterOption,
|
|
2876
2996
|
endpoint,
|
|
2877
2997
|
authOptions,
|
|
2878
|
-
fields: [
|
|
2879
|
-
|
|
2880
|
-
|
|
2881
|
-
|
|
2882
|
-
|
|
2883
|
-
|
|
2884
|
-
|
|
2885
|
-
const _super = Object.create(null, {
|
|
2886
|
-
find: { get: () => super.find }
|
|
2887
|
-
});
|
|
2888
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
2889
|
-
const filterOptions = yield _super.find.call(this, options);
|
|
2890
|
-
return filterOptions;
|
|
2891
|
-
});
|
|
2892
|
-
}
|
|
2893
|
-
delete(identifiers) {
|
|
2894
|
-
return super.delete(identifiers);
|
|
2895
|
-
}
|
|
2896
|
-
findByFilter(filterId) {
|
|
2897
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
2898
|
-
const options = yield this.find({
|
|
2899
|
-
filters: {
|
|
2900
|
-
filterId,
|
|
2901
|
-
},
|
|
2902
|
-
});
|
|
2903
|
-
return options;
|
|
2998
|
+
fields: [
|
|
2999
|
+
'id',
|
|
3000
|
+
'description',
|
|
3001
|
+
{ filterId: { columnName: 'filter_id' } },
|
|
3002
|
+
{ createdAt: { columnName: 'created_at' } },
|
|
3003
|
+
{ updatedAt: { columnName: 'updated_at' } },
|
|
3004
|
+
],
|
|
2904
3005
|
});
|
|
2905
3006
|
}
|
|
2906
3007
|
}
|
|
@@ -3473,5 +3574,5 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
3473
3574
|
* Generated bundle index. Do not edit.
|
|
3474
3575
|
*/
|
|
3475
3576
|
|
|
3476
|
-
export { AccessoryImportances, Address, Area, Authentication, AuthenticationFirebaseAuthService, AxiosAdapter, Base, BaseModel, BeardProblems, BeardSizes, BeautyProductImportances, BeautyProfile, BeautyQuestionsHelper, BillingStatus, BodyProblems, BodyShapes, BodyTattoos, Buy2Win, Buy2WinFirestoreRepository, Category, CategoryFirestoreRepository, CategoryHasuraGraphQL, CategoryHasuraGraphQLRepository, Checkout, CheckoutFirestoreRepository, CheckoutSubscription, CheckoutSubscriptionFirestoreRepository, CheckoutTypes, Coupon, CouponFirestoreRepository, CouponSubtypes, CouponTypes, DuplicatedResultsError, Edition, EditionStatus, Exclusivities, FaceSkinOilinesses, FaceSkinProblems, FaceSkinTones, FamilyIncomes, Filter,
|
|
3577
|
+
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 };
|
|
3477
3578
|
//# sourceMappingURL=infrab4a-connect.js.map
|