@infrab4a/connect 3.14.3-beta.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 +552 -105
  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 +3 -27
  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 +0 -4
  9. package/domain/catalog/models/product-for-category.d.ts +2 -0
  10. package/domain/catalog/models/product-for-kit.d.ts +7 -0
  11. package/domain/catalog/models/product.d.ts +4 -0
  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 +3 -12
  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 +1 -13
  22. package/esm2015/domain/catalog/models/product-for-category.js +8 -1
  23. package/esm2015/domain/catalog/models/product-for-kit.js +14 -0
  24. package/esm2015/domain/catalog/models/product.js +13 -1
  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 +349 -76
  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,43 +1823,43 @@
1823
1823
  return Filter;
1824
1824
  }(BaseModel));
1825
1825
 
1826
- var Product = /** @class */ (function (_super) {
1827
- __extends(Product, _super);
1828
- function Product() {
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(Product, "identifiersFields", {
1831
+ Object.defineProperty(CategoryBase, "identifiersFields", {
1832
1832
  get: function () {
1833
1833
  return ['id'];
1834
1834
  },
1835
1835
  enumerable: false,
1836
1836
  configurable: true
1837
1837
  });
1838
- return Product;
1839
- }(ProductBase));
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);
1840
1848
 
1841
- var KitProduct = /** @class */ (function (_super) {
1842
- __extends(KitProduct, _super);
1843
- function KitProduct() {
1849
+ var CategoryForProduct = /** @class */ (function (_super) {
1850
+ __extends(CategoryForProduct, _super);
1851
+ function CategoryForProduct() {
1844
1852
  return _super !== null && _super.apply(this, arguments) || this;
1845
1853
  }
1846
- Object.defineProperty(KitProduct, "identifiersFields", {
1854
+ Object.defineProperty(CategoryForProduct, "identifiersFields", {
1847
1855
  get: function () {
1848
- return ['productId', 'kitProductId'];
1856
+ return ['id'];
1849
1857
  },
1850
1858
  enumerable: false,
1851
1859
  configurable: true
1852
1860
  });
1853
- return KitProduct;
1854
- }(BaseModel));
1855
- __decorate([
1856
- classTransformer.Type(function () { return Product; }),
1857
- __metadata("design:type", Product)
1858
- ], KitProduct.prototype, "kit", void 0);
1859
- __decorate([
1860
- classTransformer.Type(function () { return Product; }),
1861
- __metadata("design:type", Product)
1862
- ], KitProduct.prototype, "product", void 0);
1861
+ return CategoryForProduct;
1862
+ }(CategoryBase));
1863
1863
 
1864
1864
  var ProductBase = /** @class */ (function (_super) {
1865
1865
  __extends(ProductBase, _super);
@@ -1897,14 +1897,48 @@
1897
1897
  });
1898
1898
  return ProductBase;
1899
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));
1900
1934
  __decorate([
1901
- classTransformer.Type(function () { return Category; }),
1902
- __metadata("design:type", Category)
1903
- ], ProductBase.prototype, "category", void 0);
1935
+ classTransformer.Type(function () { return ProductForKit; }),
1936
+ __metadata("design:type", ProductForKit)
1937
+ ], KitProduct.prototype, "kit", void 0);
1904
1938
  __decorate([
1905
- classTransformer.Type(function () { return KitProduct; }),
1906
- __metadata("design:type", Array)
1907
- ], ProductBase.prototype, "kitProducts", void 0);
1939
+ classTransformer.Type(function () { return ProductForKit; }),
1940
+ __metadata("design:type", ProductForKit)
1941
+ ], KitProduct.prototype, "product", void 0);
1908
1942
 
1909
1943
  var ProductForCategory = /** @class */ (function (_super) {
1910
1944
  __extends(ProductForCategory, _super);
@@ -1920,6 +1954,10 @@
1920
1954
  });
1921
1955
  return ProductForCategory;
1922
1956
  }(ProductBase));
1957
+ __decorate([
1958
+ classTransformer.Type(function () { return KitProduct; }),
1959
+ __metadata("design:type", Array)
1960
+ ], ProductForCategory.prototype, "kitProducts", void 0);
1923
1961
 
1924
1962
  var Category = /** @class */ (function (_super) {
1925
1963
  __extends(Category, _super);
@@ -1934,15 +1972,7 @@
1934
1972
  configurable: true
1935
1973
  });
1936
1974
  return Category;
