@infrab4a/connect 3.14.4 → 3.15.0
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 +56 -25
- package/bundles/infrab4a-connect.umd.js.map +1 -1
- package/domain/catalog/repositories/product.repository.d.ts +1 -1
- package/domain/generic/repository/find.repository.d.ts +1 -0
- package/domain/generic/repository/types/repository-find-result.type.d.ts +3 -0
- package/esm2015/domain/catalog/repositories/product.repository.js +1 -1
- package/esm2015/domain/generic/repository/find.repository.js +1 -1
- package/esm2015/domain/generic/repository/types/repository-find-result.type.js +1 -1
- package/esm2015/infra/elasticsearch/indexes/products-index.js +2 -2
- package/esm2015/infra/hasura-graphql/mixins/with-find-hasura-graphql.mixin.js +44 -14
- package/esm2015/infra/hasura-graphql/repositories/catalog/product-hasura-graphql.repository.js +2 -2
- package/esm2015/infra/hasura-graphql/types/graphql.repository.type.js +1 -1
- package/fesm2015/infrab4a-connect.js +45 -15
- package/fesm2015/infrab4a-connect.js.map +1 -1
- package/infra/hasura-graphql/mixins/with-find-hasura-graphql.mixin.d.ts +3 -2
- package/infra/hasura-graphql/mixins/with-get-hasura-graphql.mixin.d.ts +2 -2
- package/infra/hasura-graphql/types/graphql.repository.type.d.ts +4 -3
- package/package.json +1 -1
|
@@ -2595,7 +2595,7 @@
|
|
|
2595
2595
|
return __generator(this, function (_a) {
|
|
2596
2596
|
switch (_a.label) {
|
|
2597
2597
|
case 0:
|
|
2598
|
-
size = total
|
|
2598
|
+
size = total || 9;
|
|
2599
2599
|
fields = [
|
|
2600
2600
|
'EAN',
|
|
2601
2601
|
'brand',
|
|
@@ -4567,9 +4567,9 @@
|
|
|
4567
4567
|
function FindHasuraGraphQLMixin() {
|
|
4568
4568
|
var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
|
|
4569
4569
|
_this.bindOrderByAttributes = function (orderBy, fields) { return Object.keys(orderBy).reduce(function (acc, current) {
|
|
4570
|
-
var
|
|
4571
|
-
return (Object.assign(Object.assign({}, acc), (
|
|
4572
|
-
.columnName] = orderBy[current],
|
|
4570
|
+
var _j;
|
|
4571
|
+
return (Object.assign(Object.assign({}, acc), (_j = {}, _j[AttributeOptionHelper.FindByAttribute(current, fields)
|
|
4572
|
+
.columnName] = orderBy[current], _j)));
|
|
4573
4573
|
}, {}); };
|
|
4574
4574
|
_this.bindAggretageAttributes = function (aggregates, fields) {
|
|
4575
4575
|
var _a, _b;
|
|
@@ -4587,6 +4587,7 @@
|
|
|
4587
4587
|
]
|
|
4588
4588
|
: [])));
|
|
4589
4589
|
};
|
|
4590
|
+
_this.bindDistinctAttributes = function (distinct, fields) { return _this.bindAttributesToColumns(distinct, fields); };
|
|
4590
4591
|
_this.bindAttributesToColumns = function (attributes, fields) { return attributes.map(function (attr) {
|
|
4591
4592
|
var _a;
|
|
4592
4593
|
return ((_a = AttributeOptionHelper.FindByAttribute(attr.toString().split('.').pop(), fields)) === null || _a === void 0 ? void 0 : _a.columnName) || attr;
|
|
@@ -4594,16 +4595,25 @@
|
|
|
4594
4595
|
return _this;
|
|
4595
4596
|
}
|
|
4596
4597
|
FindHasuraGraphQLMixin.prototype.find = function (params) {
|
|
4597
|
-
var _a, _b, _c;
|
|
4598
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
4598
4599
|
return __awaiter(this, void 0, void 0, function () {
|
|
4599
|
-
var
|
|
4600
|
+
var _j, filters, limits, orderBy, options, enableCount, variablesFilters, variablesCount, variables, aggregateFields, result, data;
|
|
4600
4601
|
var _this = this;
|
|
4601
|
-
return __generator(this, function (
|
|
4602
|
-
switch (
|
|
4602
|
+
return __generator(this, function (_k) {
|
|
4603
|
+
switch (_k.label) {
|
|
4603
4604
|
case 0:
|
|
4604
4605
|
this.logger = DebugHelper.from(this, 'find');
|
|
4605
|
-
|
|
4606
|
+
_j = params || {}, filters = _j.filters, limits = _j.limits, orderBy = _j.orderBy, options = _j.options;
|
|
4606
4607
|
enableCount = (_a = options === null || options === void 0 ? void 0 : options.enableCount) !== null && _a !== void 0 ? _a : true;
|
|
4608
|
+
variablesFilters = lodash.isNil(filters)
|
|
4609
|
+
? {}
|
|
4610
|
+
: {
|
|
4611
|
+
where: {
|
|
4612
|
+
value: BindFilterQueryHelper.MakeGraphQLWhere(filters, this.fields),
|
|
4613
|
+
type: this.tableName + "_bool_exp",
|
|
4614
|
+
required: true,
|
|
4615
|
+
},
|
|
4616
|
+
};
|
|
4607
4617
|
variablesCount = Object.assign(Object.assign({}, (lodash.isNil(orderBy)
|
|
4608
4618
|
? {}
|
|
4609
4619
|
: {
|
|
@@ -4612,18 +4622,10 @@
|
|
|
4612
4622
|
list: true,
|
|
4613
4623
|
value: this.bindOrderByAttributes(orderBy, this.fields),
|
|
4614
4624
|
},
|
|
4615
|
-
})),
|
|
4616
|
-
? {}
|
|
4617
|
-
: {
|
|
4618
|
-
where: {
|
|
4619
|
-
value: BindFilterQueryHelper.MakeGraphQLWhere(filters, this.fields),
|
|
4620
|
-
type: this.tableName + "_bool_exp",
|
|
4621
|
-
required: true,
|
|
4622
|
-
},
|
|
4623
|
-
}));
|
|
4625
|
+
})), variablesFilters);
|
|
4624
4626
|
variables = Object.assign(Object.assign({}, (lodash.isNil(limits) ? {} : limits)), variablesCount);
|
|
4625
4627
|
aggregateFields = __spreadArray(__spreadArray([], __read((enableCount ? ['count'] : []))), __read(this.bindAggretageAttributes(params.options, this.fields)));
|
|
4626
|
-
return [4 /*yield*/, this.query(__spreadArray([
|
|
4628
|
+
return [4 /*yield*/, this.query(__spreadArray(__spreadArray([
|
|
4627
4629
|
{
|
|
4628
4630
|
operation: this.tableName,
|
|
4629
4631
|
fields: params.fields
|
|
@@ -4648,25 +4650,54 @@
|
|
|
4648
4650
|
variables: variablesCount,
|
|
4649
4651
|
},
|
|
4650
4652
|
]
|
|
4651
|
-
: []))))
|
|
4653
|
+
: []))), __read(((!((_b = params.limits) === null || _b === void 0 ? void 0 : _b.offset) &&
|
|
4654
|
+
((_d = (_c = params.options) === null || _c === void 0 ? void 0 : _c.distinct) === null || _d === void 0 ? void 0 : _d.map(function (distinct) {
|
|
4655
|
+
var _j;
|
|
4656
|
+
var _a, _b;
|
|
4657
|
+
var distinctOption = (_a = _this.fields.find(function (fieldOption) { return fieldOption === distinct; })) !== null && _a !== void 0 ? _a : _this.fields.find(function (fieldOption) { return Object.keys(fieldOption).shift() === distinct; });
|
|
4658
|
+
var fieldName = ((_b = Object.values(distinctOption).shift()) === null || _b === void 0 ? void 0 : _b.columnName) || distinct;
|
|
4659
|
+
return {
|
|
4660
|
+
operation: {
|
|
4661
|
+
name: "" + _this.tableName,
|
|
4662
|
+
alias: _this.tableName + "_" + distinct + "_distinct",
|
|
4663
|
+
},
|
|
4664
|
+
fields: [distinctOption],
|
|
4665
|
+
variables: Object.assign(Object.assign({}, variablesFilters), (_j = {}, _j[_this.tableName + "_" + fieldName + "_distinct"] = {
|
|
4666
|
+
type: _this.tableName + "_select_column!",
|
|
4667
|
+
list: true,
|
|
4668
|
+
value: fieldName,
|
|
4669
|
+
name: 'distinct_on',
|
|
4670
|
+
}, _j)),
|
|
4671
|
+
};
|
|
4672
|
+
}))) ||
|
|
4673
|
+
[]))))];
|
|
4652
4674
|
case 1:
|
|
4653
|
-
result =
|
|
4675
|
+
result = _k.sent();
|
|
4654
4676
|
data = result[this.tableName].map(function (row) { return _this.convertDataFromHasura(row); });
|
|
4655
|
-
return [2 /*return*/, Object.assign(Object.assign({ data: data, count: enableCount ? result[this.tableName + "_aggregate"].aggregate.count : Infinity }, (((
|
|
4677
|
+
return [2 /*return*/, Object.assign(Object.assign(Object.assign({ data: data, count: enableCount ? result[this.tableName + "_aggregate"].aggregate.count : Infinity }, (((_e = options === null || options === void 0 ? void 0 : options.minimal) === null || _e === void 0 ? void 0 : _e.length)
|
|
4656
4678
|
? {
|
|
4657
4679
|
minimal: options.minimal.reduce(function (minimals, current) {
|
|
4658
4680
|
var _a;
|
|
4659
4681
|
return (Object.assign(Object.assign({}, minimals), lodash.set(minimals, current, result[_this.tableName + "_aggregate"].aggregate.min[((_a = AttributeOptionHelper.FindByAttribute(current.toString().split('.').pop(), _this.fields)) === null || _a === void 0 ? void 0 : _a.columnName) || current])));
|
|
4660
4682
|
}, {}),
|
|
4661
4683
|
}
|
|
4662
|
-
: {})), (((
|
|
4684
|
+
: {})), (((_f = options === null || options === void 0 ? void 0 : options.maximum) === null || _f === void 0 ? void 0 : _f.length)
|
|
4663
4685
|
? {
|
|
4664
4686
|
maximum: options.maximum.reduce(function (maximums, current) {
|
|
4665
4687
|
var _a;
|
|
4666
4688
|
return (Object.assign(Object.assign({}, maximums), lodash.set(maximums, current, result[_this.tableName + "_aggregate"].aggregate.max[((_a = AttributeOptionHelper.FindByAttribute(current.toString().split('.').pop(), _this.fields)) === null || _a === void 0 ? void 0 : _a.columnName) || current])));
|
|
4667
4689
|
}, {}),
|
|
4668
4690
|
}
|
|
4669
|
-
: {}))
|
|
4691
|
+
: {})), (!((_g = params.limits) === null || _g === void 0 ? void 0 : _g.offset) &&
|
|
4692
|
+
((_h = options === null || options === void 0 ? void 0 : options.distinct) === null || _h === void 0 ? void 0 : _h.length) && {
|
|
4693
|
+
distinct: options === null || options === void 0 ? void 0 : options.distinct.reduce(function (distinct, current) {
|
|
4694
|
+
var _j;
|
|
4695
|
+
var _a, _b;
|
|
4696
|
+
var distinctOption = (_a = _this.fields.find(function (fieldOption) { return fieldOption === current; })) !== null && _a !== void 0 ? _a : _this.fields.find(function (fieldOption) { return Object.keys(fieldOption).shift() === current; });
|
|
4697
|
+
var fieldName = ((_b = Object.values(distinctOption).shift()) === null || _b === void 0 ? void 0 : _b.columnName) || current;
|
|
4698
|
+
return Object.assign(Object.assign({}, distinct), (_j = {}, _j[current.toString()] = result[_this.tableName + "_" + current.toString() + "_distinct"].map(function (obj) { return obj[fieldName]; }), _j));
|
|
4699
|
+
}, {}),
|
|
4700
|
+
}))];
|
|
4670
4701
|
}
|
|
4671
4702
|
});
|
|
4672
4703
|
});
|
|
@@ -6098,7 +6129,7 @@
|
|
|
6098
6129
|
ProductHasuraGraphQLRepository.prototype.findCatalog = function (params, mainGender) {
|
|
6099
6130
|
return __awaiter(this, void 0, void 0, function () {
|
|
6100
6131
|
return __generator(this, function (_p) {
|
|
6101
|
-
return [2 /*return*/, this.find(Object.assign(Object.assign({}, params), { filters: Object.assign(Object.assign({}, params.filters), { published: true }), orderBy: Object.assign({ hasStock: 'desc', intGender: mainGender === 'female' ? 'desc' : 'asc' }, lodash.omit(params.orderBy, ['hasStock', 'intGender'])) }))];
|
|
6132
|
+
return [2 /*return*/, this.find(Object.assign(Object.assign({}, params), { filters: Object.assign(Object.assign({}, params.filters), { published: true }), orderBy: Object.assign(Object.assign({ hasStock: 'desc' }, (!mainGender ? {} : { intGender: mainGender === 'female' ? 'desc' : 'asc' })), lodash.omit(params.orderBy, ['hasStock', 'intGender'])) }))];
|
|
6102
6133
|
});
|
|
6103
6134
|
});
|
|
6104
6135
|
};
|