@infrab4a/connect 3.15.0-beta.1 → 3.16.0-beta.1

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.
Files changed (54) hide show
  1. package/bundles/infrab4a-connect.umd.js +706 -148
  2. package/bundles/infrab4a-connect.umd.js.map +1 -1
  3. package/domain/catalog/models/category-base.d.ts +30 -0
  4. package/domain/catalog/models/category-filter.d.ts +2 -0
  5. package/domain/catalog/models/category-for-product.d.ts +5 -0
  6. package/domain/catalog/models/category.d.ts +5 -27
  7. package/domain/catalog/models/index.d.ts +1 -0
  8. package/domain/catalog/models/kit-product.d.ts +3 -3
  9. package/domain/catalog/models/product-base.d.ts +40 -0
  10. package/domain/catalog/models/product-for-category.d.ts +7 -0
  11. package/domain/catalog/models/product-for-kit.d.ts +7 -0
  12. package/domain/catalog/models/product.d.ts +5 -40
  13. package/domain/catalog/models/wishlist.d.ts +6 -0
  14. package/domain/catalog/repositories/category-filter.repository.d.ts +1 -0
  15. package/domain/catalog/repositories/index.d.ts +1 -0
  16. package/domain/catalog/repositories/product.repository.d.ts +1 -1
  17. package/domain/catalog/repositories/wishlist.repository.d.ts +6 -0
  18. package/domain/generic/repository/find.repository.d.ts +1 -0
  19. package/domain/generic/repository/types/repository-find-result.type.d.ts +3 -0
  20. package/esm2015/domain/catalog/models/category-base.js +18 -0
  21. package/esm2015/domain/catalog/models/category-filter.js +6 -1
  22. package/esm2015/domain/catalog/models/category-for-product.js +7 -0
  23. package/esm2015/domain/catalog/models/category.js +6 -10
  24. package/esm2015/domain/catalog/models/index.js +2 -1
  25. package/esm2015/domain/catalog/models/kit-product.js +6 -6
  26. package/esm2015/domain/catalog/models/product-base.js +25 -0
  27. package/esm2015/domain/catalog/models/product-for-category.js +14 -0
  28. package/esm2015/domain/catalog/models/product-for-kit.js +14 -0
  29. package/esm2015/domain/catalog/models/product.js +6 -24
  30. package/esm2015/domain/catalog/models/wishlist.js +7 -0
  31. package/esm2015/domain/catalog/repositories/category-filter.repository.js +1 -1
  32. package/esm2015/domain/catalog/repositories/index.js +2 -1
  33. package/esm2015/domain/catalog/repositories/product.repository.js +1 -1
  34. package/esm2015/domain/catalog/repositories/wishlist.repository.js +2 -0
  35. package/esm2015/domain/generic/repository/find.repository.js +1 -1
  36. package/esm2015/domain/generic/repository/types/repository-find-result.type.js +1 -1
  37. package/esm2015/infra/elasticsearch/indexes/products-index.js +2 -2
  38. package/esm2015/infra/hasura-graphql/mixins/helpers/bind-filter-query.helper.js +2 -2
  39. package/esm2015/infra/hasura-graphql/mixins/with-find-hasura-graphql.mixin.js +44 -14
  40. package/esm2015/infra/hasura-graphql/repositories/catalog/category-filter-hasura-graphql.repository.js +52 -1
  41. package/esm2015/infra/hasura-graphql/repositories/catalog/category-hasura-graphql.repository.js +36 -50
  42. package/esm2015/infra/hasura-graphql/repositories/catalog/index.js +2 -1
  43. package/esm2015/infra/hasura-graphql/repositories/catalog/product-hasura-graphql.repository.js +2 -2
  44. package/esm2015/infra/hasura-graphql/repositories/catalog/wishlist-hasura-graphql.repository.js +252 -0
  45. package/esm2015/infra/hasura-graphql/types/graphql.repository.type.js +1 -1
  46. package/fesm2015/infrab4a-connect.js +469 -104
  47. package/fesm2015/infrab4a-connect.js.map +1 -1
  48. package/infra/hasura-graphql/mixins/with-find-hasura-graphql.mixin.d.ts +3 -2
  49. package/infra/hasura-graphql/mixins/with-get-hasura-graphql.mixin.d.ts +2 -2
  50. package/infra/hasura-graphql/repositories/catalog/category-filter-hasura-graphql.repository.d.ts +1 -0
  51. package/infra/hasura-graphql/repositories/catalog/index.d.ts +1 -0
  52. package/infra/hasura-graphql/repositories/catalog/wishlist-hasura-graphql.repository.d.ts +27 -0
  53. package/infra/hasura-graphql/types/graphql.repository.type.d.ts +4 -3
  54. package/package.json +1 -1
@@ -1823,6 +1823,142 @@
1823
1823
  return Filter;
1824
1824
  }(BaseModel));
1825
1825
 