1937
- }(BaseModel));
1938
- __decorate([
1939
- classTransformer.Type(function () { return Category; }),
1940
- __metadata("design:type", Category)
1941
- ], Category.prototype, "parent", void 0);
1942
- __decorate([
1943
- classTransformer.Type(function () { return Filter; }),
1944
- __metadata("design:type", Array)
1945
- ], Category.prototype, "filters", void 0);
1975
+ }(CategoryBase));
1946
1976
  __decorate([
1947
1977
  classTransformer.Type(function () { return ProductForCategory; }),
1948
1978
  __metadata("design:type", Array)
@@ -2020,6 +2050,29 @@
2020
2050
  return FilterOption;
2021
2051
  }(BaseModel));
2022
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
+
2023
2076
  var Variant = /** @class */ (function (_super) {
2024
2077
  __extends(Variant, _super);
2025
2078
  function Variant() {
@@ -2035,6 +2088,21 @@
2035
2088
  return Variant;
2036
2089
  }(BaseModel));
2037
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
+
2038
2106
  var Buy2Win = /** @class */ (function (_super) {
2039
2107
  __extends(Buy2Win, _super);
2040
2108
  function Buy2Win() {
@@ -4785,6 +4853,15 @@
4785
4853
  ],
4786
4854
  }) || this;
4787
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
+ };
4788
4865
  CategoryFilterHasuraGraphQLRepository.prototype.deleteByCategoryAndFilter = function (categoryId, filterId) {
4789
4866
  return this.mutation('delete_category_filter', ['affected_rows'], {
4790
4867
  where: {
@@ -4869,6 +4946,7 @@
4869
4946
  },
4870
4947
  },
4871
4948
  { isCollection: { columnName: 'is_collection' } },
4949
+ { isWishlist: { columnName: 'is_wishlist' } },
4872
4950
  'reference',
4873
4951
  { parentId: { columnName: 'parent_id' } },
4874
4952
  {
@@ -4892,7 +4970,7 @@
4892
4970
  var metadata, data;
4893
4971
  return __generator(this, function (_c) {
4894
4972
  metadata = params.metadata, data = __rest(params, ["metadata"]);
4895
- 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 } }))];
4896
4974
  });
4897
4975
  });
4898
4976
  };
@@ -4933,7 +5011,7 @@
4933
5011
  return [4 /*yield*/, this.getId(plainData.id)];
4934
5012
  case 1:
4935
5013
  id = _j.sent();
4936
- 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 }))];
4937
5015
  case 2:
4938
5016
  category = _j.sent();
4939
5017
  _c = category;
@@ -4981,6 +5059,7 @@
4981
5059
  slug: slug,
4982
5060
  shops: { operator: exports.Where.IN, value: [shop] },
4983
5061
  published: { operator: exports.Where.EQUALS, value: true },
5062
+ isWishlist: { operator: exports.Where.EQUALS, value: false },
4984
5063
  },
