@infrab4a/connect 3.14.3 → 3.14.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.
Files changed (38) hide show
  1. package/bundles/infrab4a-connect.umd.js +578 -101
  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-for-product.d.ts +5 -0
  5. package/domain/catalog/models/category.d.ts +5 -29
  6. package/domain/catalog/models/index.d.ts +1 -0
  7. package/domain/catalog/models/kit-product.d.ts +3 -3
  8. package/domain/catalog/models/product-base.d.ts +40 -0
  9. package/domain/catalog/models/product-for-category.d.ts +7 -0
  10. package/domain/catalog/models/product-for-kit.d.ts +7 -0
  11. package/domain/catalog/models/product.d.ts +5 -40
  12. package/domain/catalog/models/wishlist.d.ts +6 -0
  13. package/domain/catalog/repositories/category-filter.repository.d.ts +1 -0
  14. package/domain/catalog/repositories/index.d.ts +1 -0
  15. package/domain/catalog/repositories/wishlist.repository.d.ts +6 -0
  16. package/esm2015/domain/catalog/models/category-base.js +18 -0
  17. package/esm2015/domain/catalog/models/category-for-product.js +7 -0
  18. package/esm2015/domain/catalog/models/category.js +5 -14
  19. package/esm2015/domain/catalog/models/index.js +2 -1
  20. package/esm2015/domain/catalog/models/kit-product.js +6 -6
  21. package/esm2015/domain/catalog/models/product-base.js +25 -0
  22. package/esm2015/domain/catalog/models/product-for-category.js +14 -0
  23. package/esm2015/domain/catalog/models/product-for-kit.js +14 -0
  24. package/esm2015/domain/catalog/models/product.js +6 -24
  25. package/esm2015/domain/catalog/models/wishlist.js +7 -0
  26. package/esm2015/domain/catalog/repositories/category-filter.repository.js +1 -1
  27. package/esm2015/domain/catalog/repositories/index.js +2 -1
  28. package/esm2015/domain/catalog/repositories/wishlist.repository.js +2 -0
  29. package/esm2015/infra/hasura-graphql/repositories/catalog/category-filter-hasura-graphql.repository.js +10 -1
  30. package/esm2015/infra/hasura-graphql/repositories/catalog/category-hasura-graphql.repository.js +36 -50
  31. package/esm2015/infra/hasura-graphql/repositories/catalog/index.js +2 -1
  32. package/esm2015/infra/hasura-graphql/repositories/catalog/wishlist-hasura-graphql.repository.js +252 -0
  33. package/fesm2015/infrab4a-connect.js +358 -73
  34. package/fesm2015/infrab4a-connect.js.map +1 -1
  35. package/infra/hasura-graphql/repositories/catalog/category-filter-hasura-graphql.repository.d.ts +1 -0
  36. package/infra/hasura-graphql/repositories/catalog/index.d.ts +1 -0
  37. package/infra/hasura-graphql/repositories/catalog/wishlist-hasura-graphql.repository.d.ts +27 -0
  38. package/package.json +1 -1
@@ -1823,35 +1823,50 @@
1823
1823
  return Filter;
1824
1824
  }(BaseModel));
1825
1825
 