1826
+ var CategoryBase = /** @class */ (function (_super) {
1827
+ __extends(CategoryBase, _super);
1828
+ function CategoryBase() {
1829
+ return _super !== null && _super.apply(this, arguments) || this;
1830
+ }
1831
+ Object.defineProperty(CategoryBase, "identifiersFields", {
1832
+ get: function () {
1833
+ return ['id'];
1834
+ },
1835
+ enumerable: false,
1836
+ configurable: true
1837
+ });
1838
+ return CategoryBase;
1839
+ }(BaseModel));
1840
+ __decorate([
1841
+ classTransformer.Type(function () { return CategoryBase; }),
1842
+ __metadata("design:type", CategoryBase)
1843
+ ], CategoryBase.prototype, "parent", void 0);
1844
+ __decorate([
1845
+ classTransformer.Type(function () { return Filter; }),
1846
+ __metadata("design:type", Array)
1847
+ ], CategoryBase.prototype, "filters", void 0);
1848
+
1849
+ var CategoryForProduct = /** @class */ (function (_super) {
1850
+ __extends(CategoryForProduct, _super);
1851
+ function CategoryForProduct() {
1852
+ return _super !== null && _super.apply(this, arguments) || this;
1853
+ }
1854
+ Object.defineProperty(CategoryForProduct, "identifiersFields", {
1855
+ get: function () {
1856
+ return ['id'];
1857
+ },
1858
+ enumerable: false,
1859
+ configurable: true
1860
+ });
1861
+ return CategoryForProduct;
1862
+ }(CategoryBase));
1863
+
1864
+ var ProductBase = /** @class */ (function (_super) {
1865
+ __extends(ProductBase, _super);
1866
+ function ProductBase() {
1867
+ return _super !== null && _super.apply(this, arguments) || this;
1868
+ }
1869
+ Object.defineProperty(ProductBase.prototype, "evaluation", {
1870
+ get: function () {
1871
+ return {
1872
+ reviews: this.reviews,
1873
+ count: this.reviewsTotal,
1874
+ rating: this.rate,
1875
+ };
1876
+ },
1877
+ set: function (evaluation) {
1878
+ if (!evaluation) {
1879
+ this.reviews = null;
1880
+ this.reviewsTotal = null;
1881
+ this.rate = null;
1882
+ return;
1883
+ }
1884
+ this.reviews = evaluation.reviews || this.reviews;
1885
+ this.reviewsTotal = evaluation.count || this.reviewsTotal;
1886
+ this.rate = evaluation.rating || this.rate;
1887
+ },
1888
+ enumerable: false,
1889
+ configurable: true
1890
+ });
1891
+ Object.defineProperty(ProductBase, "identifiersFields", {
1892
+ get: function () {
1893
+ return ['id'];
1894
+ },
1895
+ enumerable: false,
1896
+ configurable: true
1897
+ });
1898
+ return ProductBase;
1899
+ }(BaseModel));
1900
+
1901
+ var ProductForKit = /** @class */ (function (_super) {
1902
+ __extends(ProductForKit, _super);
1903
+ function ProductForKit() {
1904
+ return _super !== null && _super.apply(this, arguments) || this;
1905
+ }
1906
+ Object.defineProperty(ProductForKit, "identifiersFields", {
1907
+ get: function () {
1908
+ return ['id'];
1909
+ },
1910
+ enumerable: false,
1911
+ configurable: true
1912
+ });
1913
+ return ProductForKit;
1914
+ }(ProductBase));
1915
+ __decorate([
1916
+ classTransformer.Type(function () { return CategoryForProduct; }),
1917
+ __metadata("design:type", CategoryForProduct)
1918
+ ], ProductForKit.prototype, "category", void 0);
1919
+
1920
+ var KitProduct = /** @class */ (function (_super) {
1921
+ __extends(KitProduct, _super);
1922
+ function KitProduct() {
1923
+ return _super !== null && _super.apply(this, arguments) || this;
1924
+ }
1925
+ Object.defineProperty(KitProduct, "identifiersFields", {
1926
+ get: function () {
1927
+ return ['productId', 'kitProductId'];
1928
+ },
1929
+ enumerable: false,
1930
+ configurable: true
1931
+ });
1932
+ return KitProduct;
1933
+ }(BaseModel));
1934
+ __decorate([
1935
+ classTransformer.Type(function () { return ProductForKit; }),
1936
+ __metadata("design:type", ProductForKit)
1937
+ ], KitProduct.prototype, "kit", void 0);
1938
+ __decorate([
1939
+ classTransformer.Type(function () { return ProductForKit; }),
1940
+ __metadata("design:type", ProductForKit)
1941
+ ], KitProduct.prototype, "product", void 0);
1942
+
1943
+ var ProductForCategory = /** @class */ (function (_super) {
1944
+ __extends(ProductForCategory, _super);
1945
+ function ProductForCategory() {
1946
+ return _super !== null && _super.apply(this, arguments) || this;
1947
+ }
1948
+ Object.defineProperty(ProductForCategory, "identifiersFields", {
1949
+ get: function () {
1950
+ return ['id'];
1951
+ },
1952
+ enumerable: false,
1953
+ configurable: true
1954
+ });
1955
+ return ProductForCategory;
1956
+ }(ProductBase));
1957
+ __decorate([
1958
+ classTransformer.Type(function () { return KitProduct; }),
1959
+ __metadata("design:type", Array)
1960
+ ], ProductForCategory.prototype, "kitProducts", void 0);
1961
+
1826
1962
  var Category = /** @class */ (function (_super) {
1827
1963
  __extends(Category, _super);
1828
1964
  function Category() {
@@ -1836,15 +1972,11 @@
1836
1972
  configurable: true
1837
1973
  });
1838
1974
  return Category;
1839
- }(BaseModel));
1975
+ }(CategoryBase));
1840
1976
  __decorate([
1841
- classTransformer.Type(function () { return Category; }),
1842
- __metadata("design:type", Category)
1843
- ], Category.prototype, "parent", void 0);
1844
- __decorate([
1845
- classTransformer.Type(function () { return Filter; }),
1977
+ classTransformer.Type(function () { return ProductForCategory; }),
1846
1978
  __metadata("design:type", Array)
1847
- ], Category.prototype, "filters", void 0);
1979
+ ], Category.prototype, "childrenProducts", void 0);
1848
1980
 
1849
1981
  var CategoryCollectionChildren = /** @class */ (function (_super) {
1850
1982
  __extends(CategoryCollectionChildren, _super);
@@ -1883,6 +2015,10 @@
1883
2015
  classTransformer.Type(function () { return Filter; }),
1884
2016
  __metadata("design:type", Filter)
1885
2017
  ], CategoryFilter.prototype, "filter", void 0);
2018
+ __decorate([
2019
+ classTransformer.Type(function () { return Category; }),
2020
+ __metadata("design:type", Category)
2021
+ ], CategoryFilter.prototype, "category", void 0);
1886
2022
 
1887
2023
  exports.GenderDestination = void 0;
1888
2024
  (function (GenderDestination) {
@@ -1919,28 +2055,6 @@
1919
2055
  function Product() {
1920
2056
  return _super !== null && _super.apply(this, arguments) || this;
1921
2057
  }
1922
- Object.defineProperty(Product.prototype, "evaluation", {
1923
- get: function () {
1924
- return {
1925
- reviews: this.reviews,
1926
- count: this.reviewsTotal,
1927
- rating: this.rate,
1928
- };
1929
- },
1930
- set: function (evaluation) {
1931
- if (!evaluation) {
1932
- this.reviews = null;
1933
- this.reviewsTotal = null;
1934
- this.rate = null;
1935
- return;
1936
- }
1937
- this.reviews = evaluation.reviews || this.reviews;
1938
- this.reviewsTotal = evaluation.count || this.reviewsTotal;
1939
- this.rate = evaluation.rating || this.rate;
1940
- },
1941
- enumerable: false,
1942
- configurable: true
1943
- });
1944
2058
  Object.defineProperty(Product, "identifiersFields", {
1945
2059
  get: function () {
1946
2060
  return ['id'];
@@ -1949,53 +2063,45 @@
1949
2063
  configurable: true
1950
2064
  });
1951
2065
  return Product;
1952
- }(BaseModel));
2066
+ }(ProductBase));
1953
2067
  __decorate([
1954
- classTransformer.Type(function () { return Category; }),
1955
- __metadata("design:type", Category)
2068
+ classTransformer.Type(function () { return CategoryForProduct; }),
2069
+ __metadata("design:type", CategoryForProduct)
1956
2070
  ], Product.prototype, "category", void 0);
1957
2071
  __decorate([
1958
2072
  classTransformer.Type(function () { return KitProduct; }),
1959
2073
  __metadata("design:type", Array)
1960
2074
  ], Product.prototype, "kitProducts", void 0);
1961
2075
 