4985
5064
  options: {
4986
5065
  enableCount: false,
@@ -5009,6 +5088,7 @@
5009
5088
  filters: {
5010
5089
  shops: { operator: exports.Where.IN, value: [shop] },
5011
5090
  published: { operator: exports.Where.EQUALS, value: true },
5091
+ isWishlist: { operator: exports.Where.EQUALS, value: false },
5012
5092
  },
5013
5093
  options: {
5014
5094
  enableCount: false,
@@ -5226,104 +5306,136 @@
5226
5306
  CategoryHasuraGraphQLRepository.prototype.updateFilters = function (categoryId, _c) {
5227
5307
  var filters = _c.filters;
5228
5308
  return __awaiter(this, void 0, void 0, function () {
5229
- var i, filtersList, i, hasFilter, newCategoryFilter, error_1, filtersList, i, hasFilter, newCategoryFilter, error_2;
5230
- return __generator(this, function (_c) {
5231
- 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) {
5232
5313
  case 0:
5233
5314
  if (!('action' in filters && filters.action === 'remove' && filters.value.length)) return [3 /*break*/, 5];
5234
5315
  i = 0;
5235
- _c.label = 1;
5316
+ _e.label = 1;
5236
5317
  case 1:
5237
5318
  if (!(i < filters.value.length)) return [3 /*break*/, 4];
5238
5319
  return [4 /*yield*/, this.categoryFilterRepository.deleteByCategoryAndFilter(categoryId, filters.value[i].id)];
5239
5320
  case 2:
5240
- _c.sent();
5241
- _c.label = 3;
5321
+ _e.sent();
5322
+ _e.label = 3;
5242
5323
  case 3:
5243
5324
  i++;
5244
5325
  return [3 /*break*/, 1];
5245
5326
  case 4: return [2 /*return*/, []];
5246
5327
  case 5:
5247
- 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];
5248
5329
  filtersList = [];
5249
- i = 0;
5250
- _c.label = 6;
5251
- case 6:
5252
- if (!(i < filters.value.length)) return [3 /*break*/, 14];
5253
- _c.label = 7;
5254
- case 7:
5255
- _c.trys.push([7, 12, , 13]);
5256
5330
  return [4 /*yield*/, this.categoryFilterRepository
5257
5331
  .find({
5258
5332
  filters: {
5259
5333
  categoryId: categoryId,
5260
- filterId: filters.value[i].id,
5261
5334
  },
5262
5335
  })
5263
- .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;
5264
5365
  case 8:
5265
- hasFilter = _c.sent();
5266
- if (!hasFilter) return [3 /*break*/, 9];
5267
- filtersList.push(hasFilter);
5268
- return [3 /*break*/, 11];
5269
- case 9: return [4 /*yield*/, this.categoryFilterRepository.create({
5270
- filterId: filters.value[i].id,
5271
- categoryId: categoryId,
5272
- })];
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;
5273
5372
  case 10:
5274
- newCategoryFilter = _c.sent();
5275
- filtersList.push(newCategoryFilter);
5276
- _c.label = 11;
5277
- 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];
5278
5376
  case 12:
5279
- error_1 = _c.sent();
5280
- console.log('catch error: ', error_1);
5281
- return [3 /*break*/, 13];
5377
+ e_1_1 = _e.sent();
5378
+ e_1 = { error: e_1_1 };
5379
+ return [3 /*break*/, 14];
5282
5380
  case 13:
5283
- i++;
5284
- return [3 /*break*/, 6];
5285
- 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;
5286
5390
  case 15:
5287
- if (!(Array.isArray(filters) && filters.length)) return [3 /*break*/, 25];
5288
- filtersList = [];
5289
- i = 0;
5290
- _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
+ })];
5291
5397
  case 16:
5292
- if (!(i < filters.length)) return [3 /*break*/, 24];
5293
- _c.label = 17;
5398
+ newCategoryFilter = _e.sent();
5399
+ filtersList.push(newCategoryFilter);
5400
+ _e.label = 17;
5294
5401
  case 17:
5295
- _c.trys.push([17, 22, , 23]);
5296
- return [4 /*yield*/, this.categoryFilterRepository
5297
- .find({
5298
- filters: {
5299
- categoryId: categoryId,
5300
- filterId: filters[i].id,
5301
- },
5302
- })
5303
- .then(function (data) { return data.data.shift(); })];
5304
- case 18:
5305
- hasFilter = _c.sent();
5306
- if (!hasFilter) return [3 /*break*/, 19];
5307
- 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 };
5308
5408
  return [3 /*break*/, 21];
5309
- case 19: return [4 /*yield*/, this.categoryFilterRepository.create({
5310
- filterId: filters[i].id,
5311
- categoryId: categoryId,
5312
- })];
5313
5409
  case 20:
5314
- newCategoryFilter = _c.sent();
5315
- filtersList.push(newCategoryFilter);
5316
- _c.label = 21;
5317
- 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))];
5318
5416
  case 22:
5319
- error_2 = _c.sent();
5320
- console.log('catch error: ', error_2);
5321
- return [3 /*break*/, 23];
5417
+ if (!(Array.isArray(filters) && filters.length)) return [3 /*break*/, 28];
5418
+ return [4 /*yield*/, this.categoryFilterRepository.deleteByCategory(categoryId)];
5322
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:
5323
5435
  i++;
5324
- return [3 /*break*/, 16];
5325
- case 24: return [2 /*return*/, filtersList];
5326
- case 25: return [2 /*return*/];
5436
+ return [3 /*break*/, 24];
5437
+ case 27: return [2 /*return*/, filtersList];
5438
+ case 28: return [2 /*return*/];
5327
5439
  }
5328
5440
  });
5329
5441
  });
@@ -6445,6 +6557,339 @@
6445
6557
  return VariantHasuraGraphQLRepository;
6446
6558
  }(withCrudHasuraGraphQL(withHasuraGraphQL(Base))));
6447
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
+
6448
6893
  /**
6449
6894
  * Generated bundle index. Do not edit.
6450
6895
  */
@@ -6655,6 +7100,8 @@
6655
7100
  exports.VariantHasuraGraphQL = VariantHasuraGraphQL;
6656
7101
  exports.VariantHasuraGraphQLRepository = VariantHasuraGraphQLRepository;
6657
7102
  exports.WeakPasswordError = WeakPasswordError;
7103
+ exports.Wishlist = Wishlist;
7104
+ exports.WishlistHasuraGraphQLRepository = WishlistHasuraGraphQLRepository;
6658
7105
  exports.isDebuggable = isDebuggable;
6659
7106
  exports.isUUID = isUUID;
6660
7107
  exports.parseDateTime = parseDateTime;