1826
- var KitProduct = /** @class */ (function (_super) {
1827
- __extends(KitProduct, _super);
1828
- function KitProduct() {
1826
+ var CategoryBase = /** @class */ (function (_super) {
1827
+ __extends(CategoryBase, _super);
1828
+ function CategoryBase() {
1829
1829
  return _super !== null && _super.apply(this, arguments) || this;
1830
1830
  }
1831
- Object.defineProperty(KitProduct, "identifiersFields", {
1831
+ Object.defineProperty(CategoryBase, "identifiersFields", {
1832
1832
  get: function () {
1833
- return ['productId', 'kitProductId'];
1833
+ return ['id'];
1834
1834
  },
1835
1835
  enumerable: false,
1836
1836
  configurable: true
1837
1837
  });
1838
- return KitProduct;
1838
+ return CategoryBase;
1839
1839
  }(BaseModel));
1840
1840
  __decorate([
1841
- classTransformer.Type(function () { return Product; }),
1842
- __metadata("design:type", Product)
1843
- ], KitProduct.prototype, "kit", void 0);
1841
+ classTransformer.Type(function () { return CategoryBase; }),
1842
+ __metadata("design:type", CategoryBase)
1843
+ ], CategoryBase.prototype, "parent", void 0);
1844
1844
  __decorate([
1845
- classTransformer.Type(function () { return Product; }),
1846
- __metadata("design:type", Product)
1847
- ], KitProduct.prototype, "product", void 0);
1845
+ classTransformer.Type(function () { return Filter; }),
1846
+ __metadata("design:type", Array)
1847
+ ], CategoryBase.prototype, "filters", void 0);
1848
1848
 
1849
- var Product = /** @class */ (function (_super) {
1850
- __extends(Product, _super);
1851
- function Product() {
1849
+ var CategoryForProduct = /** @class */ (function (_super) {
1850
+ __extends(CategoryForProduct, _super);
1851
+ function CategoryForProduct() {
1852
1852
  return _super !== null && _super.apply(this, arguments) || this;
1853
1853
  }
1854
- Object.defineProperty(Product.prototype, "evaluation", {
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", {
1855
1870
  get: function () {
1856
1871
  return {
1857
1872
  reviews: this.reviews,
@@ -1873,23 +1888,76 @@
1873
1888
  enumerable: false,
1874
1889
  configurable: true
1875
1890
  });
1876
- Object.defineProperty(Product, "identifiersFields", {
1891
+ Object.defineProperty(ProductBase, "identifiersFields", {
1877
1892
  get: function () {
1878
1893
  return ['id'];
1879
1894
  },
1880
1895
  enumerable: false,
1881
1896
  configurable: true
1882
1897
  });
1883
- return Product;
1898
+ return ProductBase;
1884
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));
1885
1915
  __decorate([
1886
- classTransformer.Type(function () { return Category; }),
1887
- __metadata("design:type", Category)
1888
- ], Product.prototype, "category", void 0);
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));
1889
1957
  __decorate([
1890
1958
  classTransformer.Type(function () { return KitProduct; }),
1891
1959
  __metadata("design:type", Array)
1892
- ], Product.prototype, "kitProducts", void 0);
1960
+ ], ProductForCategory.prototype, "kitProducts", void 0);
1893
1961
 
1894
1962
  var Category = /** @class */ (function (_super) {
1895
1963
  __extends(Category, _super);
@@ -1904,17 +1972,9 @@
1904
1972
  configurable: true
1905
1973
  });
1906
1974
  return Category;
1907
- }(BaseModel));
1975
+ }(CategoryBase));
1908
1976
  __decorate([
1909
- classTransformer.Type(function () { return Category; }),
1910
- __metadata("design:type", Category)
1911
- ], Category.prototype, "parent", void 0);
1912
- __decorate([
1913
- classTransformer.Type(function () { return Filter; }),
1914
- __metadata("design:type", Array)
1915
- ], Category.prototype, "filters", void 0);
1916
- __decorate([
1917
- classTransformer.Type(function () { return Product; }),
1977
+ classTransformer.Type(function () { return ProductForCategory; }),
1918
1978
  __metadata("design:type", Array)
1919
1979
  ], Category.prototype, "childrenProducts", void 0);
1920
1980
 
@@ -1990,6 +2050,29 @@
1990
2050
  return FilterOption;
1991
2051
  }(BaseModel));
1992
2052
 
2053
+ var Product = /** @class */ (function (_super) {
2054
+ __extends(Product, _super);
2055
+ function Product() {
2056
+ return _super !== null && _super.apply(this, arguments) || this;
2057
+ }
2058
+ Object.defineProperty(Product, "identifiersFields", {
2059
+ get: function () {
2060
+ return ['id'];
2061
+ },
2062
+ enumerable: false,
2063
+ configurable: true
2064
+ });
2065
+ return Product;
2066
+ }(ProductBase));
2067
+ __decorate([
2068
+ classTransformer.Type(function () { return CategoryForProduct; }),
2069
+ __metadata("design:type", CategoryForProduct)
2070
+ ], Product.prototype, "category", void 0);
2071
+ __decorate([
2072
+ classTransformer.Type(function () { return KitProduct; }),
2073
+ __metadata("design:type", Array)
2074
+ ], Product.prototype, "kitProducts", void 0);
2075
+
1993
2076
  var Variant = /** @class */ (function (_super) {
1994
2077
  __extends(Variant, _super);
1995
2078
  function Variant() {
@@ -2005,6 +2088,21 @@
2005
2088
  return Variant;
2006
2089
  }(BaseModel));
2007
2090
 
2091
+ var Wishlist = /** @class */ (function (_super) {
2092
+ __extends(Wishlist, _super);
2093
+ function Wishlist() {
2094
+ return _super !== null && _super.apply(this, arguments) || this;
2095
+ }
2096
+ Object.defineProperty(Wishlist, "identifiersFields", {
2097
+ get: function () {
2098
+ return ['id'];
2099
+ },
2100
+ enumerable: false,
2101
+ configurable: true
2102
+ });
2103
+ return Wishlist;
2104
+ }(Category));
2105
+
2008
2106
  var Buy2Win = /** @class */ (function (_super) {
2009
2107
  __extends(Buy2Win, _super);
2010
2108
  function Buy2Win() {
@@ -4755,6 +4853,15 @@
4755
4853
  ],
4756
4854
  }) || this;
4757
4855
  }