1962
- var KitProduct = /** @class */ (function (_super) {
1963
- __extends(KitProduct, _super);
1964
- function KitProduct() {
2076
+ var Variant = /** @class */ (function (_super) {
2077
+ __extends(Variant, _super);
2078
+ function Variant() {
1965
2079
  return _super !== null && _super.apply(this, arguments) || this;
1966
2080
  }
1967
- Object.defineProperty(KitProduct, "identifiersFields", {
2081
+ Object.defineProperty(Variant, "identifiersFields", {
1968
2082
  get: function () {
1969
- return ['productId', 'kitProductId'];
2083
+ return ['id', 'productId'];
1970
2084
  },
1971
2085
  enumerable: false,
1972
2086
  configurable: true
1973
2087
  });
1974
- return KitProduct;
2088
+ return Variant;
1975
2089
  }(BaseModel));
1976
- __decorate([
1977
- classTransformer.Type(function () { return Product; }),
1978
- __metadata("design:type", Product)
1979
- ], KitProduct.prototype, "kit", void 0);
1980
- __decorate([
1981
- classTransformer.Type(function () { return Product; }),
1982
- __metadata("design:type", Product)
1983
- ], KitProduct.prototype, "product", void 0);
1984
2090
 
1985
- var Variant = /** @class */ (function (_super) {
1986
- __extends(Variant, _super);
1987
- function Variant() {
2091
+ var Wishlist = /** @class */ (function (_super) {
2092
+ __extends(Wishlist, _super);
2093
+ function Wishlist() {
1988
2094
  return _super !== null && _super.apply(this, arguments) || this;
1989
2095
  }
1990
- Object.defineProperty(Variant, "identifiersFields", {
2096
+ Object.defineProperty(Wishlist, "identifiersFields", {
1991
2097
  get: function () {
1992
- return ['id', 'productId'];
2098
+ return ['id'];
1993
2099
  },
1994
2100
  enumerable: false,
1995
2101
  configurable: true
1996
2102
  });
1997
- return Variant;
1998
- }(BaseModel));
2103
+ return Wishlist;
2104
+ }(Category));
1999
2105
 
2000
2106
  var Buy2Win = /** @class */ (function (_super) {
2001
2107
  __extends(Buy2Win, _super);
@@ -2540,7 +2646,7 @@
2540
2646
  return __generator(this, function (_a) {
2541
2647
  switch (_a.label) {
2542
2648
  case 0:
2543
- size = total >= 10 ? 500 : 9;
2649
+ size = total || 9;
2544
2650
  fields = [
2545
2651
  'EAN',
2546
2652
  'brand',
@@ -4013,7 +4119,7 @@
4013
4119
  var fieldOptions = AttributeOptionHelper.FindByAttribute(key, (fieldSentenceOptions === null || fieldSentenceOptions === void 0 ? void 0 : fieldSentenceOptions.fields) || fields);
4014
4120
  var columnName = fieldOptions.columnName;
4015
4121
  var columnFields = fieldOptions.fields;
4016
- return Object.assign(Object.assign({}, variables), (_a = {}, _a[columnName] = BindFilterQueryHelper.BuildWhereSentence(key, options[key], columnFields || []), _a));
4122
+ return Object.assign(Object.assign({}, variables), (_a = {}, _a[columnName] = BindFilterQueryHelper.BuildWhereSentence(key, options[key], (fieldSentenceOptions === null || fieldSentenceOptions === void 0 ? void 0 : fieldSentenceOptions.fields) || columnFields || fields), _a));
4017
4123
  }, {});
4018
4124
  if (!Array.isArray(options) && !lodash.isNil(fieldSentenceOptions.fields))
4019
4125
  return _a = {},
@@ -4536,9 +4642,9 @@
4536
4642
  function FindHasuraGraphQLMixin() {
4537
4643
  var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
4538
4644
  _this.bindOrderByAttributes = function (orderBy, fields) { return Object.keys(orderBy).reduce(function (acc, current) {
4539
- var _d;
4540
- return (Object.assign(Object.assign({}, acc), (_d = {}, _d[AttributeOptionHelper.FindByAttribute(current, fields)
4541
- .columnName] = orderBy[current], _d)));
4645
+ var _j;
4646
+ return (Object.assign(Object.assign({}, acc), (_j = {}, _j[AttributeOptionHelper.FindByAttribute(current, fields)
4647
+ .columnName] = orderBy[current], _j)));
4542
4648
  }, {}); };
4543
4649
  _this.bindAggretageAttributes = function (aggregates, fields) {
4544
4650
  var _a, _b;
@@ -4556,6 +4662,7 @@
4556
4662
  ]
4557
4663
  : [])));
4558
4664
  };
4665
+ _this.bindDistinctAttributes = function (distinct, fields) { return _this.bindAttributesToColumns(distinct, fields); };
4559
4666
  _this.bindAttributesToColumns = function (attributes, fields) { return attributes.map(function (attr) {
4560
4667
  var _a;
4561
4668
  return ((_a = AttributeOptionHelper.FindByAttribute(attr.toString().split('.').pop(), fields)) === null || _a === void 0 ? void 0 : _a.columnName) || attr;
@@ -4563,16 +4670,25 @@
4563
4670
  return _this;
4564
4671
  }
4565
4672
  FindHasuraGraphQLMixin.prototype.find = function (params) {
4566
- var _a, _b, _c;
4673
+ var _a, _b, _c, _d, _e, _f, _g, _h;
4567
4674
  return __awaiter(this, void 0, void 0, function () {
4568
- var _d, filters, limits, orderBy, options, enableCount, variablesCount, variables, aggregateFields, result, data;
4675
+ var _j, filters, limits, orderBy, options, enableCount, variablesFilters, variablesCount, variables, aggregateFields, result, data;
4569
4676
  var _this = this;
4570
- return __generator(this, function (_e) {
4571
- switch (_e.label) {
4677
+ return __generator(this, function (_k) {
4678
+ switch (_k.label) {
4572
4679
  case 0:
4573
4680
  this.logger = DebugHelper.from(this, 'find');
4574
- _d = params || {}, filters = _d.filters, limits = _d.limits, orderBy = _d.orderBy, options = _d.options;
4681
+ _j = params || {}, filters = _j.filters, limits = _j.limits, orderBy = _j.orderBy, options = _j.options;
4575
4682
  enableCount = (_a = options === null || options === void 0 ? void 0 : options.enableCount) !== null && _a !== void 0 ? _a : true;
4683
+ variablesFilters = lodash.isNil(filters)
4684
+ ? {}
4685
+ : {
4686
+ where: {
4687
+ value: BindFilterQueryHelper.MakeGraphQLWhere(filters, this.fields),
4688
+ type: this.tableName + "_bool_exp",
4689
+ required: true,
4690
+ },
4691
+ };
4576
4692
  variablesCount = Object.assign(Object.assign({}, (lodash.isNil(orderBy)
4577
4693
  ? {}
4578
4694
  : {
@@ -4581,18 +4697,10 @@
4581
4697
  list: true,
4582
4698
  value: this.bindOrderByAttributes(orderBy, this.fields),
4583
4699
  },
4584
- })), (lodash.isNil(filters)
4585
- ? {}
4586
- : {
4587
- where: {
4588
- value: BindFilterQueryHelper.MakeGraphQLWhere(filters, this.fields),
4589
- type: this.tableName + "_bool_exp",
4590
- required: true,
4591
- },
4592
- }));
4700
+ })), variablesFilters);
4593
4701
  variables = Object.assign(Object.assign({}, (lodash.isNil(limits) ? {} : limits)), variablesCount);
4594
4702
  aggregateFields = __spreadArray(__spreadArray([], __read((enableCount ? ['count'] : []))), __read(this.bindAggretageAttributes(params.options, this.fields)));
4595
- return [4 /*yield*/, this.query(__spreadArray([
4703
+ return [4 /*yield*/, this.query(__spreadArray(__spreadArray([
4596
4704
  {
4597
4705
  operation: this.tableName,
4598
4706
  fields: params.fields
@@ -4617,25 +4725,54 @@
4617
4725
  variables: variablesCount,
4618
4726
  },
4619
4727
  ]
4620
- : []))))];
4728
+ : []))), __read(((!((_b = params.limits) === null || _b === void 0 ? void 0 : _b.offset) &&
4729
+ ((_d = (_c = params.options) === null || _c === void 0 ? void 0 : _c.distinct) === null || _d === void 0 ? void 0 : _d.map(function (distinct) {
4730
+ var _j;
4731
+ var _a, _b;
4732
+ 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; });
4733
+ var fieldName = ((_b = Object.values(distinctOption).shift()) === null || _b === void 0 ? void 0 : _b.columnName) || distinct;
4734
+ return {
4735
+ operation: {
4736
+ name: "" + _this.tableName,
4737
+ alias: _this.tableName + "_" + distinct + "_distinct",
4738
+ },
4739
+ fields: [distinctOption],
4740
+ variables: Object.assign(Object.assign({}, variablesFilters), (_j = {}, _j[_this.tableName + "_" + fieldName + "_distinct"] = {
4741
+ type: _this.tableName + "_select_column!",
4742
+ list: true,
4743
+ value: fieldName,
4744
+ name: 'distinct_on',
4745
+ }, _j)),
4746
+ };
4747
+ }))) ||
4748
+ []))))];
4621
4749
  case 1:
4622
- result = _e.sent();
4750
+ result = _k.sent();
4623
4751
  data = result[this.tableName].map(function (row) { return _this.convertDataFromHasura(row); });
4624
- return [2 /*return*/, Object.assign(Object.assign({ data: data, count: enableCount ? result[this.tableName + "_aggregate"].aggregate.count : Infinity }, (((_b = options === null || options === void 0 ? void 0 : options.minimal) === null || _b === void 0 ? void 0 : _b.length)
4752
+ 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)
4625
4753
  ? {
4626
4754
  minimal: options.minimal.reduce(function (minimals, current) {
4627
4755
  var _a;
4628
4756
  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])));
4629
4757
  }, {}),
4630
4758
  }
4631
- : {})), (((_c = options === null || options === void 0 ? void 0 : options.maximum) === null || _c === void 0 ? void 0 : _c.length)
4759
+ : {})), (((_f = options === null || options === void 0 ? void 0 : options.maximum) === null || _f === void 0 ? void 0 : _f.length)
4632
4760
  ? {
4633
4761
  maximum: options.maximum.reduce(function (maximums, current) {
4634
4762
  var _a;
4635
4763
  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])));
4636
4764
  }, {}),
4637
4765
  }
4638
- : {}))];
4766
+ : {})), (!((_g = params.limits) === null || _g === void 0 ? void 0 : _g.offset) &&
4767
+ ((_h = options === null || options === void 0 ? void 0 : options.distinct) === null || _h === void 0 ? void 0 : _h.length) && {
4768
+ distinct: options === null || options === void 0 ? void 0 : options.distinct.reduce(function (distinct, current) {
4769
+ var _j;
4770
+ var _a, _b;
4771
+ 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; });
4772
+ var fieldName = ((_b = Object.values(distinctOption).shift()) === null || _b === void 0 ? void 0 : _b.columnName) || current;
4773
+ return Object.assign(Object.assign({}, distinct), (_j = {}, _j[current.toString()] = result[_this.tableName + "_" + current.toString() + "_distinct"].map(function (obj) { return obj[fieldName]; }), _j));
4774
+ }, {}),
4775
+ }))];
4639
4776
  }
