@infrab4a/connect 2.0.13-beta.1 → 3.0.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/bundles/infrab4a-connect.umd.js +180 -307
  2. package/bundles/infrab4a-connect.umd.js.map +1 -1
  3. package/domain/catalog/models/product.d.ts +4 -8
  4. package/domain/catalog/models/types/index.d.ts +3 -2
  5. package/domain/catalog/models/types/product-metadata.type.d.ts +4 -0
  6. package/domain/catalog/models/types/shop-description.type.d.ts +7 -0
  7. package/domain/catalog/models/types/{shops-price.type.d.ts → shop-price.type.d.ts} +0 -4
  8. package/domain/catalog/models/variant.d.ts +2 -2
  9. package/domain/generic/repository/enums/where.enum.d.ts +0 -1
  10. package/esm2015/domain/catalog/models/product.js +1 -5
  11. package/esm2015/domain/catalog/models/types/index.js +4 -3
  12. package/esm2015/domain/catalog/models/types/product-metadata.type.js +2 -0
  13. package/esm2015/domain/catalog/models/types/shop-description.type.js +2 -0
  14. package/esm2015/domain/catalog/models/types/shop-price.type.js +2 -0
  15. package/esm2015/domain/catalog/models/variant.js +1 -1
  16. package/esm2015/domain/catalog/repositories/product.repository.js +1 -1
  17. package/esm2015/domain/generic/repository/enums/where.enum.js +1 -2
  18. package/esm2015/domain/shop-settings/models/home.js +1 -1
  19. package/esm2015/infra/elasticsearch/indexes/products-index.js +2 -3
  20. package/esm2015/infra/firebase/firestore/models/user-search.js +7 -0
  21. package/esm2015/infra/firebase/firestore/repositories/catalog/category-firestore.repository.js +4 -5
  22. package/esm2015/infra/firebase/firestore/repositories/users/index.js +7 -6
  23. package/esm2015/infra/firebase/firestore/repositories/users/user-firestore.repository.js +6 -4
  24. package/esm2015/infra/firebase/firestore/repositories/users/user-search-firestore.repository.js +12 -0
  25. package/esm2015/infra/hasura-graphql/repositories/catalog/category-hasura-graphql.repository.js +3 -63
  26. package/esm2015/infra/hasura-graphql/repositories/catalog/product-hasura-graphql.repository.js +28 -55
  27. package/esm2015/infra/hasura-graphql/repositories/catalog/variant-hasura-graphql.repository.js +11 -14
  28. package/esm2015/infra/hasura-graphql/types/hasura-graphql-fields.type.js +1 -1
  29. package/fesm2015/infrab4a-connect.js +101 -182
  30. package/fesm2015/infrab4a-connect.js.map +1 -1
  31. package/infra/firebase/firestore/models/user-search.d.ts +9 -0
  32. package/infra/firebase/firestore/repositories/users/index.d.ts +6 -5
  33. package/infra/firebase/firestore/repositories/users/user-firestore.repository.d.ts +3 -1
  34. package/infra/firebase/firestore/repositories/users/user-search-firestore.repository.d.ts +9 -0
  35. package/infra/hasura-graphql/repositories/catalog/category-hasura-graphql.repository.d.ts +1 -4
  36. package/infra/hasura-graphql/types/hasura-graphql-fields.type.d.ts +1 -1
  37. package/package.json +1 -1
  38. package/domain/catalog/models/types/shops-description.type.d.ts +0 -7
  39. package/esm2015/domain/catalog/models/types/shops-description.type.js +0 -2
  40. package/esm2015/domain/catalog/models/types/shops-price.type.js +0 -2
@@ -48,7 +48,6 @@
48
48
  exports.Where = void 0;
