@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
|
@@ -1252,6 +1252,24 @@
|
|
|
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
|
+
|
|
1255
1273
|
var Category = /** @class */ (function (_super) {
|
|
1256
1274
|
__extends(Category, _super);
|
|
1257
1275
|
function Category() {
|
|
@@ -1268,7 +1286,11 @@
|
|
|
1268
1286
|
configurable: true
|
|
1269
1287
|
});
|
|
1270
1288
|
return Category;
|
|
1271
|
-
}(BaseModel));
|
|
1289
|
+
}(BaseModel));
|
|
1290
|
+
__decorate([
|
|
1291
|
+
classTransformer.Type(function () { return Filter; }),
|
|
1292
|
+
__metadata("design:type", Array)
|
|
1293
|
+
], Category.prototype, "filters", void 0);
|
|
1272
1294
|
|
|
1273
1295
|
var CategoryFilter = /** @class */ (function (_super) {
|
|
1274
1296
|
__extends(CategoryFilter, _super);
|
|
@@ -1303,24 +1325,6 @@
|
|
|
1303
1325
|
Shops["ALL"] = "ALL";
|
|
1304
1326
|
})(exports.Shops || (exports.Shops = {}));
|
|
1305
1327
|
|
|
1306
|
-
var Filter = /** @class */ (function (_super) {
|
|
1307
|
-
__extends(Filter, _super);
|
|
1308
|
-
function Filter() {
|
|
1309
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
1310
|
-
}
|
|
1311
|
-
Filter.prototype.identifierFields = function () {
|
|
1312
|
-
return ['id'];
|
|
1313
|
-
};
|
|
1314
|
-
Object.defineProperty(Filter, "identifiersFields", {
|
|
1315
|
-
get: function () {
|
|
1316
|
-
return ['id'];
|
|
1317
|
-
},
|
|
1318
|
-
enumerable: false,
|
|
1319
|
-
configurable: true
|
|
1320
|
-
});
|
|
1321
|
-
return Filter;
|
|
1322
|
-
}(BaseModel));
|
|
1323
|
-
|
|
1324
1328
|
var FilterOption = /** @class */ (function (_super) {
|
|
1325
1329
|
__extends(FilterOption, _super);
|
|
1326
1330
|
function FilterOption() {
|
|
@@ -3754,9 +3758,23 @@
|
|
|
3754
3758
|
return VariantHasuraGraphQL;
|
|
3755
3759
|
}(Variant));
|
|
3756
3760
|
|
|
3761
|
+
var CategoryFilterHasuraGraphQLRepository = /** @class */ (function (_super) {
|
|
3762
|
+
__extends(CategoryFilterHasuraGraphQLRepository, _super);
|
|
3763
|
+
function CategoryFilterHasuraGraphQLRepository(endpoint, authOptions) {
|
|
3764
|
+
return _super.call(this, {
|
|
3765
|
+
tableName: 'category_filter',
|
|
3766
|
+
model: CategoryFilter,
|
|
3767
|
+
endpoint: endpoint,
|
|
3768
|
+
authOptions: authOptions,
|
|
3769
|
+
fields: ['id', { filterId: { columnName: 'filter_id' } }, { categoryId: { columnName: 'category_id' } }],
|
|
3770
|
+
}) || this;
|
|
3771
|
+
}
|
|
3772
|
+
return CategoryFilterHasuraGraphQLRepository;
|
|
3773
|
+
}(withCrudHasuraGraphQL(withHasuraGraphQL(Base))));
|
|
3774
|
+
|
|
3757
3775
|
var CategoryHasuraGraphQLRepository = /** @class */ (function (_super_1) {
|
|
3758
3776
|
__extends(CategoryHasuraGraphQLRepository, _super_1);
|
|
3759
|
-
function CategoryHasuraGraphQLRepository(endpoint, authOptions, productRepository) {
|
|
3777
|
+
function CategoryHasuraGraphQLRepository(endpoint, authOptions, productRepository, categoryFilterRepository) {
|
|
3760
3778
|
var _this = _super_1.call(this, {
|
|
3761
3779
|
tableName: 'category',
|
|
3762
3780
|
model: Category,
|
|
@@ -3792,11 +3810,17 @@
|
|
|
3792
3810
|
},
|
|
3793
3811
|
},
|
|
3794
3812
|
},
|
|
3795
|
-
|
|
3796
|
-
|
|
3797
|
-
|
|
3798
|
-
|
|
3799
|
-
|
|
3813
|
+
{
|
|
3814
|
+
filters: {
|
|
3815
|
+
columnName: 'filters',
|
|
3816
|
+
foreignKeyColumn: { filter_id: 'id' },
|
|
3817
|
+
fields: [{ filter: ['id', 'description', 'slug', 'enabled'] }],
|
|
3818
|
+
bindPersistData: function (value) { return ({
|
|
3819
|
+
filters: { data: value.map(function (filter) { return ({ filter_id: filter.id }); }) },
|
|
3820
|
+
}); },
|
|
3821
|
+
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; })) || []; },
|
|
3822
|
+
},
|
|
3823
|
+
},
|
|
3800
3824
|
{ createdAt: { columnName: 'created_at' } },
|
|
3801
3825
|
{ updatedAt: { columnName: 'updated_at' } },
|
|
3802
3826
|
{
|
|
@@ -3821,6 +3845,7 @@
|
|
|
3821
3845
|
],
|
|
3822
3846
|
}) || this;
|
|
3823
3847
|
_this.productRepository = productRepository;
|
|
3848
|
+
_this.categoryFilterRepository = categoryFilterRepository;
|
|
3824
3849
|
return _this;
|
|
3825
3850
|
}
|
|
3826
3851
|
CategoryHasuraGraphQLRepository.prototype.create = function (params) {
|
|
@@ -3863,25 +3888,25 @@
|
|
|
3863
3888
|
update: { get: function () { return _super_1.prototype.update; } }
|
|
3864
3889
|
});
|
|
3865
3890
|
return __awaiter(this, void 0, void 0, function () {
|
|
3866
|
-
var products, checkId, metadata, data, plainData, id, category, _c, _d, _e, _f;
|
|
3867
|
-
return __generator(this, function (
|
|
3868
|
-
switch (
|
|
3891
|
+
var products, checkId, metadata, filters, data, plainData, id, category, _c, _d, _e, _f, _g, _h;
|
|
3892
|
+
return __generator(this, function (_j) {
|
|
3893
|
+
switch (_j.label) {
|
|
3869
3894
|
case 0:
|
|
3870
|
-
products = params.products, checkId = params.id, metadata = params.metadata, data = __rest(params, ["products", "id", "metadata"]);
|
|
3895
|
+
products = params.products, checkId = params.id, metadata = params.metadata, filters = params.filters, data = __rest(params, ["products", "id", "metadata", "filters"]);
|
|
3871
3896
|
plainData = this.paramsToPlain({ id: checkId });
|
|
3872
3897
|
return [4 /*yield*/, this.getId(plainData.id)];
|
|
3873
3898
|
case 1:
|
|
3874
|
-
id =
|
|
3899
|
+
id = _j.sent();
|
|
3875
3900
|
return [4 /*yield*/, _super.update.call(this, Object.assign({ id: id }, data))];
|
|
3876
3901
|
case 2:
|
|
3877
|
-
category =
|
|
3902
|
+
category = _j.sent();
|
|
3878
3903
|
_c = category;
|
|
3879
3904
|
_d = products;
|
|
3880
3905
|
if (!_d) return [3 /*break*/, 4];
|
|
3881
3906
|
return [4 /*yield*/, this.updateProducts(+id, { products: products })];
|
|
3882
3907
|
case 3:
|
|
3883
|
-
_d = (
|
|
3884
|
-
|
|
3908
|
+
_d = (_j.sent());
|
|
3909
|
+
_j.label = 4;
|
|
3885
3910
|
case 4:
|
|
3886
3911
|
_c.products = _d;
|
|
3887
3912
|
_e = category;
|
|
@@ -3889,10 +3914,19 @@
|
|
|
3889
3914
|
if (!_f) return [3 /*break*/, 6];
|
|
3890
3915
|
return [4 /*yield*/, this.updateMetadata(+id, { metadata: metadata })];
|
|
3891
3916
|
case 5:
|
|
3892
|
-
_f = (
|
|
3893
|
-
|
|
3917
|
+
_f = (_j.sent());
|
|
3918
|
+
_j.label = 6;
|
|
3894
3919
|
case 6:
|
|
3895
3920
|
_e.metadata = _f;
|
|
3921
|
+
_g = category;
|
|
3922
|
+
_h = filters;
|
|
3923
|
+
if (!_h) return [3 /*break*/, 8];
|
|
3924
|
+
return [4 /*yield*/, this.updateFilters(+id, { filters: filters })];
|
|
3925
|
+
case 7:
|
|
3926
|
+
_h = (_j.sent());
|
|
3927
|
+
_j.label = 8;
|
|
3928
|
+
case 8:
|
|
3929
|
+
_g.filters = _h;
|
|
3896
3930
|
return [2 /*return*/, category];
|
|
3897
3931
|
}
|
|
3898
3932
|
});
|
|
@@ -4118,12 +4152,111 @@
|
|
|
4118
4152
|
});
|
|
4119
4153
|
});
|
|
4120
4154
|
};
|
|
4155
|
+
CategoryHasuraGraphQLRepository.prototype.updateFilters = function (categoryId, _c) {
|
|
4156
|
+
var filters = _c.filters;
|
|
4157
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
4158
|
+
var i, filtersList, i, hasFilter, error_1, newCategoryFilter, filtersList, i, hasFilter, error_2, newCategoryFilter;
|
|
4159
|
+
return __generator(this, function (_c) {
|
|
4160
|
+
switch (_c.label) {
|
|
4161
|
+
case 0:
|
|
4162
|
+
if (!('action' in filters && filters.action === 'remove' && filters.value.length)) return [3 /*break*/, 5];
|
|
4163
|
+
i = 0;
|
|
4164
|
+
_c.label = 1;
|
|
4165
|
+
case 1:
|
|
4166
|
+
if (!(i < filters.value.length)) return [3 /*break*/, 4];
|
|
4167
|
+
return [4 /*yield*/, this.categoryFilterRepository.delete({ id: filters.value[i].id })];
|
|
4168
|
+
case 2:
|
|
4169
|
+
_c.sent();
|
|
4170
|
+
_c.label = 3;
|
|
4171
|
+
case 3:
|
|
4172
|
+
i++;
|
|
4173
|
+
return [3 /*break*/, 1];
|
|
4174
|
+
case 4: return [2 /*return*/, []];
|
|
4175
|
+
case 5:
|
|
4176
|
+
if (!('action' in filters && filters.action === 'merge' && filters.value.length)) return [3 /*break*/, 13];
|
|
4177
|
+
filtersList = [];
|
|
4178
|
+
i = 0;
|
|
4179
|
+
_c.label = 6;
|
|
4180
|
+
case 6:
|
|
4181
|
+
if (!(i < filters.value.length)) return [3 /*break*/, 12];
|
|
4182
|
+
_c.label = 7;
|
|
4183
|
+
case 7:
|
|
4184
|
+
_c.trys.push([7, 9, , 11]);
|
|
4185
|
+
return [4 /*yield*/, this.categoryFilterRepository
|
|
4186
|
+
.find({
|
|
4187
|
+
filters: {
|
|
4188
|
+
categoryId: categoryId,
|
|
4189
|
+
filterId: filters[i].id,
|
|
4190
|
+
},
|
|
4191
|
+
})
|
|
4192
|
+
.then(function (data) { return data.data.shift(); })];
|
|
4193
|
+
case 8:
|
|
4194
|
+
hasFilter = _c.sent();
|
|
4195
|
+
if (hasFilter)
|
|
4196
|
+
filtersList.push(hasFilter);
|
|
4197
|
+
return [3 /*break*/, 11];
|
|
4198
|
+
case 9:
|
|
4199
|
+
error_1 = _c.sent();
|
|
4200
|
+
return [4 /*yield*/, this.categoryFilterRepository.create({
|
|
4201
|
+
filterId: filters.value[i].id,
|
|
4202
|
+
categoryId: categoryId,
|
|
4203
|
+
})];
|
|
4204
|
+
case 10:
|
|
4205
|
+
newCategoryFilter = _c.sent();
|
|
4206
|
+
filtersList.push(newCategoryFilter);
|
|
4207
|
+
return [3 /*break*/, 11];
|
|
4208
|
+
case 11:
|
|
4209
|
+
i++;
|
|
4210
|
+
return [3 /*break*/, 6];
|
|
4211
|
+
case 12: return [2 /*return*/, filtersList];
|
|
4212
|
+
case 13:
|
|
4213
|
+
if (!(Array.isArray(filters) && filters.length)) return [3 /*break*/, 21];
|
|
4214
|
+
filtersList = [];
|
|
4215
|
+
i = 0;
|
|
4216
|
+
_c.label = 14;
|
|
4217
|
+
case 14:
|
|
4218
|
+
if (!(i < filters.length)) return [3 /*break*/, 20];
|
|
4219
|
+
_c.label = 15;
|
|
4220
|
+
case 15:
|
|
4221
|
+
_c.trys.push([15, 17, , 19]);
|
|
4222
|
+
return [4 /*yield*/, this.categoryFilterRepository
|
|
4223
|
+
.find({
|
|
4224
|
+
filters: {
|
|
4225
|
+
categoryId: categoryId,
|
|
4226
|
+
filterId: filters[i].id,
|
|
4227
|
+
},
|
|
4228
|
+
})
|
|
4229
|
+
.then(function (data) { return data.data.shift(); })];
|
|
4230
|
+
case 16:
|
|
4231
|
+
hasFilter = _c.sent();
|
|
4232
|
+
if (hasFilter)
|
|
4233
|
+
filtersList.push(hasFilter);
|
|
4234
|
+
return [3 /*break*/, 19];
|
|
4235
|
+
case 17:
|
|
4236
|
+
error_2 = _c.sent();
|
|
4237
|
+
return [4 /*yield*/, this.categoryFilterRepository.create({
|
|
4238
|
+
filterId: filters[i].id,
|
|
4239
|
+
categoryId: categoryId,
|
|
4240
|
+
})];
|
|
4241
|
+
case 18:
|
|
4242
|
+
newCategoryFilter = _c.sent();
|
|
4243
|
+
filtersList.push(newCategoryFilter);
|
|
4244
|
+
return [3 /*break*/, 19];
|
|
4245
|
+
case 19:
|
|
4246
|
+
i++;
|
|
4247
|
+
return [3 /*break*/, 14];
|
|
4248
|
+
case 20: return [2 /*return*/, filtersList];
|
|
4249
|
+
case 21: return [2 /*return*/];
|
|
4250
|
+
}
|
|
4251
|
+
});
|
|
4252
|
+
});
|
|
4253
|
+
};
|
|
4121
4254
|
return CategoryHasuraGraphQLRepository;
|
|
4122
4255
|
}(withCrudHasuraGraphQL(withHasuraGraphQL(Base))));
|
|
4123
4256
|
|
|
4124
4257
|
var FilterHasuraGraphQLRepository = /** @class */ (function (_super_1) {
|
|
4125
4258
|
__extends(FilterHasuraGraphQLRepository, _super_1);
|
|
4126
|
-
function FilterHasuraGraphQLRepository(endpoint, authOptions, filterOptionRepository) {
|
|
4259
|
+
function FilterHasuraGraphQLRepository(endpoint, authOptions, filterOptionRepository, categoryFilterRepository) {
|
|
4127
4260
|
var _this = _super_1.call(this, {
|
|
4128
4261
|
tableName: 'filter',
|
|
4129
4262
|
model: Filter,
|
|
@@ -4152,6 +4285,7 @@
|
|
|
4152
4285
|
],
|
|
4153
4286
|
}) || this;
|
|
4154
4287
|
_this.filterOptionRepository = filterOptionRepository;
|
|
4288
|
+
_this.categoryFilterRepository = categoryFilterRepository;
|
|
4155
4289
|
return _this;
|
|
4156
4290
|
}
|
|
4157
4291
|
FilterHasuraGraphQLRepository.prototype.update = function (params) {
|
|
@@ -4261,23 +4395,27 @@
|
|
|
4261
4395
|
delete: { get: function () { return _super_1.prototype.delete; } }
|
|
4262
4396
|
});
|
|
4263
4397
|
return __awaiter(this, void 0, void 0, function () {
|
|
4264
|
-
var options, data;
|
|
4398
|
+
var options, data, categoryFilters;
|
|
4265
4399
|
return __generator(this, function (_a) {
|
|
4266
4400
|
switch (_a.label) {
|
|
4267
4401
|
case 0:
|
|
4268
|
-
options = params.options, data = __rest(params
|
|
4269
|
-
|
|
4270
|
-
|
|
4271
|
-
|
|
4272
|
-
|
|
4273
|
-
|
|
4274
|
-
|
|
4402
|
+
options = params.options, data = __rest(params, ["options"]);
|
|
4403
|
+
return [4 /*yield*/, this.categoryFilterRepository
|
|
4404
|
+
.find({
|
|
4405
|
+
filters: {
|
|
4406
|
+
filterId: +data.id,
|
|
4407
|
+
},
|
|
4408
|
+
})
|
|
4409
|
+
.then(function (result) { return result.data; })];
|
|
4275
4410
|
case 1:
|
|
4276
|
-
|
|
4277
|
-
|
|
4411
|
+
categoryFilters = _a.sent();
|
|
4412
|
+
if (categoryFilters.length)
|
|
4413
|
+
throw new Error('Erro: o filtro está associado a uma ou mais categoria(s)');
|
|
4414
|
+
return [4 /*yield*/, this.deleteOptions(options)];
|
|
4415
|
+
case 2:
|
|
4278
4416
|
_a.sent();
|
|
4279
4417
|
return [4 /*yield*/, _super.delete.call(this, { id: +data.id })];
|
|
4280
|
-
case
|
|
4418
|
+
case 3:
|
|
4281
4419
|
_a.sent();
|
|
4282
4420
|
return [2 /*return*/];
|
|
4283
4421
|
}
|
|
@@ -5268,6 +5406,7 @@
|
|
|
5268
5406
|
exports.Buy2WinFirestoreRepository = Buy2WinFirestoreRepository;
|
|
5269
5407
|
exports.Category = Category;
|
|
5270
5408
|
exports.CategoryFilter = CategoryFilter;
|
|
5409
|
+
exports.CategoryFilterHasuraGraphQLRepository = CategoryFilterHasuraGraphQLRepository;
|
|
5271
5410
|
exports.CategoryFirestoreRepository = CategoryFirestoreRepository;
|
|
5272
5411
|
exports.CategoryHasuraGraphQL = CategoryHasuraGraphQL;
|
|
5273
5412
|
exports.CategoryHasuraGraphQLRepository = CategoryHasuraGraphQLRepository;
|