4640
4777
  });
4641
4778
  });
@@ -4777,9 +4914,60 @@
4777
4914
  ],
4778
4915
  },
4779
4916
  },
4917
+ {
4918
+ category: {
4919
+ columnName: 'category',
4920
+ foreignKeyColumn: { id: 'categoryId' },
4921
+ fields: [
4922
+ 'id',
4923
+ 'description',
4924
+ {
4925
+ products: {
4926
+ columnName: 'products',
4927
+ fields: ['product_id'],
4928
+ from: function (value) { return value.map(function (product) { return product.product_id.toString(); }); },
4929
+ to: function (productIds) { return productIds.map(function (productId) { return ({
4930
+ product_id: +productId,
4931
+ }); }); },
4932
+ },
4933
+ },
4934
+ {
4935
+ childrenProducts: {
4936
+ columnName: 'children_products',
4937
+ foreignKeyColumn: { category_id: 'id' },
4938
+ fields: [
4939
+ 'id',
4940
+ 'name',
4941
+ 'slug',
4942
+ {
4943
+ categories: {
4944
+ columnName: 'categories',
4945
+ fields: ['category_id'],
4946
+ bindPersistData: function (value) { return ({
4947
+ categories: { data: value.map(function (category) { return ({ category_id: +category }); }) },
4948
+ }); },
4949
+ to: function (categories) { return categories.map(function (categoryId) { return +categoryId; }); },
4950
+ from: function (categories) { return (categories === null || categories === void 0 ? void 0 : categories.map(function (category) { var _a; return (_a = category === null || category === void 0 ? void 0 : category.category_id) === null || _a === void 0 ? void 0 : _a.toString(); })) || []; },
4951
+ },
4952
+ },
4953
+ ],
4954
+ },
4955
+ },
4956
+ ],
4957
+ },
4958
+ },
4780
4959
  ],
4781
4960
  }) || this;
4782
4961
  }
4962
+ CategoryFilterHasuraGraphQLRepository.prototype.deleteByCategory = function (categoryId) {
4963
+ return this.mutation('delete_category_filter', ['affected_rows'], {
4964
+ where: {
4965
+ type: 'category_filter_bool_exp',
4966
+ required: true,
4967
+ value: { category_id: { _eq: categoryId } },
4968
+ },
4969
+ });
4970
+ };
4783
4971
  CategoryFilterHasuraGraphQLRepository.prototype.deleteByCategoryAndFilter = function (categoryId, filterId) {
4784
4972
  return this.mutation('delete_category_filter', ['affected_rows'], {
4785
4973
  where: {
@@ -4864,6 +5052,7 @@
4864
5052
  },
4865
5053
  },
4866
5054
  { isCollection: { columnName: 'is_collection' } },
5055
+ { isWishlist: { columnName: 'is_wishlist' } },
4867
5056
  'reference',
4868
5057
  { parentId: { columnName: 'parent_id' } },
4869
5058
  {
@@ -4887,7 +5076,7 @@
4887
5076
  var metadata, data;
4888
5077
  return __generator(this, function (_c) {
4889
5078
  metadata = params.metadata, data = __rest(params, ["metadata"]);
4890
- return [2 /*return*/, _super.create.call(this, Object.assign(Object.assign({}, data), { metadata: metadata || { description: null, title: null } }))];
5079
+ return [2 /*return*/, _super.create.call(this, Object.assign(Object.assign({}, data), { isWishlist: false, metadata: metadata || { description: null, title: null } }))];
4891
5080
  });
4892
5081
  });
4893
5082
  };
