@infrab4a/connect 4.9.7-beta.28 → 4.9.7-beta.3

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 (70) hide show
  1. package/index.cjs.js +503 -943
  2. package/index.esm.js +504 -938
  3. package/package.json +1 -1
  4. package/src/domain/catalog/models/category-base.d.ts +1 -17
  5. package/src/domain/catalog/models/enums/index.d.ts +0 -1
  6. package/src/domain/catalog/models/filter.d.ts +0 -1
  7. package/src/domain/catalog/models/product-base.d.ts +1 -2
  8. package/src/domain/catalog/models/types/category-metadata.type.d.ts +0 -2
  9. package/src/domain/catalog/models/types/index.d.ts +0 -4
  10. package/src/domain/catalog/models/wishlist.d.ts +0 -3
  11. package/src/domain/catalog/repositories/category.repository.d.ts +3 -3
  12. package/src/domain/catalog/repositories/product-reviews.repository.d.ts +0 -1
  13. package/src/domain/catalog/repositories/product-stock-notification.repository.d.ts +1 -9
  14. package/src/domain/catalog/repositories/wishlist.repository.d.ts +1 -4
  15. package/src/domain/general/index.d.ts +0 -3
  16. package/src/domain/shopping/index.d.ts +0 -1
  17. package/src/domain/shopping/models/buy-2-win.d.ts +0 -2
  18. package/src/domain/shopping/models/coupons/coupon.d.ts +4 -4
  19. package/src/domain/shopping/models/coupons/enums/coupon-types.enum.d.ts +1 -2
  20. package/src/domain/shopping/models/coupons/enums/index.d.ts +1 -2
  21. package/src/domain/shopping/models/index.d.ts +0 -1
  22. package/src/domain/shopping/models/order.d.ts +0 -4
  23. package/src/domain/shopping/repositories/index.d.ts +0 -1
  24. package/src/domain/users/models/enums/index.d.ts +0 -1
  25. package/src/domain/users/models/index.d.ts +2 -3
  26. package/src/infra/elasticsearch/indexes/products-index.d.ts +1 -37
  27. package/src/infra/firebase/firestore/mixins/with-helpers.mixin.d.ts +1 -1
  28. package/src/infra/firebase/firestore/repositories/catalog/category-firestore.repository.d.ts +2 -2
  29. package/src/infra/firebase/firestore/repositories/index.d.ts +2 -3
  30. package/src/infra/firebase/firestore/repositories/shopping/index.d.ts +0 -1
  31. package/src/infra/hasura-graphql/mixins/with-find-hasura-graphql.mixin.d.ts +0 -1
  32. package/src/infra/hasura-graphql/repositories/catalog/category-hasura-graphql.repository.d.ts +2 -2
  33. package/src/infra/hasura-graphql/repositories/catalog/product-review-hasura-graphql.repository.d.ts +0 -1
  34. package/src/infra/hasura-graphql/repositories/catalog/product-stock-notification-hasura-graphql.repository.d.ts +1 -8
  35. package/src/infra/hasura-graphql/repositories/catalog/wishlist-hasura-graphql.repository.d.ts +11 -13
  36. package/src/infra/index.d.ts +0 -1
  37. package/src/domain/catalog/models/enums/wishlist-log.enum.d.ts +0 -7
  38. package/src/domain/catalog/models/types/category-images.type.d.ts +0 -8
  39. package/src/domain/catalog/models/types/category-most-relevant.type.d.ts +0 -4
  40. package/src/domain/catalog/models/types/product-label.type.d.ts +0 -1
  41. package/src/domain/catalog/models/types/report-stock-notification.type.d.ts +0 -21
  42. package/src/domain/general/models/index.d.ts +0 -1
  43. package/src/domain/general/models/log-document.d.ts +0 -15
  44. package/src/domain/general/repositories/index.d.ts +0 -1
  45. package/src/domain/general/repositories/log.repository.d.ts +0 -4
  46. package/src/domain/general/search/index.d.ts +0 -1
  47. package/src/domain/general/search/product-search-index.d.ts +0 -3
  48. package/src/domain/shopping/models/coupons/enums/coupon-category.enum.d.ts +0 -17
  49. package/src/domain/shopping/models/order-blocked.d.ts +0 -26
  50. package/src/domain/shopping/repositories/order-blocked.repository.d.ts +0 -6
  51. package/src/domain/shopping/types/index.d.ts +0 -2
  52. package/src/domain/shopping/types/order-tracking-events.type.d.ts +0 -14
  53. package/src/domain/shopping/types/payment-card-info.type.d.ts +0 -4
  54. package/src/domain/users/models/enums/person-types.enum.d.ts +0 -5
  55. package/src/domain/users/models/types/index.d.ts +0 -1
  56. package/src/domain/users/models/types/person.type.d.ts +0 -2
  57. package/src/infra/firebase/firestore/repositories/general/index.d.ts +0 -1
  58. package/src/infra/firebase/firestore/repositories/general/log-firestore.repository.d.ts +0 -7
  59. package/src/infra/firebase/firestore/repositories/shopping/order-blocked-firestore.repository.ts.d.ts +0 -9
  60. package/src/infra/hasura-graphql/models/wishlist-hasura-graphql.d.ts +0 -4
  61. package/src/infra/vertex-ai/adapters/index.d.ts +0 -2
  62. package/src/infra/vertex-ai/adapters/vertex-ai-search.adapter.d.ts +0 -10
  63. package/src/infra/vertex-ai/adapters/vertex-axios.adapter.d.ts +0 -15
  64. package/src/infra/vertex-ai/index.d.ts +0 -3
  65. package/src/infra/vertex-ai/indexes/index.d.ts +0 -1
  66. package/src/infra/vertex-ai/indexes/products-vertex-search.d.ts +0 -13
  67. package/src/infra/vertex-ai/types/axios-vertex-search-config.d.ts +0 -4
  68. package/src/infra/vertex-ai/types/index.d.ts +0 -3
  69. package/src/infra/vertex-ai/types/product-bulk.d.ts +0 -4
  70. package/src/infra/vertex-ai/types/product-search.d.ts +0 -21
package/index.esm.js CHANGED
@@ -36,30 +36,6 @@ class BaseModel {
36
36
  }
37
37
  }
38
38
 