4856
+ CategoryFilterHasuraGraphQLRepository.prototype.deleteByCategory = function (categoryId) {
4857
+ return this.mutation('delete_category_filter', ['affected_rows'], {
4858
+ where: {
4859
+ type: 'category_filter_bool_exp',
4860
+ required: true,
4861
+ value: { category_id: { _eq: categoryId } },
4862
+ },
4863
+ });
4864
+ };
4758
4865
  CategoryFilterHasuraGraphQLRepository.prototype.deleteByCategoryAndFilter = function (categoryId, filterId) {
4759
4866
  return this.mutation('delete_category_filter', ['affected_rows'], {
4760
4867
  where: {
@@ -4839,6 +4946,7 @@
4839
4946
  },
4840
4947
  },
4841
4948
  { isCollection: { columnName: 'is_collection' } },
4949
+ { isWishlist: { columnName: 'is_wishlist' } },
4842
4950
  'reference',
4843
4951
  { parentId: { columnName: 'parent_id' } },
4844
4952
  {
@@ -4862,7 +4970,7 @@
4862
4970
  var metadata, data;
4863
4971
  return __generator(this, function (_c) {
4864
4972
  metadata = params.metadata, data = __rest(params, ["metadata"]);
4865
- return [2 /*return*/, _super.create.call(this, Object.assign(Object.assign({}, data), { metadata: metadata || { description: null, title: null } }))];
4973
+ return [2 /*return*/, _super.create.call(this, Object.assign(Object.assign({}, data), { isWishlist: false, metadata: metadata || { description: null, title: null } }))];
4866
4974
  });
4867
4975
  });
4868
4976
  };
@@ -4903,7 +5011,7 @@
4903
5011
  return [4 /*yield*/, this.getId(plainData.id)];
4904
5012
  case 1:
4905
5013
  id = _j.sent();
4906
- return [4 /*yield*/, _super.update.call(this, Object.assign({ id: id }, data))];
5014
+ return [4 /*yield*/, _super.update.call(this, Object.assign(Object.assign({ id: id }, data), { isWishlist: false }))];
4907
5015
  case 2:
4908
5016
  category = _j.sent();
4909
5017
  _c = category;
@@ -4951,6 +5059,7 @@
4951
5059
  slug: slug,
4952
5060
  shops: { operator: exports.Where.IN, value: [shop] },
4953
5061
  published: { operator: exports.Where.EQUALS, value: true },
5062
+ isWishlist: { operator: exports.Where.EQUALS, value: false },
4954
5063
  },