49
49
  (function (Where) {
50
50
  Where["EQUALS"] = "==";
51
- Where["NOTEQUALS"] = "!=";
52
51
  Where["GT"] = ">";
53
52
  Where["GTE"] = ">=";
54
53
  Where["IN"] = "in";
@@ -1293,10 +1292,6 @@
1293
1292
  Product.prototype.identifierFields = function () {
1294
1293
  return ['id'];
1295
1294
  };
1296
- Product.prototype.getInfoByShop = function (shop) {
1297
- var _a, _b, _c, _d, _e, _f;
1298
- return Object.assign(Object.assign(Object.assign({}, (((_b = (_a = this.description) === null || _a === void 0 ? void 0 : _a[shop]) === null || _b === void 0 ? void 0 : _b.description) ? { description: (_d = (_c = this.description) === null || _c === void 0 ? void 0 : _c[shop]) === null || _d === void 0 ? void 0 : _d.description } : {})), (((_e = this.price) === null || _e === void 0 ? void 0 : _e[shop]) || {})), (((_f = this.stock) === null || _f === void 0 ? void 0 : _f[shop]) || {}));
1299
- };
1300
1295
  Object.defineProperty(Product, "identifiersFields", {
1301
1296
  get: function () {
1302
1297
  return ['id'];
@@ -1774,7 +1769,6 @@
1774
1769
  'weight',
1775
1770
  'tags',
1776
1771
  'hasVariants',
1777
- 'type'
1778
1772
  ];
1779
1773
  return [4 /*yield*/, this.adapter.query('products/_search', Object.assign({ _source: fields, query: {
1780
1774
  bool: {
@@ -1832,7 +1826,7 @@
1832
1826
  return [3 /*break*/, 6];
1833
1827
  case 4:
1834
1828
  error_1 = _a.sent();
1835
- console.error(error_1.message);
1829
+ console.info(error_1.message);
1836
1830
  return [4 /*yield*/, this.adapter.save("products/_doc/" + product.id, product.toPlain())];
1837
1831
  case 5:
1838
1832
  _a.sent();
@@ -2236,32 +2230,6 @@
2236
2230
  }(withUpdateFirestore(withGetFirestore(withFindFirestore(withDeleteFirestore(withCreateFirestore(MixinBase)))))));
2237
2231
  };
2238
2232
 
2239
- var LeadFirestoreRepository = /** @class */ (function (_super) {
2240
- __extends(LeadFirestoreRepository, _super);
2241
- function LeadFirestoreRepository(firestore) {
2242
- var _this = _super.call(this) || this;
2243
- _this.firestore = firestore;
2244
- _this.collectionName = 'leads';
2245
- _this.model = Lead;
2246
- return _this;
2247
- }
2248
- return LeadFirestoreRepository;
2249
- }(withCrudFirestore(withHelpers(withFirestore(Base)))));
2250
-
2251
- var SubscriptionEditionFirestoreRepository = /** @class */ (function (_super) {
2252
- __extends(SubscriptionEditionFirestoreRepository, _super);
2253
- function SubscriptionEditionFirestoreRepository(firestore, parentRepository) {
2254
- var _this = _super.call(this) || this;
2255
- _this.firestore = firestore;
2256
- _this.parentRepository = parentRepository;
2257
- _this.collectionName = 'editions';
2258
- _this.parentIdField = 'subscriptionId';
2259
- _this.model = Edition;
2260
- return _this;
2261
- }
2262
- return SubscriptionEditionFirestoreRepository;
2263
- }(withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), Subscription)));
2264
-
2265
2233
  var SubscriptionFirestoreRepository = /** @class */ (function (_super) {
2266
2234
  __extends(SubscriptionFirestoreRepository, _super);
2267
2235
  function SubscriptionFirestoreRepository(firestore) {
@@ -2274,53 +2242,40 @@
2274
2242
  return SubscriptionFirestoreRepository;
2275
2243
  }(withCrudFirestore(withHelpers(withFirestore(Base)))));
2276
2244
 
2277
- var SubscriptionPaymentFirestoreRepository = /** @class */ (function (_super) {
2278
- __extends(SubscriptionPaymentFirestoreRepository, _super);
2279
- function SubscriptionPaymentFirestoreRepository(firestore, parentRepository) {
2280
- var _this = _super.call(this) || this;
2281
- _this.firestore = firestore;
2282
- _this.parentRepository = parentRepository;
2283
- _this.collectionName = 'payments';
2284
- _this.parentIdField = 'subscriptionId';
2285
- _this.model = SubscriptionPayment;
2286
- return _this;
2287
- }
2288
- return SubscriptionPaymentFirestoreRepository;
2289
- }(withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), Subscription)));
2290
-
2291
- var UserAddressFirestoreRepository = /** @class */ (function (_super) {
2292
- __extends(UserAddressFirestoreRepository, _super);
2293
- function UserAddressFirestoreRepository(firestore, parentRepository) {
2294
- var _this = _super.call(this) || this;
2295
- _this.firestore = firestore;
2296
- _this.parentRepository = parentRepository;
2297
- _this.collectionName = 'address';
2298
- _this.parentIdField = 'userId';
2299
- _this.model = UserAddress;
2300
- return _this;
2245
+ var UserSearch = /** @class */ (function (_super) {
2246
+ __extends(UserSearch, _super);
2247
+ function UserSearch() {
2248
+ return _super !== null && _super.apply(this, arguments) || this;
2301
2249
  }
2302
- return UserAddressFirestoreRepository;
2303
- }(withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), User)));
2250
+ Object.defineProperty(UserSearch, "identifiersFields", {
2251
+ get: function () {
2252
+ return ['id'];
2253
+ },
2254
+ enumerable: false,
2255
+ configurable: true
2256
+ });
2257
+ return UserSearch;
2258
+ }(BaseModel));
2304
2259
 
2305
- var UserBeautyProfileFirestoreRepository = /** @class */ (function (_super) {
2306
- __extends(UserBeautyProfileFirestoreRepository, _super);
2307
- function UserBeautyProfileFirestoreRepository(firestore, parentRepository) {
2260
+ var UserSearchFirestoreRepository = /** @class */ (function (_super) {
2261
+ __extends(UserSearchFirestoreRepository, _super);
2262
+ function UserSearchFirestoreRepository(firestore) {
2308
2263
  var _this = _super.call(this) || this;
2309
2264
  _this.firestore = firestore;
2310
- _this.parentRepository = parentRepository;
2311
- _this.collectionName = 'CX';
2312
- _this.parentIdField = 'userId';
2313
- _this.model = BeautyProfile;
2265
+ _this.collectionName = 'userSearch';
2266
+ _this.model = UserSearch;
2314
2267
  return _this;
2315
2268
  }
2316
- return UserBeautyProfileFirestoreRepository;
2317
- }(withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), User)));
2269
+ return UserSearchFirestoreRepository;
2270
+ }(withCrudFirestore(withHelpers(withFirestore(Base)))));
2318
2271
 
2319
2272
  var UserFirestoreRepository = /** @class */ (function (_super_1) {
2320
2273
  __extends(UserFirestoreRepository, _super_1);
2321
- function UserFirestoreRepository(firestore) {
2274
+ function UserFirestoreRepository(firestore, userSearchFirestoreRepository) {
2275
+ if (userSearchFirestoreRepository === void 0) { userSearchFirestoreRepository = new UserSearchFirestoreRepository(firestore); }
2322
2276
  var _this = _super_1.call(this) || this;
2323
2277
  _this.firestore = firestore;
2278
+ _this.userSearchFirestoreRepository = userSearchFirestoreRepository;
2324
2279
  _this.collectionName = 'users';
2325
2280
  _this.model = User;
2326
2281
  return _this;
@@ -2355,7 +2310,7 @@
2355
2310
  var _a;
2356
2311
  return __generator(this, function (_b) {
2357
2312
  switch (_b.label) {
2358
- case 0: return [4 /*yield*/, this.find({ filters: (_a = {}, _a[field] = value, _a) })];
2313
+ case 0: return [4 /*yield*/, this.userSearchFirestoreRepository.find((_a = {}, _a[field] = { operator: exports.Where.EQUALS, value: value }, _a))];
2359
2314
  case 1:
2360
2315
  result = _b.sent();
2361
2316
  return [2 /*return*/, result.count > 0];
@@ -2418,6 +2373,48 @@
2418
2373
  return UserFirestoreRepository;
2419
2374
  }(withCrudFirestore(withHelpers(withFirestore(Base)))));
2420
2375
 
2376
+ var SubscriptionEditionFirestoreRepository = /** @class */ (function (_super) {
2377
+ __extends(SubscriptionEditionFirestoreRepository, _super);
2378
+ function SubscriptionEditionFirestoreRepository(firestore, parentRepository) {
2379
+ var _this = _super.call(this) || this;
2380
+ _this.firestore = firestore;
2381
+ _this.parentRepository = parentRepository;
2382
+ _this.collectionName = 'editions';
2383
+ _this.parentIdField = 'subscriptionId';
2384
+ _this.model = Edition;
2385
+ return _this;
2386
+ }
2387
+ return SubscriptionEditionFirestoreRepository;
2388
+ }(withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), Subscription)));
2389
+
2390
+ var UserBeautyProfileFirestoreRepository = /** @class */ (function (_super) {
2391
+ __extends(UserBeautyProfileFirestoreRepository, _super);
2392
+ function UserBeautyProfileFirestoreRepository(firestore, parentRepository) {
2393
+ var _this = _super.call(this) || this;
2394
+ _this.firestore = firestore;
2395
+ _this.parentRepository = parentRepository;
2396
+ _this.collectionName = 'CX';
2397
+ _this.parentIdField = 'userId';
2398
+ _this.model = BeautyProfile;
2399
+ return _this;
2400
+ }
2401
+ return UserBeautyProfileFirestoreRepository;
2402
+ }(withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), User)));
2403
+
2404
+ var UserAddressFirestoreRepository = /** @class */ (function (_super) {
2405
+ __extends(UserAddressFirestoreRepository, _super);
2406
+ function UserAddressFirestoreRepository(firestore, parentRepository) {
2407
+ var _this = _super.call(this) || this;
2408
+ _this.firestore = firestore;
2409
+ _this.parentRepository = parentRepository;
2410
+ _this.collectionName = 'address';
2411
+ _this.parentIdField = 'userId';
2412
+ _this.model = UserAddress;
2413
+ return _this;
2414
+ }
2415
+ return UserAddressFirestoreRepository;
2416
+ }(withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), User)));
2417
+
2421
2418
  var UserPaymentMethodFirestoreRepository = /** @class */ (function (_super) {
2422
2419
  __extends(UserPaymentMethodFirestoreRepository, _super);
2423
2420
  function UserPaymentMethodFirestoreRepository(firestore, parentRepository) {
@@ -2432,6 +2429,32 @@
2432
2429
  return UserPaymentMethodFirestoreRepository;
2433
2430
  }(withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), User)));