39
- var GenderDestination;
40
- (function (GenderDestination) {
41
- GenderDestination["FEMALE"] = "female";
42
- GenderDestination["MALE"] = "male";
43
- GenderDestination["UNISEX"] = "unisex";
44
- })(GenderDestination || (GenderDestination = {}));
45
-
46
- var Shops;
47
- (function (Shops) {
48
- Shops["MENSMARKET"] = "mensmarket";
49
- Shops["GLAMSHOP"] = "Glamshop";
50
- Shops["GLAMPOINTS"] = "Glampoints";
51
- Shops["ALL"] = "ALL";
52
- })(Shops || (Shops = {}));
53
-
54
- var WishlistLogType;
55
- (function (WishlistLogType) {
56
- WishlistLogType["CREATE"] = "create";
57
- WishlistLogType["UPDATE"] = "update";
58
- WishlistLogType["DELETE"] = "delete";
59
- WishlistLogType["ADD_PRODUCT"] = "add_product";
60
- WishlistLogType["REMOVE_PRODUCT"] = "remove_product";
61
- })(WishlistLogType || (WishlistLogType = {}));
62
-
63
39
  class Filter extends BaseModel {
64
40
  static get identifiersFields() {
65
41
  return ['id'];
@@ -74,33 +50,6 @@ class CategoryBase extends BaseModel {
74
50
  static get identifiersFields() {
75
51
  return ['id'];
76
52
  }
77
- get glamImages() {
78
- return this.images && this.images[Shops.GLAMSHOP]
79
- ? this.images[Shops.GLAMSHOP]
80
- : {
81
- brandBanner: null,
82
- brandBannerMobile: null,
83
- image: null,
84
- };
85
- }
86
- get mensImages() {
87
- return this.images && this.images[Shops.MENSMARKET]
88
- ? this.images[Shops.MENSMARKET]
89
- : {
90
- brandBanner: null,
91
- brandBannerMobile: null,
92
- image: null,
93
- };
94
- }
95
- get glamMetadata() {
96
- return this.metadatas.find((metadata) => metadata.shop === Shops.GLAMSHOP);
97
- }
98
- get mensMetadata() {
99
- return this.metadatas.find((metadata) => metadata.shop === Shops.MENSMARKET);
100
- }
101
- getMostRelevantByShop(shop) {
102
- return this.mostRelevants && this.mostRelevants[shop] ? this.mostRelevants[shop] : [];
103
- }
104
53
  }
105
54
  __decorate([
106
55
  Type(() => CategoryBase),
@@ -209,6 +158,21 @@ __decorate([
209
158
  __metadata("design:type", Category)
210
159
  ], CategoryFilter.prototype, "category", void 0);
211
160
 
161
+ var GenderDestination;
162
+ (function (GenderDestination) {
163
+ GenderDestination["FEMALE"] = "female";
164
+ GenderDestination["MALE"] = "male";
165
+ GenderDestination["UNISEX"] = "unisex";
166
+ })(GenderDestination || (GenderDestination = {}));
167
+
168
+ var Shops;
169
+ (function (Shops) {
170
+ Shops["MENSMARKET"] = "mensmarket";
171
+ Shops["GLAMSHOP"] = "Glamshop";
172
+ Shops["GLAMPOINTS"] = "Glampoints";
173
+ Shops["ALL"] = "ALL";
174
+ })(Shops || (Shops = {}));
175
+
212
176
  class FilterOption extends BaseModel {
213
177
  static get identifiersFields() {
214
178
  return ['id'];
@@ -301,17 +265,6 @@ class CampaignHashtag extends BaseModel {
301
265
  }
302
266
  }
303
267
 
304
- class BeautyProfile extends BaseModel {
305
- toPlain() {
306
- const plain = super.toPlain();
307
- delete plain.id;
308
- return plain;
309
- }
310
- static get identifiersFields() {
311
- return ['id', 'userId'];
312
- }
313
- }
314
-
315
268
  var AccessoryImportances;
316
269
  (function (AccessoryImportances) {
317
270
  AccessoryImportances["NOT_INTERESTED"] = "N\u00E3o tenho interesse";
@@ -488,13 +441,6 @@ var OfficePosition;
488
441
  OfficePosition["Director"] = "Diretor";
489
442
  })(OfficePosition || (OfficePosition = {}));
490
443
 
491
- var PersonTypes;
492
- (function (PersonTypes) {
493
- PersonTypes["GLAMGIRL"] = "glamgirl";
494
- PersonTypes["BFLU"] = "bflu";
495
- PersonTypes["NONE"] = "none";
496
- })(PersonTypes || (PersonTypes = {}));
497
-
498
444
  var ProductSpents;
499
445
  (function (ProductSpents) {
500
446
  ProductSpents["UNTIL_50"] = "At\u00E9 R$50";
@@ -515,12 +461,6 @@ var UserType;
515
461
  UserType["Influencer"] = "Influencer";
516
462
  })(UserType || (UserType = {}));
517
463
 
518
- class Lead extends BaseModel {
519
- static get identifiersFields() {
520
- return ['id'];
521
- }
522
- }
523
-
524
464
  class Edition extends BaseModel {
525
465
  static get identifiersFields() {
526
466
  return ['id', 'subscriptionId'];
@@ -1846,6 +1786,40 @@ const parseDateTime = (value) => {
1846
1786
  return date;
1847
1787
  };
1848
1788
 
1789
+ var CheckoutTypes;
1790
+ (function (CheckoutTypes) {
1791
+ CheckoutTypes[CheckoutTypes["ECOMMERCE"] = 1] = "ECOMMERCE";
1792
+ CheckoutTypes[CheckoutTypes["SUBSCRIPTION"] = 2] = "SUBSCRIPTION";
1793
+ CheckoutTypes[CheckoutTypes["ALL"] = 3] = "ALL";
1794
+ })(CheckoutTypes || (CheckoutTypes = {}));
1795
+
1796
+ var CouponTypes;
1797
+ (function (CouponTypes) {
1798
+ CouponTypes[CouponTypes["ABSOLUTE"] = 1] = "ABSOLUTE";
1799
+ CouponTypes[CouponTypes["PERCENTAGE"] = 2] = "PERCENTAGE";
1800
+ // FINANCIAL = 1,
1801
+ // PRODUCT,
1802
+ // GIFTCARD,
1803
+ // VOUCHER,
1804
+ })(CouponTypes || (CouponTypes = {}));
1805
+
1806
+ var CouponSubtypes;
1807
+ (function (CouponSubtypes) {
1808
+ CouponSubtypes[CouponSubtypes["ABSOLUTE"] = 1] = "ABSOLUTE";
1809
+ CouponSubtypes[CouponSubtypes["PERCENTAGE"] = 2] = "PERCENTAGE";
1810
+ })(CouponSubtypes || (CouponSubtypes = {}));
1811
+
1812
+ var Exclusivities;
1813
+ (function (Exclusivities) {
1814
+ Exclusivities[Exclusivities["ALL_USERS"] = 1] = "ALL_USERS";
1815
+ Exclusivities[Exclusivities["SPECIFIC_USER"] = 2] = "SPECIFIC_USER";
1816
+ Exclusivities[Exclusivities["COLLABORATORS"] = 3] = "COLLABORATORS";
1817
+ Exclusivities[Exclusivities["ACTIVE_SUBSCRIBER"] = 4] = "ACTIVE_SUBSCRIBER";
1818
+ Exclusivities[Exclusivities["INACTIVE_SUBSCRIBER"] = 5] = "INACTIVE_SUBSCRIBER";
1819
+ Exclusivities[Exclusivities["NON_SUBSCRIBER"] = 6] = "NON_SUBSCRIBER";
1820
+ })(Exclusivities || (Exclusivities = {}));
1821
+
1822
+ const COUPON_EXPIRATION = +1000 * 60 * 60 * 24 * 30;
1849
1823
  class Coupon extends BaseModel {
1850
1824
  get isInfluencer() {
1851
1825
  return !isNil(this.influencerEmail);
@@ -1853,6 +1827,30 @@ class Coupon extends BaseModel {
1853
1827
  static get identifiersFields() {
1854
1828
  return ['id'];
1855
1829
  }
1830
+ static createCoupon(userId) {
1831
+ return this.toInstance({
1832
+ nickname: `${Date.now()}`,
1833
+ checkoutType: CheckoutTypes.ECOMMERCE,
1834
+ discount: {
1835
+ subscriber: {
1836
+ type: CouponTypes.ABSOLUTE,
1837
+ value: 10,
1838
+ },
1839
+ non_subscriber: {
1840
+ type: CouponTypes.ABSOLUTE,
1841
+ value: 10,
1842
+ },
1843
+ subscription: {
1844
+ type: CouponTypes.ABSOLUTE,
1845
+ value: 10,
1846
+ },
1847
+ },
1848
+ user: userId,
1849
+ createdAt: new Date(Date.now()),
1850
+ beginAt: new Date(Date.now()),
1851
+ expiresIn: new Date(Date.now() + COUPON_EXPIRATION),
1852
+ });
1853
+ }
1856
1854
  }
1857
1855
 
1858
1856
  class SubscriptionPlan extends BaseModel {
@@ -1861,6 +1859,17 @@ class SubscriptionPlan extends BaseModel {
1861
1859
  }
1862
1860
  }
1863
1861
 
1862
+ class BeautyProfile extends BaseModel {
1863
+ toPlain() {
1864
+ const plain = super.toPlain();
1865
+ delete plain.id;
1866
+ return plain;
1867
+ }
1868
+ static get identifiersFields() {
1869
+ return ['id', 'userId'];
1870
+ }
1871
+ }
1872
+
1864
1873
  class User extends BaseModel {
1865
1874
  static toInstance(data) {
1866
1875
  const instance = super.toInstance(data);
@@ -1974,6 +1983,12 @@ class UserPaymentMethod extends BaseModel {
1974
1983
  }
1975
1984
  }
1976
1985
 
1986
+ class Lead extends BaseModel {
1987
+ static get identifiersFields() {
1988
+ return ['id'];
1989
+ }
1990
+ }
1991
+
1977
1992
  class UnauthorizedError extends CustomError {
1978
1993
  constructor(message) {
1979
1994
  super(message);
@@ -2127,55 +2142,6 @@ __decorate([
2127
2142
  __metadata("design:type", Coupon)
2128
2143
  ], Checkout.prototype, "coupon", void 0);
2129
2144
 
2130
- var CouponCategory;
2131
- (function (CouponCategory) {
2132
- CouponCategory["Reembolso"] = "Reembolso";
2133
- CouponCategory["Desculpas"] = "Desculpas";
2134
- CouponCategory["BFlu"] = "BFlu";
2135
- CouponCategory["ROYAL"] = "Royal";
2136
- CouponCategory["Glamqueen"] = "Glamqueen";
2137
- CouponCategory["Glampartner"] = "Glampartner";
2138
- CouponCategory["Glamgirl"] = "Glamgirl";
2139
- CouponCategory["Glamdiva"] = "Glamdiva";
2140
- CouponCategory["Impulsionamento"] = "Impulsionamento";
2141
- CouponCategory["PaidMedia"] = "Paid Media";
2142
- CouponCategory["Organic"] = "Organic";
2143
- CouponCategory["Direct"] = "Direct";
2144
- CouponCategory["CRM"] = "CRM";
2145
- CouponCategory["LOJAUNICO"] = "Loja \u00FAnico";
2146
- CouponCategory["Outros"] = "Outros";
2147
- })(CouponCategory || (CouponCategory = {}));
2148
-
2149
- var CouponSubtypes;
2150
- (function (CouponSubtypes) {
2151
- CouponSubtypes[CouponSubtypes["ABSOLUTE"] = 1] = "ABSOLUTE";
2152
- CouponSubtypes[CouponSubtypes["PERCENTAGE"] = 2] = "PERCENTAGE";
2153
- })(CouponSubtypes || (CouponSubtypes = {}));
2154
-
2155
- var CouponTypes;
2156
- (function (CouponTypes) {
2157
- CouponTypes[CouponTypes["ABSOLUTE"] = 1] = "ABSOLUTE";
2158
- CouponTypes[CouponTypes["PERCENTAGE"] = 2] = "PERCENTAGE";
2159
- CouponTypes[CouponTypes["SHIPPING"] = 3] = "SHIPPING";
2160
- })(CouponTypes || (CouponTypes = {}));
2161
-
2162
- var Exclusivities;
2163
- (function (Exclusivities) {
2164
- Exclusivities[Exclusivities["ALL_USERS"] = 1] = "ALL_USERS";
2165
- Exclusivities[Exclusivities["SPECIFIC_USER"] = 2] = "SPECIFIC_USER";
2166
- Exclusivities[Exclusivities["COLLABORATORS"] = 3] = "COLLABORATORS";
2167
- Exclusivities[Exclusivities["ACTIVE_SUBSCRIBER"] = 4] = "ACTIVE_SUBSCRIBER";
2168
- Exclusivities[Exclusivities["INACTIVE_SUBSCRIBER"] = 5] = "INACTIVE_SUBSCRIBER";
2169
- Exclusivities[Exclusivities["NON_SUBSCRIBER"] = 6] = "NON_SUBSCRIBER";
2170
- })(Exclusivities || (Exclusivities = {}));
2171
-
2172
- var CheckoutTypes;
2173
- (function (CheckoutTypes) {
2174
- CheckoutTypes[CheckoutTypes["ECOMMERCE"] = 1] = "ECOMMERCE";
2175
- CheckoutTypes[CheckoutTypes["SUBSCRIPTION"] = 2] = "SUBSCRIPTION";
2176
- CheckoutTypes[CheckoutTypes["ALL"] = 3] = "ALL";
2177
- })(CheckoutTypes || (CheckoutTypes = {}));
2178
-
2179
2145
  var OrderStatus;
2180
2146
  (function (OrderStatus) {
2181
2147
  OrderStatus["AGUARDANDO_PAGAMENTO"] = "Aguardando pagamento";
@@ -2195,12 +2161,6 @@ __decorate([
2195
2161
  __metadata("design:type", Payment)
2196
2162
  ], Order.prototype, "payment", void 0);
2197
2163
 
2198
- class OrderBlocked extends BaseModel {
2199
- static get identifiersFields() {
2200
- return ['id'];
2201
- }
2202
- }
2203
-
2204
2164
  class CheckoutSubscription extends BaseModel {
2205
2165
  static get identifiersFields() {
2206
2166
  return ['id'];
@@ -2237,12 +2197,6 @@ class RoundProductPricesHelper {
2237
2197
  }
2238
2198
  }
2239
2199
 
2240
- class LogDocument extends BaseModel {
2241
- static get identifiersFields() {
2242
- return ['id'];
2243
- }
2244
- }
2245
-
2246
2200
  var FilterType;
2247
2201
  (function (FilterType) {
2248
2202
  FilterType["ACCESSORY_IMPORTANCE"] = "accessoryImportance";
@@ -2541,6 +2495,8 @@ class ProductsIndex {
2541
2495
  'rate',
2542
2496
  ];
2543
2497
  const filter = [{ term: { published: true } }];
2498
+ if (shop && shop !== Shops.ALL)
2499
+ filter.push({ term: { tags: shop == Shops.GLAMSHOP ? 'feminino' : 'masculino' } });
2544
2500
  if (size > 9)
2545
2501
  fields.push(...['pricePaid', 'isGift', 'stock', 'weight', 'tags']);
2546
2502
  const query = {
@@ -2596,9 +2552,7 @@ class ProductsIndex {
2596
2552
  RoundProductPricesHelper.roundProductPrices(hit._source);
2597
2553
  return hit;
2598
2554
  });
2599
- return search.hits.map((hit) => {
2600
- return Object.assign(Object.assign({}, hit._source), { stock: hit._source.stock.quantity });
2601
- });
2555
+ return search;
2602
2556
  }
2603
2557
  async save(product) {
2604
2558
  try {
@@ -3032,8 +2986,6 @@ const withUpdateFirestore = (MixinBase) => {
3032
2986
  try {
3033
2987
  const identifiers = getValueFromParams(data, keyField);
3034
2988
  const docRef = this.collection(collectionName).getDoc(identifiers.toString());
3035
- if (!(await docRef.get()).data())
3036
- throw new NotFoundError(`Document '${collectionName}/${Object.values(identifiers.toString())}' not found`);
3037
2989
  const plainFromData = this.model.toInstance(this.paramsToPlain(data));
3038
2990
  const intercepted = await ((_b = (_a = this.interceptors) === null || _a === void 0 ? void 0 : _a.request) === null || _b === void 0 ? void 0 : _b.call(_a, { instance: plainFromData }));
3039
2991
  const builded = (intercepted === null || intercepted === void 0 ? void 0 : intercepted.instance) || plainFromData;
@@ -3110,280 +3062,359 @@ const withCrudFirestore = (MixinBase) => {
3110
3062
  };
3111
3063
  };
3112
3064
 
3113
- class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3065
+ class LeadFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3114
3066
  constructor({ firestore, interceptors }) {
3115
3067
  super({
3116
3068
  firestore,
3117
- collectionName: 'categories',
3118
- model: Category,
3069
+ collectionName: 'leads',
3070
+ model: Lead,
3119
3071
  interceptors,
3120
3072
  });
3121
3073
  }
3122
- async getCategoryBySlug(slug, shop) {
3123
- const categoryDocs = await this.collection(this.collectionName)
3124
- .where('slug', '==', slug)
3125
- .where('shop', '==', shop)
3126
- .where('published', '==', true)
3127
- .getDocs();
3128
- if (categoryDocs.size > 1)
3129
- throw new DuplicatedResultsError('Query returned duplicated values');
3130
- if (categoryDocs.empty)
3131
- throw new NotFoundError(`Document with slug ${slug} not found`);
3132
- return categoryDocs.docs[0].data();
3133
- }
3134
- async getCategoriesForHome(categoryIds, shop, limit = 4) {
3135
- const categorySnap = await this.collection(this.collectionName)
3136
- .where('id', 'in', categoryIds.filter(Boolean))
3137
- .where('published', '==', true)
3138
- .getDocs();
3139
- if (categorySnap.empty)
3140
- throw new NotFoundError('Categories not found');
3141
- const categories = categorySnap.docs.map((doc) => doc.data());
3142
- const homeSections = await Promise.all(categories.map(async (category) => ({
3143
- category,
3144
- products: await this.mountCategory(category, shop, { limit, hasStock: true }),
3145
- })));
3146
- return homeSections;
3147
- }
3148
- async mountCategory(category, shop, options) {
3149
- if (!category.products)
3150
- throw new RequiredArgumentError(['Category products is empty']);
3151
- const chunks = chunk(category.products, 10);
3152
- const products = [];
3153
- const wheres = [];
3154
- for (const productIds of chunks) {
3155
- if ((options === null || options === void 0 ? void 0 : options.limit) && products.length >= (options === null || options === void 0 ? void 0 : options.limit))
3156
- break;
3157
- wheres.push(['published', '==', true], ['id', 'in', productIds]);
3158
- if (options === null || options === void 0 ? void 0 : options.hasStock)
3159
- wheres.push(['stock.quantity', '>', 0]);
3160
- if (options === null || options === void 0 ? void 0 : options.gender)
3161
- wheres.push(['tags', 'array-contains', options === null || options === void 0 ? void 0 : options.gender]);
3162
- const productSnap = await wheres
3163
- .reduce((collection, where) => collection.where(...where), (options === null || options === void 0 ? void 0 : options.limit)
3164
- ? this.collection('productsErpVitrine').limit(options.limit)
3165
- : this.collection('productsErpVitrine'))
3166
- .getDocs();
3167
- if (productSnap.empty)
3168
- continue;
3169
- products.push(...productSnap.docs);
3170
- }
3171
- return is(products);
3172
- }
3173
- getCategoryByShop(shop) {
3174
- return;
3175
- }
3176
- getChildren(parentId) {
3177
- return;
3074
+ }
3075
+
3076
+ class SubscriptionEditionFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
3077
+ constructor({ firestore, interceptors }, parentRepository) {
3078
+ super({
3079
+ firestore,
3080
+ collectionName: 'editions',
3081
+ parentIdField: 'subscriptionId',
3082
+ model: Edition,
3083
+ interceptors,
3084
+ });
3085
+ this.parentRepository = parentRepository;
3178
3086
  }
3179
- isChild(id, parentId) {
3180
- return;
3087
+ }
3088
+
3089
+ class SubscriptionFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3090
+ constructor({ firestore, interceptors, }) {
3091
+ super({
3092
+ firestore,
3093
+ collectionName: 'subscription',
3094
+ model: Subscription,
3095
+ interceptors,
3096
+ });
3181
3097
  }
3182
3098
  }
3183
- __decorate([
3184
- Log(),
3185
- __metadata("design:type", Function),
3186
- __metadata("design:paramtypes", [String, String]),
3187
- __metadata("design:returntype", Promise)
3188
- ], CategoryFirestoreRepository.prototype, "getCategoryBySlug", null);
3189
- __decorate([
3190
- Log(),
3191
- __metadata("design:type", Function),
3192
- __metadata("design:paramtypes", [Array, String, Object]),
3193
- __metadata("design:returntype", Promise)
3194
- ], CategoryFirestoreRepository.prototype, "getCategoriesForHome", null);
3195
- __decorate([
3196
- Log(),
3197
- __metadata("design:type", Function),
3198
- __metadata("design:paramtypes", [Category, String, Object]),
3199
- __metadata("design:returntype", Promise)
3200
- ], CategoryFirestoreRepository.prototype, "mountCategory", null);
3201
3099
 
3202
- class ProductFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3100
+ class SubscriptionMaterializationFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3203
3101
  constructor({ firestore, interceptors }) {
3204
3102
  super({
3205
3103
  firestore,
3206
- collectionName: 'productsErpVitrine',
3207
- model: Product,
3104
+ collectionName: 'subscriptionMaterialization',
3105
+ model: SubscriptionMaterialization,
3208
3106
  interceptors,
3209
3107
  });
3210
- this.reviews = {};
3211
3108
  }
3212
- fetchProductReviews(filters) {
3213
- throw new Error('Method not implemented.');
3109
+ }
3110
+
3111
+ class SubscriptionPaymentFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
3112
+ constructor({ firestore, interceptors }, parentRepository) {
3113
+ super({
3114
+ firestore,
3115
+ collectionName: 'payments',
3116
+ parentIdField: 'subscriptionId',
3117
+ model: SubscriptionPayment,
3118
+ interceptors,
3119
+ });
3120
+ this.parentRepository = parentRepository;
3214
3121
  }
3215
- async getBySlug(slug) {
3216
- var _a;
3217
- const result = await this.find({
3218
- filters: {
3219
- slug: { operator: Where.EQUALS, value: slug },
3220
- },
3122
+ }
3123
+
3124
+ class SubscriptionSummaryFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3125
+ constructor({ firestore, interceptors, }) {
3126
+ super({
3127
+ firestore,
3128
+ collectionName: 'subscriptionSummary',
3129
+ model: SubscriptionSummary,
3130
+ interceptors,
3221
3131
  });
3222
- return (_a = result === null || result === void 0 ? void 0 : result.data) === null || _a === void 0 ? void 0 : _a.shift();
3223
3132
  }
3224
- async fetchReviews(status) {
3225
- const { data: products } = await this.find();
3226
- products.forEach((product) => {
3227
- var _a;
3228
- if ([undefined, 0].includes((_a = product.reviews) === null || _a === void 0 ? void 0 : _a.length))
3229
- return;
3230
- const productInfo = {
3231
- productId: product.id,
3232
- productName: product.name,
3233
- productSku: product.sku,
3234
- };
3235
- this.reviews.pending = [];
3236
- this.reviews.approved = [];
3237
- this.reviews.rejected = [];
3238
- product.reviews.forEach((review) => {
3239
- if ([null, undefined].includes(review.status))
3240
- return this.reviews.pending.push(Object.assign(Object.assign({}, review), productInfo));
3241
- if (review.status === false)
3242
- return this.reviews.rejected.push(Object.assign(Object.assign({}, review), productInfo));
3243
- if (!!review.status)
3244
- return this.reviews.approved.push(Object.assign(Object.assign({}, review), productInfo));
3245
- return review;
3246
- });
3133
+ }
3134
+
3135
+ class UserAddressFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
3136
+ constructor({ firestore, interceptors }, parentRepository) {
3137
+ super({
3138
+ firestore,
3139
+ collectionName: 'address',
3140
+ parentIdField: 'userId',
3141
+ model: UserAddress,
3142
+ interceptors,
3247
3143
  });
3248
- return this.reviews[status];
3144
+ this.parentRepository = parentRepository;
3249
3145
  }
3250
- cleanShoppingCountFromIds() {
3251
- return;
3146
+ }
3147
+
3148
+ class UserBeautyProfileFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
3149
+ constructor({ firestore, interceptors }, parentRepository) {
3150
+ super({
3151
+ firestore,
3152
+ collectionName: 'CX',
3153
+ parentIdField: 'userId',
3154
+ model: BeautyProfile,
3155
+ interceptors,
3156
+ });
3157
+ this.parentRepository = parentRepository;
3252
3158
  }
3253
- findCatalog(params) {
3254
- return this.find(params);
3159
+ }
3160
+
3161
+ class UserFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3162
+ constructor({ firestore, interceptors }) {
3163
+ super({
3164
+ firestore,
3165
+ collectionName: 'users',
3166
+ model: User,
3167
+ interceptors,
3168
+ });
3255
3169
  }
3256
- async fetchPaginatedReviews() {
3257
- return Promise.resolve([]);
3170
+ async get(identifiers) {
3171
+ const user = await super.get({ id: identifiers.id });
3172
+ user.beautyProfile = await this.getBeautyProfile(user.id);
3173
+ user.isSubscriber = await this.checkIfIsSubscriber(user.id);
3174
+ return user;
3175
+ }
3176
+ async checkIfExistsByField(field, value) {
3177
+ const result = await this.find({ filters: { [field]: value } });
3178
+ return result.count > 0;
3179
+ }
3180
+ buildModelInstance() {
3181
+ const { fromFirestore, toFirestore } = super.buildModelInstance();
3182
+ return {
3183
+ toFirestore: (data) => {
3184
+ const plain = toFirestore(data);
3185
+ delete plain.isSubscriber;
3186
+ return plain;
3187
+ },
3188
+ fromFirestore,
3189
+ };
3190
+ }
3191
+ async getBeautyProfile(userId) {
3192
+ const beautyProfile = await this.firestore
3193
+ .getCollection(`${this.collectionName}/${userId}/CX`)
3194
+ .withConverter(this.buildBeautyProfileModelInstance())
3195
+ .getDoc('beautyProfile')
3196
+ .get();
3197
+ return beautyProfile.data();
3198
+ }
3199
+ async checkIfIsSubscriber(userId) {
3200
+ const docs = await this.collection('subscription')
3201
+ .where('user.id', '==', userId)
3202
+ .where('status', '==', 'active')
3203
+ .getDocs();
3204
+ return !!docs && !!docs.size;
3205
+ }
3206
+ buildBeautyProfileModelInstance() {
3207
+ return {
3208
+ toFirestore: (data) => data.toPlain(),
3209
+ fromFirestore: (snap) => BeautyProfile.toInstance(snap.data()),
3210
+ };
3258
3211
  }
3259
3212
  }
3260
3213
  __decorate([
3261
3214
  Log(),
3262
3215
  __metadata("design:type", Function),
3263
- __metadata("design:paramtypes", [String]),
3216
+ __metadata("design:paramtypes", [Object]),
3264
3217
  __metadata("design:returntype", Promise)
3265
- ], ProductFirestoreRepository.prototype, "getBySlug", null);
3218
+ ], UserFirestoreRepository.prototype, "get", null);
3266
3219
  __decorate([
3267
3220
  Log(),
3268
3221
  __metadata("design:type", Function),
3269
- __metadata("design:paramtypes", [String]),
3222
+ __metadata("design:paramtypes", [String, String]),
3270
3223
  __metadata("design:returntype", Promise)
3271
- ], ProductFirestoreRepository.prototype, "fetchReviews", null);
3224
+ ], UserFirestoreRepository.prototype, "checkIfExistsByField", null);
3272
3225
 
3273
- class ProductVariantFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
3226
+ class UserPaymentMethodFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
3274
3227
  constructor({ firestore, interceptors }, parentRepository) {
3275
3228
  super({
3276
3229
  firestore,
3277
- collectionName: 'variants',
3278
- parentIdField: 'productId',
3279
- model: Variant,
3230
+ collectionName: 'payment_method',
3231
+ parentIdField: 'userId',
3232
+ model: UserPaymentMethod,
3280
3233
  interceptors,
3281
3234
  });
3282
3235
  this.parentRepository = parentRepository;
3283
3236
  }
3284
3237
  }
3285
3238
 
3286
- class SubscriptionProductFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3239
+ class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3287
3240
  constructor({ firestore, interceptors }) {
3288
3241
  super({
3289
3242
  firestore,
3290
- collectionName: 'subscriptionProducts',
3291
- model: Product,
3243
+ collectionName: 'categories',
3244
+ model: Category,
3292
3245
  interceptors,
3293
3246
  });
3294
3247
  }
3295
- }
3296
-
3297
- class LogFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3298
- constructor({ firestore, interceptors, }) {
3299
- super({
3300
- firestore,
3301
- collectionName: 'logs',
3302
- model: LogDocument,
3303
- interceptors,
3304
- });
3248
+ async getCategoryBySlug(slug, shop) {
3249
+ const categoryDocs = await this.collection(this.collectionName)
3250
+ .where('slug', '==', slug)
3251
+ .where('shop', '==', shop)
3252
+ .where('published', '==', true)
3253
+ .getDocs();
3254
+ if (categoryDocs.size > 1)
3255
+ throw new DuplicatedResultsError('Query returned duplicated values');
3256
+ if (categoryDocs.empty)
3257
+ throw new NotFoundError(`Document with slug ${slug} not found`);
3258
+ return categoryDocs.docs[0].data();
3259
+ }
3260
+ async getCategoriesForHome(categoryIds, limit = 4, gender) {
3261
+ const categorySnap = await this.collection(this.collectionName)
3262
+ .where('id', 'in', categoryIds.filter(Boolean))
3263
+ .where('published', '==', true)
3264
+ .getDocs();
3265
+ if (categorySnap.empty)
3266
+ throw new NotFoundError('Categories not found');
3267
+ const categories = categorySnap.docs.map((doc) => doc.data());
3268
+ const homeSections = await Promise.all(categories.map(async (category) => ({
3269
+ category,
3270
+ products: await this.mountCategory(category, { limit, hasStock: true, gender }),
3271
+ })));
3272
+ return homeSections;
3273
+ }
3274
+ async mountCategory(category, options) {
3275
+ if (!category.products)
3276
+ throw new RequiredArgumentError(['Category products is empty']);
3277
+ const chunks = chunk(category.products, 10);
3278
+ const products = [];
3279
+ const wheres = [];
3280
+ for (const productIds of chunks) {
3281
+ if ((options === null || options === void 0 ? void 0 : options.limit) && products.length >= (options === null || options === void 0 ? void 0 : options.limit))
3282
+ break;
3283
+ wheres.push(['published', '==', true], ['id', 'in', productIds]);
3284
+ if (options === null || options === void 0 ? void 0 : options.hasStock)
3285
+ wheres.push(['stock.quantity', '>', 0]);
3286
+ if (options === null || options === void 0 ? void 0 : options.gender)
3287
+ wheres.push(['tags', 'array-contains', options === null || options === void 0 ? void 0 : options.gender]);
3288
+ const productSnap = await wheres
3289
+ .reduce((collection, where) => collection.where(...where), (options === null || options === void 0 ? void 0 : options.limit)
3290
+ ? this.collection('productsErpVitrine').limit(options.limit)
3291
+ : this.collection('productsErpVitrine'))
3292
+ .getDocs();
3293
+ if (productSnap.empty)
3294
+ continue;
3295
+ products.push(...productSnap.docs);
3296
+ }
3297
+ return is(products);
3298
+ }
3299
+ getCategoryByShop(shop) {
3300
+ return;
3301
+ }
3302
+ getChildren(parentId) {
3303
+ return;
3304
+ }
3305
+ isChild(id, parentId) {
3306
+ return;
3305
3307
  }
3306
3308
  }
3309
+ __decorate([
3310
+ Log(),
3311
+ __metadata("design:type", Function),
3312
+ __metadata("design:paramtypes", [String, String]),
3313
+ __metadata("design:returntype", Promise)
3314
+ ], CategoryFirestoreRepository.prototype, "getCategoryBySlug", null);
3315
+ __decorate([
3316
+ Log(),
3317
+ __metadata("design:type", Function),
3318
+ __metadata("design:paramtypes", [Array, Object, String]),
3319
+ __metadata("design:returntype", Promise)
3320
+ ], CategoryFirestoreRepository.prototype, "getCategoriesForHome", null);
3321
+ __decorate([
3322
+ Log(),
3323
+ __metadata("design:type", Function),
3324
+ __metadata("design:paramtypes", [Category, Object]),
3325
+ __metadata("design:returntype", Promise)
3326
+ ], CategoryFirestoreRepository.prototype, "mountCategory", null);
3307
3327
 
3308
- class HomeFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3328
+ class ProductFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3309
3329
  constructor({ firestore, interceptors }) {
3310
3330
  super({
3311
3331
  firestore,
3312
- collectionName: 'dms',
3313
- model: Home,
3332
+ collectionName: 'productsErpVitrine',
3333
+ model: Product,
3314
3334
  interceptors,
3315
3335
  });
3316
- this.homeCategoryGroupToPlain = (homeCategoryGroup) => {
3317
- var _a, _b, _c;
3318
- return ({
3319
- category: ((_a = homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category) === null || _a === void 0 ? void 0 : _a.toPlain)
3320
- ? (_b = homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category) === null || _b === void 0 ? void 0 : _b.toPlain()
3321
- : homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category,
3322
- products: ((_c = homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.products) === null || _c === void 0 ? void 0 : _c.map((product) => ((product === null || product === void 0 ? void 0 : product.toPlain) ? product === null || product === void 0 ? void 0 : product.toPlain() : product)).filter(Boolean)) || [],
3323
- });
3324
- };
3325
- this.plainToHomeCategoryGroup = (homeCategoryGroup) => {
3326
- var _a;
3327
- return ({
3328
- category: Category.toInstance(homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category),
3329
- products: (_a = homeCategoryGroup.products) === null || _a === void 0 ? void 0 : _a.map((product) => Product.toInstance(product)),
3330
- });
3331
- };
3336
+ this.reviews = {};
3332
3337
  }
3333
- buildModelInstance() {
3334
- const { fromFirestore, toFirestore } = super.buildModelInstance();
3335
- return {
3336
- toFirestore: (data) => {
3337
- const modifiedData = this.homeToFirestore(data);
3338
- return toFirestore(modifiedData);
3339
- },
3340
- fromFirestore: (snap) => {
3341
- const instance = fromFirestore(snap);
3342
- return this.homeFromFirestore(instance);
3338
+ fetchProductReviews(filters) {
3339
+ throw new Error('Method not implemented.');
3340
+ }
3341
+ async getBySlug(slug) {
3342
+ var _a;
3343
+ const result = await this.find({
3344
+ filters: {
3345
+ slug: { operator: Where.EQUALS, value: slug },
3343
3346
  },
3344
- };
3347
+ });
3348
+ return (_a = result === null || result === void 0 ? void 0 : result.data) === null || _a === void 0 ? void 0 : _a.shift();
3345
3349
  }
3346
- homeToFirestore(home) {
3347
- var _a, _b, _c, _d;
3348
- if ((_a = home.data) === null || _a === void 0 ? void 0 : _a.data) {
3349
- home.data.data.discoverProducts = ((_b = home.data.data.discoverProducts) === null || _b === void 0 ? void 0 : _b.map(this.homeCategoryGroupToPlain)) || [];
3350
- home.data.data.featuredProducts = ((_c = home.data.data.featuredProducts) === null || _c === void 0 ? void 0 : _c.map(this.homeCategoryGroupToPlain)) || [];
3351
- home.data.data.verticalProducts = ((_d = home.data.data.verticalProducts) === null || _d === void 0 ? void 0 : _d.map(this.homeCategoryGroupToPlain)) || [];
3352
- }
3353
- return home;
3350
+ async fetchReviews(status) {
3351
+ const { data: products } = await this.find();
3352
+ products.forEach((product) => {
3353
+ var _a;
3354
+ if ([undefined, 0].includes((_a = product.reviews) === null || _a === void 0 ? void 0 : _a.length))
3355
+ return;
3356
+ const productInfo = {
3357
+ productId: product.id,
3358
+ productName: product.name,
3359
+ productSku: product.sku,
3360
+ };
3361
+ this.reviews.pending = [];
3362
+ this.reviews.approved = [];
3363
+ this.reviews.rejected = [];
3364
+ product.reviews.forEach((review) => {
3365
+ if ([null, undefined].includes(review.status))
3366
+ return this.reviews.pending.push(Object.assign(Object.assign({}, review), productInfo));
3367
+ if (review.status === false)
3368
+ return this.reviews.rejected.push(Object.assign(Object.assign({}, review), productInfo));
3369
+ if (!!review.status)
3370
+ return this.reviews.approved.push(Object.assign(Object.assign({}, review), productInfo));
3371
+ return review;
3372
+ });
3373
+ });
3374
+ return this.reviews[status];
3375
+ }
3376
+ cleanShoppingCountFromIds() {
3377
+ return;
3354
3378
  }
3355
- homeFromFirestore(home) {
3356
- var _a;
3357
- if ((_a = home.data) === null || _a === void 0 ? void 0 : _a.data) {
3358
- home.data.data.discoverProducts = home.data.data.discoverProducts.map(this.plainToHomeCategoryGroup);
3359
- home.data.data.featuredProducts = home.data.data.featuredProducts.map(this.plainToHomeCategoryGroup);
3360
- home.data.data.verticalProducts = home.data.data.verticalProducts.map(this.plainToHomeCategoryGroup);
3361
- home.data.createdAt =
3362
- home.data.createdAt instanceof Timestamp ? home.data.createdAt.toDate() : home.data.createdAt;
3363
- home.data.expiresAt =
3364
- home.data.expiresAt instanceof Timestamp ? home.data.expiresAt.toDate() : home.data.expiresAt;
3365
- }
3366
- return home;
3379
+ findCatalog(params) {
3380
+ return this.find(params);
3381
+ }
3382
+ async fetchPaginatedReviews() {
3383
+ return Promise.resolve([]);
3367
3384
  }
3368
3385
  }
3386
+ __decorate([
3387
+ Log(),
3388
+ __metadata("design:type", Function),
3389
+ __metadata("design:paramtypes", [String]),
3390
+ __metadata("design:returntype", Promise)
3391
+ ], ProductFirestoreRepository.prototype, "getBySlug", null);
3392
+ __decorate([
3393
+ Log(),
3394
+ __metadata("design:type", Function),
3395
+ __metadata("design:paramtypes", [String]),
3396
+ __metadata("design:returntype", Promise)
3397
+ ], ProductFirestoreRepository.prototype, "fetchReviews", null);
3369
3398
 
3370
- class ShopMenuFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3371
- constructor({ firestore, interceptors }) {
3399
+ class ProductVariantFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
3400
+ constructor({ firestore, interceptors }, parentRepository) {
3372
3401
  super({
3373
3402
  firestore,
3374
- collectionName: 'shopMenus',
3375
- model: ShopMenu,
3403
+ collectionName: 'variants',
3404
+ parentIdField: 'productId',
3405
+ model: Variant,
3376
3406
  interceptors,
3377
3407
  });
3408
+ this.parentRepository = parentRepository;
3378
3409
  }
3379
3410
  }
3380
3411
 
3381
- class ShopSettingsFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3382
- constructor({ firestore, interceptors, }) {
3412
+ class SubscriptionProductFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3413
+ constructor({ firestore, interceptors }) {
3383
3414
  super({
3384
3415
  firestore,
3385
- collectionName: 'shopSettings',
3386
- model: ShopSettings,
3416
+ collectionName: 'subscriptionProducts',
3417
+ model: Product,
3387
3418
  interceptors,
3388
3419
  });
3389
3420
  }
@@ -3519,47 +3550,6 @@ class LegacyOrderFirestoreRepository extends OrderFirestoreRepository {
3519
3550
  }
3520
3551
  }
3521
3552
 
3522
- class OrderBlockedFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3523
- constructor({ firestore, interceptors, }) {
3524
- super({
3525
- firestore,
3526
- collectionName: 'paymentBlockedAttempts',
3527
- model: OrderBlocked,
3528
- interceptors,
3529
- });
3530
- }
3531
- async createBlockedOrderOrPayment(checkout, blockType, type, limiteRange, card = null) {
3532
- var _a, _b, _c, _d, _e, _f, _g, _h;
3533
- return this.create(OrderBlocked.toInstance({
3534
- customer: {
3535
- name: ((_a = checkout.user) === null || _a === void 0 ? void 0 : _a.displayName) || '',
3536
- cpf: ((_b = checkout.user) === null || _b === void 0 ? void 0 : _b.cpf) || '',
3537
- id: (_c = checkout.user) === null || _c === void 0 ? void 0 : _c.id,
3538
- email: ((_d = checkout.user) === null || _d === void 0 ? void 0 : _d.email) || '',
3539
- phoneNumber: '+55' + ((_e = checkout.user) === null || _e === void 0 ? void 0 : _e.phone),
3540
- isSubscriber: (_f = checkout.user) === null || _f === void 0 ? void 0 : _f.isSubscriber,
3541
- subscriptionPlan: ((_g = checkout.user) === null || _g === void 0 ? void 0 : _g.subscriptionPlan) || '',
3542
- shippingAddress: Object.assign(Object.assign({}, checkout.shippingAddress), { zip: this.formatZip((_h = checkout.shippingAddress) === null || _h === void 0 ? void 0 : _h.zip) }),
3543
- },
3544
- blockType,
3545
- limiteRange,
3546
- type,
3547
- card,
3548
- checkout: {
3549
- id: checkout.id,
3550
- shop: checkout.shop,
3551
- total: checkout.totalPrice,
3552
- },
3553
- date: new Date(),
3554
- }));
3555
- }
3556
- formatZip(zip) {
3557
- if (zip.length === 8)
3558
- return zip.substring(0, 5) + '-' + zip.substring(5, 8);
3559
- return zip;
3560
- }
3561
- }
3562
-
3563
3553
  class PaymentFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3564
3554
  constructor({ firestore, interceptors }) {
3565
3555
  super({
@@ -3582,177 +3572,87 @@ class SubscriptionPlanFirestoreRepository extends withCrudFirestore(withHelpers(
3582
3572
  }
3583
3573
  }
3584
3574
 
3585
- class LeadFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3586
- constructor({ firestore, interceptors }) {
3587
- super({
3588
- firestore,
3589
- collectionName: 'leads',
3590
- model: Lead,
3591
- interceptors,
3592
- });
3593
- }
3594
- }
3595
-
3596
- class SubscriptionEditionFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
3597
- constructor({ firestore, interceptors }, parentRepository) {
3598
- super({
3599
- firestore,
3600
- collectionName: 'editions',
3601
- parentIdField: 'subscriptionId',
3602
- model: Edition,
3603
- interceptors,
3604
- });
3605
- this.parentRepository = parentRepository;
3606
- }
3607
- }
3608
-
3609
- class SubscriptionFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3610
- constructor({ firestore, interceptors, }) {
3611
- super({
3612
- firestore,
3613
- collectionName: 'subscription',
3614
- model: Subscription,
3615
- interceptors,
3616
- });
3617
- }
3618
- }
3619
-
3620
- class SubscriptionMaterializationFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3621
- constructor({ firestore, interceptors }) {
3622
- super({
3623
- firestore,
3624
- collectionName: 'subscriptionMaterialization',
3625
- model: SubscriptionMaterialization,
3626
- interceptors,
3627
- });
3628
- }
3629
- }
3630
-
3631
- class SubscriptionPaymentFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
3632
- constructor({ firestore, interceptors }, parentRepository) {
3633
- super({
3634
- firestore,
3635
- collectionName: 'payments',
3636
- parentIdField: 'subscriptionId',
3637
- model: SubscriptionPayment,
3638
- interceptors,
3639
- });
3640
- this.parentRepository = parentRepository;
3641
- }
3642
- }
3643
-
3644
- class SubscriptionSummaryFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3645
- constructor({ firestore, interceptors, }) {
3646
- super({
3647
- firestore,
3648
- collectionName: 'subscriptionSummary',
3649
- model: SubscriptionSummary,
3650
- interceptors,
3651
- });
3652
- }
3653
- }
3654
-
3655
- class UserAddressFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
3656
- constructor({ firestore, interceptors }, parentRepository) {
3657
- super({
3658
- firestore,
3659
- collectionName: 'address',
3660
- parentIdField: 'userId',
3661
- model: UserAddress,
3662
- interceptors,
3663
- });
3664
- this.parentRepository = parentRepository;
3665
- }
3666
- }
3667
-
3668
- class UserBeautyProfileFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
3669
- constructor({ firestore, interceptors }, parentRepository) {
3670
- super({
3671
- firestore,
3672
- collectionName: 'CX',
3673
- parentIdField: 'userId',
3674
- model: BeautyProfile,
3675
- interceptors,
3676
- });
3677
- this.parentRepository = parentRepository;
3678
- }
3679
- }
3680
-
3681
- class UserFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3575
+ class HomeFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3682
3576
  constructor({ firestore, interceptors }) {
3683
3577
  super({
3684
3578
  firestore,
3685
- collectionName: 'users',
3686
- model: User,
3579
+ collectionName: 'dms',
3580
+ model: Home,
3687
3581
  interceptors,
3688
3582
  });
3689
- }
3690
- async get(identifiers) {
3691
- const user = await super.get({ id: identifiers.id });
3692
- user.beautyProfile = await this.getBeautyProfile(user.id);
3693
- user.isSubscriber = await this.checkIfIsSubscriber(user.id);
3694
- return user;
3695
- }
3696
- async checkIfExistsByField(field, value) {
3697
- const result = await this.find({ filters: { [field]: value } });
3698
- return result.count > 0;
3583
+ this.homeCategoryGroupToPlain = (homeCategoryGroup) => {
3584
+ var _a, _b, _c;
3585
+ return ({
3586
+ category: ((_a = homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category) === null || _a === void 0 ? void 0 : _a.toPlain)
3587
+ ? (_b = homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category) === null || _b === void 0 ? void 0 : _b.toPlain()
3588
+ : homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category,
3589
+ products: ((_c = homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.products) === null || _c === void 0 ? void 0 : _c.map((product) => ((product === null || product === void 0 ? void 0 : product.toPlain) ? product === null || product === void 0 ? void 0 : product.toPlain() : product)).filter(Boolean)) || [],
3590
+ });
3591
+ };
3592
+ this.plainToHomeCategoryGroup = (homeCategoryGroup) => {
3593
+ var _a;
3594
+ return ({
3595
+ category: Category.toInstance(homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category),
3596
+ products: (_a = homeCategoryGroup.products) === null || _a === void 0 ? void 0 : _a.map((product) => Product.toInstance(product)),
3597
+ });
3598
+ };
3699
3599
  }
3700
3600
  buildModelInstance() {
3701
3601
  const { fromFirestore, toFirestore } = super.buildModelInstance();
3702
3602
  return {
3703
3603
  toFirestore: (data) => {
3704
- const plain = toFirestore(data);
3705
- delete plain.isSubscriber;
3706
- return plain;
3604
+ const modifiedData = this.homeToFirestore(data);
3605
+ return toFirestore(modifiedData);
3606
+ },
3607
+ fromFirestore: (snap) => {
3608
+ const instance = fromFirestore(snap);
3609
+ return this.homeFromFirestore(instance);
3707
3610
  },
3708
- fromFirestore,
3709
3611
  };
3710
3612
  }
3711
- async getBeautyProfile(userId) {
3712
- const beautyProfile = await this.firestore
3713
- .getCollection(`${this.collectionName}/${userId}/CX`)
3714
- .withConverter(this.buildBeautyProfileModelInstance())
3715
- .getDoc('beautyProfile')
3716
- .get();
3717
- return beautyProfile.data();
3718
- }
3719
- async checkIfIsSubscriber(userId) {
3720
- const docs = await this.collection('subscription')
3721
- .where('user.id', '==', userId)
3722
- .where('status', '==', 'active')
3723
- .getDocs();
3724
- return !!docs && !!docs.size;
3613
+ homeToFirestore(home) {
3614
+ var _a, _b, _c, _d;
3615
+ if ((_a = home.data) === null || _a === void 0 ? void 0 : _a.data) {
3616
+ home.data.data.discoverProducts = ((_b = home.data.data.discoverProducts) === null || _b === void 0 ? void 0 : _b.map(this.homeCategoryGroupToPlain)) || [];
3617
+ home.data.data.featuredProducts = ((_c = home.data.data.featuredProducts) === null || _c === void 0 ? void 0 : _c.map(this.homeCategoryGroupToPlain)) || [];
3618
+ home.data.data.verticalProducts = ((_d = home.data.data.verticalProducts) === null || _d === void 0 ? void 0 : _d.map(this.homeCategoryGroupToPlain)) || [];
3619
+ }
3620
+ return home;
3725
3621
  }
3726
- buildBeautyProfileModelInstance() {
3727
- return {
3728
- toFirestore: (data) => data.toPlain(),
3729
- fromFirestore: (snap) => BeautyProfile.toInstance(snap.data()),
3730
- };
3622
+ homeFromFirestore(home) {
3623
+ var _a;
3624
+ if ((_a = home.data) === null || _a === void 0 ? void 0 : _a.data) {
3625
+ home.data.data.discoverProducts = home.data.data.discoverProducts.map(this.plainToHomeCategoryGroup);
3626
+ home.data.data.featuredProducts = home.data.data.featuredProducts.map(this.plainToHomeCategoryGroup);
3627
+ home.data.data.verticalProducts = home.data.data.verticalProducts.map(this.plainToHomeCategoryGroup);
3628
+ home.data.createdAt =
3629
+ home.data.createdAt instanceof Timestamp ? home.data.createdAt.toDate() : home.data.createdAt;
3630
+ home.data.expiresAt =
3631
+ home.data.expiresAt instanceof Timestamp ? home.data.expiresAt.toDate() : home.data.expiresAt;
3632
+ }
3633
+ return home;
3634
+ }
3635
+ }
3636
+
3637
+ class ShopMenuFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3638
+ constructor({ firestore, interceptors }) {
3639
+ super({
3640
+ firestore,
3641
+ collectionName: 'shopMenus',
3642
+ model: ShopMenu,
3643
+ interceptors,
3644
+ });
3731
3645
  }
3732
3646
  }
3733
- __decorate([
3734
- Log(),
3735
- __metadata("design:type", Function),
3736
- __metadata("design:paramtypes", [Object]),
3737
- __metadata("design:returntype", Promise)
3738
- ], UserFirestoreRepository.prototype, "get", null);
3739
- __decorate([
3740
- Log(),
3741
- __metadata("design:type", Function),
3742
- __metadata("design:paramtypes", [String, String]),
3743
- __metadata("design:returntype", Promise)
3744
- ], UserFirestoreRepository.prototype, "checkIfExistsByField", null);
3745
3647
 
3746
- class UserPaymentMethodFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
3747
- constructor({ firestore, interceptors }, parentRepository) {
3648
+ class ShopSettingsFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3649
+ constructor({ firestore, interceptors, }) {
3748
3650
  super({
3749
3651
  firestore,
3750
- collectionName: 'payment_method',
3751
- parentIdField: 'userId',
3752
- model: UserPaymentMethod,
3652
+ collectionName: 'shopSettings',
3653
+ model: ShopSettings,
3753
3654
  interceptors,
3754
3655
  });
3755
- this.parentRepository = parentRepository;
3756
3656
  }
3757
3657
  }
3758
3658
 
@@ -4305,7 +4205,7 @@ const withHasuraGraphQL = (MixinBase) => {
4305
4205
  const response = await axios(request);
4306
4206
  if (!isNil(response.data.errors)) {
4307
4207
  this.logger.error({ req: request, res: response.data.errors });
4308
- throw new Error(JSON.stringify(response.data.errors));
4208
+ throw new Error(response.data.errors);
4309
4209
  }
4310
4210
  this.logger.log({ req: request, res: response.data });
4311
4211
  return response.data.data;
@@ -4446,7 +4346,6 @@ const withFindHasuraGraphQL = (MixinBase) => {
4446
4346
  return class FindHasuraGraphQLMixin extends MixinBase {
4447
4347
  constructor() {
4448
4348
  super(...arguments);
4449
- this.lastDistinct = {};
4450
4349
  this.bindOrderByAttributes = (orderBy, fields) => Object.keys(orderBy).reduce((acc, current) => [
4451
4350
  ...acc,
4452
4351
  {
@@ -4482,10 +4381,9 @@ const withFindHasuraGraphQL = (MixinBase) => {
4482
4381
  });
4483
4382
  }
4484
4383
  async find(params) {
4485
- var _a, _b, _c, _d, _e, _f, _g;
4384
+ var _a, _b, _c, _d, _e, _f, _g, _h;
4486
4385
  this.logger = DebugHelper.from(this, 'find');
4487
4386
  const { filters, limits, orderBy, options } = params || {};
4488
- const tableFiltersNamed = `${this.tableName}:${JSON.stringify(filters)}`;
4489
4387
  const enableCount = (_a = options === null || options === void 0 ? void 0 : options.enableCount) !== null && _a !== void 0 ? _a : true;
4490
4388
  const variablesFilters = isNil(filters)
4491
4389
  ? {}
@@ -4536,8 +4434,8 @@ const withFindHasuraGraphQL = (MixinBase) => {
4536
4434
  },
4537
4435
  ]
4538
4436
  : []),
4539
- ...((!this.lastDistinct[tableFiltersNamed] &&
4540
- ((_c = (_b = params.options) === null || _b === void 0 ? void 0 : _b.distinct) === null || _c === void 0 ? void 0 : _c.map((distinct) => {
4437
+ ...((!((_b = params.limits) === null || _b === void 0 ? void 0 : _b.offset) &&
4438
+ ((_d = (_c = params.options) === null || _c === void 0 ? void 0 : _c.distinct) === null || _d === void 0 ? void 0 : _d.map((distinct) => {
4541
4439
  var _a, _b;
4542
4440
  const distinctOption = (_a = this.fields.find((fieldOption) => fieldOption === distinct)) !== null && _a !== void 0 ? _a : this.fields.find((fieldOption) => Object.keys(fieldOption).shift() === distinct);
4543
4441
  const fieldName = ((_b = Object.values(distinctOption).shift()) === null || _b === void 0 ? void 0 : _b.columnName) || distinct;
@@ -4558,27 +4456,28 @@ const withFindHasuraGraphQL = (MixinBase) => {
4558
4456
  []),
4559
4457
  ]);
4560
4458
  const data = result[this.tableName].map((row) => this.convertDataFromHasura(row));
4561
- return Object.assign(Object.assign(Object.assign({ data, count: enableCount ? result[`${this.tableName}_aggregate`].aggregate.count : Infinity }, (((_d = options === null || options === void 0 ? void 0 : options.minimal) === null || _d === void 0 ? void 0 : _d.length)
4459
+ return Object.assign(Object.assign(Object.assign({ data, count: enableCount ? result[`${this.tableName}_aggregate`].aggregate.count : Infinity }, (((_e = options === null || options === void 0 ? void 0 : options.minimal) === null || _e === void 0 ? void 0 : _e.length)
4562
4460
  ? {
4563
4461
  minimal: options.minimal.reduce((minimals, current) => {
4564
4462
  var _a;
4565
4463
  return (Object.assign(Object.assign({}, minimals), set(minimals, current, result[`${this.tableName}_aggregate`].aggregate.min[((_a = AttributeOptionHelper.FindByAttribute(current.toString().split('.').pop(), this.fields)) === null || _a === void 0 ? void 0 : _a.columnName) || current])));
4566
4464
  }, {}),
4567
4465
  }
4568
- : {})), (((_e = options === null || options === void 0 ? void 0 : options.maximum) === null || _e === void 0 ? void 0 : _e.length)
4466
+ : {})), (((_f = options === null || options === void 0 ? void 0 : options.maximum) === null || _f === void 0 ? void 0 : _f.length)
4569
4467
  ? {
4570
4468
  maximum: options.maximum.reduce((maximums, current) => {
4571
4469
  var _a;
4572
4470
  return (Object.assign(Object.assign({}, maximums), set(maximums, current, result[`${this.tableName}_aggregate`].aggregate.max[((_a = AttributeOptionHelper.FindByAttribute(current.toString().split('.').pop(), this.fields)) === null || _a === void 0 ? void 0 : _a.columnName) || current])));
4573
4471
  }, {}),
4574
4472
  }
4575
- : {})), (((_f = options === null || options === void 0 ? void 0 : options.distinct) === null || _f === void 0 ? void 0 : _f.length) && {
4576
- distinct: (_g = this.lastDistinct[tableFiltersNamed]) !== null && _g !== void 0 ? _g : (this.lastDistinct[tableFiltersNamed] = options === null || options === void 0 ? void 0 : options.distinct.reduce((distinct, current) => {
4473
+ : {})), (!((_g = params.limits) === null || _g === void 0 ? void 0 : _g.offset) &&
4474
+ ((_h = options === null || options === void 0 ? void 0 : options.distinct) === null || _h === void 0 ? void 0 : _h.length) && {
4475
+ distinct: options === null || options === void 0 ? void 0 : options.distinct.reduce((distinct, current) => {
4577
4476
  var _a, _b;
4578
4477
  const distinctOption = (_a = this.fields.find((fieldOption) => fieldOption === current)) !== null && _a !== void 0 ? _a : this.fields.find((fieldOption) => Object.keys(fieldOption).shift() === current);
4579
4478
  const fieldName = ((_b = Object.values(distinctOption).shift()) === null || _b === void 0 ? void 0 : _b.columnName) || current;
4580
4479
  return Object.assign(Object.assign({}, distinct), { [current.toString()]: result[`${this.tableName}_${current.toString()}_distinct`].map((obj) => obj[fieldName]) });
4581
- }, {})),
4480
+ }, {}),
4582
4481
  }));
4583
4482
  }
4584
4483
  };
@@ -4673,7 +4572,6 @@ class CategoryFilterHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHa
4673
4572
  fields: [
4674
4573
  'id',
4675
4574
  'description',
4676
- 'title',
4677
4575
  'slug',
4678
4576
  'enabled',
4679
4577
  { createdAt: { columnName: 'created_at' } },
@@ -4785,7 +4683,6 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
4785
4683
  'name',
4786
4684
  'description',
4787
4685
  'image',
4788
- { images: { columnName: 'images', type: HasuraGraphQLColumnType.Jsonb } },
4789
4686
  'published',
4790
4687
  'shop',
4791
4688
  { shops: { columnName: 'shops', type: HasuraGraphQLColumnType.Jsonb } },
@@ -4818,11 +4715,11 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
4818
4715
  filters: {
4819
4716
  columnName: 'filters',
4820
4717
  foreignKeyColumn: { filter_id: 'id' },
4821
- fields: [{ filter: ['id', 'title', 'description', 'slug', 'enabled'] }],
4718
+ fields: [{ filter: ['id', 'description', 'slug', 'enabled'] }],
4822
4719
  bindPersistData: (value) => ({
4823
4720
  filters: { data: value.map((filter) => ({ filter_id: filter.id })) },
4824
4721
  }),
4825
- from: (filters) => (filters === null || filters === void 0 ? void 0 : filters.map((filter) => filter === null || filter === void 0 ? void 0 : filter.filter).filter((filter) => filter.enabled)) || [],
4722
+ from: (filters) => (filters === null || filters === void 0 ? void 0 : filters.map((filter) => filter === null || filter === void 0 ? void 0 : filter.filter)) || [],
4826
4723
  },
4827
4724
  },
4828
4725
  { createdAt: { columnName: 'created_at' } },
@@ -4841,21 +4738,12 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
4841
4738
  {
4842
4739
  metadata: {
4843
4740
  columnName: 'metadata',
4844
- fields: ['shop', 'title', 'description'],
4741
+ fields: ['title', 'description'],
4845
4742
  bindPersistData: (value) => ({
4846
4743
  metadata: { data: value },
4847
4744
  }),
4848
4745
  },
4849
4746
  },
4850
- {
4851
- metadatas: {
4852
- columnName: 'metadatas',
4853
- fields: ['shop', 'title', 'description'],
4854
- bindPersistData: (value) => ({
4855
- metadatas: { data: value },
4856
- }),
4857
- },
4858
- },
4859
4747
  { isCollection: { columnName: 'is_collection' } },
4860
4748
  { isWishlist: { columnName: 'is_wishlist' } },
4861
4749
  'reference',
@@ -4870,29 +4758,14 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
4870
4758
  'theme',
4871
4759
  { bannerUrl: { columnName: 'banner_url' } },
4872
4760
  { mostRelevant: { columnName: 'most_relevant', type: HasuraGraphQLColumnType.Jsonb } },
4873
- { mostRelevants: { columnName: 'most_relevants', type: HasuraGraphQLColumnType.Jsonb } },
4874
4761
  ],
4875
4762
  });
4876
4763
  this.productRepository = productRepository;
4877
4764
  this.categoryFilterRepository = categoryFilterRepository;
4878
4765
  }
4879
4766
  async create(params) {
4880
- const { images, mostRelevants, metadatas } = params, data = __rest(params, ["images", "mostRelevants", "metadatas"]);
4881
- return super.create(Object.assign(Object.assign({}, data), { isWishlist: false, metadatas: metadatas || [{ shop: null, description: null, title: null }], mostRelevants: mostRelevants || {
4882
- [Shops.GLAMSHOP]: null,
4883
- [Shops.MENSMARKET]: null,
4884
- }, images: images || {
4885
- [Shops.GLAMSHOP]: {
4886
- brandBanner: null,
4887
- brandBannerMobile: null,
4888
- image: null,
4889
- },
4890
- [Shops.MENSMARKET]: {
4891
- brandBanner: null,
4892
- brandBannerMobile: null,
4893
- image: null,
4894
- },
4895
- } }));
4767
+ const { metadata } = params, data = __rest(params, ["metadata"]);
4768
+ return super.create(Object.assign(Object.assign({}, data), { isWishlist: false, metadata: metadata || { description: null, title: null } }));
4896
4769
  }
4897
4770
  async get(identifiers) {
4898
4771
  var _a;
@@ -4901,12 +4774,12 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
4901
4774
  : super.get(identifiers);
4902
4775
  }
4903
4776
  async update(params) {
4904
- const { products, id: checkId, metadatas, filters } = params, data = __rest(params, ["products", "id", "metadatas", "filters"]);
4777
+ const { products, id: checkId, metadata, filters } = params, data = __rest(params, ["products", "id", "metadata", "filters"]);
4905
4778
  const plainData = this.paramsToPlain({ id: checkId });
4906
4779
  const id = await this.getId(plainData.id);
4907
4780
  const category = await super.update(Object.assign(Object.assign({ id }, data), { isWishlist: false }));
4908
4781
  category.products = products && (await this.updateProducts(+id, { products }));
4909
- category.metadatas = metadatas && (await this.updateMetadata(+id, { metadatas }));
4782
+ category.metadata = metadata && (await this.updateMetadata(+id, { metadata }));
4910
4783
  category.filters = filters && (await this.updateFilters(+id, { filters }));
4911
4784
  return category;
4912
4785
  }
@@ -4944,7 +4817,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
4944
4817
  });
4945
4818
  return data;
4946
4819
  }
4947
- async getCategoriesForHome(categoryIds, shop, limit = 4) {
4820
+ async getCategoriesForHome(categoryIds, limit = 4, gender) {
4948
4821
  if (!(categoryIds === null || categoryIds === void 0 ? void 0 : categoryIds.length))
4949
4822
  return [];
4950
4823
  const categoriesFirestore = categoryIds.filter((categoryId) => Number.isNaN(+categoryId));
@@ -4956,32 +4829,22 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
4956
4829
  }).then(({ data }) => data)));
4957
4830
  if (categoriesHasura.length)
4958
4831
  categories.push(...(await this.find({
4959
- filters: {
4960
- id: { operator: Where.IN, value: categoriesHasura.filter(Boolean) },
4961
- published: true,
4962
- },
4832
+ filters: { id: { operator: Where.IN, value: categoriesHasura.filter(Boolean) }, published: true },
4963
4833
  }).then(({ data }) => data)));
4964
4834
  if (!categories.length)
4965
4835
  return [];
4966
4836
  const homeSections = await Promise.all(categories.map(async (category) => ({
4967
4837
  category,
4968
- products: await this.mountCategory(category, shop, { limit, hasStock: true }),
4838
+ products: await this.mountCategory(category, { limit, hasStock: true, gender }),
4969
4839
  })));
4970
4840
  return homeSections;
4971
4841
  }
4972
- async mountCategory(category, shop, options) {
4842
+ async mountCategory(category, options) {
4973
4843
  var _a;
4974
4844
  if (!((_a = category === null || category === void 0 ? void 0 : category.products) === null || _a === void 0 ? void 0 : _a.length))
4975
4845
  return [];
4976
- const mostRelevants = category.getMostRelevantByShop(shop);
4977
- const mostRelevantProductsIds = [...new Set(mostRelevants.concat(category.products))];
4978
4846
  const products = [];
4979
- const { data: productsData } = await this.productRepository.findCatalog({
4980
- filters: {
4981
- id: { operator: Where.IN, value: mostRelevantProductsIds },
4982
- published: true,
4983
- },
4984
- fields: [
4847
+ const { data: productsData } = await this.productRepository.find(Object.assign(Object.assign({ filters: Object.assign(Object.assign({ id: { operator: Where.IN, value: category.products }, published: true }, ((options === null || options === void 0 ? void 0 : options.hasStock) ? { stock: { quantity: { operator: Where.GT, value: 0 } } } : {})), ((options === null || options === void 0 ? void 0 : options.gender) ? { tags: { operator: Where.IN, value: [options === null || options === void 0 ? void 0 : options.gender] } } : {})), fields: [
4985
4848
  'id',
4986
4849
  'name',
4987
4850
  'slug',
@@ -5007,29 +4870,12 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
5007
4870
  'shoppingCount',
5008
4871
  'gender',
5009
4872
  'createdAt',
5010
- ],
5011
- options: { enableCount: false },
5012
- orderBy: {
5013
- shoppingCount: 'desc',
5014
- rate: 'desc',
5015
- stock: 'desc',
5016
- name: 'asc',
5017
- },
5018
- }, shop === Shops.MENSMARKET ? 'male' : 'female');
5019
- const mostRelevantWithouyStock = productsData.filter((product) => mostRelevants.includes(product.id) && product.stock.quantity <= 0);
5020
- const firstProducts = productsData
5021
- .filter((product) => mostRelevants.includes(product.id) && product.stock.quantity > 0)
5022
- .sort((a, b) => mostRelevants.indexOf(a.id) - mostRelevants.indexOf(b.id));
5023
- const lastProducts = productsData
5024
- .filter((product) => !mostRelevants.includes(product.id) && product.stock.quantity > 0)
5025
- .concat(mostRelevantWithouyStock);
5026
- const categoryMostRelevants = firstProducts.concat(lastProducts);
5027
- const resultFinal = categoryMostRelevants.slice(0, options.limit);
5028
- products.push(...resultFinal);
4873
+ ] }, ((options === null || options === void 0 ? void 0 : options.limit) ? { limits: { limit: options === null || options === void 0 ? void 0 : options.limit } } : {})), { options: { enableCount: false } }));
4874
+ products.push(...productsData);
5029
4875
  return products;
5030
4876
  }
5031
4877
  async getChildren(parentId) {
5032
- const { category_tree } = await this.query('category_tree', ['id', 'name', 'parent_id', 'slug', 'reference', 'published', 'shops'], {
4878
+ const { category_tree } = await this.query('category_tree', ['id', 'name', 'parent_id', 'slug', 'reference'], {
5033
4879
  args: {
5034
4880
  type: 'category_tree_args',
5035
4881
  value: { parentid: parentId },
@@ -5109,36 +4955,23 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
5109
4955
  });
5110
4956
  return plainData.products;
5111
4957
  }
5112
- async updateMetadata(categoryId, { metadatas }) {
5113
- if (Array.isArray(metadatas) && !metadatas.length)
5114
- return [];
5115
- if (Array.isArray(metadatas) && metadatas.length) {
5116
- await this.mutation('delete_category_metadata', ['affected_rows'], {
5117
- where: {
5118
- type: 'category_metadata_bool_exp',
5119
- required: true,
5120
- value: { category_id: { _eq: categoryId } },
5121
- },
5122
- });
5123
- await this.mutation('insert_category_metadata', ['affected_rows'], {
5124
- objects: {
5125
- type: '[category_metadata_insert_input!]',
5126
- required: true,
5127
- value: metadatas.map((m) => (Object.assign({ category_id: categoryId }, m))),
5128
- },
5129
- });
5130
- return metadatas;
5131
- }
5132
- if ('action' in metadatas && metadatas.action === 'remove' && metadatas.value.length) {
5133
- await this.mutation('delete_category_metadata', ['affected_rows'], {
5134
- where: {
5135
- type: 'category_metadata_bool_exp',
5136
- required: true,
5137
- value: { category_id: { _eq: categoryId } },
5138
- },
5139
- });
5140
- return [];
5141
- }
4958
+ async updateMetadata(categoryId, { metadata }) {
4959
+ const plainData = this.paramsToPlain({ metadata });
4960
+ if (!plainData.metadata)
4961
+ return null;
4962
+ await this.mutation('update_category_metadata_by_pk', ['category_id'], {
4963
+ pk_columns: {
4964
+ value: { category_id: categoryId },
4965
+ type: 'category_metadata_pk_columns_input',
4966
+ required: true,
4967
+ },
4968
+ _set: {
4969
+ value: omit(metadata, ['category_id']),
4970
+ type: 'category_metadata_set_input',
4971
+ required: true,
4972
+ },
4973
+ });
4974
+ return plainData.metadata;
5142
4975
  }
5143
4976
  async updateFilters(categoryId, { filters }) {
5144
4977
  if ('action' in filters && filters.action === 'remove' && filters.value.length) {
@@ -5200,13 +5033,13 @@ __decorate([
5200
5033
  __decorate([
5201
5034
  Log(),
5202
5035
  __metadata("design:type", Function),
5203
- __metadata("design:paramtypes", [Array, String, Object]),
5036
+ __metadata("design:paramtypes", [Array, Object, String]),
5204
5037
  __metadata("design:returntype", Promise)
5205
5038
  ], CategoryHasuraGraphQLRepository.prototype, "getCategoriesForHome", null);
5206
5039
  __decorate([
5207
5040
  Log(),
5208
5041
  __metadata("design:type", Function),
5209
- __metadata("design:paramtypes", [Category, String, Object]),
5042
+ __metadata("design:paramtypes", [Category, Object]),
5210
5043
  __metadata("design:returntype", Promise)
5211
5044
  ], CategoryHasuraGraphQLRepository.prototype, "mountCategory", null);
5212
5045
  __decorate([
@@ -5232,7 +5065,6 @@ class FilterHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGrap
5232
5065
  interceptors,
5233
5066
  fields: [
5234
5067
  'id',
5235
- 'title',
5236
5068
  'description',
5237
5069
  'slug',
5238
5070
  'enabled',
@@ -5488,7 +5320,6 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
5488
5320
  { subscriberPrice: { columnName: 'subscriber_price' } },
5489
5321
  'published',
5490
5322
  'outlet',
5491
- 'label',
5492
5323
  'sku',
5493
5324
  {
5494
5325
  stock: {
@@ -5621,8 +5452,6 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
5621
5452
  enableCount: false,
5622
5453
  },
5623
5454
  });
5624
- if (!result.data.length)
5625
- return null;
5626
5455
  const product = (_a = result === null || result === void 0 ? void 0 : result.data) === null || _a === void 0 ? void 0 : _a.shift();
5627
5456
  RoundProductPricesHelper.roundProductPrices(product);
5628
5457
  return product;
@@ -5922,24 +5751,6 @@ class ProductReviewsHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHa
5922
5751
  ],
5923
5752
  });
5924
5753
  }
5925
- async updateManyStatus(reviews) {
5926
- return await this.mutation('update_product_review_many', ['affected_rows'], {
5927
- updates: {
5928
- type: '[product_review_updates!]',
5929
- required: true,
5930
- value: [
5931
- {
5932
- _set: { status: true },
5933
- where: { id: { _in: reviews.filter((review) => review.status).map((review) => review.id) } },
5934
- },
5935
- {
5936
- _set: { status: false },
5937
- where: { id: { _in: reviews.filter((review) => !review.status).map((review) => review.id) } },
5938
- },
5939
- ],
5940
- },
5941
- });
5942
- }
5943
5754
  aproveReview(id) {
5944
5755
  return this.update({ id, status: true });
5945
5756
  }
@@ -5994,31 +5805,6 @@ class ProductStockNotificationHasuraGraphQLRepository extends withCrudHasuraGrap
5994
5805
  email,
5995
5806
  });
5996
5807
  }
5997
- async getNotificationsReport(params, orderBy, pagination) {
5998
- const query = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (params.productId && { product_id: { _eq: params.productId } })), (params.ean && { ean: { _eq: params.ean } })), (params.sku && { sku: { _eq: params.sku } })), (params.name && { name: { _iregex: params.name } })), (params.categoryId && { category_id: { _eq: params.categoryId } })), (params.category && { category: { _iregex: params.category } })), (params.reference && { category_reference: { _eq: params.reference } })), (params.emailsCount && { emails_registered: { _eq: params.emailsCount } }));
5999
- const orderByField = {
6000
- [orderBy.field]: orderBy.direction,
6001
- };
6002
- const { report_stock_notification } = await this.query('report_stock_notification', ['product_id', 'ean', 'sku', 'name', 'stock', 'category_id', 'category', 'reference', 'emails_registered'], {
6003
- where: {
6004
- type: 'report_stock_notification_bool_exp',
6005
- value: query,
6006
- required: true,
6007
- },
6008
- order_by: {
6009
- type: '[report_stock_notification_order_by]',
6010
- value: orderByField,
6011
- required: true,
6012
- },
6013
- });
6014
- const data = (pagination === null || pagination === void 0 ? void 0 : pagination.limit)
6015
- ? report_stock_notification.slice(pagination === null || pagination === void 0 ? void 0 : pagination.offset, (pagination === null || pagination === void 0 ? void 0 : pagination.offset) + (pagination === null || pagination === void 0 ? void 0 : pagination.limit))
6016
- : report_stock_notification;
6017
- return {
6018
- data,
6019
- count: report_stock_notification.length,
6020
- };
6021
- }
6022
5808
  }
6023
5809
 
6024
5810
  class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
@@ -6127,14 +5913,11 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
6127
5913
  }
6128
5914
  }
6129
5915
 
6130
- class WishlistHasuraGraphQL extends Wishlist {
6131
- }
6132
-
6133
5916
  class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
6134
5917
  constructor({ endpoint, authOptions, interceptors, }, categoryFilterRepository) {
6135
5918
  super({
6136
5919
  tableName: 'category',
6137
- model: WishlistHasuraGraphQL,
5920
+ model: Wishlist,
6138
5921
  endpoint,
6139
5922
  authOptions,
6140
5923
  interceptors,
@@ -6195,21 +5978,12 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
6195
5978
  {
6196
5979
  metadata: {
6197
5980
  columnName: 'metadata',
6198
- fields: ['shop', 'title', 'description'],
5981
+ fields: ['title', 'description'],
6199
5982
  bindPersistData: (value) => ({
6200
5983
  metadata: { data: value },
6201
5984
  }),
6202
5985
  },
6203
5986
  },
6204
- {
6205
- metadatas: {
6206
- columnName: 'metadatas',
6207
- fields: ['shop', 'title', 'description'],
6208
- bindPersistData: (value) => ({
6209
- metadatas: { data: value },
6210
- }),
6211
- },
6212
- },
6213
5987
  { isCollection: { columnName: 'is_collection' } },
6214
5988
  { isWishlist: { columnName: 'is_wishlist' } },
6215
5989
  'reference',
@@ -6224,34 +5998,15 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
6224
5998
  { personId: { columnName: 'person_id' } },
6225
5999
  { personName: { columnName: 'person_name' } },
6226
6000
  { personPhoto: { columnName: 'person_photo' } },
6227
- { personType: { columnName: 'person_type' } },
6228
- { personIsSubscriber: { columnName: 'person_is_subscriber' } },
6229
6001
  'theme',
6230
6002
  { bannerUrl: { columnName: 'banner_url' } },
6231
- { personHasPhoto: { columnName: 'person_has_photo' } },
6232
- { mostRelevants: { columnName: 'most_relevants', type: HasuraGraphQLColumnType.Jsonb } },
6233
6003
  ],
6234
6004
  });
6235
6005
  this.categoryFilterRepository = categoryFilterRepository;
6236
6006
  }
6237
6007
  async create(params) {
6238
- var _a;
6239
- const { images, mostRelevants, metadatas } = params, data = __rest(params, ["images", "mostRelevants", "metadatas"]);
6240
- return super.create(Object.assign(Object.assign({}, data), { isWishlist: true, isCollection: true, brandCategory: false, metadatas: metadatas || [{ shop: (_a = data.shop) !== null && _a !== void 0 ? _a : null, description: data.description, title: data.name }], mostRelevants: mostRelevants || {
6241
- [Shops.GLAMSHOP]: null,
6242
- [Shops.MENSMARKET]: null,
6243
- }, images: images || {
6244
- [Shops.GLAMSHOP]: {
6245
- brandBanner: null,
6246
- brandBannerMobile: null,
6247
- image: null,
6248
- },
6249
- [Shops.MENSMARKET]: {
6250
- brandBanner: null,
6251
- brandBannerMobile: null,
6252
- image: null,
6253
- },
6254
- } }));
6008
+ const { metadata } = params, data = __rest(params, ["metadata"]);
6009
+ return super.create(Object.assign(Object.assign({}, data), { isWishlist: true, isCollection: true, brandCategory: false, metadata: metadata || { description: data.description, title: data.name } }));
6255
6010
  }
6256
6011
  async get(identifiers) {
6257
6012
  const data = await super.get(identifiers);
@@ -6264,12 +6019,12 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
6264
6019
  return await super.find(Object.assign(Object.assign({}, rest), { filters: Object.assign(Object.assign({}, filters), { isWishlist: { operator: Where.EQUALS, value: true } }) }));
6265
6020
  }
6266
6021
  async update(params) {
6267
- const { products, id: checkId, metadatas, filters } = params, data = __rest(params, ["products", "id", "metadatas", "filters"]);
6022
+ const { products, id: checkId, metadata, filters } = params, data = __rest(params, ["products", "id", "metadata", "filters"]);
6268
6023
  const plainData = this.paramsToPlain({ id: checkId });
6269
6024
  const id = plainData.id;
6270
6025
  const category = await super.update(Object.assign(Object.assign({ id }, data), { isWishlist: true, isCollection: true, brandCategory: false }));
6271
6026
  category.products = products && (await this.updateProducts(+id, { products }));
6272
- category.metadatas = metadatas && (await this.updateMetadata(+id, { metadatas }));
6027
+ category.metadata = metadata && (await this.updateMetadata(+id, { metadata }));
6273
6028
  return category;
6274
6029
  }
6275
6030
  async getWishlistBySlug(slug) {
@@ -6301,18 +6056,12 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
6301
6056
  options: {
6302
6057
  enableCount: false,
6303
6058
  },
6304
- orderBy: {
6305
- id: 'asc',
6306
- },
6307
- limits: {
6308
- limit: 1,
6309
- },
6310
6059
  });
6311
6060
  if (!data.length)
6312
6061
  throw new NotFoundError(`Wishlists from person ${personId} not found`);
6313
6062
  return data;
6314
6063
  }
6315
- async getCategoryBySlug(slug, _shop) {
6064
+ getCategoryBySlug(slug, _shop) {
6316
6065
  return this.getWishlistBySlug(slug);
6317
6066
  }
6318
6067
  async getCategoryByShop(shop) {
@@ -6330,17 +6079,10 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
6330
6079
  });
6331
6080
  return data;
6332
6081
  }
6333
- async findBfluOrGlamgirlWishlists(params, shops) {
6334
- var _a, _b;
6335
- return this.find(Object.assign(Object.assign({}, params), { filters: Object.assign(Object.assign({}, params.filters), { published: true, shops: { operator: Where.LIKE, value: shops }, personType: (_b = (_a = params.filters) === null || _a === void 0 ? void 0 : _a.personType) !== null && _b !== void 0 ? _b : {
6336
- operator: Where.IN,
6337
- value: [PersonTypes.BFLU, PersonTypes.GLAMGIRL],
6338
- } }), orderBy: Object.assign({ personHasPhoto: 'desc' }, omit(params.orderBy, ['personHasPhoto'])) }));
6339
- }
6340
- getCategoriesForHome(categoryIds, gender, limit) {
6082
+ getCategoriesForHome(categoryIds, limit, gender) {
6341
6083
  return;
6342
6084
  }
6343
- mountCategory(category, shop, options) {
6085
+ mountCategory(category, options) {
6344
6086
  return;
6345
6087
  }
6346
6088
  getChildren(parentId) {
@@ -6387,40 +6129,23 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
6387
6129
  });
6388
6130
  return plainData.products;
6389
6131
  }
6390
- async updateMetadata(categoryId, { metadatas }) {
6391
- if (Array.isArray(metadatas) && !metadatas.length)
6392
- return [];
6393
- if (Array.isArray(metadatas) && metadatas.length) {
6394
- const metadataUpdated = [];
6395
- for (const data of metadatas) {
6396
- const update = await this.mutation('update_category_metadata_by_pk', ['category_id', 'shop'], {
6397
- pk_columns: {
6398
- value: { category_id: categoryId, shop: data.shop },
6399
- type: 'category_metadata_pk_columns_input',
6400
- required: true,
6401
- },
6402
- _set: {
6403
- value: omit(data, ['category_id', 'shop']),
6404
- type: 'category_metadata_set_input',
6405
- required: true,
6406
- },
6407
- });
6408
- metadataUpdated.push(update);
6409
- }
6410
- return metadataUpdated;
6411
- }
6412
- if ('action' in metadatas && metadatas.action === 'remove' && metadatas.value.length) {
6413
- for (let i = 0; i < metadatas.value.length; i++) {
6414
- await this.mutation('delete_category_metadata', ['affected_rows'], {
6415
- where: {
6416
- type: 'category_metadata_bool_exp',
6417
- required: true,
6418
- value: { category_id: { _eq: categoryId }, shop: metadatas.value[i].shop },
6419
- },
6420
- });
6421
- }
6422
- return [];
6423
- }
6132
+ async updateMetadata(categoryId, { metadata }) {
6133
+ const plainData = this.paramsToPlain({ metadata });
6134
+ if (!plainData.metadata)
6135
+ return;
6136
+ await this.mutation('update_category_metadata_by_pk', ['category_id'], {
6137
+ pk_columns: {
6138
+ value: { category_id: categoryId },
6139
+ type: 'category_metadata_pk_columns_input',
6140
+ required: true,
6141
+ },
6142
+ _set: {
6143
+ value: omit(metadata, ['category_id']),
6144
+ type: 'category_metadata_set_input',
6145
+ required: true,
6146
+ },
6147
+ });
6148
+ return plainData.metadata;
6424
6149
  }
6425
6150
  }
6426
6151
  __decorate([
@@ -6441,164 +6166,5 @@ __decorate([
6441
6166
  __metadata("design:paramtypes", [String]),
6442
6167
  __metadata("design:returntype", Promise)
6443
6168
  ], WishlistHasuraGraphQLRepository.prototype, "getCategoryByShop", null);
6444
- __decorate([
6445
- Log(),
6446
- __metadata("design:type", Function),
6447
- __metadata("design:paramtypes", [Object, Array]),
6448
- __metadata("design:returntype", Promise)
6449
- ], WishlistHasuraGraphQLRepository.prototype, "findBfluOrGlamgirlWishlists", null);
6450
-
6451
- class VertexAxiosAdapter {
6452
- constructor(config) {
6453
- this.config = config;
6454
- this.logger = DebugHelper.from(this);
6455
- }
6456
- async query(term, total, gender) {
6457
- const logger = this.logger.with('query');
6458
- const req = {
6459
- url: `${this.config.url}/search`,
6460
- method: 'POST',
6461
- responseType: 'json',
6462
- headers: {
6463
- Accept: 'application/json',
6464
- },
6465
- data: { term, total, gender },
6466
- };
6467
- try {
6468
- const { data } = await axios(req);
6469
- return data;
6470
- }
6471
- catch (error) {
6472
- logger.error({ req, res: error });
6473
- throw error;
6474
- }
6475
- }
6476
- async get(id) {
6477
- const logger = this.logger.with('update');
6478
- const req = {
6479
- url: `${this.config.url}/${id}`,
6480
- method: 'GET',
6481
- responseType: 'json',
6482
- headers: {
6483
- Accept: 'application/json',
6484
- },
6485
- };
6486
- try {
6487
- const { data } = await axios(req);
6488
- return data;
6489
- }
6490
- catch (error) {
6491
- logger.error({ req, res: error });
6492
- throw error;
6493
- }
6494
- }
6495
- async save(data) {
6496
- const logger = this.logger.with('save');
6497
- const req = {
6498
- url: `${this.config.url}/sync`,
6499
- method: 'POST',
6500
- responseType: 'json',
6501
- headers: {
6502
- Accept: 'application/json',
6503
- },
6504
- data,
6505
- };
6506
- try {
6507
- const { data } = await axios(req);
6508
- return data;
6509
- }
6510
- catch (error) {
6511
- logger.error({ req, res: error });
6512
- throw error;
6513
- }
6514
- }
6515
- async update(id, data) {
6516
- const logger = this.logger.with('update');
6517
- const req = {
6518
- url: `${this.config.url}/${id}`,
6519
- method: 'PUT',
6520
- responseType: 'json',
6521
- headers: {
6522
- Accept: 'application/json',
6523
- },
6524
- data,
6525
- };
6526
- try {
6527
- const { data } = await axios(req);
6528
- return data;
6529
- }
6530
- catch (error) {
6531
- logger.error({ req, res: error });
6532
- throw error;
6533
- }
6534
- }
6535
- async delete(id) {
6536
- const logger = this.logger.with('delete');
6537
- const req = {
6538
- url: `${this.config.url}/${id}`,
6539
- method: 'DELETE',
6540
- responseType: 'json',
6541
- headers: {
6542
- Accept: 'application/json',
6543
- },
6544
- };
6545
- try {
6546
- const { data } = await axios(req);
6547
- return data;
6548
- }
6549
- catch (error) {
6550
- logger.error({ req, res: error });
6551
- throw error;
6552
- }
6553
- }
6554
- bulkProducts(products) {
6555
- return;
6556
- }
6557
- }
6558
-
6559
- class ProductsVertexSearch {
6560
- constructor(adapter) {
6561
- this.adapter = adapter;
6562
- }
6563
- async getById(id) {
6564
- const data = await this.adapter.get(id);
6565
- return data;
6566
- }
6567
- async search(searchTerm, total, gender) {
6568
- try {
6569
- const result = await this.adapter.query(searchTerm, total, gender);
6570
- return result;
6571
- }
6572
- catch (error) {
6573
- console.error(error);
6574
- }
6575
- }
6576
- async save(product) {
6577
- try {
6578
- const _a = product.toPlain(), { createdAt, updatedAt, kitProducts } = _a, data = __rest(_a, ["createdAt", "updatedAt", "kitProducts"]);
6579
- const newProduct = Product.toInstance(data);
6580
- await this.adapter.save(newProduct);
6581
- }
6582
- catch (error) {
6583
- console.error(error);
6584
- }
6585
- }
6586
- async update(product) {
6587
- try {
6588
- await this.adapter.update(product.id, product);
6589
- }
6590
- catch (error) {
6591
- console.error(error);
6592
- }
6593
- }
6594
- async delete(id) {
6595
- try {
6596
- await this.adapter.delete(id);
6597
- }
6598
- catch (error) {
6599
- console.error(error);
6600
- }
6601
- }
6602
- }
6603
6169
 
6604
- export { AccessoryImportances, Address, Area, Authentication, AuthenticationFirebaseAuthService, AxiosAdapter, Base, BaseModel, BeardProblems, BeardSizes, BeautyProductImportances, BeautyProfile, BeautyQuestionsHelper, BillingStatus, BodyProblems, BodyShapes, BodyTattoos, Buy2Win, Buy2WinFirestoreRepository, Campaign, CampaignBanner, CampaignDashboard, CampaignDashboardFirestoreRepository, CampaignHashtag, CampaignHashtagFirestoreRepository, Category, CategoryCollectionChildren, CategoryCollectionChildrenHasuraGraphQLRepository, CategoryFilter, CategoryFilterHasuraGraphQLRepository, CategoryFirestoreRepository, CategoryHasuraGraphQL, CategoryHasuraGraphQLRepository, Checkout, CheckoutFirestoreRepository, CheckoutSubscription, CheckoutSubscriptionFirestoreRepository, CheckoutTypes, ClassNameHelper, ConnectBaseDocumentSnapshot, ConnectCollectionService, ConnectDocumentService, ConnectFirestoreService, Coupon, CouponCategory, CouponFirestoreRepository, CouponSubtypes, CouponTypes, Debug, DebugDecoratorHelper, DebugHelper, DebugNamespaces, DuplicatedResultsError, Edition, EditionStatus, Exclusivities, FaceSkinOilinesses, FaceSkinProblems, FaceSkinTones, FamilyIncomes, Filter, FilterHasuraGraphQLRepository, FilterOption, FilterOptionHasuraGraphQLRepository, FilterType, FirebaseFileUploaderService, FragranceImportances, GenderDestination, HairColors, HairProblems, HairStrands, HairTypes, Home, HomeFirestoreRepository, InvalidArgumentError, KitProduct, KitProductHasuraGraphQL, Lead, LeadFirestoreRepository, LegacyOrderFirestoreRepository, LineItem, Log, LogDocument, LogFirestoreRepository, Logger, NotFoundError, OfficePosition, Order, OrderBlocked, OrderBlockedFirestoreRepository, OrderFirestoreRepository, OrderStatus, Payment, PaymentFirestoreRepository, PaymentType, PersonTypes, Plans, Product, ProductFirestoreRepository, ProductHasuraGraphQL, ProductHasuraGraphQLRepository, ProductReviews, ProductReviewsHasuraGraphQLRepository, ProductSpents, ProductStockNotification, ProductStockNotificationHasuraGraphQLRepository, ProductVariantFirestoreRepository, ProductsIndex, ProductsVertexSearch, QuestionsFilters, RecoveryPassword, ReflectHelper, Register, RegisterFirebaseAuthService, RequiredArgumentError, RoundProductPricesHelper, ShippingMethod, ShopMenu, ShopMenuFirestoreRepository, ShopPageName, ShopSettings, ShopSettingsFirestoreRepository, Shops, SignInMethods, SignOut, Status, Subscription, SubscriptionEditionFirestoreRepository, SubscriptionFirestoreRepository, SubscriptionMaterialization, SubscriptionMaterializationFirestoreRepository, SubscriptionPayment, SubscriptionPaymentFirestoreRepository, SubscriptionPlan, SubscriptionPlanFirestoreRepository, SubscriptionProductFirestoreRepository, SubscriptionSummary, SubscriptionSummaryFirestoreRepository, Trace, UnauthorizedError, UpdateOptionActions, UpdateUserImage, User, UserAddress, UserAddressFirestoreRepository, UserAlreadyRegisteredError, UserBeautyProfileFirestoreRepository, UserFirestoreRepository, UserPaymentMethod, UserPaymentMethodFirestoreRepository, UserType, Variant, VariantHasuraGraphQL, VariantHasuraGraphQLRepository, VertexAxiosAdapter, WeakPasswordError, Where, Wishlist, WishlistHasuraGraphQLRepository, WishlistLogType, is, isDebuggable, isUUID, parseDateTime, withCreateFirestore, withCreateHasuraGraphQL, withCrudFirestore, withCrudHasuraGraphQL, withDeleteFirestore, withDeleteHasuraGraphQL, withFindFirestore, withFindHasuraGraphQL, withFirestore, withGetFirestore, withGetHasuraGraphQL, withHasuraGraphQL, withHelpers, withSubCollection, withUpdateFirestore, withUpdateHasuraGraphQL };
6170
+ export { AccessoryImportances, Address, Area, Authentication, AuthenticationFirebaseAuthService, AxiosAdapter, Base, BaseModel, BeardProblems, BeardSizes, BeautyProductImportances, BeautyProfile, BeautyQuestionsHelper, BillingStatus, BodyProblems, BodyShapes, BodyTattoos, Buy2Win, Buy2WinFirestoreRepository, Campaign, CampaignBanner, CampaignDashboard, CampaignDashboardFirestoreRepository, CampaignHashtag, CampaignHashtagFirestoreRepository, Category, CategoryCollectionChildren, CategoryCollectionChildrenHasuraGraphQLRepository, CategoryFilter, CategoryFilterHasuraGraphQLRepository, CategoryFirestoreRepository, CategoryHasuraGraphQL, CategoryHasuraGraphQLRepository, Checkout, CheckoutFirestoreRepository, CheckoutSubscription, CheckoutSubscriptionFirestoreRepository, CheckoutTypes, ClassNameHelper, ConnectBaseDocumentSnapshot, ConnectCollectionService, ConnectDocumentService, ConnectFirestoreService, Coupon, CouponFirestoreRepository, CouponSubtypes, CouponTypes, Debug, DebugDecoratorHelper, DebugHelper, DebugNamespaces, DuplicatedResultsError, Edition, EditionStatus, Exclusivities, FaceSkinOilinesses, FaceSkinProblems, FaceSkinTones, FamilyIncomes, Filter, FilterHasuraGraphQLRepository, FilterOption, FilterOptionHasuraGraphQLRepository, FilterType, FirebaseFileUploaderService, FragranceImportances, GenderDestination, HairColors, HairProblems, HairStrands, HairTypes, Home, HomeFirestoreRepository, InvalidArgumentError, KitProduct, KitProductHasuraGraphQL, Lead, LeadFirestoreRepository, LegacyOrderFirestoreRepository, LineItem, Log, Logger, NotFoundError, OfficePosition, Order, OrderFirestoreRepository, OrderStatus, Payment, PaymentFirestoreRepository, PaymentType, Plans, Product, ProductFirestoreRepository, ProductHasuraGraphQL, ProductHasuraGraphQLRepository, ProductReviews, ProductReviewsHasuraGraphQLRepository, ProductSpents, ProductStockNotification, ProductStockNotificationHasuraGraphQLRepository, ProductVariantFirestoreRepository, ProductsIndex, QuestionsFilters, RecoveryPassword, ReflectHelper, Register, RegisterFirebaseAuthService, RequiredArgumentError, RoundProductPricesHelper, ShippingMethod, ShopMenu, ShopMenuFirestoreRepository, ShopPageName, ShopSettings, ShopSettingsFirestoreRepository, Shops, SignInMethods, SignOut, Status, Subscription, SubscriptionEditionFirestoreRepository, SubscriptionFirestoreRepository, SubscriptionMaterialization, SubscriptionMaterializationFirestoreRepository, SubscriptionPayment, SubscriptionPaymentFirestoreRepository, SubscriptionPlan, SubscriptionPlanFirestoreRepository, SubscriptionProductFirestoreRepository, SubscriptionSummary, SubscriptionSummaryFirestoreRepository, Trace, UnauthorizedError, UpdateOptionActions, UpdateUserImage, User, UserAddress, UserAddressFirestoreRepository, UserAlreadyRegisteredError, UserBeautyProfileFirestoreRepository, UserFirestoreRepository, UserPaymentMethod, UserPaymentMethodFirestoreRepository, UserType, Variant, VariantHasuraGraphQL, VariantHasuraGraphQLRepository, WeakPasswordError, Where, Wishlist, WishlistHasuraGraphQLRepository, is, isDebuggable, isUUID, parseDateTime, withCreateFirestore, withCreateHasuraGraphQL, withCrudFirestore, withCrudHasuraGraphQL, withDeleteFirestore, withDeleteHasuraGraphQL, withFindFirestore, withFindHasuraGraphQL, withFirestore, withGetFirestore, withGetHasuraGraphQL, withHasuraGraphQL, withHelpers, withSubCollection, withUpdateFirestore, withUpdateHasuraGraphQL };