@infrab4a/connect 3.4.0-beta.15 → 3.4.0-beta.3
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 +48 -324
- 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/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/esm2015/domain/catalog/models/category.js +1 -8
- package/esm2015/domain/catalog/models/filter-option.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/infra/elasticsearch/indexes/products-index.js +2 -3
- package/esm2015/infra/hasura-graphql/mixins/helpers/attribute-option.helper.js +2 -2
- package/esm2015/infra/hasura-graphql/repositories/catalog/category-hasura-graphql.repository.js +4 -84
- package/esm2015/infra/hasura-graphql/repositories/catalog/filter-hasura-graphql.repository.js +10 -67
- package/esm2015/infra/hasura-graphql/repositories/catalog/index.js +1 -2
- package/esm2015/infra/hasura-graphql/repositories/catalog/product-hasura-graphql.repository.js +1 -2
- package/esm2015/infra/hasura-graphql/types/hasura-graphql-fields.type.js +1 -1
- package/fesm2015/infrab4a-connect.js +24 -197
- package/fesm2015/infrab4a-connect.js.map +1 -1
- 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 +2 -6
- package/infra/hasura-graphql/repositories/catalog/index.d.ts +0 -1
- package/infra/hasura-graphql/types/hasura-graphql-fields.type.d.ts +1 -1
- package/package.json +1 -1
- package/domain/catalog/models/category-filter.d.ts +0 -9
- package/domain/catalog/repositories/category-filter.repository.d.ts +0 -5
- package/esm2015/domain/catalog/models/category-filter.js +0 -10
- package/esm2015/domain/catalog/repositories/category-filter.repository.js +0 -2
- package/esm2015/infra/hasura-graphql/repositories/catalog/category-filter-hasura-graphql.repository.js +0 -24
- package/infra/hasura-graphql/repositories/catalog/category-filter-hasura-graphql.repository.d.ts +0 -11
|
@@ -1252,24 +1252,6 @@
|
|
|
1252
1252
|
return RecoveryPassword;
|
|
1253
1253
|
}());
|
|
1254
1254
|
|
|
1255
|
-
var Filter = /** @class */ (function (_super) {
|
|
1256
|
-
__extends(Filter, _super);
|
|
1257
|
-
function Filter() {
|
|
1258
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
1259
|
-
}
|
|
1260
|
-
Filter.prototype.identifierFields = function () {
|
|
1261
|
-
return ['id'];
|
|
1262
|
-
};
|
|
1263
|
-
Object.defineProperty(Filter, "identifiersFields", {
|
|
1264
|
-
get: function () {
|
|
1265
|
-
return ['id'];
|
|
1266
|
-
},
|
|
1267
|
-
enumerable: false,
|
|
1268
|
-
configurable: true
|
|
1269
|
-
});
|
|
1270
|
-
return Filter;
|
|
1271
|
-
}(BaseModel));
|
|
1272
|
-
|
|
1273
1255
|
var Category = /** @class */ (function (_super) {
|
|
1274
1256
|
__extends(Category, _super);
|
|
1275
1257
|
function Category() {
|
|
@@ -1286,28 +1268,6 @@
|
|
|
1286
1268
|
configurable: true
|
|
1287
1269
|
});
|
|
1288
1270
|
return Category;
|
|
1289
|
-
}(BaseModel));
|
|
1290
|
-
__decorate([
|
|
1291
|
-
classTransformer.Type(function () { return Filter; }),
|
|
1292
|
-
__metadata("design:type", Array)
|
|
1293
|
-
], Category.prototype, "filters", void 0);
|
|
1294
|
-
|
|
1295
|
-
var CategoryFilter = /** @class */ (function (_super) {
|
|
1296
|
-
__extends(CategoryFilter, _super);
|
|
1297
|
-
function CategoryFilter() {
|
|
1298
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
1299
|
-
}
|
|
1300
|
-
Object.defineProperty(CategoryFilter, "identifiersFields", {
|
|
1301
|
-
// identifierFields(): NonFunctionPropertyNames<CategoryFilter>[] {
|
|
1302
|
-
// return ['id']
|
|
1303
|
-
// }
|
|
1304
|
-
get: function () {
|
|
1305
|
-
return ['id', 'filterId', 'categoryId'];
|
|
1306
|
-
},
|
|
1307
|
-
enumerable: false,
|
|
1308
|
-
configurable: true
|
|
1309
|
-
});
|
|
1310
|
-
return CategoryFilter;
|
|
1311
1271
|
}(BaseModel));
|
|
1312
1272
|
|
|
1313
1273
|
exports.GenderDestination = void 0;
|
|
@@ -1325,6 +1285,24 @@
|
|
|
1325
1285
|
Shops["ALL"] = "ALL";
|
|
1326
1286
|
})(exports.Shops || (exports.Shops = {}));
|
|
1327
1287
|
|
|
1288
|
+
var Filter = /** @class */ (function (_super) {
|
|
1289
|
+
__extends(Filter, _super);
|
|
1290
|
+
function Filter() {
|
|
1291
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
1292
|
+
}
|
|
1293
|
+
Filter.prototype.identifierFields = function () {
|
|
1294
|
+
return ['id'];
|
|
1295
|
+
};
|
|
1296
|
+
Object.defineProperty(Filter, "identifiersFields", {
|
|
1297
|
+
get: function () {
|
|
1298
|
+
return ['id'];
|
|
1299
|
+
},
|
|
1300
|
+
enumerable: false,
|
|
1301
|
+
configurable: true
|
|
1302
|
+
});
|
|
1303
|
+
return Filter;
|
|
1304
|
+
}(BaseModel));
|
|
1305
|
+
|
|
1328
1306
|
var FilterOption = /** @class */ (function (_super) {
|
|
1329
1307
|
__extends(FilterOption, _super);
|
|
1330
1308
|
function FilterOption() {
|
|
@@ -1825,9 +1803,8 @@
|
|
|
1825
1803
|
'stock',
|
|
1826
1804
|
'weight',
|
|
1827
1805
|
'tags',
|
|
1828
|
-
'filters',
|
|
1829
1806
|
'hasVariants',
|
|
1830
|
-
'type'
|
|
1807
|
+
'type'
|
|
1831
1808
|
];
|
|
1832
1809
|
return [4 /*yield*/, this.adapter.query('products/_search', Object.assign({ _source: fields, query: {
|
|
1833
1810
|
bool: {
|
|
@@ -3065,7 +3042,7 @@
|
|
|
3065
3042
|
}());
|
|
3066
3043
|
AttributeOptionHelper.FindByAttribute = function (attributeName, fields) {
|
|
3067
3044
|
if (fields.includes(attributeName))
|
|
3068
|
-
return { columnName: attributeName.toString(), attributeName: attributeName
|
|
3045
|
+
return { columnName: attributeName.toString(), attributeName: attributeName };
|
|
3069
3046
|
var field = fields.find(function (columnOption) { return lodash.isObject(columnOption) && Object.keys(columnOption).includes(attributeName.toString()); });
|
|
3070
3047
|
var fieldOption = field === null || field === void 0 ? void 0 : field[attributeName.toString()];
|
|
3071
3048
|
if (lodash.isNil(fieldOption))
|
|
@@ -3759,32 +3736,9 @@
|
|
|
3759
3736
|
return VariantHasuraGraphQL;
|
|
3760
3737
|
}(Variant));
|
|
3761
3738
|
|
|
3762
|
-
var CategoryFilterHasuraGraphQLRepository = /** @class */ (function (_super) {
|
|
3763
|
-
__extends(CategoryFilterHasuraGraphQLRepository, _super);
|
|
3764
|
-
function CategoryFilterHasuraGraphQLRepository(endpoint, authOptions) {
|
|
3765
|
-
return _super.call(this, {
|
|
3766
|
-
tableName: 'category_filter',
|
|
3767
|
-
model: CategoryFilter,
|
|
3768
|
-
endpoint: endpoint,
|
|
3769
|
-
authOptions: authOptions,
|
|
3770
|
-
fields: ['id', { filterId: { columnName: 'filter_id' } }, { categoryId: { columnName: 'category_id' } }],
|
|
3771
|
-
}) || this;
|
|
3772
|
-
}
|
|
3773
|
-
CategoryFilterHasuraGraphQLRepository.prototype.deleteByCategoryAndFilter = function (categoryId, filterId) {
|
|
3774
|
-
return this.mutation('delete_category_filter', ['affected_rows'], {
|
|
3775
|
-
where: {
|
|
3776
|
-
type: 'category_filter_bool_exp',
|
|
3777
|
-
required: true,
|
|
3778
|
-
value: { category_id: { _eq: categoryId }, filter_id: { _eq: filterId } },
|
|
3779
|
-
},
|
|
3780
|
-
});
|
|
3781
|
-
};
|
|
3782
|
-
return CategoryFilterHasuraGraphQLRepository;
|
|
3783
|
-
}(withCrudHasuraGraphQL(withHasuraGraphQL(Base))));
|
|
3784
|
-
|
|
3785
3739
|
var CategoryHasuraGraphQLRepository = /** @class */ (function (_super_1) {
|
|
3786
3740
|
__extends(CategoryHasuraGraphQLRepository, _super_1);
|
|
3787
|
-
function CategoryHasuraGraphQLRepository(endpoint, authOptions, productRepository
|
|
3741
|
+
function CategoryHasuraGraphQLRepository(endpoint, authOptions, productRepository) {
|
|
3788
3742
|
var _this = _super_1.call(this, {
|
|
3789
3743
|
tableName: 'category',
|
|
3790
3744
|
model: Category,
|
|
@@ -3820,17 +3774,7 @@
|
|
|
3820
3774
|
},
|
|
3821
3775
|
},
|
|
3822
3776
|
},
|
|
3823
|
-
|
|
3824
|
-
filters: {
|
|
3825
|
-
columnName: 'filters',
|
|
3826
|
-
foreignKeyColumn: { filter_id: 'id' },
|
|
3827
|
-
fields: [{ filter: ['id', 'description', 'slug', 'enabled'] }],
|
|
3828
|
-
bindPersistData: function (value) { return ({
|
|
3829
|
-
filters: { data: value.map(function (filter) { return ({ filter_id: filter.id }); }) },
|
|
3830
|
-
}); },
|
|
3831
|
-
from: function (filters) { return (filters === null || filters === void 0 ? void 0 : filters.map(function (filter) { return filter === null || filter === void 0 ? void 0 : filter.filter; })) || []; },
|
|
3832
|
-
},
|
|
3833
|
-
},
|
|
3777
|
+
'filters',
|
|
3834
3778
|
{ createdAt: { columnName: 'created_at' } },
|
|
3835
3779
|
{ updatedAt: { columnName: 'updated_at' } },
|
|
3836
3780
|
{
|
|
@@ -3855,7 +3799,6 @@
|
|
|
3855
3799
|
],
|
|
3856
3800
|
}) || this;
|
|
3857
3801
|
_this.productRepository = productRepository;
|
|
3858
|
-
_this.categoryFilterRepository = categoryFilterRepository;
|
|
3859
3802
|
return _this;
|
|
3860
3803
|
}
|
|
3861
3804
|
CategoryHasuraGraphQLRepository.prototype.create = function (params) {
|
|
@@ -3898,25 +3841,25 @@
|
|
|
3898
3841
|
update: { get: function () { return _super_1.prototype.update; } }
|
|
3899
3842
|
});
|
|
3900
3843
|
return __awaiter(this, void 0, void 0, function () {
|
|
3901
|
-
var products, checkId, metadata,
|
|
3902
|
-
return __generator(this, function (
|
|
3903
|
-
switch (
|
|
3844
|
+
var products, checkId, metadata, data, plainData, id, category, _c, _d, _e, _f;
|
|
3845
|
+
return __generator(this, function (_g) {
|
|
3846
|
+
switch (_g.label) {
|
|
3904
3847
|
case 0:
|
|
3905
|
-
products = params.products, checkId = params.id, metadata = params.metadata,
|
|
3848
|
+
products = params.products, checkId = params.id, metadata = params.metadata, data = __rest(params, ["products", "id", "metadata"]);
|
|
3906
3849
|
plainData = this.paramsToPlain({ id: checkId });
|
|
3907
3850
|
return [4 /*yield*/, this.getId(plainData.id)];
|
|
3908
3851
|
case 1:
|
|
3909
|
-
id =
|
|
3852
|
+
id = _g.sent();
|
|
3910
3853
|
return [4 /*yield*/, _super.update.call(this, Object.assign({ id: id }, data))];
|
|
3911
3854
|
case 2:
|
|
3912
|
-
category =
|
|
3855
|
+
category = _g.sent();
|
|
3913
3856
|
_c = category;
|
|
3914
3857
|
_d = products;
|
|
3915
3858
|
if (!_d) return [3 /*break*/, 4];
|
|
3916
3859
|
return [4 /*yield*/, this.updateProducts(+id, { products: products })];
|
|
3917
3860
|
case 3:
|
|
3918
|
-
_d = (
|
|
3919
|
-
|
|
3861
|
+
_d = (_g.sent());
|
|
3862
|
+
_g.label = 4;
|
|
3920
3863
|
case 4:
|
|
3921
3864
|
_c.products = _d;
|
|
3922
3865
|
_e = category;
|
|
@@ -3924,19 +3867,10 @@
|
|
|
3924
3867
|
if (!_f) return [3 /*break*/, 6];
|
|
3925
3868
|
return [4 /*yield*/, this.updateMetadata(+id, { metadata: metadata })];
|
|
3926
3869
|
case 5:
|
|
3927
|
-
_f = (
|
|
3928
|
-
|
|
3870
|
+
_f = (_g.sent());
|
|
3871
|
+
_g.label = 6;
|
|
3929
3872
|
case 6:
|
|
3930
3873
|
_e.metadata = _f;
|
|
3931
|
-
_g = category;
|
|
3932
|
-
_h = filters;
|
|
3933
|
-
if (!_h) return [3 /*break*/, 8];
|
|
3934
|
-
return [4 /*yield*/, this.updateFilters(+id, { filters: filters })];
|
|
3935
|
-
case 7:
|
|
3936
|
-
_h = (_j.sent());
|
|
3937
|
-
_j.label = 8;
|
|
3938
|
-
case 8:
|
|
3939
|
-
_g.filters = _h;
|
|
3940
3874
|
return [2 /*return*/, category];
|
|
3941
3875
|
}
|
|
3942
3876
|
});
|
|
@@ -4162,117 +4096,12 @@
|
|
|
4162
4096
|
});
|
|
4163
4097
|
});
|
|
4164
4098
|
};
|
|
4165
|
-
CategoryHasuraGraphQLRepository.prototype.updateFilters = function (categoryId, _c) {
|
|
4166
|
-
var filters = _c.filters;
|
|
4167
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
4168
|
-
var i, filtersList, i, hasFilter, newCategoryFilter, error_1, filtersList, i, hasFilter, newCategoryFilter, error_2;
|
|
4169
|
-
return __generator(this, function (_c) {
|
|
4170
|
-
switch (_c.label) {
|
|
4171
|
-
case 0:
|
|
4172
|
-
if (!('action' in filters && filters.action === 'remove' && filters.value.length)) return [3 /*break*/, 5];
|
|
4173
|
-
i = 0;
|
|
4174
|
-
_c.label = 1;
|
|
4175
|
-
case 1:
|
|
4176
|
-
if (!(i < filters.value.length)) return [3 /*break*/, 4];
|
|
4177
|
-
return [4 /*yield*/, this.categoryFilterRepository.deleteByCategoryAndFilter(categoryId, filters.value[i].id)];
|
|
4178
|
-
case 2:
|
|
4179
|
-
_c.sent();
|
|
4180
|
-
_c.label = 3;
|
|
4181
|
-
case 3:
|
|
4182
|
-
i++;
|
|
4183
|
-
return [3 /*break*/, 1];
|
|
4184
|
-
case 4: return [2 /*return*/, []];
|
|
4185
|
-
case 5:
|
|
4186
|
-
if (!('action' in filters && filters.action === 'merge' && filters.value.length)) return [3 /*break*/, 15];
|
|
4187
|
-
filtersList = [];
|
|
4188
|
-
i = 0;
|
|
4189
|
-
_c.label = 6;
|
|
4190
|
-
case 6:
|
|
4191
|
-
if (!(i < filters.value.length)) return [3 /*break*/, 14];
|
|
4192
|
-
_c.label = 7;
|
|
4193
|
-
case 7:
|
|
4194
|
-
_c.trys.push([7, 12, , 13]);
|
|
4195
|
-
return [4 /*yield*/, this.categoryFilterRepository
|
|
4196
|
-
.find({
|
|
4197
|
-
filters: {
|
|
4198
|
-
categoryId: categoryId,
|
|
4199
|
-
filterId: filters.value[i].id,
|
|
4200
|
-
},
|
|
4201
|
-
})
|
|
4202
|
-
.then(function (data) { return data.data.shift(); })];
|
|
4203
|
-
case 8:
|
|
4204
|
-
hasFilter = _c.sent();
|
|
4205
|
-
if (!hasFilter) return [3 /*break*/, 9];
|
|
4206
|
-
filtersList.push(hasFilter);
|
|
4207
|
-
return [3 /*break*/, 11];
|
|
4208
|
-
case 9: return [4 /*yield*/, this.categoryFilterRepository.create({
|
|
4209
|
-
filterId: filters.value[i].id,
|
|
4210
|
-
categoryId: categoryId,
|
|
4211
|
-
})];
|
|
4212
|
-
case 10:
|
|
4213
|
-
newCategoryFilter = _c.sent();
|
|
4214
|
-
filtersList.push(newCategoryFilter);
|
|
4215
|
-
_c.label = 11;
|
|
4216
|
-
case 11: return [3 /*break*/, 13];
|
|
4217
|
-
case 12:
|
|
4218
|
-
error_1 = _c.sent();
|
|
4219
|
-
console.log('catch error: ', error_1);
|
|
4220
|
-
return [3 /*break*/, 13];
|
|
4221
|
-
case 13:
|
|
4222
|
-
i++;
|
|
4223
|
-
return [3 /*break*/, 6];
|
|
4224
|
-
case 14: return [2 /*return*/, filtersList];
|
|
4225
|
-
case 15:
|
|
4226
|
-
if (!(Array.isArray(filters) && filters.length)) return [3 /*break*/, 25];
|
|
4227
|
-
filtersList = [];
|
|
4228
|
-
i = 0;
|
|
4229
|
-
_c.label = 16;
|
|
4230
|
-
case 16:
|
|
4231
|
-
if (!(i < filters.length)) return [3 /*break*/, 24];
|
|
4232
|
-
_c.label = 17;
|
|
4233
|
-
case 17:
|
|
4234
|
-
_c.trys.push([17, 22, , 23]);
|
|
4235
|
-
return [4 /*yield*/, this.categoryFilterRepository
|
|
4236
|
-
.find({
|
|
4237
|
-
filters: {
|
|
4238
|
-
categoryId: categoryId,
|
|
4239
|
-
filterId: filters[i].id,
|
|
4240
|
-
},
|
|
4241
|
-
})
|
|
4242
|
-
.then(function (data) { return data.data.shift(); })];
|
|
4243
|
-
case 18:
|
|
4244
|
-
hasFilter = _c.sent();
|
|
4245
|
-
if (!hasFilter) return [3 /*break*/, 19];
|
|
4246
|
-
filtersList.push(hasFilter);
|
|
4247
|
-
return [3 /*break*/, 21];
|
|
4248
|
-
case 19: return [4 /*yield*/, this.categoryFilterRepository.create({
|
|
4249
|
-
filterId: filters[i].id,
|
|
4250
|
-
categoryId: categoryId,
|
|
4251
|
-
})];
|
|
4252
|
-
case 20:
|
|
4253
|
-
newCategoryFilter = _c.sent();
|
|
4254
|
-
filtersList.push(newCategoryFilter);
|
|
4255
|
-
_c.label = 21;
|
|
4256
|
-
case 21: return [3 /*break*/, 23];
|
|
4257
|
-
case 22:
|
|
4258
|
-
error_2 = _c.sent();
|
|
4259
|
-
console.log('catch error: ', error_2);
|
|
4260
|
-
return [3 /*break*/, 23];
|
|
4261
|
-
case 23:
|
|
4262
|
-
i++;
|
|
4263
|
-
return [3 /*break*/, 16];
|
|
4264
|
-
case 24: return [2 /*return*/, filtersList];
|
|
4265
|
-
case 25: return [2 /*return*/];
|
|
4266
|
-
}
|
|
4267
|
-
});
|
|
4268
|
-
});
|
|
4269
|
-
};
|
|
4270
4099
|
return CategoryHasuraGraphQLRepository;
|
|
4271
4100
|
}(withCrudHasuraGraphQL(withHasuraGraphQL(Base))));
|
|
4272
4101
|
|
|
4273
4102
|
var FilterHasuraGraphQLRepository = /** @class */ (function (_super_1) {
|
|
4274
4103
|
__extends(FilterHasuraGraphQLRepository, _super_1);
|
|
4275
|
-
function FilterHasuraGraphQLRepository(endpoint, authOptions, filterOptionRepository
|
|
4104
|
+
function FilterHasuraGraphQLRepository(endpoint, authOptions, filterOptionRepository) {
|
|
4276
4105
|
var _this = _super_1.call(this, {
|
|
4277
4106
|
tableName: 'filter',
|
|
4278
4107
|
model: Filter,
|
|
@@ -4281,7 +4110,6 @@
|
|
|
4281
4110
|
fields: [
|
|
4282
4111
|
'id',
|
|
4283
4112
|
'description',
|
|
4284
|
-
'slug',
|
|
4285
4113
|
'enabled',
|
|
4286
4114
|
{ createdAt: { columnName: 'created_at' } },
|
|
4287
4115
|
{ updatedAt: { columnName: 'updated_at' } },
|
|
@@ -4301,7 +4129,6 @@
|
|
|
4301
4129
|
],
|
|
4302
4130
|
}) || this;
|
|
4303
4131
|
_this.filterOptionRepository = filterOptionRepository;
|
|
4304
|
-
_this.categoryFilterRepository = categoryFilterRepository;
|
|
4305
4132
|
return _this;
|
|
4306
4133
|
}
|
|
4307
4134
|
FilterHasuraGraphQLRepository.prototype.update = function (params) {
|
|
@@ -4329,13 +4156,13 @@
|
|
|
4329
4156
|
FilterHasuraGraphQLRepository.prototype.updateOptions = function (filterId, _a) {
|
|
4330
4157
|
var options = _a.options;
|
|
4331
4158
|
return __awaiter(this, void 0, void 0, function () {
|
|
4332
|
-
var i, filterOptions, i, hasFilter,
|
|
4159
|
+
var i, filterOptions, i, hasFilter, newOption;
|
|
4333
4160
|
return __generator(this, function (_a) {
|
|
4334
4161
|
switch (_a.label) {
|
|
4335
4162
|
case 0:
|
|
4336
4163
|
if (!options)
|
|
4337
4164
|
return [2 /*return*/, []];
|
|
4338
|
-
if (!('action' in options && options.action === 'remove'
|
|
4165
|
+
if (!('action' in options && options.action === 'remove')) return [3 /*break*/, 5];
|
|
4339
4166
|
i = 0;
|
|
4340
4167
|
_a.label = 1;
|
|
4341
4168
|
case 1:
|
|
@@ -4349,129 +4176,29 @@
|
|
|
4349
4176
|
return [3 /*break*/, 1];
|
|
4350
4177
|
case 4: return [2 /*return*/, []];
|
|
4351
4178
|
case 5:
|
|
4352
|
-
if (!('action' in options && options.action === '
|
|
4179
|
+
if (!('action' in options && options.action === 'update')) return [3 /*break*/, 12];
|
|
4353
4180
|
filterOptions = [];
|
|
4354
4181
|
i = 0;
|
|
4355
4182
|
_a.label = 6;
|
|
4356
4183
|
case 6:
|
|
4357
|
-
if (!(i < options.value.length)) return [3 /*break*/,
|
|
4358
|
-
_a.label = 7;
|
|
4359
|
-
case 7:
|
|
4360
|
-
_a.trys.push([7, 9, , 11]);
|
|
4184
|
+
if (!(i < options.value.length)) return [3 /*break*/, 11];
|
|
4361
4185
|
return [4 /*yield*/, this.filterOptionRepository.get({ id: options.value[i].id })];
|
|
4362
|
-
case
|
|
4186
|
+
case 7:
|
|
4363
4187
|
hasFilter = _a.sent();
|
|
4364
|
-
if (hasFilter)
|
|
4365
|
-
|
|
4366
|
-
|
|
4367
|
-
case 9:
|
|
4368
|
-
error_1 = _a.sent();
|
|
4369
|
-
return [4 /*yield*/, this.filterOptionRepository.create(Object.assign(Object.assign({}, options.value[i]), { filterId: filterId }))];
|
|
4370
|
-
case 10:
|
|
4188
|
+
if (!!hasFilter) return [3 /*break*/, 9];
|
|
4189
|
+
return [4 /*yield*/, this.filterOptionRepository.create(options.value[i])];
|
|
4190
|
+
case 8:
|
|
4371
4191
|
newOption = _a.sent();
|
|
4372
4192
|
filterOptions.push(newOption);
|
|
4373
|
-
return [3 /*break*/,
|
|
4374
|
-
case
|
|
4193
|
+
return [3 /*break*/, 10];
|
|
4194
|
+
case 9:
|
|
4195
|
+
filterOptions.push(hasFilter);
|
|
4196
|
+
_a.label = 10;
|
|
4197
|
+
case 10:
|
|
4375
4198
|
i++;
|
|
4376
4199
|
return [3 /*break*/, 6];
|
|
4377
|
-
case
|
|
4378
|
-
case
|
|
4379
|
-
if (!(Array.isArray(options) && options.length)) return [3 /*break*/, 20];
|
|
4380
|
-
filterOptions = [];
|
|
4381
|
-
i = 0;
|
|
4382
|
-
_a.label = 14;
|
|
4383
|
-
case 14:
|
|
4384
|
-
if (!(i < options.length)) return [3 /*break*/, 20];
|
|
4385
|
-
_a.label = 15;
|
|
4386
|
-
case 15:
|
|
4387
|
-
_a.trys.push([15, 17, , 19]);
|
|
4388
|
-
return [4 /*yield*/, this.filterOptionRepository.get({ id: options[i].id })];
|
|
4389
|
-
case 16:
|
|
4390
|
-
hasFilter = _a.sent();
|
|
4391
|
-
if (hasFilter)
|
|
4392
|
-
filterOptions.push(hasFilter);
|
|
4393
|
-
return [3 /*break*/, 19];
|
|
4394
|
-
case 17:
|
|
4395
|
-
error_2 = _a.sent();
|
|
4396
|
-
return [4 /*yield*/, this.filterOptionRepository.create(Object.assign(Object.assign({}, options[i]), { filterId: filterId }))];
|
|
4397
|
-
case 18:
|
|
4398
|
-
newOption = _a.sent();
|
|
4399
|
-
filterOptions.push(newOption);
|
|
4400
|
-
return [3 /*break*/, 19];
|
|
4401
|
-
case 19:
|
|
4402
|
-
i++;
|
|
4403
|
-
return [3 /*break*/, 14];
|
|
4404
|
-
case 20: return [2 /*return*/, []];
|
|
4405
|
-
}
|
|
4406
|
-
});
|
|
4407
|
-
});
|
|
4408
|
-
};
|
|
4409
|
-
FilterHasuraGraphQLRepository.prototype.delete = function (params) {
|
|
4410
|
-
var _super = Object.create(null, {
|
|
4411
|
-
delete: { get: function () { return _super_1.prototype.delete; } }
|
|
4412
|
-
});
|
|
4413
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
4414
|
-
var data, categoryFilters, options;
|
|
4415
|
-
return __generator(this, function (_a) {
|
|
4416
|
-
switch (_a.label) {
|
|
4417
|
-
case 0:
|
|
4418
|
-
data = params;
|
|
4419
|
-
return [4 /*yield*/, this.categoryFilterRepository
|
|
4420
|
-
.find({
|
|
4421
|
-
filters: {
|
|
4422
|
-
filterId: +data.id,
|
|
4423
|
-
},
|
|
4424
|
-
})
|
|
4425
|
-
.then(function (result) { return result.data; })];
|
|
4426
|
-
case 1:
|
|
4427
|
-
categoryFilters = _a.sent();
|
|
4428
|
-
if (categoryFilters.length)
|
|
4429
|
-
throw new Error('O filtro está associado a uma ou mais categoria(s)');
|
|
4430
|
-
return [4 /*yield*/, this.filterOptionRepository
|
|
4431
|
-
.find({
|
|
4432
|
-
filters: {
|
|
4433
|
-
filterId: +data.id,
|
|
4434
|
-
},
|
|
4435
|
-
})
|
|
4436
|
-
.then(function (data) { return data.data; })];
|
|
4437
|
-
case 2:
|
|
4438
|
-
options = _a.sent();
|
|
4439
|
-
return [4 /*yield*/, this.deleteOptions(options)];
|
|
4440
|
-
case 3:
|
|
4441
|
-
_a.sent();
|
|
4442
|
-
return [4 /*yield*/, _super.delete.call(this, { id: +data.id })];
|
|
4443
|
-
case 4:
|
|
4444
|
-
_a.sent();
|
|
4445
|
-
return [2 /*return*/];
|
|
4446
|
-
}
|
|
4447
|
-
});
|
|
4448
|
-
});
|
|
4449
|
-
};
|
|
4450
|
-
FilterHasuraGraphQLRepository.prototype.deleteOptions = function (options) {
|
|
4451
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
4452
|
-
var i, error_3;
|
|
4453
|
-
return __generator(this, function (_a) {
|
|
4454
|
-
switch (_a.label) {
|
|
4455
|
-
case 0:
|
|
4456
|
-
i = 0;
|
|
4457
|
-
_a.label = 1;
|
|
4458
|
-
case 1:
|
|
4459
|
-
if (!(i < options.length)) return [3 /*break*/, 6];
|
|
4460
|
-
_a.label = 2;
|
|
4461
|
-
case 2:
|
|
4462
|
-
_a.trys.push([2, 4, , 5]);
|
|
4463
|
-
return [4 /*yield*/, this.filterOptionRepository.delete({ id: options[i].id })];
|
|
4464
|
-
case 3:
|
|
4465
|
-
_a.sent();
|
|
4466
|
-
return [3 /*break*/, 5];
|
|
4467
|
-
case 4:
|
|
4468
|
-
error_3 = _a.sent();
|
|
4469
|
-
console.log(error_3);
|
|
4470
|
-
return [3 /*break*/, 5];
|
|
4471
|
-
case 5:
|
|
4472
|
-
i++;
|
|
4473
|
-
return [3 /*break*/, 1];
|
|
4474
|
-
case 6: return [2 /*return*/];
|
|
4200
|
+
case 11: return [2 /*return*/, filterOptions];
|
|
4201
|
+
case 12: return [2 /*return*/];
|
|
4475
4202
|
}
|
|
4476
4203
|
});
|
|
4477
4204
|
});
|
|
@@ -4603,7 +4330,6 @@
|
|
|
4603
4330
|
'weight',
|
|
4604
4331
|
'gender',
|
|
4605
4332
|
{ tags: { columnName: 'tags', type: HasuraGraphQLColumnType.Jsonb } },
|
|
4606
|
-
{ filters: { columnName: 'filters', type: HasuraGraphQLColumnType.Jsonb } },
|
|
4607
4333
|
{ isKit: { columnName: 'is_kit' } },
|
|
4608
4334
|
{ createdAt: { columnName: 'created_at' } },
|
|
4609
4335
|
{ updatedAt: { columnName: 'updated_at' } },
|
|
@@ -5431,8 +5157,6 @@
|
|
|
5431
5157
|
exports.Buy2Win = Buy2Win;
|
|
5432
5158
|
exports.Buy2WinFirestoreRepository = Buy2WinFirestoreRepository;
|
|
5433
5159
|
exports.Category = Category;
|
|
5434
|
-
exports.CategoryFilter = CategoryFilter;
|
|
5435
|
-
exports.CategoryFilterHasuraGraphQLRepository = CategoryFilterHasuraGraphQLRepository;
|
|
5436
5160
|
exports.CategoryFirestoreRepository = CategoryFirestoreRepository;
|
|
5437
5161
|
exports.CategoryHasuraGraphQL = CategoryHasuraGraphQL;
|
|
5438
5162
|
exports.CategoryHasuraGraphQLRepository = CategoryHasuraGraphQLRepository;
|