4955
5064
  options: {
4956
5065
  enableCount: false,
@@ -4979,6 +5088,7 @@
4979
5088
  filters: {
4980
5089
  shops: { operator: exports.Where.IN, value: [shop] },
4981
5090
  published: { operator: exports.Where.EQUALS, value: true },
5091
+ isWishlist: { operator: exports.Where.EQUALS, value: false },
4982
5092
  },
4983
5093
  options: {
4984
5094
  enableCount: false,
@@ -5196,104 +5306,136 @@
5196
5306
  CategoryHasuraGraphQLRepository.prototype.updateFilters = function (categoryId, _c) {
5197
5307
  var filters = _c.filters;
5198
5308
  return __awaiter(this, void 0, void 0, function () {
5199
- var i, filtersList, i, hasFilter, newCategoryFilter, error_1, filtersList, i, hasFilter, newCategoryFilter, error_2;
5200
- return __generator(this, function (_c) {
5201
- switch (_c.label) {
5309
+ 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;
5310
+ var e_1, _c, e_2, _d;
5311
+ return __generator(this, function (_e) {
5312
+ switch (_e.label) {
5202
5313
  case 0:
5203
5314
  if (!('action' in filters && filters.action === 'remove' && filters.value.length)) return [3 /*break*/, 5];
5204
5315
  i = 0;
5205
- _c.label = 1;
5316
+ _e.label = 1;
5206
5317
  case 1:
5207
5318
  if (!(i < filters.value.length)) return [3 /*break*/, 4];
5208
5319
  return [4 /*yield*/, this.categoryFilterRepository.deleteByCategoryAndFilter(categoryId, filters.value[i].id)];
5209
5320
  case 2:
5210
- _c.sent();
5211
- _c.label = 3;
5321
+ _e.sent();
5322
+ _e.label = 3;
5212
5323
  case 3:
5213
5324
  i++;
5214
5325
  return [3 /*break*/, 1];
5215
5326
  case 4: return [2 /*return*/, []];
5216
5327
  case 5:
5217
- if (!('action' in filters && filters.action === 'merge' && filters.value.length)) return [3 /*break*/, 15];
5328
+ if (!('action' in filters && filters.action === 'merge' && filters.value.length)) return [3 /*break*/, 22];
5218
5329
  filtersList = [];
5219
- i = 0;
5220
- _c.label = 6;
5221
- case 6:
5222
- if (!(i < filters.value.length)) return [3 /*break*/, 14];
5223
- _c.label = 7;
5224
- case 7:
5225
- _c.trys.push([7, 12, , 13]);
5226
5330
  return [4 /*yield*/, this.categoryFilterRepository
5227
5331
  .find({
5228
5332
  filters: {
5229
5333
  categoryId: categoryId,
5230
- filterId: filters.value[i].id,
5231
5334
  },
5232
5335
  })
5233
- .then(function (data) { return data.data.shift(); })];
5336
+ .then(function (res) { return res.data; })];
5337
+ case 6:
5338
+ currentFilters = _e.sent();
5339
+ currentFiltersId_1 = currentFilters.map(function (f) { return f.id; });
5340
+ filtersUpdatedId_1 = filters.value.map(function (f) { return f.id; });
5341
+ filterToBeDeleted = currentFiltersId_1.filter(function (c) { return !filtersUpdatedId_1.includes(c); });
5342
+ filterToBeInserted = filtersUpdatedId_1.filter(function (c) { return !currentFiltersId_1.includes(c); });
5343
+ _loop_1 = function (filter) {
5344
+ var index;
5345
+ return __generator(this, function (_f) {
5346
+ switch (_f.label) {
5347
+ case 0:
5348
+ index = currentFilters.findIndex(function (f) { return f.id == filter; });
5349
+ if (index != -1) {
5350
+ currentFilters.splice(index, 1);
5351
+ }
5352
+ return [4 /*yield*/, this_1.categoryFilterRepository.deleteByCategoryAndFilter(categoryId, filter)];
5353
+ case 1:
5354
+ _f.sent();
5355
+ return [2 /*return*/];
5356
+ }
5357
+ });
5358
+ };
5359
+ this_1 = this;
5360
+ _e.label = 7;
5361
+ case 7:
5362
+ _e.trys.push([7, 12, 13, 14]);
5363
+ filterToBeDeleted_1 = __values(filterToBeDeleted), filterToBeDeleted_1_1 = filterToBeDeleted_1.next();
5364
+ _e.label = 8;
5234
5365
  case 8:
5235
- hasFilter = _c.sent();
5236
- if (!hasFilter) return [3 /*break*/, 9];
5237
- filtersList.push(hasFilter);
5238
- return [3 /*break*/, 11];
5239
- case 9: return [4 /*yield*/, this.categoryFilterRepository.create({
5240
- filterId: filters.value[i].id,
5241
- categoryId: categoryId,
5242
- })];
5366
+ if (!!filterToBeDeleted_1_1.done) return [3 /*break*/, 11];
5367
+ filter = filterToBeDeleted_1_1.value;
5368
+ return [5 /*yield**/, _loop_1(filter)];
5369
+ case 9:
5370
+ _e.sent();
5371
+ _e.label = 10;
5243
5372
  case 10:
5244
- newCategoryFilter = _c.sent();
5245
- filtersList.push(newCategoryFilter);
5246
- _c.label = 11;
5247
- case 11: return [3 /*break*/, 13];
5373
+ filterToBeDeleted_1_1 = filterToBeDeleted_1.next();
5374
+ return [3 /*break*/, 8];
5375
+ case 11: return [3 /*break*/, 14];
5248
5376
  case 12:
5249
- error_1 = _c.sent();
5250
- console.log('catch error: ', error_1);
5251
- return [3 /*break*/, 13];
5377
+ e_1_1 = _e.sent();
5378
+ e_1 = { error: e_1_1 };
5379
+ return [3 /*break*/, 14];
5252
5380
  case 13:
5253
- i++;
5254
- return [3 /*break*/, 6];
5255
- case 14: return [2 /*return*/, filtersList];
5381
+ try {
5382
+ if (filterToBeDeleted_1_1 && !filterToBeDeleted_1_1.done && (_c = filterToBeDeleted_1.return)) _c.call(filterToBeDeleted_1);
5383
+ }
5384
+ finally { if (e_1) throw e_1.error; }
5385
+ return [7 /*endfinally*/];
5386
+ case 14:
5387
+ _e.trys.push([14, 19, 20, 21]);
5388
+ filterToBeInserted_1 = __values(filterToBeInserted), filterToBeInserted_1_1 = filterToBeInserted_1.next();
5389
+ _e.label = 15;
5256
5390
  case 15:
5257
- if (!(Array.isArray(filters) && filters.length)) return [3 /*break*/, 25];
5258
- filtersList = [];
5259
- i = 0;
5260
- _c.label = 16;
5391
+ if (!!filterToBeInserted_1_1.done) return [3 /*break*/, 18];
5392
+ filter = filterToBeInserted_1_1.value;
5393
+ return [4 /*yield*/, this.categoryFilterRepository.create({
5394
+ filterId: filter,
5395
+ categoryId: categoryId,
5396
+ })];
5261
5397
  case 16:
5262
- if (!(i < filters.length)) return [3 /*break*/, 24];
5263
- _c.label = 17;
5398
+ newCategoryFilter = _e.sent();
5399
+ filtersList.push(newCategoryFilter);
5400
+ _e.label = 17;
5264
5401
  case 17:
5265
- _c.trys.push([17, 22, , 23]);
5266
- return [4 /*yield*/, this.categoryFilterRepository
5267
- .find({
5268
- filters: {
5269
- categoryId: categoryId,
5270
- filterId: filters[i].id,
5271
- },
5272
- })
5273
- .then(function (data) { return data.data.shift(); })];
5274
- case 18:
5275
- hasFilter = _c.sent();
5276
- if (!hasFilter) return [3 /*break*/, 19];
5277
- filtersList.push(hasFilter);
5402
+ filterToBeInserted_1_1 = filterToBeInserted_1.next();
5403
+ return [3 /*break*/, 15];
5404
+ case 18: return [3 /*break*/, 21];
5405
+ case 19:
5406
+ e_2_1 = _e.sent();
5407
+ e_2 = { error: e_2_1 };
5278
5408
  return [3 /*break*/, 21];
5279
- case 19: return [4 /*yield*/, this.categoryFilterRepository.create({
5280
- filterId: filters[i].id,
5281
- categoryId: categoryId,
5282
- })];
5283
5409
  case 20:
5284
- newCategoryFilter = _c.sent();
5285
- filtersList.push(newCategoryFilter);
5286
- _c.label = 21;
5287
- case 21: return [3 /*break*/, 23];
5410
+ try {
5411
+ if (filterToBeInserted_1_1 && !filterToBeInserted_1_1.done && (_d = filterToBeInserted_1.return)) _d.call(filterToBeInserted_1);
5412
+ }
5413
+ finally { if (e_2) throw e_2.error; }
5414
+ return [7 /*endfinally*/];
5415
+ case 21: return [2 /*return*/, __spreadArray(__spreadArray([], __read(currentFilters)), __read(filtersList))];
5288
5416
  case 22:
5289
- error_2 = _c.sent();
5290
- console.log('catch error: ', error_2);
5291
- return [3 /*break*/, 23];
5417
+ if (!(Array.isArray(filters) && filters.length)) return [3 /*break*/, 28];
5418
+ return [4 /*yield*/, this.categoryFilterRepository.deleteByCategory(categoryId)];
5292
5419
  case 23:
5420
+ _e.sent();
5421
+ filtersList = [];
5422
+ i = 0;
5423
+ _e.label = 24;
5424
+ case 24:
5425
+ if (!(i < filters.length)) return [3 /*break*/, 27];
5426
+ return [4 /*yield*/, this.categoryFilterRepository.create({
5427
+ filterId: filters[i].id,
5428
+ categoryId: categoryId,
5429
+ })];
5430
+ case 25:
5431
+ newCategoryFilter = _e.sent();
5432
+ filtersList.push(newCategoryFilter);
5433
+ _e.label = 26;
5434
+ case 26:
5293
5435
  i++;
5294
- return [3 /*break*/, 16];
5295
- case 24: return [2 /*return*/, filtersList];
5296
- case 25: return [2 /*return*/];
5436
+ return [3 /*break*/, 24];
5437
+ case 27: return [2 /*return*/, filtersList];
5438
+ case 28: return [2 /*return*/];
5297
5439
  }
5298
5440
  });
5299
5441
  });
@@ -6415,6 +6557,339 @@
6415
6557
  return VariantHasuraGraphQLRepository;
6416
6558
  }(withCrudHasuraGraphQL(withHasuraGraphQL(Base))));
6417
6559
 
6560
+ var WishlistHasuraGraphQLRepository = /** @class */ (function (_super_1) {
6561
+ __extends(WishlistHasuraGraphQLRepository, _super_1);
6562
+ function WishlistHasuraGraphQLRepository(endpoint, authOptions, categoryFilterRepository) {
6563
+ var _this = _super_1.call(this, {
6564
+ tableName: 'category',
6565
+ model: Wishlist,
6566
+ endpoint: endpoint,
6567
+ authOptions: authOptions,
6568
+ fields: [
6569
+ { id: { columnName: 'id', to: function (value) { return +value; }, from: function (value) { return value.toString(); } } },
6570
+ { firestoreId: { columnName: 'firestore_id' } },
6571
+ 'name',
6572
+ 'description',
6573
+ 'image',
6574
+ 'published',
6575
+ 'shop',
6576
+ { shops: { columnName: 'shops', type: HasuraGraphQLColumnType.Jsonb } },
6577
+ 'slug',
6578
+ { brandCategory: { columnName: 'brand_category' } },
6579
+ { brandCategoryBanner: { columnName: 'brand_banner' } },
6580
+ { brandCategoryBannerMobile: { columnName: 'brand_banner_mobile' } },
6581
+ { brandLogo: { columnName: 'brand_logo' } },
6582
+ { brandCondition: { columnName: 'brand_condition' } },
6583
+ {
6584
+ conditions: {
6585
+ columnName: 'tag_condition',
6586
+ type: HasuraGraphQLColumnType.Jsonb,
6587
+ from: function (tags, row) { return ({ brand: row.brand_condition, tags: Array.isArray(tags) ? tags : [] }); },
6588
+ bindPersistData: function (value) {
6589
+ return {
6590
+ brand_condition: value.brand,
6591
+ tag_condition: (value === null || value === void 0 ? void 0 : value.tags) || [],
6592
+ };
6593
+ },
6594
+ bindFindFilter: function (sentence) {
6595
+ return Object.assign(Object.assign({}, (sentence.brand ? { brand_condition: sentence.brand } : {})), (sentence.tags ? { tag_condition: sentence.tags } : {}));
6596
+ },
6597
+ },
6598
+ },
6599
+ {
6600
+ filters: {
6601
+ columnName: 'filters',
6602
+ foreignKeyColumn: { filter_id: 'id' },
6603
+ fields: [{ filter: ['id', 'description', 'slug', 'enabled'] }],
6604
+ bindPersistData: function (value) { return ({
6605
+ filters: { data: value.map(function (filter) { return ({ filter_id: filter.id }); }) },
6606
+ }); },
6607
+ 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; })) || []; },
6608
+ },
6609
+ },
6610
+ { createdAt: { columnName: 'created_at' } },
6611
+ { updatedAt: { columnName: 'updated_at' } },
6612
+ {
6613
+ products: {
6614
+ columnName: 'products',
6615
+ fields: ['product_id'],
6616
+ from: function (value) { return value.map(function (product) { return product.product_id.toString(); }); },
6617
+ to: function (productIds) { return productIds.map(function (productId) { return ({
6618
+ product_id: +productId,
6619
+ }); }); },
6620
+ },
6621
+ },
6622
+ {
6623
+ metadata: {
6624
+ columnName: 'metadata',
6625
+ fields: ['title', 'description'],
6626
+ bindPersistData: function (value) { return ({
6627
+ metadata: { data: value },
6628
+ }); },
6629
+ },
6630
+ },
6631
+ { isCollection: { columnName: 'is_collection' } },
6632
+ { isWishlist: { columnName: 'is_wishlist' } },
6633
+ 'reference',
6634
+ { parentId: { columnName: 'parent_id' } },
6635
+ {
6636
+ parent: {
6637
+ columnName: 'parent',
6638
+ foreignKeyColumn: { id: 'parentId' },
6639
+ fields: ['id', 'name', 'reference', 'slug'],
6640
+ },
6641
+ },
6642
+ { personId: { columnName: 'person_id' } },
6643
+ ],
6644
+ }) || this;
6645
+ _this.categoryFilterRepository = categoryFilterRepository;
6646
+ return _this;
6647
+ }
6648
+ WishlistHasuraGraphQLRepository.prototype.create = function (params) {
6649
+ var _super = Object.create(null, {
6650
+ create: { get: function () { return _super_1.prototype.create; } }
6651
+ });
6652
+ return __awaiter(this, void 0, void 0, function () {
6653
+ var metadata, data;
6654
+ return __generator(this, function (_a) {
6655
+ metadata = params.metadata, data = __rest(params, ["metadata"]);
6656
+ 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 } }))];
6657
+ });
6658
+ });
6659
+ };
6660
+ WishlistHasuraGraphQLRepository.prototype.get = function (identifiers) {
6661
+ var _super = Object.create(null, {
6662
+ get: { get: function () { return _super_1.prototype.get; } }
6663
+ });
6664
+ return __awaiter(this, void 0, void 0, function () {
6665
+ var data;
6666
+ return __generator(this, function (_a) {
6667
+ switch (_a.label) {
6668
+ case 0: return [4 /*yield*/, _super.get.call(this, identifiers)];
6669
+ case 1:
6670
+ data = _a.sent();
6671
+ if (!data.isWishlist)
6672
+ throw new NotFoundError("Category with id " + identifiers.id + " is not a wishlist");
6673
+ return [2 /*return*/, data];
6674
+ }
6675
+ });
6676
+ });
6677
+ };
6678
+ WishlistHasuraGraphQLRepository.prototype.update = function (params) {
6679
+ var _super = Object.create(null, {
6680
+ update: { get: function () { return _super_1.prototype.update; } }
6681
+ });
6682
+ return __awaiter(this, void 0, void 0, function () {
6683
+ var products, checkId, metadata, filters, data, plainData, id, category, _a, _b, _c, _d;
6684
+ return __generator(this, function (_e) {
6685
+ switch (_e.label) {
6686
+ case 0:
6687
+ products = params.products, checkId = params.id, metadata = params.metadata, filters = params.filters, data = __rest(params, ["products", "id", "metadata", "filters"]);
6688
+ plainData = this.paramsToPlain({ id: checkId });
6689
+ id = plainData.id;
6690
+ return [4 /*yield*/, _super.update.call(this, Object.assign(Object.assign({ id: id }, data), { isWishlist: true, isCollection: true, brandCategory: false }))];
6691
+ case 1:
6692
+ category = _e.sent();
6693
+ _a = category;
6694
+ _b = products;
6695
+ if (!_b) return [3 /*break*/, 3];
6696
+ return [4 /*yield*/, this.updateProducts(+id, { products: products })];
6697
+ case 2:
6698
+ _b = (_e.sent());
6699
+ _e.label = 3;
6700
+ case 3:
6701
+ _a.products = _b;
6702
+ _c = category;
6703
+ _d = metadata;
6704
+ if (!_d) return [3 /*break*/, 5];
6705
+ return [4 /*yield*/, this.updateMetadata(+id, { metadata: metadata })];
6706
+ case 4:
6707
+ _d = (_e.sent());
6708
+ _e.label = 5;
6709
+ case 5:
6710
+ _c.metadata = _d;
6711
+ return [2 /*return*/, category];
6712
+ }
6713
+ });
6714
+ });
6715
+ };
6716
+ WishlistHasuraGraphQLRepository.prototype.getWishlistBySlug = function (slug) {
6717
+ return __awaiter(this, void 0, void 0, function () {
6718
+ var data;
6719
+ return __generator(this, function (_a) {
6720
+ switch (_a.label) {
6721
+ case 0:
6722
+ if (!slug)
6723
+ return [2 /*return*/];
6724
+ return [4 /*yield*/, this.find({
6725
+ filters: {
6726
+ slug: slug,
6727
+ isWishlist: { operator: exports.Where.EQUALS, value: true },
6728
+ },
6729
+ options: {
6730
+ enableCount: false,
6731
+ },
6732
+ })];
6733
+ case 1:
6734
+ data = (_a.sent()).data;
6735
+ if (!data.length)
6736
+ throw new NotFoundError("Wishlist with slug " + slug + " not found");
6737
+ if (data.length > 1)
6738
+ throw new DuplicatedResultsError('Query returned duplicated values');
6739
+ return [2 /*return*/, data.shift()];
6740
+ }
6741
+ });
6742
+ });
6743
+ };
6744
+ WishlistHasuraGraphQLRepository.prototype.getWishlistByPerson = function (personId) {
6745
+ return __awaiter(this, void 0, void 0, function () {
6746
+ var data;
6747
+ return __generator(this, function (_a) {
6748
+ switch (_a.label) {
6749
+ case 0:
6750
+ if (!personId)
6751
+ return [2 /*return*/];
6752
+ return [4 /*yield*/, this.find({
6753
+ filters: {
6754
+ personId: { operator: exports.Where.EQUALS, value: personId },
6755
+ isWishlist: { operator: exports.Where.EQUALS, value: true },
6756
+ },
6757
+ options: {
6758
+ enableCount: false,
6759
+ },
6760
+ })];
6761
+ case 1:
6762
+ data = (_a.sent()).data;
6763
+ if (!data.length)
6764
+ throw new NotFoundError("Wishlists from person " + personId + " not found");
6765
+ return [2 /*return*/, data];
6766
+ }
6767
+ });
6768
+ });
6769
+ };
6770
+ WishlistHasuraGraphQLRepository.prototype.updateProducts = function (categoryId, _a) {
6771
+ var products = _a.products;
6772
+ return __awaiter(this, void 0, void 0, function () {
6773
+ var plainData;
6774
+ return __generator(this, function (_a) {
6775
+ switch (_a.label) {
6776
+ case 0:
6777
+ if (!('action' in products && products.action === 'remove')) return [3 /*break*/, 3];
6778
+ return [4 /*yield*/, this.mutation('delete_category_product', ['affected_rows'], {
6779
+ where: {
6780
+ type: 'category_product_bool_exp',
6781
+ required: true,
6782
+ value: { category_id: { _eq: categoryId } },
6783
+ },
6784
+ })];
6785
+ case 1:
6786
+ _a.sent();
6787
+ return [4 /*yield*/, this.categoryFilterRepository.deleteByCategory(categoryId)];
6788
+ case 2:
6789
+ _a.sent();
6790
+ return [2 /*return*/, []];
6791
+ case 3:
6792
+ plainData = this.paramsToPlain({ products: products });
6793
+ if (!plainData.products || plainData.products.length <= 0)
6794
+ return [2 /*return*/, []];
6795
+ return [4 /*yield*/, this.mutation('delete_category_product', ['affected_rows'], {
6796
+ where: {
6797
+ type: 'category_product_bool_exp',
6798
+ required: true,
6799
+ value: { category_id: { _eq: categoryId } },
6800
+ },
6801
+ })];
6802
+ case 4:
6803
+ _a.sent();
6804
+ return [4 /*yield*/, this.categoryFilterRepository.deleteByCategory(categoryId)];
6805
+ case 5:
6806
+ _a.sent();
6807
+ return [4 /*yield*/, this.mutation('insert_category_product', ['affected_rows'], {
6808
+ objects: {
6809
+ type: '[category_product_insert_input!]',
6810
+ required: true,
6811
+ value: plainData.products.map(function (productId) { return ({ category_id: categoryId, product_id: productId }); }),
6812
+ },
6813
+ })];
6814
+ case 6:
6815
+ _a.sent();
6816
+ return [2 /*return*/, plainData.products];
6817
+ }
6818
+ });
6819
+ });
6820
+ };
6821
+ WishlistHasuraGraphQLRepository.prototype.updateMetadata = function (categoryId, _a) {
6822
+ var metadata = _a.metadata;
6823
+ return __awaiter(this, void 0, void 0, function () {
6824
+ var plainData;
6825
+ return __generator(this, function (_a) {
6826
+ switch (_a.label) {
6827
+ case 0:
6828
+ plainData = this.paramsToPlain({ metadata: metadata });
6829
+ if (!plainData.metadata)
6830
+ return [2 /*return*/];
6831
+ return [4 /*yield*/, this.mutation('update_category_metadata_by_pk', ['category_id'], {
6832
+ pk_columns: {
6833
+ value: { category_id: categoryId },
6834
+ type: 'category_metadata_pk_columns_input',
6835
+ required: true,
6836
+ },
6837
+ _set: {
6838
+ value: lodash.omit(metadata, ['category_id']),
6839
+ type: 'category_metadata_set_input',
6840
+ required: true,
6841
+ },
6842
+ })];
6843
+ case 1:
6844
+ _a.sent();
6845
+ return [2 /*return*/, plainData.metadata];
6846
+ }
6847
+ });
6848
+ });
6849
+ };
6850
+ WishlistHasuraGraphQLRepository.prototype.getCategoryBySlug = function (slug, _shop) {
6851
+ return this.getWishlistBySlug(slug);
6852
+ };
6853
+ WishlistHasuraGraphQLRepository.prototype.getCategoryByShop = function (shop) {
6854
+ return __awaiter(this, void 0, void 0, function () {
6855
+ var data;
6856
+ return __generator(this, function (_a) {
6857
+ switch (_a.label) {
6858
+ case 0:
6859
+ if (!shop)
6860
+ return [2 /*return*/];
6861
+ return [4 /*yield*/, this.find({
6862
+ filters: {
6863
+ shops: { operator: exports.Where.IN, value: [shop] },
6864
+ published: { operator: exports.Where.EQUALS, value: true },
6865
+ isWishlist: { operator: exports.Where.EQUALS, value: true },
6866
+ },
6867
+ options: {
6868
+ enableCount: false,
6869
+ },
6870
+ })];
6871
+ case 1:
6872
+ data = (_a.sent()).data;
6873
+ return [2 /*return*/, data];
6874
+ }
6875
+ });
6876
+ });
6877
+ };
6878
+ WishlistHasuraGraphQLRepository.prototype.getCategoriesForHome = function (categoryIds, limit, gender) {
6879
+ return;
6880
+ };
6881
+ WishlistHasuraGraphQLRepository.prototype.mountCategory = function (category, options) {
6882
+ return;
6883
+ };
6884
+ WishlistHasuraGraphQLRepository.prototype.getChildren = function (parentId) {
6885
+ return;
6886
+ };
6887
+ WishlistHasuraGraphQLRepository.prototype.isChild = function (id, parentId) {
6888
+ return;
6889
+ };
6890
+ return WishlistHasuraGraphQLRepository;
6891
+ }(withCrudHasuraGraphQL(withHasuraGraphQL(Base))));
6892
+
6418
6893
  /**
6419
6894
  * Generated bundle index. Do not edit.
6420
6895
  */
@@ -6625,6 +7100,8 @@
6625
7100
  exports.VariantHasuraGraphQL = VariantHasuraGraphQL;
6626
7101
  exports.VariantHasuraGraphQLRepository = VariantHasuraGraphQLRepository;
6627
7102
  exports.WeakPasswordError = WeakPasswordError;
7103
+ exports.Wishlist = Wishlist;
7104
+ exports.WishlistHasuraGraphQLRepository = WishlistHasuraGraphQLRepository;
6628
7105
  exports.isDebuggable = isDebuggable;
6629
7106
  exports.isUUID = isUUID;
6630
7107
  exports.parseDateTime = parseDateTime;