2434
2431
 
2432
+ var SubscriptionPaymentFirestoreRepository = /** @class */ (function (_super) {
2433
+ __extends(SubscriptionPaymentFirestoreRepository, _super);
2434
+ function SubscriptionPaymentFirestoreRepository(firestore, parentRepository) {
2435
+ var _this = _super.call(this) || this;
2436
+ _this.firestore = firestore;
2437
+ _this.parentRepository = parentRepository;
2438
+ _this.collectionName = 'payments';
2439
+ _this.parentIdField = 'subscriptionId';
2440
+ _this.model = SubscriptionPayment;
2441
+ return _this;
2442
+ }
2443
+ return SubscriptionPaymentFirestoreRepository;
2444
+ }(withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), Subscription)));
2445
+
2446
+ var LeadFirestoreRepository = /** @class */ (function (_super) {
2447
+ __extends(LeadFirestoreRepository, _super);
2448
+ function LeadFirestoreRepository(firestore) {
2449
+ var _this = _super.call(this) || this;
2450
+ _this.firestore = firestore;
2451
+ _this.collectionName = 'leads';
2452
+ _this.model = Lead;
2453
+ return _this;
2454
+ }
2455
+ return LeadFirestoreRepository;
2456
+ }(withCrudFirestore(withHelpers(withFirestore(Base)))));
2457
+
2435
2458
  var CategoryFirestoreRepository = /** @class */ (function (_super) {
2436
2459
  __extends(CategoryFirestoreRepository, _super);
2437
2460
  function CategoryFirestoreRepository(firestore) {
@@ -2495,7 +2518,7 @@
2495
2518
  };
2496
2519
  CategoryFirestoreRepository.prototype.mountCategory = function (category, options) {
2497
2520
  return __awaiter(this, void 0, void 0, function () {
2498
- var chunks, products, publishedField, chunks_1, chunks_1_1, productIds, query, productSnap, e_1_1;
2521
+ var chunks, products, chunks_1, chunks_1_1, productIds, query, productSnap, e_1_1;
2499
2522
  var e_1, _a;
2500
2523
  return __generator(this, function (_b) {
2501
2524
  switch (_b.label) {
@@ -2504,7 +2527,6 @@
2504
2527
  throw new RequiredArgumentError(['Category products is empty']);
2505
2528
  chunks = lodash.chunk(category.products, 10);
2506
2529
  products = [];
2507
- publishedField = category.shop === exports.Shops.GLAMSHOP ? 'publishedGlam' : 'published';
2508
2530
  _b.label = 1;
2509
2531
  case 1:
2510
2532
  _b.trys.push([1, 7, 8, 9]);
@@ -2516,7 +2538,7 @@
2516
2538
  if ((options === null || options === void 0 ? void 0 : options.limit) && products.length >= (options === null || options === void 0 ? void 0 : options.limit))
2517
2539
  return [3 /*break*/, 6];
2518
2540
  return [4 /*yield*/, this.collection('productsErpVitrine')
2519
- .where(publishedField, '==', true)
2541
+ .where('published', '==', true)
2520
2542
  .where('id', 'in', productIds)];
2521
2543
  case 3:
2522
2544
  query = _b.sent();
@@ -3679,65 +3701,34 @@
3679
3701
  });
3680
3702
  var _a;
3681
3703
  return __awaiter(this, void 0, void 0, function () {
3682
- var _c;
3683
- return __generator(this, function (_d) {
3684
- switch (_d.label) {
3704
+ var _b;
3705
+ return __generator(this, function (_c) {
3706
+ switch (_c.label) {
3685
3707
  case 0:
3686
3708
  if (!Number.isNaN(+identifiers.id)) return [3 /*break*/, 2];
3687
3709
  return [4 /*yield*/, this.find({ filters: { firestoreId: identifiers.id } })];
3688
3710
  case 1:
3689
- _c = (_a = (_d.sent()).data) === null || _a === void 0 ? void 0 : _a[0];
3711
+ _b = (_a = (_c.sent()).data) === null || _a === void 0 ? void 0 : _a[0];
3690
3712
  return [3 /*break*/, 3];
3691
3713
  case 2:
3692
- _c = _super.get.call(this, identifiers);
3693
- _d.label = 3;
3694
- case 3: return [2 /*return*/, _c];
3695
- }
3696
- });
3697
- });
3698
- };
3699
- CategoryHasuraGraphQLRepository.prototype.update = function (params) {
3700
- var _super = Object.create(null, {
3701
- update: { get: function () { return _super_1.prototype.update; } }
3702
- });
3703
- return __awaiter(this, void 0, void 0, function () {
3704
- var products, checkId, data, plainData, id, category, _c, _d;
3705
- return __generator(this, function (_e) {
3706
- switch (_e.label) {
3707
- case 0:
3708
- products = params.products, checkId = params.id, data = __rest(params, ["products", "id"]);
3709
- plainData = this.paramsToPlain({ id: checkId });
3710
- return [4 /*yield*/, this.getId(plainData.id)];
3711
- case 1:
3712
- id = _e.sent();
3713
- return [4 /*yield*/, _super.update.call(this, Object.assign({ id: id }, data))];
3714
- case 2:
3715
- category = _e.sent();
3716
- _c = category;
3717
- _d = products;
3718
- if (!_d) return [3 /*break*/, 4];
3719
- return [4 /*yield*/, this.updateProducts(+id, { products: products })];
3720
- case 3:
3721
- _d = (_e.sent());
3722
- _e.label = 4;
3723
- case 4:
3724
- _c.products = _d;
3725
- return [2 /*return*/, category];
3714
+ _b = _super.get.call(this, identifiers);
3715
+ _c.label = 3;
3716
+ case 3: return [2 /*return*/, _b];
3726
3717
  }
3727
3718
  });
3728
3719
  });
3729
3720
  };
3730
3721
  CategoryHasuraGraphQLRepository.prototype.getCategoryBySlug = function (slug, shop) {
3731
3722
  return __awaiter(this, void 0, void 0, function () {
3732
- var _c, data, count;
3733
- return __generator(this, function (_d) {
3734
- switch (_d.label) {
3723
+ var _b, data, count;
3724
+ return __generator(this, function (_c) {
3725
+ switch (_c.label) {
3735
3726
  case 0:
3736
3727
  if (!slug)
3737
3728
  return [2 /*return*/];
3738
3729
  return [4 /*yield*/, this.find({ filters: { slug: slug, shop: shop, published: true } })];
3739
3730
  case 1:
3740
- _c = _d.sent(), data = _c.data, count = _c.count;
3731
+ _b = _c.sent(), data = _b.data, count = _b.count;
3741
3732
  if (count > 1)
3742
3733
  throw new DuplicatedResultsError('Query returned duplicated values');
3743
3734
  if (!count)
@@ -3750,33 +3741,33 @@
3750
3741
  CategoryHasuraGraphQLRepository.prototype.getCategoriesForHome = function (categoryIds, limit) {
3751
3742
  if (limit === void 0) { limit = 4; }
3752
3743
  return __awaiter(this, void 0, void 0, function () {
3753
- var _c, categories, count, homeSections;
3744
+ var _b, categories, count, homeSections;
3754
3745
  var _this = this;
3755
- return __generator(this, function (_d) {
3756
- switch (_d.label) {
3746
+ return __generator(this, function (_c) {
3747
+ switch (_c.label) {
3757
3748
  case 0: return [4 /*yield*/, this.find({
3758
3749
  filters: { firestoreId: { operator: exports.Where.IN, value: categoryIds.filter(Boolean) }, published: true },
3759
3750
  })];
3760
3751
  case 1:
3761
- _c = _d.sent(), categories = _c.data, count = _c.count;
3752
+ _b = _c.sent(), categories = _b.data, count = _b.count;
3762
3753
  if (!count)
3763
3754
  throw new NotFoundError('Categories not found');
3764
3755
  return [4 /*yield*/, Promise.all(categories.map(function (category) { return __awaiter(_this, void 0, void 0, function () {
3765
- var _c;
3766
- return __generator(this, function (_d) {
3767
- switch (_d.label) {
3756
+ var _b;
3757
+ return __generator(this, function (_c) {
3758
+ switch (_c.label) {
3768
3759
  case 0:
3769
- _c = {
3760
+ _b = {
3770
3761
  category: category
3771
3762
  };
3772
3763
  return [4 /*yield*/, this.mountCategory(category, { limit: limit, hasStock: true })];
3773
- case 1: return [2 /*return*/, (_c.products = _d.sent(),
3774
- _c)];
3764
+ case 1: return [2 /*return*/, (_b.products = _c.sent(),
3765
+ _b)];
3775
3766
  }
3776
3767
  });
3777
3768
  }); }))];
3778
3769
  case 2:
3779
- homeSections = _d.sent();
3770
+ homeSections = _c.sent();
3780
3771
  return [2 /*return*/, homeSections];
3781
3772
  }
3782
3773
  });
@@ -3785,15 +3776,15 @@
3785
3776
  CategoryHasuraGraphQLRepository.prototype.mountCategory = function (category, options) {
3786
3777
  return __awaiter(this, void 0, void 0, function () {
3787
3778
  var products, publishedField, productsData;
3788
- var _c;
3789
- return __generator(this, function (_d) {
3790
- switch (_d.label) {
3779
+ var _b;
3780
+ return __generator(this, function (_c) {
3781
+ switch (_c.label) {
3791
3782
  case 0:
3792
3783
  if (!category.products)
3793
3784
  throw new RequiredArgumentError(['Category products is empty']);
3794
3785
  products = [];
3795
3786
  publishedField = category.shop === exports.Shops.GLAMSHOP ? 'publishedGlam' : 'published';
3796
- return [4 /*yield*/, this.productRepository.find(Object.assign({ filters: Object.assign((_c = { id: { operator: exports.Where.IN, value: category.products } }, _c[publishedField] = true, _c), ((options === null || options === void 0 ? void 0 : options.hasStock) ? { stock: { quantity: { operator: exports.Where.GT, value: 0 } } } : {})), fields: [
3787
+ return [4 /*yield*/, this.productRepository.find(Object.assign({ filters: Object.assign((_b = { id: { operator: exports.Where.IN, value: category.products } }, _b[publishedField] = true, _b), ((options === null || options === void 0 ? void 0 : options.hasStock) ? { stock: { quantity: { operator: exports.Where.GT, value: 0 } } } : {})), fields: [
3797
3788
  'id',
3798
3789
  'name',
3799
3790
  'slug',
@@ -3805,7 +3796,6 @@
3805
3796
  'subscriberPrice',
3806
3797
  'stock',
3807
3798
  'published',
3808
- 'publishedGlam',
3809
3799
  'CEST',
3810
3800
  'EAN',
3811
3801
  'NCM',
@@ -3813,85 +3803,18 @@
3813
3803
  'costPrice',
3814
3804
  'hasVariants',
3815
3805
  'isKit',
3816
- 'shopAvailability',
3817
3806
  'sku',
3818
3807
  'rate',
3819
3808
  'tags',
3820
- 'type',
3821
- 'shoppingCount',
3822
3809
  ] }, ((options === null || options === void 0 ? void 0 : options.limit) ? { limits: { limit: options === null || options === void 0 ? void 0 : options.limit } } : {})))];
3823
3810
  case 1:
3824
- productsData = (_d.sent()).data;
3811
+ productsData = (_c.sent()).data;
3825
3812
  products.push.apply(products, __spreadArray([], __read(productsData)));
3826
3813
  return [2 /*return*/, products];
3827
3814
  }
3828
3815
  });
3829
3816
  });
3830
3817
  };
3831
- CategoryHasuraGraphQLRepository.prototype.getId = function (id) {
3832
- var _a, _b;
3833
- return __awaiter(this, void 0, void 0, function () {
3834
- var data;
3835
- return __generator(this, function (_c) {
3836
- switch (_c.label) {
3837
- case 0:
3838
- if (!Number.isNaN(+id))
3839
- return [2 /*return*/, id];
3840
- return [4 /*yield*/, this.find({ filters: { firestoreId: id } })];
3841
- case 1:
3842
- data = (_c.sent()).data;
3843
- if ((_a = data === null || data === void 0 ? void 0 : data[0]) === null || _a === void 0 ? void 0 : _a.id)
3844
- return [2 /*return*/, (_b = data === null || data === void 0 ? void 0 : data[0]) === null || _b === void 0 ? void 0 : _b.id];
3845
- throw new NotFoundError("Category with id " + id + " not found");
3846
- }
3847
- });
3848
- });
3849
- };
3850
- CategoryHasuraGraphQLRepository.prototype.updateProducts = function (categoryId, _c) {
3851
- var products = _c.products;
3852
- return __awaiter(this, void 0, void 0, function () {
3853
- var plainData;
3854
- return __generator(this, function (_c) {
3855
- switch (_c.label) {
3856
- case 0:
3857
- if (!('action' in products && products.action === 'remove')) return [3 /*break*/, 2];
3858
- return [4 /*yield*/, this.mutation('delete_category_product', ['affected_rows'], {
3859
- where: {
3860
- type: 'category_product_bool_exp',
3861
- required: true,
3862
- value: { category_id: { _eq: categoryId } },
3863
- },
3864
- })];
3865
- case 1:
3866
- _c.sent();
3867
- return [2 /*return*/, []];
3868
- case 2:
3869
- plainData = this.paramsToPlain({ products: products });
3870
- if (!plainData.products || plainData.products.length <= 0)
3871
- return [2 /*return*/, []];
3872
- return [4 /*yield*/, this.mutation('delete_category_product', ['affected_rows'], {
3873
- where: {
3874
- type: 'category_product_bool_exp',
3875
- required: true,
3876
- value: { category_id: { _eq: categoryId } },
3877
- },
3878
- })];
3879
- case 3:
3880
- _c.sent();
3881
- return [4 /*yield*/, this.mutation('insert_category_product', ['affected_rows'], {
3882
- objects: {
3883
- type: '[category_product_insert_input!]',
3884
- required: true,
3885
- value: plainData.products.map(function (productId) { return ({ category_id: categoryId, product_id: productId }); }),
3886
- },
3887
- })];
3888
- case 4:
3889
- _c.sent();
3890
- return [2 /*return*/, plainData.products];
3891
- }
3892
- });
3893
- });
3894
- };
3895
3818
  return CategoryHasuraGraphQLRepository;
3896
3819
  }(withCrudHasuraGraphQL(withHasuraGraphQL(Base))));
3897
3820
 
@@ -3919,11 +3842,8 @@
3919
3842
  {
3920
3843
  description: {
3921
3844
  columnName: 'description',
3922
- from: function (description) { return Object.values(exports.Shops).reduce(function (shops, shop) {
3923
- var _c;
3924
- return (Object.assign(Object.assign({}, shops), (_c = {}, _c[shop] = { description: description }, _c)));
3925
- }, {}); },
3926
- to: function (value) { return Object.values(value).shift().description; },
3845
+ from: function (description) { return ({ description: description }); },
3846
+ to: function (value) { return value.description; },
3927
3847
  },
3928
3848
  },
3929
3849
  { hasVariants: { columnName: 'has_variants' } },
@@ -3933,15 +3853,12 @@
3933
3853
  {
3934
3854
  price: {
3935
3855
  columnName: 'price',
3936
- from: function (price, data) { return Object.values(exports.Shops).reduce(function (prices, shop) {
3937
- var _c;
3938
- return (Object.assign(Object.assign({}, prices), (_c = {}, _c[shop] = {
3939
- price: price,
3940
- fullPrice: data.full_price,
3941
- subscriberDiscountPercentage: data.subscriber_discount_percentage,
3942
- subscriberPrice: data.subscriber_price,
3943
- }, _c)));
3944
- }, {}); },
3856
+ from: function (price, data) { return ({
3857
+ price: price,
3858
+ fullPrice: data.full_price,
3859
+ subscriberDiscountPercentage: data.subscriber_discount_percentage,
3860
+ subscriberPrice: data.subscriber_price,
3861
+ }); },
3945
3862
  bindFindFilter: function (sentence) {
3946
3863
  var filters = Object.values(sentence).shift();
3947
3864
  return Object.assign(Object.assign(Object.assign(Object.assign({}, (((filters === null || filters === void 0 ? void 0 : filters.price) || (filters === null || filters === void 0 ? void 0 : filters.price) === 0) && { price: filters.price })), ((filters.fullPrice || filters.fullPrice === 0) && { full_price: filters.fullPrice })), ((filters.subscriberDiscountPercentage || filters.subscriberDiscountPercentage === 0) && {
@@ -3950,19 +3867,15 @@
3950
3867
  subscriber_price: filters.subscriberPrice,
3951
3868
  }));
3952
3869
  },
3953
- bindPersistData: function (value) {
3954
- var priceData = Object.values(value).shift();
3955
- return Object.assign(Object.assign(Object.assign(Object.assign({}, ((priceData === null || priceData === void 0 ? void 0 : priceData.price) >= 0 && { price: priceData.price })), (priceData.fullPrice >= 0 && { full_price: priceData.fullPrice })), (priceData.subscriberDiscountPercentage >= 0 && {
3956
- subscriber_discount_percentage: priceData.subscriberDiscountPercentage,
3957
- })), (priceData.subscriberPrice >= 0 && { subscriber_price: priceData.subscriberPrice }));
3958
- },
3870
+ bindPersistData: function (priceData) { return (Object.assign(Object.assign(Object.assign(Object.assign({}, ((priceData === null || priceData === void 0 ? void 0 : priceData.price) >= 0 && { price: priceData.price })), (priceData.fullPrice >= 0 && { full_price: priceData.fullPrice })), (priceData.subscriberDiscountPercentage >= 0 && {
3871
+ subscriber_discount_percentage: priceData.subscriberDiscountPercentage,
3872
+ })), (priceData.subscriberPrice >= 0 && { subscriber_price: priceData.subscriberPrice }))); },
3959
3873
  },
3960
3874
  },
3961
3875
  { fullPrice: { columnName: 'full_price' } },
3962
3876
  { subscriberDiscountPercentage: { columnName: 'subscriber_discount_percentage' } },
3963
3877
  { subscriberPrice: { columnName: 'subscriber_price' } },
3964
3878
  'published',
3965
- { publishedGlam: { columnName: 'published_glam' } },
3966
3879
  'sku',
3967
3880
  {
3968
3881
  stock: {
@@ -3976,14 +3889,6 @@
3976
3889
  'video',
3977
3890
  'weight',
3978
3891
  'gender',
3979
- {
3980
- shopAvailability: {
3981
- columnName: 'shop_availabilities',
3982
- fields: ['shop'],
3983
- from: function (shop) { return (Array.isArray(shop) ? shop.map(function (row) { return row.shop; }) : []); },
3984
- bindPersistData: function (shops) { return ({ shop_availabilities: { data: shops.map(function (shop) { return ({ shop: shop }); }) } }); },
3985
- },
3986
- },
3987
3892
  { tags: { columnName: 'tags', type: HasuraGraphQLColumnType.Jsonb } },
3988
3893
  { isKit: { columnName: 'is_kit' } },
3989
3894
  { createdAt: { columnName: 'created_at' } },
@@ -3995,7 +3900,6 @@
3995
3900
  from: function (value) { return value.aggregate.avg.rate; },
3996
3901
  },
3997
3902
  },
3998
- { shoppingCount: { columnName: 'shopping_count' } },
3999
3903
  ];
4000
3904
  _this.fields = __spreadArray(__spreadArray([], __read(commonFields)), [
4001
3905
  {
@@ -4022,10 +3926,12 @@
4022
3926
  },
4023
3927
  },
4024
3928
  {
4025
- reviews: {
4026
- columnName: 'reviews',
4027
- foreignKeyColumn: { product_id: 'id' },
4028
- fields: _this.reviewsFields,
3929
+ metadata: {
3930
+ columnName: 'metadata',
3931
+ fields: ['title', 'description'],
3932
+ bindPersistData: function (value) { return ({
3933
+ metadata: { data: value },
3934
+ }); },
4029
3935
  },
4030
3936
  },
4031
3937
  ]);
@@ -4058,32 +3964,27 @@
4058
3964
  create: { get: function () { return _super_1.prototype.create; } }
4059
3965
  });
4060
3966
  return __awaiter(this, void 0, void 0, function () {
4061
- var product, _c, _d, error_1;
4062
- return __generator(this, function (_e) {
4063
- switch (_e.label) {
3967
+ var product, _c, error_1;
3968
+ return __generator(this, function (_d) {
3969
+ switch (_d.label) {
4064
3970
  case 0: return [4 /*yield*/, _super.create.call(this, lodash.omit(data, ['reviews']))];
4065
3971
  case 1:
4066
- product = _e.sent();
4067
- _e.label = 2;
3972
+ product = _d.sent();
3973
+ _d.label = 2;
4068
3974
  case 2:
4069
- _e.trys.push([2, 5, , 7]);
3975
+ _d.trys.push([2, 4, , 6]);
4070
3976
  _c = product;
4071
- _d = data.reviews;
4072
- if (!_d) return [3 /*break*/, 4];
4073
3977
  return [4 /*yield*/, this.updateReviews(+product.id, data)];
4074
3978
  case 3:
4075
- _d = (_e.sent());
4076
- _e.label = 4;
3979
+ _c.reviews = _d.sent();
3980
+ return [3 /*break*/, 6];
4077
3981
  case 4:
4078
- _c.reviews = _d;
4079
- return [3 /*break*/, 7];
4080
- case 5:
4081
- error_1 = _e.sent();
3982
+ error_1 = _d.sent();
4082
3983
  return [4 /*yield*/, this.delete({ id: product.id })];
4083
- case 6:
4084
- _e.sent();
3984
+ case 5:
3985
+ _d.sent();
4085
3986
  throw error_1;
4086
- case 7: return [2 /*return*/, product];
3987
+ case 6: return [2 /*return*/, product];
4087
3988
  }
4088
3989
  });
4089
3990
  });
@@ -4094,32 +3995,27 @@
4094
3995
  });
4095
3996
  var _a;
4096
3997
  return __awaiter(this, void 0, void 0, function () {
4097
- var product, _c, _d, _e;
4098
- return __generator(this, function (_f) {
4099
- switch (_f.label) {
3998
+ var product, _c, _d;
3999
+ return __generator(this, function (_e) {
4000
+ switch (_e.label) {
4100
4001
  case 0:
4101
4002
  if (!Number.isNaN(+identifiers.id)) return [3 /*break*/, 2];
4102
4003
  return [4 /*yield*/, this.find({ filters: { firestoreId: identifiers.id } })];
4103
4004
  case 1:
4104
- _c = (_a = (_f.sent()).data) === null || _a === void 0 ? void 0 : _a[0];
4005
+ _c = (_a = (_e.sent()).data) === null || _a === void 0 ? void 0 : _a[0];
4105
4006
  return [3 /*break*/, 4];
4106
4007
  case 2: return [4 /*yield*/, _super.get.call(this, identifiers)];
4107
4008
  case 3:
4108
- _c = _f.sent();
4109
- _f.label = 4;
4009
+ _c = _e.sent();
4010
+ _e.label = 4;
4110
4011
  case 4:
4111
4012
  product = _c;
4112
4013
  if (product.productId)
4113
4014
  throw new NotFoundError('Product not found, it is a variant');
4114
4015
  _d = product;
4115
- _e = product.reviews;
4116
- if (_e) return [3 /*break*/, 6];
4117
4016
  return [4 /*yield*/, this.findReviewsByProduct(+product.id)];
4118
4017
  case 5:
4119
- _e = (_f.sent());
4120
- _f.label = 6;
4121
- case 6:
4122
- _d.reviews = _e;
4018
+ _d.reviews = _e.sent();
4123
4019
  return [2 /*return*/, product];
4124
4020
  }
4125
4021
  });
@@ -4130,14 +4026,10 @@
4130
4026
  find: { get: function () { return _super_1.prototype.find; } }
4131
4027
  });
4132
4028
  return __awaiter(this, void 0, void 0, function () {
4133
- var _a, filters, fields, options, bindFields;
4029
+ var _a, filters, options;
4134
4030
  return __generator(this, function (_c) {
4135
- _a = params || {}, filters = _a.filters, fields = _a.fields, options = __rest(_a, ["filters", "fields"]);
4136
- bindFields = fields ||
4137
- this.fields
4138
- .map(function (field) { return (typeof field === 'string' ? field : Object.keys(field).shift()); })
4139
- .filter(function (field) { return field !== 'reviews'; });
4140
- return [2 /*return*/, _super.find.call(this, Object.assign(Object.assign({}, options), { filters: Object.assign(Object.assign({}, filters), { productId: { operator: exports.Where.ISNULL } }), fields: bindFields }))];
4031
+ _a = params || {}, filters = _a.filters, options = __rest(_a, ["filters"]);
4032
+ return [2 /*return*/, _super.find.call(this, Object.assign(Object.assign({}, options), { filters: Object.assign(Object.assign({}, filters), { productId: { operator: exports.Where.ISNULL } }) }))];
4141
4033
  });
4142
4034
  });
4143
4035
  };
@@ -4169,11 +4061,11 @@
4169
4061
  update: { get: function () { return _super_1.prototype.update; } }
4170
4062
  });
4171
4063
  return __awaiter(this, void 0, void 0, function () {
4172
- var categories, kitProducts, reviews, checkId, shopAvailability, rate, data, plainData, id, product, _c, _d, _e, _f, _g, _h;
4064
+ var categories, kitProducts, reviews, checkId, rate, data, plainData, id, product, _c, _d, _e, _f, _g, _h;
4173
4065
  return __generator(this, function (_j) {
4174
4066
  switch (_j.label) {
4175
4067
  case 0:
4176
- categories = params.categories, kitProducts = params.kitProducts, reviews = params.reviews, checkId = params.id, shopAvailability = params.shopAvailability, rate = params.rate, data = __rest(params, ["categories", "kitProducts", "reviews", "id", "shopAvailability", "rate"]);
4068
+ categories = params.categories, kitProducts = params.kitProducts, reviews = params.reviews, checkId = params.id, rate = params.rate, data = __rest(params, ["categories", "kitProducts", "reviews", "id", "rate"]);
4177
4069
  plainData = this.paramsToPlain({ id: checkId });
4178
4070
  return [4 /*yield*/, this.getId(plainData.id)];
4179
4071
  case 1:
@@ -4215,18 +4107,18 @@
4215
4107
  };
4216
4108
  ProductHasuraGraphQLRepository.prototype.fetchReviews = function (status) {
4217
4109
  return __awaiter(this, void 0, void 0, function () {
4218
- var reviewsExpression, data;
4110
+ var reviews, data;
4219
4111
  var _c, _d;
4220
4112
  var _this = this;
4221
4113
  return __generator(this, function (_e) {
4222
4114
  switch (_e.label) {
4223
4115
  case 0:
4224
- reviewsExpression = {
4116
+ reviews = {
4225
4117
  status: status === 'pending'
4226
4118
  ? (_c = {}, _c[HasuraGraphQLWhere.ISNULL] = true, _c) : (_d = {}, _d[HasuraGraphQLWhere.EQUALS] = status === 'approved', _d),
4227
4119
  };
4228
4120
  return [4 /*yield*/, this.query('product', ['id', 'name', 'sku', { reviews: { columnName: 'reviews', fields: this.reviewsFields } }], {
4229
- where: { value: { reviews: reviewsExpression }, type: 'product_bool_exp', required: true },
4121
+ where: { value: { reviews: reviews }, type: 'product_bool_exp', required: true },
4230
4122
  })];
4231
4123
  case 1:
4232
4124
  data = (_e.sent()).product;
@@ -4246,21 +4138,7 @@
4246
4138
  return __generator(this, function (_c) {
4247
4139
  switch (_c.label) {
4248
4140
  case 0:
4249
- if (!('action' in categories && categories.action === 'remove')) return [3 /*break*/, 2];
4250
- return [4 /*yield*/, this.mutation('delete_category_product', ['affected_rows'], {
4251
- where: {
4252
- type: 'category_product_bool_exp',
4253
- required: true,
4254
- value: { product_id: { _eq: productId } },
4255
- },
4256
- })];
4257
- case 1:
4258
- _c.sent();
4259
- return [2 /*return*/, []];
4260
- case 2:
4261
4141
  plainData = this.paramsToPlain({ categories: categories });
4262
- if (!plainData.categories || plainData.categories.length <= 0)
4263
- return [2 /*return*/, []];
4264
4142
  return [4 /*yield*/, this.mutation('delete_category_product', ['affected_rows'], {
4265
4143
  where: {
4266
4144
  type: 'category_product_bool_exp',
@@ -4268,7 +4146,7 @@
4268
4146
  value: { product_id: { _eq: productId } },
4269
4147
  },
4270
4148
  })];
4271
- case 3:
4149
+ case 1:
4272
4150
  _c.sent();
4273
4151
  return [4 /*yield*/, this.mutation('insert_category_product', ['affected_rows'], {
4274
4152
  objects: {
@@ -4277,7 +4155,7 @@
4277
4155
  value: plainData.categories.map(function (categoryId) { return ({ category_id: categoryId, product_id: productId }); }),
4278
4156
  },
4279
4157
  })];
4280
- case 4:
4158
+ case 2:
4281
4159
  _c.sent();
4282
4160
  return [2 /*return*/, plainData.categories];
4283
4161
  }
@@ -4327,6 +4205,8 @@
4327
4205
  return __generator(this, function (_c) {
4328
4206
  switch (_c.label) {
4329
4207
  case 0:
4208
+ if (!reviews)
4209
+ return [2 /*return*/, []];
4330
4210
  if (!('action' in reviews && reviews.action === 'remove')) return [3 /*break*/, 3];
4331
4211
  return [4 /*yield*/, Promise.all(reviews.value.map(function (reviewData) { return __awaiter(_this, void 0, void 0, function () {
4332
4212
  var review;
@@ -4349,8 +4229,6 @@
4349
4229
  return [2 /*return*/, reviews.value.map(function (review, index) { return !reviewIds_1[index] && review; }).filter(Boolean)];
4350
4230
  case 3:
4351
4231
  plainData = this.paramsToPlain({ reviews: reviews });
4352
- if (!plainData.reviews || plainData.reviews.length <= 0)
4353
- return [2 /*return*/, []];
4354
4232
  return [2 /*return*/, Promise.all(plainData.reviews.map(function (reviewData) { return __awaiter(_this, void 0, void 0, function () {
4355
4233
  var review, _c, _d;
4356
4234
  return __generator(this, function (_e) {
@@ -4520,15 +4398,12 @@
4520
4398
  {
4521
4399
  price: {
4522
4400
  columnName: 'price',
4523
- from: function (price, data) { return Object.values(exports.Shops).reduce(function (prices, shop) {
4524
- var _c;
4525
- return (Object.assign(Object.assign({}, prices), (_c = {}, _c[shop] = {
4526
- price: price,
4527
- fullPrice: data.full_price,
4528
- subscriberDiscountPercentage: data.subscriber_discount_percentage,
4529
- subscriberPrice: data.subscriber_price,
4530
- }, _c)));
4531
- }, {}); },
4401
+ from: function (price, data) { return ({
4402
+ price: price,
4403
+ fullPrice: data.full_price,
4404
+ subscriberDiscountPercentage: data.subscriber_discount_percentage,
4405
+ subscriberPrice: data.subscriber_price,
4406
+ }); },
4532
4407
  bindFindFilter: function (sentence) {
4533
4408
  var filters = Object.values(sentence).shift();
4534
4409
  return Object.assign(Object.assign(Object.assign(Object.assign({}, (((filters === null || filters === void 0 ? void 0 : filters.price) || (filters === null || filters === void 0 ? void 0 : filters.price) === 0) && { price: filters.price })), ((filters.fullPrice || filters.fullPrice === 0) && { full_price: filters.fullPrice })), ((filters.subscriberDiscountPercentage || filters.subscriberDiscountPercentage === 0) && {
@@ -4537,12 +4412,9 @@
4537
4412
  subscriber_price: filters.subscriberPrice,
4538
4413
  }));
4539
4414
  },
4540
- bindPersistData: function (value) {
4541
- var priceData = Object.values(value).shift();
4542
- return Object.assign(Object.assign(Object.assign(Object.assign({}, ((priceData === null || priceData === void 0 ? void 0 : priceData.price) >= 0 && { price: priceData.price })), (priceData.fullPrice >= 0 && { full_price: priceData.fullPrice })), (priceData.subscriberDiscountPercentage >= 0 && {
4543
- subscriber_discount_percentage: priceData.subscriberDiscountPercentage,
4544
- })), (priceData.subscriberPrice >= 0 && { subscriber_price: priceData.subscriberPrice }));
4545
- },
4415
+ bindPersistData: function (priceData) { return (Object.assign(Object.assign(Object.assign(Object.assign({}, ((priceData === null || priceData === void 0 ? void 0 : priceData.price) >= 0 && { price: priceData.price })), (priceData.fullPrice >= 0 && { full_price: priceData.fullPrice })), (priceData.subscriberDiscountPercentage >= 0 && {
4416
+ subscriber_discount_percentage: priceData.subscriberDiscountPercentage,
4417
+ })), (priceData.subscriberPrice >= 0 && { subscriber_price: priceData.subscriberPrice }))); },
4546
4418
  },
4547
4419
  },
4548
4420
  { fullPrice: { columnName: 'full_price' } },
@@ -4826,6 +4698,7 @@
4826
4698
  exports.UserFirestoreRepository = UserFirestoreRepository;
4827
4699
  exports.UserPaymentMethod = UserPaymentMethod;
4828
4700
  exports.UserPaymentMethodFirestoreRepository = UserPaymentMethodFirestoreRepository;
4701
+ exports.UserSearchFirestoreRepository = UserSearchFirestoreRepository;
4829
4702
  exports.Variant = Variant;
4830
4703
  exports.VariantHasuraGraphQL = VariantHasuraGraphQL;
4831
4704
  exports.VariantHasuraGraphQLRepository = VariantHasuraGraphQLRepository;