@@ -4928,7 +5117,7 @@
4928
5117
  return [4 /*yield*/, this.getId(plainData.id)];
4929
5118
  case 1:
4930
5119
  id = _j.sent();
4931
- return [4 /*yield*/, _super.update.call(this, Object.assign({ id: id }, data))];
5120
+ return [4 /*yield*/, _super.update.call(this, Object.assign(Object.assign({ id: id }, data), { isWishlist: false }))];
4932
5121
  case 2:
4933
5122
  category = _j.sent();
4934
5123
  _c = category;
@@ -4976,6 +5165,7 @@
4976
5165
  slug: slug,
4977
5166
  shops: { operator: exports.Where.IN, value: [shop] },
4978
5167
  published: { operator: exports.Where.EQUALS, value: true },
5168
+ isWishlist: { operator: exports.Where.EQUALS, value: false },
4979
5169
  },
4980
5170
  options: {
4981
5171
  enableCount: false,
@@ -5004,6 +5194,7 @@
5004
5194
  filters: {
5005
5195
  shops: { operator: exports.Where.IN, value: [shop] },
5006
5196
  published: { operator: exports.Where.EQUALS, value: true },
5197
+ isWishlist: { operator: exports.Where.EQUALS, value: false },
5007
5198
  },
5008
5199
  options: {
5009
5200
  enableCount: false,
@@ -5221,104 +5412,136 @@
5221
5412
  CategoryHasuraGraphQLRepository.prototype.updateFilters = function (categoryId, _c) {
5222
5413
  var filters = _c.filters;
5223
5414
  return __awaiter(this, void 0, void 0, function () {
5224
- var i, filtersList, i, hasFilter, newCategoryFilter, error_1, filtersList, i, hasFilter, newCategoryFilter, error_2;
5225
- return __generator(this, function (_c) {
5226
- switch (_c.label) {
5415
+ var i, filtersList, currentFilters, currentFiltersId_1, filtersUpdatedId_1, filterToBeDeleted, filterToBeInserted, _loop_1, this_1, filterToBeDeleted_1, filterToBeDeleted_1_1, filter, e_1_1, filterToBeInserted_1, filterToBeInserted_1_1, filter, newCategoryFilter, e_2_1, filtersList, i, newCategoryFilter;
5416
+ var e_1, _c, e_2, _d;
5417
+ return __generator(this, function (_e) {
5418
+ switch (_e.label) {
5227
5419
  case 0:
5228
5420
  if (!('action' in filters && filters.action === 'remove' && filters.value.length)) return [3 /*break*/, 5];
5229
5421
  i = 0;
5230
- _c.label = 1;
5422
+ _e.label = 1;
5231
5423
  case 1:
5232
5424
  if (!(i < filters.value.length)) return [3 /*break*/, 4];
5233
5425
  return [4 /*yield*/, this.categoryFilterRepository.deleteByCategoryAndFilter(categoryId, filters.value[i].id)];
5234
5426
  case 2:
5235
- _c.sent();
5236
- _c.label = 3;
5427
+ _e.sent();
5428
+ _e.label = 3;
5237
5429
  case 3:
5238
5430
  i++;
5239
5431
  return [3 /*break*/, 1];
5240
5432
  case 4: return [2 /*return*/, []];
5241
5433
  case 5:
5242
- if (!('action' in filters && filters.action === 'merge' && filters.value.length)) return [3 /*break*/, 15];
5434
+ if (!('action' in filters && filters.action === 'merge' && filters.value.length)) return [3 /*break*/, 22];
5243
5435
  filtersList = [];
5244
- i = 0;
5245
- _c.label = 6;
5246
- case 6:
5247
- if (!(i < filters.value.length)) return [3 /*break*/, 14];
5248
- _c.label = 7;
5249
- case 7:
5250
- _c.trys.push([7, 12, , 13]);
5251
5436
  return [4 /*yield*/, this.categoryFilterRepository
5252
5437
  .find({
5253
5438
  filters: {
5254
5439
  categoryId: categoryId,
5255
- filterId: filters.value[i].id,
5256
5440
  },
5257
5441
  })
5258
- .then(function (data) { return data.data.shift(); })];
5442
+ .then(function (res) { return res.data; })];
5443
+ case 6:
5444
+ currentFilters = _e.sent();
5445
+ currentFiltersId_1 = currentFilters.map(function (f) { return f.id; });
5446
+ filtersUpdatedId_1 = filters.value.map(function (f) { return f.id; });
5447
+ filterToBeDeleted = currentFiltersId_1.filter(function (c) { return !filtersUpdatedId_1.includes(c); });
5448
+ filterToBeInserted = filtersUpdatedId_1.filter(function (c) { return !currentFiltersId_1.includes(c); });
5449
+ _loop_1 = function (filter) {
5450
+ var index;
5451
+ return __generator(this, function (_f) {
5452
+ switch (_f.label) {
5453
+ case 0:
5454
+ index = currentFilters.findIndex(function (f) { return f.id == filter; });
5455
+ if (index != -1) {
5456
+ currentFilters.splice(index, 1);
5457
+ }
5458
+ return [4 /*yield*/, this_1.categoryFilterRepository.deleteByCategoryAndFilter(categoryId, filter)];
5459
+ case 1:
5460
+ _f.sent();
5461
+ return [2 /*return*/];
5462
+ }
5463
+ });
5464
+ };
5465
+ this_1 = this;
5466
+ _e.label = 7;
5467
+ case 7:
5468
+ _e.trys.push([7, 12, 13, 14]);
5469
+ filterToBeDeleted_1 = __values(filterToBeDeleted), filterToBeDeleted_1_1 = filterToBeDeleted_1.next();
5470
+ _e.label = 8;
5259
5471
  case 8:
5260
- hasFilter = _c.sent();
5261
- if (!hasFilter) return [3 /*break*/, 9];
5262
- filtersList.push(hasFilter);
5263
- return [3 /*break*/, 11];
5264
- case 9: return [4 /*yield*/, this.categoryFilterRepository.create({
5265
- filterId: filters.value[i].id,
5266
- categoryId: categoryId,
5267
- })];
5472
+ if (!!filterToBeDeleted_1_1.done) return [3 /*break*/, 11];
5473
+ filter = filterToBeDeleted_1_1.value;
5474
+ return [5 /*yield**/, _loop_1(filter)];
5475
+ case 9:
5476
+ _e.sent();
5477
+ _e.label = 10;
5268
5478
  case 10:
5269
- newCategoryFilter = _c.sent();
5270
- filtersList.push(newCategoryFilter);
5271
- _c.label = 11;
5272
- case 11: return [3 /*break*/, 13];
5479
+ filterToBeDeleted_1_1 = filterToBeDeleted_1.next();
5480
+ return [3 /*break*/, 8];
5481
+ case 11: return [3 /*break*/, 14];
5273
5482
  case 12:
5274
- error_1 = _c.sent();
5275
- console.log('catch error: ', error_1);
5276
- return [3 /*break*/, 13];
5483
+ e_1_1 = _e.sent();
5484
+ e_1 = { error: e_1_1 };
5485
+ return [3 /*break*/, 14];
5277
5486
  case 13:
5278
- i++;
5279
- return [3 /*break*/, 6];
5280
- case 14: return [2 /*return*/, filtersList];
5487
+ try {
5488
+ if (filterToBeDeleted_1_1 && !filterToBeDeleted_1_1.done && (_c = filterToBeDeleted_1.return)) _c.call(filterToBeDeleted_1);
5489
+ }
5490
+ finally { if (e_1) throw e_1.error; }
5491
+ return [7 /*endfinally*/];
5492
+ case 14:
5493
+ _e.trys.push([14, 19, 20, 21]);
5494
+ filterToBeInserted_1 = __values(filterToBeInserted), filterToBeInserted_1_1 = filterToBeInserted_1.next();
5495
+ _e.label = 15;
5281
5496
  case 15:
5282
- if (!(Array.isArray(filters) && filters.length)) return [3 /*break*/, 25];
5283
- filtersList = [];
5284
- i = 0;
5285
- _c.label = 16;
5497
+ if (!!filterToBeInserted_1_1.done) return [3 /*break*/, 18];
5498
+ filter = filterToBeInserted_1_1.value;
5499
+ return [4 /*yield*/, this.categoryFilterRepository.create({
5500
+ filterId: filter,
5501
+ categoryId: categoryId,
5502
+ })];
5286
5503
  case 16:
5287
- if (!(i < filters.length)) return [3 /*break*/, 24];
5288
- _c.label = 17;
5504
+ newCategoryFilter = _e.sent();
5505
+ filtersList.push(newCategoryFilter);
5506
+ _e.label = 17;
5289
5507
  case 17:
5290
- _c.trys.push([17, 22, , 23]);
5291
- return [4 /*yield*/, this.categoryFilterRepository
5292
- .find({
5293
- filters: {
5294
- categoryId: categoryId,
5295
- filterId: filters[i].id,
5296
- },
5297
- })
5298
- .then(function (data) { return data.data.shift(); })];
5299
- case 18:
5300
- hasFilter = _c.sent();
5301
- if (!hasFilter) return [3 /*break*/, 19];
5302
- filtersList.push(hasFilter);
5508
+ filterToBeInserted_1_1 = filterToBeInserted_1.next();
5509
+ return [3 /*break*/, 15];
5510
+ case 18: return [3 /*break*/, 21];
5511
+ case 19:
5512
+ e_2_1 = _e.sent();
5513
+ e_2 = { error: e_2_1 };
5303
5514
  return [3 /*break*/, 21];
5304
- case 19: return [4 /*yield*/, this.categoryFilterRepository.create({
5305
- filterId: filters[i].id,
5306
- categoryId: categoryId,
5307
- })];
5308
5515
  case 20:
5309
- newCategoryFilter = _c.sent();
5310
- filtersList.push(newCategoryFilter);
5311
- _c.label = 21;
5312
- case 21: return [3 /*break*/, 23];
5516
+ try {
5517
+ if (filterToBeInserted_1_1 && !filterToBeInserted_1_1.done && (_d = filterToBeInserted_1.return)) _d.call(filterToBeInserted_1);
5518
+ }
5519
+ finally { if (e_2) throw e_2.error; }
5520
+ return [7 /*endfinally*/];
5521
+ case 21: return [2 /*return*/, __spreadArray(__spreadArray([], __read(currentFilters)), __read(filtersList))];
5313
5522
  case 22:
5314
- error_2 = _c.sent();
5315
- console.log('catch error: ', error_2);
5316
- return [3 /*break*/, 23];
5523
+ if (!(Array.isArray(filters) && filters.length)) return [3 /*break*/, 28];
5524
+ return [4 /*yield*/, this.categoryFilterRepository.deleteByCategory(categoryId)];
5317
5525
  case 23:
5526
+ _e.sent();
5527
+ filtersList = [];
5528
+ i = 0;
5529
+ _e.label = 24;
5530
+ case 24:
5531
+ if (!(i < filters.length)) return [3 /*break*/, 27];
5532
+ return [4 /*yield*/, this.categoryFilterRepository.create({
5533
+ filterId: filters[i].id,
5534
+ categoryId: categoryId,
5535
+ })];
5536
+ case 25:
5537
+ newCategoryFilter = _e.sent();
5538
+ filtersList.push(newCategoryFilter);
5539
+ _e.label = 26;
5540
+ case 26:
5318
5541
  i++;
5319
- return [3 /*break*/, 16];
5320
- case 24: return [2 /*return*/, filtersList];
5321
- case 25: return [2 /*return*/];
5542
+ return [3 /*break*/, 24];
5543
+ case 27: return [2 /*return*/, filtersList];
5544
+ case 28: return [2 /*return*/];
5322
5545
  }
5323
5546
  });
5324
5547
  });
@@ -5981,7 +6204,7 @@
5981
6204
  ProductHasuraGraphQLRepository.prototype.findCatalog = function (params, mainGender) {
5982
6205
  return __awaiter(this, void 0, void 0, function () {
5983
6206
  return __generator(this, function (_p) {
5984
- 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'])) }))];
6207
+ 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'])) }))];
5985
6208
  });
5986
6209
  });
5987
6210
  };
@@ -6440,6 +6663,339 @@
6440
6663
  return VariantHasuraGraphQLRepository;
6441
6664
  }(withCrudHasuraGraphQL(withHasuraGraphQL(Base))));
6442
6665
 
6666
+ var WishlistHasuraGraphQLRepository = /** @class */ (function (_super_1) {
6667
+ __extends(WishlistHasuraGraphQLRepository, _super_1);
6668
+ function WishlistHasuraGraphQLRepository(endpoint, authOptions, categoryFilterRepository) {
6669
+ var _this = _super_1.call(this, {
6670
+ tableName: 'category',
6671
+ model: Wishlist,
6672
+ endpoint: endpoint,
6673
+ authOptions: authOptions,
6674
+ fields: [
6675
+ { id: { columnName: 'id', to: function (value) { return +value; }, from: function (value) { return value.toString(); } } },
6676
+ { firestoreId: { columnName: 'firestore_id' } },
6677
+ 'name',
6678
+ 'description',
6679
+ 'image',
6680
+ 'published',
6681
+ 'shop',
6682
+ { shops: { columnName: 'shops', type: HasuraGraphQLColumnType.Jsonb } },
6683
+ 'slug',
6684
+ { brandCategory: { columnName: 'brand_category' } },
6685
+ { brandCategoryBanner: { columnName: 'brand_banner' } },
6686
+ { brandCategoryBannerMobile: { columnName: 'brand_banner_mobile' } },
6687
+ { brandLogo: { columnName: 'brand_logo' } },
6688
+ { brandCondition: { columnName: 'brand_condition' } },
6689
+ {
6690
+ conditions: {
6691
+ columnName: 'tag_condition',
6692
+ type: HasuraGraphQLColumnType.Jsonb,
6693
+ from: function (tags, row) { return ({ brand: row.brand_condition, tags: Array.isArray(tags) ? tags : [] }); },
6694
+ bindPersistData: function (value) {
6695
+ return {
6696
+ brand_condition: value.brand,
6697
+ tag_condition: (value === null || value === void 0 ? void 0 : value.tags) || [],
6698
+ };
6699
+ },
6700
+ bindFindFilter: function (sentence) {
6701
+ return Object.assign(Object.assign({}, (sentence.brand ? { brand_condition: sentence.brand } : {})), (sentence.tags ? { tag_condition: sentence.tags } : {}));
6702
+ },
6703
+ },
6704
+ },
6705
+ {
6706
+ filters: {
6707
+ columnName: 'filters',
6708
+ foreignKeyColumn: { filter_id: 'id' },
6709
+ fields: [{ filter: ['id', 'description', 'slug', 'enabled'] }],
6710
+ bindPersistData: function (value) { return ({
6711
+ filters: { data: value.map(function (filter) { return ({ filter_id: filter.id }); }) },
6712
+ }); },
6713
+ 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; })) || []; },
6714
+ },
6715
+ },
6716
+ { createdAt: { columnName: 'created_at' } },
6717
+ { updatedAt: { columnName: 'updated_at' } },
6718
+ {
6719
+ products: {
6720
+ columnName: 'products',
6721
+ fields: ['product_id'],
6722
+ from: function (value) { return value.map(function (product) { return product.product_id.toString(); }); },
6723
+ to: function (productIds) { return productIds.map(function (productId) { return ({
6724
+ product_id: +productId,
6725
+ }); }); },
6726
+ },
6727
+ },
6728
+ {
6729
+ metadata: {
6730
+ columnName: 'metadata',
6731
+ fields: ['title', 'description'],
6732
+ bindPersistData: function (value) { return ({
6733
+ metadata: { data: value },
6734
+ }); },
6735
+ },
6736
+ },
6737
+ { isCollection: { columnName: 'is_collection' } },
6738
+ { isWishlist: { columnName: 'is_wishlist' } },
6739
+ 'reference',
6740
+ { parentId: { columnName: 'parent_id' } },
6741
+ {
6742
+ parent: {
6743
+ columnName: 'parent',
6744
+ foreignKeyColumn: { id: 'parentId' },
6745
+ fields: ['id', 'name', 'reference', 'slug'],
6746
+ },
6747
+ },
6748
+ { personId: { columnName: 'person_id' } },
6749
+ ],
6750
+ }) || this;
6751
+ _this.categoryFilterRepository = categoryFilterRepository;
6752
+ return _this;
6753
+ }
6754
+ WishlistHasuraGraphQLRepository.prototype.create = function (params) {
6755
+ var _super = Object.create(null, {
6756
+ create: { get: function () { return _super_1.prototype.create; } }
6757
+ });
6758
+ return __awaiter(this, void 0, void 0, function () {
6759
+ var metadata, data;
6760
+ return __generator(this, function (_a) {
6761
+ metadata = params.metadata, data = __rest(params, ["metadata"]);
6762
+ return [2 /*return*/, _super.create.call(this, Object.assign(Object.assign({}, data), { isWishlist: true, isCollection: true, brandCategory: false, metadata: metadata || { description: data.description, title: data.name } }))];
6763
+ });
6764
+ });
6765
+ };
6766
+ WishlistHasuraGraphQLRepository.prototype.get = function (identifiers) {
6767
+ var _super = Object.create(null, {
6768
+ get: { get: function () { return _super_1.prototype.get; } }
6769
+ });
6770
+ return __awaiter(this, void 0, void 0, function () {
6771
+ var data;
6772
+ return __generator(this, function (_a) {
6773
+ switch (_a.label) {
6774
+ case 0: return [4 /*yield*/, _super.get.call(this, identifiers)];
6775
+ case 1:
6776
+ data = _a.sent();
6777
+ if (!data.isWishlist)
6778
+ throw new NotFoundError("Category with id " + identifiers.id + " is not a wishlist");
6779
+ return [2 /*return*/, data];
6780
+ }
6781
+ });
6782
+ });
6783
+ };
6784
+ WishlistHasuraGraphQLRepository.prototype.update = function (params) {
6785
+ var _super = Object.create(null, {
6786
+ update: { get: function () { return _super_1.prototype.update; } }
6787
+ });
6788
+ return __awaiter(this, void 0, void 0, function () {
6789
+ var products, checkId, metadata, filters, data, plainData, id, category, _a, _b, _c, _d;
6790
+ return __generator(this, function (_e) {
6791
+ switch (_e.label) {
6792
+ case 0:
6793
+ products = params.products, checkId = params.id, metadata = params.metadata, filters = params.filters, data = __rest(params, ["products", "id", "metadata", "filters"]);
6794
+ plainData = this.paramsToPlain({ id: checkId });
6795
+ id = plainData.id;
6796
+ return [4 /*yield*/, _super.update.call(this, Object.assign(Object.assign({ id: id }, data), { isWishlist: true, isCollection: true, brandCategory: false }))];
6797
+ case 1:
6798
+ category = _e.sent();
6799
+ _a = category;
6800
+ _b = products;
6801
+ if (!_b) return [3 /*break*/, 3];
6802
+ return [4 /*yield*/, this.updateProducts(+id, { products: products })];
6803
+ case 2:
6804
+ _b = (_e.sent());
6805
+ _e.label = 3;
6806
+ case 3:
6807
+ _a.products = _b;
6808
+ _c = category;
6809
+ _d = metadata;
6810
+ if (!_d) return [3 /*break*/, 5];
6811
+ return [4 /*yield*/, this.updateMetadata(+id, { metadata: metadata })];
6812
+ case 4:
6813
+ _d = (_e.sent());
6814
+ _e.label = 5;
6815
+ case 5:
6816
+ _c.metadata = _d;
6817
+ return [2 /*return*/, category];
6818
+ }
6819
+ });
6820
+ });
6821
+ };
6822
+ WishlistHasuraGraphQLRepository.prototype.getWishlistBySlug = function (slug) {
6823
+ return __awaiter(this, void 0, void 0, function () {
6824
+ var data;
6825
+ return __generator(this, function (_a) {
6826
+ switch (_a.label) {
6827
+ case 0:
6828
+ if (!slug)
6829
+ return [2 /*return*/];
6830
+ return [4 /*yield*/, this.find({
6831
+ filters: {
6832
+ slug: slug,
6833
+ isWishlist: { operator: exports.Where.EQUALS, value: true },
6834
+ },
6835
+ options: {
6836
+ enableCount: false,
6837
+ },
6838
+ })];
6839
+ case 1:
6840
+ data = (_a.sent()).data;
6841
+ if (!data.length)
6842
+ throw new NotFoundError("Wishlist with slug " + slug + " not found");
6843
+ if (data.length > 1)
6844
+ throw new DuplicatedResultsError('Query returned duplicated values');
6845
+ return [2 /*return*/, data.shift()];
6846
+ }
6847
+ });
6848
+ });
6849
+ };
6850
+ WishlistHasuraGraphQLRepository.prototype.getWishlistByPerson = function (personId) {
6851
+ return __awaiter(this, void 0, void 0, function () {
6852
+ var data;
6853
+ return __generator(this, function (_a) {
6854
+ switch (_a.label) {
6855
+ case 0:
6856
+ if (!personId)
6857
+ return [2 /*return*/];
6858
+ return [4 /*yield*/, this.find({
6859
+ filters: {
6860
+ personId: { operator: exports.Where.EQUALS, value: personId },
6861
+ isWishlist: { operator: exports.Where.EQUALS, value: true },
6862
+ },
6863
+ options: {
6864
+ enableCount: false,
6865
+ },
6866
+ })];
6867
+ case 1:
6868
+ data = (_a.sent()).data;
6869
+ if (!data.length)
6870
+ throw new NotFoundError("Wishlists from person " + personId + " not found");
6871
+ return [2 /*return*/, data];
6872
+ }
6873
+ });
6874
+ });
6875
+ };
6876
+ WishlistHasuraGraphQLRepository.prototype.updateProducts = function (categoryId, _a) {
6877
+ var products = _a.products;
6878
+ return __awaiter(this, void 0, void 0, function () {
6879
+ var plainData;
6880
+ return __generator(this, function (_a) {
6881
+ switch (_a.label) {
6882
+ case 0:
6883
+ if (!('action' in products && products.action === 'remove')) return [3 /*break*/, 3];
6884
+ return [4 /*yield*/, this.mutation('delete_category_product', ['affected_rows'], {
6885
+ where: {
6886
+ type: 'category_product_bool_exp',
6887
+ required: true,
6888
+ value: { category_id: { _eq: categoryId } },
6889
+ },
6890
+ })];
6891
+ case 1:
6892
+ _a.sent();
6893
+ return [4 /*yield*/, this.categoryFilterRepository.deleteByCategory(categoryId)];
6894
+ case 2:
6895
+ _a.sent();
6896
+ return [2 /*return*/, []];
6897
+ case 3:
6898
+ plainData = this.paramsToPlain({ products: products });
6899
+ if (!plainData.products || plainData.products.length <= 0)
6900
+ return [2 /*return*/, []];
6901
+ return [4 /*yield*/, this.mutation('delete_category_product', ['affected_rows'], {
6902
+ where: {
6903
+ type: 'category_product_bool_exp',
6904
+ required: true,
6905
+ value: { category_id: { _eq: categoryId } },
6906
+ },
6907
+ })];
6908
+ case 4:
6909
+ _a.sent();
6910
+ return [4 /*yield*/, this.categoryFilterRepository.deleteByCategory(categoryId)];
6911
+ case 5:
6912
+ _a.sent();
6913
+ return [4 /*yield*/, this.mutation('insert_category_product', ['affected_rows'], {
6914
+ objects: {
6915
+ type: '[category_product_insert_input!]',
6916
+ required: true,
6917
+ value: plainData.products.map(function (productId) { return ({ category_id: categoryId, product_id: productId }); }),
6918
+ },
6919
+ })];
6920
+ case 6:
6921
+ _a.sent();
6922
+ return [2 /*return*/, plainData.products];
6923
+ }
6924
+ });
6925
+ });
6926
+ };
6927
+ WishlistHasuraGraphQLRepository.prototype.updateMetadata = function (categoryId, _a) {
6928
+ var metadata = _a.metadata;
6929
+ return __awaiter(this, void 0, void 0, function () {
6930
+ var plainData;
6931
+ return __generator(this, function (_a) {
6932
+ switch (_a.label) {
6933
+ case 0:
6934
+ plainData = this.paramsToPlain({ metadata: metadata });
6935
+ if (!plainData.metadata)
6936
+ return [2 /*return*/];
6937
+ return [4 /*yield*/, this.mutation('update_category_metadata_by_pk', ['category_id'], {
6938
+ pk_columns: {
6939
+ value: { category_id: categoryId },
6940
+ type: 'category_metadata_pk_columns_input',
6941
+ required: true,
6942
+ },
6943
+ _set: {
6944
+ value: lodash.omit(metadata, ['category_id']),
6945
+ type: 'category_metadata_set_input',
6946
+ required: true,
6947
+ },
6948
+ })];
6949
+ case 1:
6950
+ _a.sent();
6951
+ return [2 /*return*/, plainData.metadata];
6952
+ }
6953
+ });
6954
+ });
6955
+ };
6956
+ WishlistHasuraGraphQLRepository.prototype.getCategoryBySlug = function (slug, _shop) {
6957
+ return this.getWishlistBySlug(slug);
6958
+ };
6959
+ WishlistHasuraGraphQLRepository.prototype.getCategoryByShop = function (shop) {
6960
+ return __awaiter(this, void 0, void 0, function () {
6961
+ var data;
6962
+ return __generator(this, function (_a) {
6963
+ switch (_a.label) {
6964
+ case 0:
6965
+ if (!shop)
6966
+ return [2 /*return*/];
6967
+ return [4 /*yield*/, this.find({
6968
+ filters: {
6969
+ shops: { operator: exports.Where.IN, value: [shop] },
6970
+ published: { operator: exports.Where.EQUALS, value: true },
6971
+ isWishlist: { operator: exports.Where.EQUALS, value: true },
6972
+ },
6973
+ options: {
6974
+ enableCount: false,
6975
+ },
6976
+ })];
6977
+ case 1:
6978
+ data = (_a.sent()).data;
6979
+ return [2 /*return*/, data];
6980
+ }
6981
+ });
6982
+ });
6983
+ };
6984
+ WishlistHasuraGraphQLRepository.prototype.getCategoriesForHome = function (categoryIds, limit, gender) {
6985
+ return;
6986
+ };
6987
+ WishlistHasuraGraphQLRepository.prototype.mountCategory = function (category, options) {
6988
+ return;
6989
+ };
6990
+ WishlistHasuraGraphQLRepository.prototype.getChildren = function (parentId) {
6991
+ return;
6992
+ };
6993
+ WishlistHasuraGraphQLRepository.prototype.isChild = function (id, parentId) {
6994
+ return;
6995
+ };
6996
+ return WishlistHasuraGraphQLRepository;
6997
+ }(withCrudHasuraGraphQL(withHasuraGraphQL(Base))));
6998
+
6443
6999
  /**
6444
7000
  * Generated bundle index. Do not edit.
6445
7001
  */
@@ -6654,6 +7210,8 @@
6654
7210
  exports.VariantHasuraGraphQL = VariantHasuraGraphQL;
6655
7211
  exports.VariantHasuraGraphQLRepository = VariantHasuraGraphQLRepository;
6656
7212
  exports.WeakPasswordError = WeakPasswordError;
7213
+ exports.Wishlist = Wishlist;
7214
+ exports.WishlistHasuraGraphQLRepository = WishlistHasuraGraphQLRepository;
6657
7215
  exports.isDebuggable = isDebuggable;
6658
7216
  exports.isUUID = isUUID;
6659
7217
  exports.parseDateTime = parseDateTime;