@infrab4a/connect 3.0.0-beta.2 → 3.0.0-beta.4
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 +82 -18
- package/bundles/infrab4a-connect.umd.js.map +1 -1
- package/esm2015/infra/hasura-graphql/models/product-hasura-graphql.js +1 -1
- package/esm2015/infra/hasura-graphql/repositories/catalog/product-hasura-graphql.repository.js +53 -7
- package/fesm2015/infrab4a-connect.js +52 -6
- package/fesm2015/infrab4a-connect.js.map +1 -1
- package/infra/hasura-graphql/models/product-hasura-graphql.d.ts +4 -0
- package/infra/hasura-graphql/repositories/catalog/product-hasura-graphql.repository.d.ts +2 -1
- package/package.json +1 -1
|
@@ -3905,10 +3905,32 @@
|
|
|
3905
3905
|
{
|
|
3906
3906
|
description: {
|
|
3907
3907
|
columnName: 'description',
|
|
3908
|
-
from: function (description) { return ({
|
|
3909
|
-
|
|
3908
|
+
from: function (description, data) { return ({
|
|
3909
|
+
description: description,
|
|
3910
|
+
differentials: data.differentials,
|
|
3911
|
+
whoMustUse: data.who_must_use,
|
|
3912
|
+
howToUse: data.how_to_use,
|
|
3913
|
+
brand: data.brand_description,
|
|
3914
|
+
}); },
|
|
3915
|
+
bindFindFilter: function (sentence) {
|
|
3916
|
+
var filters = Object.values(sentence).shift();
|
|
3917
|
+
return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, ((filters === null || filters === void 0 ? void 0 : filters.description) && { description: filters.description })), (filters.differentials && { differentials: filters.differentials })), (filters.whoMustUse && {
|
|
3918
|
+
who_must_use: filters.whoMustUse,
|
|
3919
|
+
})), (filters.howToUse && {
|
|
3920
|
+
how_to_use: filters.howToUse,
|
|
3921
|
+
})), (filters.brand && {
|
|
3922
|
+
brand_description: filters.brand,
|
|
3923
|
+
}));
|
|
3924
|
+
},
|
|
3925
|
+
bindPersistData: function (descriptionData) { return (Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, ((descriptionData === null || descriptionData === void 0 ? void 0 : descriptionData.description) && { description: descriptionData.description })), (descriptionData.differentials && { differentials: descriptionData.differentials })), (descriptionData.whoMustUse && {
|
|
3926
|
+
who_must_use: descriptionData.whoMustUse,
|
|
3927
|
+
})), (descriptionData.howToUse && { how_to_use: descriptionData.howToUse })), (descriptionData.brand && { brand_description: descriptionData.brand }))); },
|
|
3910
3928
|
},
|
|
3911
3929
|
},
|
|
3930
|
+
{ differentials: { columnName: 'differentials' } },
|
|
3931
|
+
{ whoMustUse: { columnName: 'who_must_use' } },
|
|
3932
|
+
{ howToUse: { columnName: 'how_to_use' } },
|
|
3933
|
+
{ brandDescription: { columnName: 'brand_description' } },
|
|
3912
3934
|
{ hasVariants: { columnName: 'has_variants' } },
|
|
3913
3935
|
{ images: { columnName: 'images', to: function (value) { var _a; return "{\"" + (((_a = value === null || value === void 0 ? void 0 : value.join) === null || _a === void 0 ? void 0 : _a.call(value, "\",\"")) || '') + "\"}"; } } },
|
|
3914
3936
|
{ miniatures: { columnName: 'miniatures', to: function (value) { var _a; return "{\"" + (((_a = value === null || value === void 0 ? void 0 : value.join) === null || _a === void 0 ? void 0 : _a.call(value, "\",\"")) || '') + "\"}"; } } },
|
|
@@ -3991,7 +4013,7 @@
|
|
|
3991
4013
|
{
|
|
3992
4014
|
reviews: {
|
|
3993
4015
|
columnName: 'reviews',
|
|
3994
|
-
foreignKeyColumn: {
|
|
4016
|
+
foreignKeyColumn: { product_id: 'id' },
|
|
3995
4017
|
fields: _this.reviewsFields,
|
|
3996
4018
|
},
|
|
3997
4019
|
},
|
|
@@ -4029,15 +4051,17 @@
|
|
|
4029
4051
|
enumerable: false,
|
|
4030
4052
|
configurable: true
|
|
4031
4053
|
});
|
|
4032
|
-
ProductHasuraGraphQLRepository.prototype.create = function (
|
|
4054
|
+
ProductHasuraGraphQLRepository.prototype.create = function (params) {
|
|
4033
4055
|
var _super = Object.create(null, {
|
|
4034
4056
|
create: { get: function () { return _super_1.prototype.create; } }
|
|
4035
4057
|
});
|
|
4036
4058
|
return __awaiter(this, void 0, void 0, function () {
|
|
4037
|
-
var product, _c, error_1;
|
|
4059
|
+
var metadata, data, product, _c, error_1;
|
|
4038
4060
|
return __generator(this, function (_d) {
|
|
4039
4061
|
switch (_d.label) {
|
|
4040
|
-
case 0:
|
|
4062
|
+
case 0:
|
|
4063
|
+
metadata = params.metadata, data = __rest(params, ["metadata"]);
|
|
4064
|
+
return [4 /*yield*/, _super.create.call(this, lodash.omit(Object.assign(Object.assign({}, data), { metadata: metadata || { description: null, title: null } }), ['reviews']))];
|
|
4041
4065
|
case 1:
|
|
4042
4066
|
product = _d.sent();
|
|
4043
4067
|
_d.label = 2;
|
|
@@ -4140,25 +4164,25 @@
|
|
|
4140
4164
|
update: { get: function () { return _super_1.prototype.update; } }
|
|
4141
4165
|
});
|
|
4142
4166
|
return __awaiter(this, void 0, void 0, function () {
|
|
4143
|
-
var categories, kitProducts, reviews, checkId, rate, data, plainData, id, product, _c, _d, _e, _f, _g, _h;
|
|
4144
|
-
return __generator(this, function (
|
|
4145
|
-
switch (
|
|
4167
|
+
var categories, kitProducts, reviews, checkId, rate, metadata, data, plainData, id, product, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
4168
|
+
return __generator(this, function (_l) {
|
|
4169
|
+
switch (_l.label) {
|
|
4146
4170
|
case 0:
|
|
4147
|
-
categories = params.categories, kitProducts = params.kitProducts, reviews = params.reviews, checkId = params.id, rate = params.rate, data = __rest(params, ["categories", "kitProducts", "reviews", "id", "rate"]);
|
|
4171
|
+
categories = params.categories, kitProducts = params.kitProducts, reviews = params.reviews, checkId = params.id, rate = params.rate, metadata = params.metadata, data = __rest(params, ["categories", "kitProducts", "reviews", "id", "rate", "metadata"]);
|
|
4148
4172
|
plainData = this.paramsToPlain({ id: checkId });
|
|
4149
4173
|
return [4 /*yield*/, this.getId(plainData.id)];
|
|
4150
4174
|
case 1:
|
|
4151
|
-
id =
|
|
4175
|
+
id = _l.sent();
|
|
4152
4176
|
return [4 /*yield*/, _super.update.call(this, Object.assign({ id: id }, data))];
|
|
4153
4177
|
case 2:
|
|
4154
|
-
product =
|
|
4178
|
+
product = _l.sent();
|
|
4155
4179
|
_c = product;
|
|
4156
4180
|
_d = categories;
|
|
4157
4181
|
if (!_d) return [3 /*break*/, 4];
|
|
4158
4182
|
return [4 /*yield*/, this.updateCategories(+id, { categories: categories })];
|
|
4159
4183
|
case 3:
|
|
4160
|
-
_d = (
|
|
4161
|
-
|
|
4184
|
+
_d = (_l.sent());
|
|
4185
|
+
_l.label = 4;
|
|
4162
4186
|
case 4:
|
|
4163
4187
|
_c.categories = _d;
|
|
4164
4188
|
_e = product;
|
|
@@ -4166,8 +4190,8 @@
|
|
|
4166
4190
|
if (!_f) return [3 /*break*/, 6];
|
|
4167
4191
|
return [4 /*yield*/, this.updateKitProducts(+id, { kitProducts: kitProducts })];
|
|
4168
4192
|
case 5:
|
|
4169
|
-
_f = (
|
|
4170
|
-
|
|
4193
|
+
_f = (_l.sent());
|
|
4194
|
+
_l.label = 6;
|
|
4171
4195
|
case 6:
|
|
4172
4196
|
_e.kitProducts = _f;
|
|
4173
4197
|
_g = product;
|
|
@@ -4175,10 +4199,19 @@
|
|
|
4175
4199
|
if (!_h) return [3 /*break*/, 8];
|
|
4176
4200
|
return [4 /*yield*/, this.updateReviews(+id, { reviews: reviews })];
|
|
4177
4201
|
case 7:
|
|
4178
|
-
_h = (
|
|
4179
|
-
|
|
4202
|
+
_h = (_l.sent());
|
|
4203
|
+
_l.label = 8;
|
|
4180
4204
|
case 8:
|
|
4181
4205
|
_g.reviews = _h;
|
|
4206
|
+
_j = product;
|
|
4207
|
+
_k = metadata;
|
|
4208
|
+
if (!_k) return [3 /*break*/, 10];
|
|
4209
|
+
return [4 /*yield*/, this.updateMetadata(+id, { metadata: metadata })];
|
|
4210
|
+
case 9:
|
|
4211
|
+
_k = (_l.sent());
|
|
4212
|
+
_l.label = 10;
|
|
4213
|
+
case 10:
|
|
4214
|
+
_j.metadata = _k;
|
|
4182
4215
|
return [2 /*return*/, product];
|
|
4183
4216
|
}
|
|
4184
4217
|
});
|
|
@@ -4298,6 +4331,8 @@
|
|
|
4298
4331
|
return __generator(this, function (_c) {
|
|
4299
4332
|
switch (_c.label) {
|
|
4300
4333
|
case 0:
|
|
4334
|
+
if (!reviews)
|
|
4335
|
+
return [2 /*return*/, []];
|
|
4301
4336
|
if (!('action' in reviews && reviews.action === 'remove')) return [3 /*break*/, 3];
|
|
4302
4337
|
return [4 /*yield*/, Promise.all(reviews.value.map(function (reviewData) { return __awaiter(_this, void 0, void 0, function () {
|
|
4303
4338
|
var review;
|
|
@@ -4361,6 +4396,35 @@
|
|
|
4361
4396
|
});
|
|
4362
4397
|
});
|
|
4363
4398
|
};
|
|
4399
|
+
ProductHasuraGraphQLRepository.prototype.updateMetadata = function (productId, _c) {
|
|
4400
|
+
var metadata = _c.metadata;
|
|
4401
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
4402
|
+
var plainData;
|
|
4403
|
+
return __generator(this, function (_c) {
|
|
4404
|
+
switch (_c.label) {
|
|
4405
|
+
case 0:
|
|
4406
|
+
plainData = this.paramsToPlain({ metadata: metadata });
|
|
4407
|
+
if (!plainData.metadata)
|
|
4408
|
+
return [2 /*return*/];
|
|
4409
|
+
return [4 /*yield*/, this.mutation('update_product_metadata_by_pk', ['product_id'], {
|
|
4410
|
+
pk_columns: {
|
|
4411
|
+
value: { product_id: productId },
|
|
4412
|
+
type: 'product_metadata_pk_columns_input',
|
|
4413
|
+
required: true,
|
|
4414
|
+
},
|
|
4415
|
+
_set: {
|
|
4416
|
+
value: lodash.omit(metadata, ['product_id']),
|
|
4417
|
+
type: 'product_metadata_set_input',
|
|
4418
|
+
required: true,
|
|
4419
|
+
},
|
|
4420
|
+
})];
|
|
4421
|
+
case 1:
|
|
4422
|
+
_c.sent();
|
|
4423
|
+
return [2 /*return*/, plainData.metadata];
|
|
4424
|
+
}
|
|
4425
|
+
});
|
|
4426
|
+
});
|
|
4427
|
+
};
|
|
4364
4428
|
ProductHasuraGraphQLRepository.prototype.getId = function (id) {
|
|
4365
4429
|
var _a, _b;
|
|
4366
4430
|
return __awaiter(this, void 0, void 0, function () {
|