@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.cjs.js CHANGED
@@ -42,30 +42,6 @@ class BaseModel {
42
42
  }
43
43
  }
44
44
 
45
- exports.GenderDestination = void 0;
46
- (function (GenderDestination) {
47
- GenderDestination["FEMALE"] = "female";
48
- GenderDestination["MALE"] = "male";
49
- GenderDestination["UNISEX"] = "unisex";
50
- })(exports.GenderDestination || (exports.GenderDestination = {}));
51
-
52
- exports.Shops = void 0;
53
- (function (Shops) {
54
- Shops["MENSMARKET"] = "mensmarket";
55
- Shops["GLAMSHOP"] = "Glamshop";
56
- Shops["GLAMPOINTS"] = "Glampoints";
57
- Shops["ALL"] = "ALL";
58
- })(exports.Shops || (exports.Shops = {}));
59
-
60
- exports.WishlistLogType = void 0;
61
- (function (WishlistLogType) {
62
- WishlistLogType["CREATE"] = "create";
63
- WishlistLogType["UPDATE"] = "update";
64
- WishlistLogType["DELETE"] = "delete";
65
- WishlistLogType["ADD_PRODUCT"] = "add_product";
66
- WishlistLogType["REMOVE_PRODUCT"] = "remove_product";
67
- })(exports.WishlistLogType || (exports.WishlistLogType = {}));
68
-
69
45
  class Filter extends BaseModel {
70
46
  static get identifiersFields() {
71
47
  return ['id'];
@@ -80,33 +56,6 @@ class CategoryBase extends BaseModel {
80
56
  static get identifiersFields() {
81
57
  return ['id'];
82
58
  }
83
- get glamImages() {
84
- return this.images && this.images[exports.Shops.GLAMSHOP]
85
- ? this.images[exports.Shops.GLAMSHOP]
86
- : {
87
- brandBanner: null,
88
- brandBannerMobile: null,
89
- image: null,
90
- };
91
- }
92
- get mensImages() {
93
- return this.images && this.images[exports.Shops.MENSMARKET]
94
- ? this.images[exports.Shops.MENSMARKET]
95
- : {
96
- brandBanner: null,
97
- brandBannerMobile: null,
98
- image: null,
99
- };
100
- }
101
- get glamMetadata() {
102
- return this.metadatas.find((metadata) => metadata.shop === exports.Shops.GLAMSHOP);
103
- }
104
- get mensMetadata() {
105
- return this.metadatas.find((metadata) => metadata.shop === exports.Shops.MENSMARKET);
106
- }
107
- getMostRelevantByShop(shop) {
108
- return this.mostRelevants && this.mostRelevants[shop] ? this.mostRelevants[shop] : [];
109
- }
110
59
  }
111
60
  tslib.__decorate([
112
61
  classTransformer.Type(() => CategoryBase),
@@ -215,6 +164,21 @@ tslib.__decorate([
215
164
  tslib.__metadata("design:type", Category)
216
165
  ], CategoryFilter.prototype, "category", void 0);
217
166
 
167
+ exports.GenderDestination = void 0;
168
+ (function (GenderDestination) {
169
+ GenderDestination["FEMALE"] = "female";
170
+ GenderDestination["MALE"] = "male";
171
+ GenderDestination["UNISEX"] = "unisex";
172
+ })(exports.GenderDestination || (exports.GenderDestination = {}));
173
+
174
+ exports.Shops = void 0;
175
+ (function (Shops) {
176
+ Shops["MENSMARKET"] = "mensmarket";
177
+ Shops["GLAMSHOP"] = "Glamshop";
178
+ Shops["GLAMPOINTS"] = "Glampoints";
179
+ Shops["ALL"] = "ALL";
180
+ })(exports.Shops || (exports.Shops = {}));
181
+
218
182
  class FilterOption extends BaseModel {
219
183
  static get identifiersFields() {
220
184
  return ['id'];
@@ -307,17 +271,6 @@ class CampaignHashtag extends BaseModel {
307
271
  }
308
272
  }
309
273
 
310
- class BeautyProfile extends BaseModel {
311
- toPlain() {
312
- const plain = super.toPlain();
313
- delete plain.id;
314
- return plain;
315
- }
316
- static get identifiersFields() {
317
- return ['id', 'userId'];
318
- }
319
- }
320
-
321
274
  exports.AccessoryImportances = void 0;
322
275
  (function (AccessoryImportances) {
323
276
  AccessoryImportances["NOT_INTERESTED"] = "N\u00E3o tenho interesse";
@@ -494,13 +447,6 @@ exports.OfficePosition = void 0;
494
447
  OfficePosition["Director"] = "Diretor";
495
448
  })(exports.OfficePosition || (exports.OfficePosition = {}));
496
449
 
497
- exports.PersonTypes = void 0;
498
- (function (PersonTypes) {
499
- PersonTypes["GLAMGIRL"] = "glamgirl";
500
- PersonTypes["BFLU"] = "bflu";
501
- PersonTypes["NONE"] = "none";
502
- })(exports.PersonTypes || (exports.PersonTypes = {}));
503
-
504
450
  exports.ProductSpents = void 0;
505
451
  (function (ProductSpents) {
506
452
  ProductSpents["UNTIL_50"] = "At\u00E9 R$50";
@@ -521,12 +467,6 @@ exports.UserType = void 0;
521
467
  UserType["Influencer"] = "Influencer";
522
468
  })(exports.UserType || (exports.UserType = {}));
523
469
 
524
- class Lead extends BaseModel {
525
- static get identifiersFields() {
526
- return ['id'];
527
- }
528
- }
529
-
530
470
  class Edition extends BaseModel {
531
471
  static get identifiersFields() {
532
472
  return ['id', 'subscriptionId'];
@@ -1852,6 +1792,40 @@ const parseDateTime = (value) => {
1852
1792
  return date;
1853
1793
  };
1854
1794
 
1795
+ exports.CheckoutTypes = void 0;
1796
+ (function (CheckoutTypes) {
1797
+ CheckoutTypes[CheckoutTypes["ECOMMERCE"] = 1] = "ECOMMERCE";
1798
+ CheckoutTypes[CheckoutTypes["SUBSCRIPTION"] = 2] = "SUBSCRIPTION";
1799
+ CheckoutTypes[CheckoutTypes["ALL"] = 3] = "ALL";
1800
+ })(exports.CheckoutTypes || (exports.CheckoutTypes = {}));
1801
+
1802
+ exports.CouponTypes = void 0;
1803
+ (function (CouponTypes) {
1804
+ CouponTypes[CouponTypes["ABSOLUTE"] = 1] = "ABSOLUTE";
1805
+ CouponTypes[CouponTypes["PERCENTAGE"] = 2] = "PERCENTAGE";
1806
+ // FINANCIAL = 1,
1807
+ // PRODUCT,
1808
+ // GIFTCARD,
1809
+ // VOUCHER,
1810
+ })(exports.CouponTypes || (exports.CouponTypes = {}));
1811
+
1812
+ exports.CouponSubtypes = void 0;
1813
+ (function (CouponSubtypes) {
1814
+ CouponSubtypes[CouponSubtypes["ABSOLUTE"] = 1] = "ABSOLUTE";
1815
+ CouponSubtypes[CouponSubtypes["PERCENTAGE"] = 2] = "PERCENTAGE";
1816
+ })(exports.CouponSubtypes || (exports.CouponSubtypes = {}));
1817
+
1818
+ exports.Exclusivities = void 0;
1819
+ (function (Exclusivities) {
1820
+ Exclusivities[Exclusivities["ALL_USERS"] = 1] = "ALL_USERS";
1821
+ Exclusivities[Exclusivities["SPECIFIC_USER"] = 2] = "SPECIFIC_USER";
1822
+ Exclusivities[Exclusivities["COLLABORATORS"] = 3] = "COLLABORATORS";
1823
+ Exclusivities[Exclusivities["ACTIVE_SUBSCRIBER"] = 4] = "ACTIVE_SUBSCRIBER";
1824
+ Exclusivities[Exclusivities["INACTIVE_SUBSCRIBER"] = 5] = "INACTIVE_SUBSCRIBER";
1825
+ Exclusivities[Exclusivities["NON_SUBSCRIBER"] = 6] = "NON_SUBSCRIBER";
1826
+ })(exports.Exclusivities || (exports.Exclusivities = {}));
1827
+
1828
+ const COUPON_EXPIRATION = +1000 * 60 * 60 * 24 * 30;
1855
1829
  class Coupon extends BaseModel {
1856
1830
  get isInfluencer() {
1857
1831
  return !lodash.isNil(this.influencerEmail);
@@ -1859,6 +1833,30 @@ class Coupon extends BaseModel {
1859
1833
  static get identifiersFields() {
1860
1834
  return ['id'];
1861
1835
  }
1836
+ static createCoupon(userId) {
1837
+ return this.toInstance({
1838
+ nickname: `${Date.now()}`,
1839
+ checkoutType: exports.CheckoutTypes.ECOMMERCE,
1840
+ discount: {
1841
+ subscriber: {
1842
+ type: exports.CouponTypes.ABSOLUTE,
1843
+ value: 10,
1844
+ },
1845
+ non_subscriber: {
1846
+ type: exports.CouponTypes.ABSOLUTE,
1847
+ value: 10,
1848
+ },
1849
+ subscription: {
1850
+ type: exports.CouponTypes.ABSOLUTE,
1851
+ value: 10,
1852
+ },
1853
+ },
1854
+ user: userId,
1855
+ createdAt: new Date(Date.now()),
1856
+ beginAt: new Date(Date.now()),
1857
+ expiresIn: new Date(Date.now() + COUPON_EXPIRATION),
1858
+ });
1859
+ }
1862
1860
  }
1863
1861
 
1864
1862
  class SubscriptionPlan extends BaseModel {
@@ -1867,6 +1865,17 @@ class SubscriptionPlan extends BaseModel {
1867
1865
  }
1868
1866
  }
1869
1867
 
1868
+ class BeautyProfile extends BaseModel {
1869
+ toPlain() {
1870
+ const plain = super.toPlain();
1871
+ delete plain.id;
1872
+ return plain;
1873
+ }
1874
+ static get identifiersFields() {
1875
+ return ['id', 'userId'];
1876
+ }
1877
+ }
1878
+
1870
1879
  class User extends BaseModel {
1871
1880
  static toInstance(data) {
1872
1881
  const instance = super.toInstance(data);
@@ -1980,6 +1989,12 @@ class UserPaymentMethod extends BaseModel {
1980
1989
  }
1981
1990
  }
1982
1991
 
1992
+ class Lead extends BaseModel {
1993
+ static get identifiersFields() {
1994
+ return ['id'];
1995
+ }
1996
+ }
1997
+
1983
1998
  class UnauthorizedError extends tsCustomError.CustomError {
1984
1999
  constructor(message) {
1985
2000
  super(message);
@@ -2133,55 +2148,6 @@ tslib.__decorate([
2133
2148
  tslib.__metadata("design:type", Coupon)
2134
2149
  ], Checkout.prototype, "coupon", void 0);
2135
2150
 
2136
- exports.CouponCategory = void 0;
2137
- (function (CouponCategory) {
2138
- CouponCategory["Reembolso"] = "Reembolso";
2139
- CouponCategory["Desculpas"] = "Desculpas";
2140
- CouponCategory["BFlu"] = "BFlu";
2141
- CouponCategory["ROYAL"] = "Royal";
2142
- CouponCategory["Glamqueen"] = "Glamqueen";
2143
- CouponCategory["Glampartner"] = "Glampartner";
2144
- CouponCategory["Glamgirl"] = "Glamgirl";
2145
- CouponCategory["Glamdiva"] = "Glamdiva";
2146
- CouponCategory["Impulsionamento"] = "Impulsionamento";
2147
- CouponCategory["PaidMedia"] = "Paid Media";
2148
- CouponCategory["Organic"] = "Organic";
2149
- CouponCategory["Direct"] = "Direct";
2150
- CouponCategory["CRM"] = "CRM";
2151
- CouponCategory["LOJAUNICO"] = "Loja \u00FAnico";
2152
- CouponCategory["Outros"] = "Outros";
2153
- })(exports.CouponCategory || (exports.CouponCategory = {}));
2154
-
2155
- exports.CouponSubtypes = void 0;
2156
- (function (CouponSubtypes) {
2157
- CouponSubtypes[CouponSubtypes["ABSOLUTE"] = 1] = "ABSOLUTE";
2158
- CouponSubtypes[CouponSubtypes["PERCENTAGE"] = 2] = "PERCENTAGE";
2159
- })(exports.CouponSubtypes || (exports.CouponSubtypes = {}));
2160
-
2161
- exports.CouponTypes = void 0;
2162
- (function (CouponTypes) {
2163
- CouponTypes[CouponTypes["ABSOLUTE"] = 1] = "ABSOLUTE";
2164
- CouponTypes[CouponTypes["PERCENTAGE"] = 2] = "PERCENTAGE";
2165
- CouponTypes[CouponTypes["SHIPPING"] = 3] = "SHIPPING";
2166
- })(exports.CouponTypes || (exports.CouponTypes = {}));
2167
-
2168
- exports.Exclusivities = void 0;
2169
- (function (Exclusivities) {
2170
- Exclusivities[Exclusivities["ALL_USERS"] = 1] = "ALL_USERS";
2171
- Exclusivities[Exclusivities["SPECIFIC_USER"] = 2] = "SPECIFIC_USER";
2172
- Exclusivities[Exclusivities["COLLABORATORS"] = 3] = "COLLABORATORS";
2173
- Exclusivities[Exclusivities["ACTIVE_SUBSCRIBER"] = 4] = "ACTIVE_SUBSCRIBER";
2174
- Exclusivities[Exclusivities["INACTIVE_SUBSCRIBER"] = 5] = "INACTIVE_SUBSCRIBER";
2175
- Exclusivities[Exclusivities["NON_SUBSCRIBER"] = 6] = "NON_SUBSCRIBER";
2176
- })(exports.Exclusivities || (exports.Exclusivities = {}));
2177
-
2178
- exports.CheckoutTypes = void 0;
2179
- (function (CheckoutTypes) {
2180
- CheckoutTypes[CheckoutTypes["ECOMMERCE"] = 1] = "ECOMMERCE";
2181
- CheckoutTypes[CheckoutTypes["SUBSCRIPTION"] = 2] = "SUBSCRIPTION";
2182
- CheckoutTypes[CheckoutTypes["ALL"] = 3] = "ALL";
2183
- })(exports.CheckoutTypes || (exports.CheckoutTypes = {}));
2184
-
2185
2151
  exports.OrderStatus = void 0;
2186
2152
  (function (OrderStatus) {
2187
2153
  OrderStatus["AGUARDANDO_PAGAMENTO"] = "Aguardando pagamento";
@@ -2201,12 +2167,6 @@ tslib.__decorate([
2201
2167
  tslib.__metadata("design:type", Payment)
2202
2168
  ], Order.prototype, "payment", void 0);
2203
2169
 
2204
- class OrderBlocked extends BaseModel {
2205
- static get identifiersFields() {
2206
- return ['id'];
2207
- }
2208
- }
2209
-
2210
2170
  class CheckoutSubscription extends BaseModel {
2211
2171
  static get identifiersFields() {
2212
2172
  return ['id'];
@@ -2243,12 +2203,6 @@ class RoundProductPricesHelper {
2243
2203
  }
2244
2204
  }
2245
2205
 
2246
- class LogDocument extends BaseModel {
2247
- static get identifiersFields() {
2248
- return ['id'];
2249
- }
2250
- }
2251
-
2252
2206
  exports.FilterType = void 0;
2253
2207
  (function (FilterType) {
2254
2208
  FilterType["ACCESSORY_IMPORTANCE"] = "accessoryImportance";
@@ -2547,6 +2501,8 @@ class ProductsIndex {
2547
2501
  'rate',
2548
2502
  ];
2549
2503
  const filter = [{ term: { published: true } }];
2504
+ if (shop && shop !== exports.Shops.ALL)
2505
+ filter.push({ term: { tags: shop == exports.Shops.GLAMSHOP ? 'feminino' : 'masculino' } });
2550
2506
  if (size > 9)
2551
2507
  fields.push(...['pricePaid', 'isGift', 'stock', 'weight', 'tags']);
2552
2508
  const query = {
@@ -2602,9 +2558,7 @@ class ProductsIndex {
2602
2558
  RoundProductPricesHelper.roundProductPrices(hit._source);
2603
2559
  return hit;
2604
2560
  });
2605
- return search.hits.map((hit) => {
2606
- return Object.assign(Object.assign({}, hit._source), { stock: hit._source.stock.quantity });
2607
- });
2561
+ return search;
2608
2562
  }
2609
2563
  async save(product) {
2610
2564
  try {
@@ -3038,8 +2992,6 @@ const withUpdateFirestore = (MixinBase) => {
3038
2992
  try {
3039
2993
  const identifiers = getValueFromParams(data, keyField);
3040
2994
  const docRef = this.collection(collectionName).getDoc(identifiers.toString());
3041
- if (!(await docRef.get()).data())
3042
- throw new NotFoundError(`Document '${collectionName}/${Object.values(identifiers.toString())}' not found`);
3043
2995
  const plainFromData = this.model.toInstance(this.paramsToPlain(data));
3044
2996
  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 }));
3045
2997
  const builded = (intercepted === null || intercepted === void 0 ? void 0 : intercepted.instance) || plainFromData;
@@ -3116,280 +3068,359 @@ const withCrudFirestore = (MixinBase) => {
3116
3068
  };
3117
3069
  };
3118
3070
 
3119
- class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3071
+ class LeadFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3120
3072
  constructor({ firestore, interceptors }) {
3121
3073
  super({
3122
3074
  firestore,
3123
- collectionName: 'categories',
3124
- model: Category,
3075
+ collectionName: 'leads',
3076
+ model: Lead,
3125
3077
  interceptors,
3126
3078
  });
3127
3079
  }
3128
- async getCategoryBySlug(slug, shop) {
3129
- const categoryDocs = await this.collection(this.collectionName)
3130
- .where('slug', '==', slug)
3131
- .where('shop', '==', shop)
3132
- .where('published', '==', true)
3133
- .getDocs();
3134
- if (categoryDocs.size > 1)
3135
- throw new DuplicatedResultsError('Query returned duplicated values');
3136
- if (categoryDocs.empty)
3137
- throw new NotFoundError(`Document with slug ${slug} not found`);
3138
- return categoryDocs.docs[0].data();
3139
- }
3140
- async getCategoriesForHome(categoryIds, shop, limit = 4) {
3141
- const categorySnap = await this.collection(this.collectionName)
3142
- .where('id', 'in', categoryIds.filter(Boolean))
3143
- .where('published', '==', true)
3144
- .getDocs();
3145
- if (categorySnap.empty)
3146
- throw new NotFoundError('Categories not found');
3147
- const categories = categorySnap.docs.map((doc) => doc.data());
3148
- const homeSections = await Promise.all(categories.map(async (category) => ({
3149
- category,
3150
- products: await this.mountCategory(category, shop, { limit, hasStock: true }),
3151
- })));
3152
- return homeSections;
3153
- }
3154
- async mountCategory(category, shop, options) {
3155
- if (!category.products)
3156
- throw new RequiredArgumentError(['Category products is empty']);
3157
- const chunks = lodash.chunk(category.products, 10);
3158
- const products = [];
3159
- const wheres = [];
3160
- for (const productIds of chunks) {
3161
- if ((options === null || options === void 0 ? void 0 : options.limit) && products.length >= (options === null || options === void 0 ? void 0 : options.limit))
3162
- break;
3163
- wheres.push(['published', '==', true], ['id', 'in', productIds]);
3164
- if (options === null || options === void 0 ? void 0 : options.hasStock)
3165
- wheres.push(['stock.quantity', '>', 0]);
3166
- if (options === null || options === void 0 ? void 0 : options.gender)
3167
- wheres.push(['tags', 'array-contains', options === null || options === void 0 ? void 0 : options.gender]);
3168
- const productSnap = await wheres
3169
- .reduce((collection, where) => collection.where(...where), (options === null || options === void 0 ? void 0 : options.limit)
3170
- ? this.collection('productsErpVitrine').limit(options.limit)
3171
- : this.collection('productsErpVitrine'))
3172
- .getDocs();
3173
- if (productSnap.empty)
3174
- continue;
3175
- products.push(...productSnap.docs);
3176
- }
3177
- return is(products);
3178
- }
3179
- getCategoryByShop(shop) {
3180
- return;
3181
- }
3182
- getChildren(parentId) {
3183
- return;
3080
+ }
3081
+
3082
+ class SubscriptionEditionFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
3083
+ constructor({ firestore, interceptors }, parentRepository) {
3084
+ super({
3085
+ firestore,
3086
+ collectionName: 'editions',
3087
+ parentIdField: 'subscriptionId',
3088
+ model: Edition,
3089
+ interceptors,
3090
+ });
3091
+ this.parentRepository = parentRepository;
3184
3092
  }
3185
- isChild(id, parentId) {
3186
- return;
3093
+ }
3094
+
3095
+ class SubscriptionFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3096
+ constructor({ firestore, interceptors, }) {
3097
+ super({
3098
+ firestore,
3099
+ collectionName: 'subscription',
3100
+ model: Subscription,
3101
+ interceptors,
3102
+ });
3187
3103
  }
3188
3104
  }
3189
- tslib.__decorate([
3190
- Log(),
3191
- tslib.__metadata("design:type", Function),
3192
- tslib.__metadata("design:paramtypes", [String, String]),
3193
- tslib.__metadata("design:returntype", Promise)
3194
- ], CategoryFirestoreRepository.prototype, "getCategoryBySlug", null);
3195
- tslib.__decorate([
3196
- Log(),
3197
- tslib.__metadata("design:type", Function),
3198
- tslib.__metadata("design:paramtypes", [Array, String, Object]),
3199
- tslib.__metadata("design:returntype", Promise)
3200
- ], CategoryFirestoreRepository.prototype, "getCategoriesForHome", null);
3201
- tslib.__decorate([
3202
- Log(),
3203
- tslib.__metadata("design:type", Function),
3204
- tslib.__metadata("design:paramtypes", [Category, String, Object]),
3205
- tslib.__metadata("design:returntype", Promise)
3206
- ], CategoryFirestoreRepository.prototype, "mountCategory", null);
3207
3105
 
3208
- class ProductFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3106
+ class SubscriptionMaterializationFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3209
3107
  constructor({ firestore, interceptors }) {
3210
3108
  super({
3211
3109
  firestore,
3212
- collectionName: 'productsErpVitrine',
3213
- model: Product,
3110
+ collectionName: 'subscriptionMaterialization',
3111
+ model: SubscriptionMaterialization,
3214
3112
  interceptors,
3215
3113
  });
3216
- this.reviews = {};
3217
3114
  }
3218
- fetchProductReviews(filters) {
3219
- throw new Error('Method not implemented.');
3115
+ }
3116
+
3117
+ class SubscriptionPaymentFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
3118
+ constructor({ firestore, interceptors }, parentRepository) {
3119
+ super({
3120
+ firestore,
3121
+ collectionName: 'payments',
3122
+ parentIdField: 'subscriptionId',
3123
+ model: SubscriptionPayment,
3124
+ interceptors,
3125
+ });
3126
+ this.parentRepository = parentRepository;
3220
3127
  }
3221
- async getBySlug(slug) {
3222
- var _a;
3223
- const result = await this.find({
3224
- filters: {
3225
- slug: { operator: exports.Where.EQUALS, value: slug },
3226
- },
3128
+ }
3129
+
3130
+ class SubscriptionSummaryFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3131
+ constructor({ firestore, interceptors, }) {
3132
+ super({
3133
+ firestore,
3134
+ collectionName: 'subscriptionSummary',
3135
+ model: SubscriptionSummary,
3136
+ interceptors,
3227
3137
  });
3228
- return (_a = result === null || result === void 0 ? void 0 : result.data) === null || _a === void 0 ? void 0 : _a.shift();
3229
3138
  }
3230
- async fetchReviews(status) {
3231
- const { data: products } = await this.find();
3232
- products.forEach((product) => {
3233
- var _a;
3234
- if ([undefined, 0].includes((_a = product.reviews) === null || _a === void 0 ? void 0 : _a.length))
3235
- return;
3236
- const productInfo = {
3237
- productId: product.id,
3238
- productName: product.name,
3239
- productSku: product.sku,
3240
- };
3241
- this.reviews.pending = [];
3242
- this.reviews.approved = [];
3243
- this.reviews.rejected = [];
3244
- product.reviews.forEach((review) => {
3245
- if ([null, undefined].includes(review.status))
3246
- return this.reviews.pending.push(Object.assign(Object.assign({}, review), productInfo));
3247
- if (review.status === false)
3248
- return this.reviews.rejected.push(Object.assign(Object.assign({}, review), productInfo));
3249
- if (!!review.status)
3250
- return this.reviews.approved.push(Object.assign(Object.assign({}, review), productInfo));
3251
- return review;
3252
- });
3139
+ }
3140
+
3141
+ class UserAddressFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
3142
+ constructor({ firestore, interceptors }, parentRepository) {
3143
+ super({
3144
+ firestore,
3145
+ collectionName: 'address',
3146
+ parentIdField: 'userId',
3147
+ model: UserAddress,
3148
+ interceptors,
3253
3149
  });
3254
- return this.reviews[status];
3150
+ this.parentRepository = parentRepository;
3255
3151
  }
3256
- cleanShoppingCountFromIds() {
3257
- return;
3152
+ }
3153
+
3154
+ class UserBeautyProfileFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
3155
+ constructor({ firestore, interceptors }, parentRepository) {
3156
+ super({
3157
+ firestore,
3158
+ collectionName: 'CX',
3159
+ parentIdField: 'userId',
3160
+ model: BeautyProfile,
3161
+ interceptors,
3162
+ });
3163
+ this.parentRepository = parentRepository;
3258
3164
  }
3259
- findCatalog(params) {
3260
- return this.find(params);
3165
+ }
3166
+
3167
+ class UserFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3168
+ constructor({ firestore, interceptors }) {
3169
+ super({
3170
+ firestore,
3171
+ collectionName: 'users',
3172
+ model: User,
3173
+ interceptors,
3174
+ });
3261
3175
  }
3262
- async fetchPaginatedReviews() {
3263
- return Promise.resolve([]);
3176
+ async get(identifiers) {
3177
+ const user = await super.get({ id: identifiers.id });
3178
+ user.beautyProfile = await this.getBeautyProfile(user.id);
3179
+ user.isSubscriber = await this.checkIfIsSubscriber(user.id);
3180
+ return user;
3181
+ }
3182
+ async checkIfExistsByField(field, value) {
3183
+ const result = await this.find({ filters: { [field]: value } });
3184
+ return result.count > 0;
3185
+ }
3186
+ buildModelInstance() {
3187
+ const { fromFirestore, toFirestore } = super.buildModelInstance();
3188
+ return {
3189
+ toFirestore: (data) => {
3190
+ const plain = toFirestore(data);
3191
+ delete plain.isSubscriber;
3192
+ return plain;
3193
+ },
3194
+ fromFirestore,
3195
+ };
3196
+ }
3197
+ async getBeautyProfile(userId) {
3198
+ const beautyProfile = await this.firestore
3199
+ .getCollection(`${this.collectionName}/${userId}/CX`)
3200
+ .withConverter(this.buildBeautyProfileModelInstance())
3201
+ .getDoc('beautyProfile')
3202
+ .get();
3203
+ return beautyProfile.data();
3204
+ }
3205
+ async checkIfIsSubscriber(userId) {
3206
+ const docs = await this.collection('subscription')
3207
+ .where('user.id', '==', userId)
3208
+ .where('status', '==', 'active')
3209
+ .getDocs();
3210
+ return !!docs && !!docs.size;
3211
+ }
3212
+ buildBeautyProfileModelInstance() {
3213
+ return {
3214
+ toFirestore: (data) => data.toPlain(),
3215
+ fromFirestore: (snap) => BeautyProfile.toInstance(snap.data()),
3216
+ };
3264
3217
  }
3265
3218
  }
3266
3219
  tslib.__decorate([
3267
3220
  Log(),
3268
3221
  tslib.__metadata("design:type", Function),
3269
- tslib.__metadata("design:paramtypes", [String]),
3222
+ tslib.__metadata("design:paramtypes", [Object]),
3270
3223
  tslib.__metadata("design:returntype", Promise)
3271
- ], ProductFirestoreRepository.prototype, "getBySlug", null);
3224
+ ], UserFirestoreRepository.prototype, "get", null);
3272
3225
  tslib.__decorate([
3273
3226
  Log(),
3274
3227
  tslib.__metadata("design:type", Function),
3275
- tslib.__metadata("design:paramtypes", [String]),
3228
+ tslib.__metadata("design:paramtypes", [String, String]),
3276
3229
  tslib.__metadata("design:returntype", Promise)
3277
- ], ProductFirestoreRepository.prototype, "fetchReviews", null);
3230
+ ], UserFirestoreRepository.prototype, "checkIfExistsByField", null);
3278
3231
 
3279
- class ProductVariantFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
3232
+ class UserPaymentMethodFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
3280
3233
  constructor({ firestore, interceptors }, parentRepository) {
3281
3234
  super({
3282
3235
  firestore,
3283
- collectionName: 'variants',
3284
- parentIdField: 'productId',
3285
- model: Variant,
3236
+ collectionName: 'payment_method',
3237
+ parentIdField: 'userId',
3238
+ model: UserPaymentMethod,
3286
3239
  interceptors,
3287
3240
  });
3288
3241
  this.parentRepository = parentRepository;
3289
3242
  }
3290
3243
  }
3291
3244
 
3292
- class SubscriptionProductFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3245
+ class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3293
3246
  constructor({ firestore, interceptors }) {
3294
3247
  super({
3295
3248
  firestore,
3296
- collectionName: 'subscriptionProducts',
3297
- model: Product,
3249
+ collectionName: 'categories',
3250
+ model: Category,
3298
3251
  interceptors,
3299
3252
  });
3300
3253
  }
3301
- }
3302
-
3303
- class LogFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3304
- constructor({ firestore, interceptors, }) {
3305
- super({
3306
- firestore,
3307
- collectionName: 'logs',
3308
- model: LogDocument,
3309
- interceptors,
3310
- });
3254
+ async getCategoryBySlug(slug, shop) {
3255
+ const categoryDocs = await this.collection(this.collectionName)
3256
+ .where('slug', '==', slug)
3257
+ .where('shop', '==', shop)
3258
+ .where('published', '==', true)
3259
+ .getDocs();
3260
+ if (categoryDocs.size > 1)
3261
+ throw new DuplicatedResultsError('Query returned duplicated values');
3262
+ if (categoryDocs.empty)
3263
+ throw new NotFoundError(`Document with slug ${slug} not found`);
3264
+ return categoryDocs.docs[0].data();
3265
+ }
3266
+ async getCategoriesForHome(categoryIds, limit = 4, gender) {
3267
+ const categorySnap = await this.collection(this.collectionName)
3268
+ .where('id', 'in', categoryIds.filter(Boolean))
3269
+ .where('published', '==', true)
3270
+ .getDocs();
3271
+ if (categorySnap.empty)
3272
+ throw new NotFoundError('Categories not found');
3273
+ const categories = categorySnap.docs.map((doc) => doc.data());
3274
+ const homeSections = await Promise.all(categories.map(async (category) => ({
3275
+ category,
3276
+ products: await this.mountCategory(category, { limit, hasStock: true, gender }),
3277
+ })));
3278
+ return homeSections;
3279
+ }
3280
+ async mountCategory(category, options) {
3281
+ if (!category.products)
3282
+ throw new RequiredArgumentError(['Category products is empty']);
3283
+ const chunks = lodash.chunk(category.products, 10);
3284
+ const products = [];
3285
+ const wheres = [];
3286
+ for (const productIds of chunks) {
3287
+ if ((options === null || options === void 0 ? void 0 : options.limit) && products.length >= (options === null || options === void 0 ? void 0 : options.limit))
3288
+ break;
3289
+ wheres.push(['published', '==', true], ['id', 'in', productIds]);
3290
+ if (options === null || options === void 0 ? void 0 : options.hasStock)
3291
+ wheres.push(['stock.quantity', '>', 0]);
3292
+ if (options === null || options === void 0 ? void 0 : options.gender)
3293
+ wheres.push(['tags', 'array-contains', options === null || options === void 0 ? void 0 : options.gender]);
3294
+ const productSnap = await wheres
3295
+ .reduce((collection, where) => collection.where(...where), (options === null || options === void 0 ? void 0 : options.limit)
3296
+ ? this.collection('productsErpVitrine').limit(options.limit)
3297
+ : this.collection('productsErpVitrine'))
3298
+ .getDocs();
3299
+ if (productSnap.empty)
3300
+ continue;
3301
+ products.push(...productSnap.docs);
3302
+ }
3303
+ return is(products);
3304
+ }
3305
+ getCategoryByShop(shop) {
3306
+ return;
3307
+ }
3308
+ getChildren(parentId) {
3309
+ return;
3310
+ }
3311
+ isChild(id, parentId) {
3312
+ return;
3311
3313
  }
3312
3314
  }
3315
+ tslib.__decorate([
3316
+ Log(),
3317
+ tslib.__metadata("design:type", Function),
3318
+ tslib.__metadata("design:paramtypes", [String, String]),
3319
+ tslib.__metadata("design:returntype", Promise)
3320
+ ], CategoryFirestoreRepository.prototype, "getCategoryBySlug", null);
3321
+ tslib.__decorate([
3322
+ Log(),
3323
+ tslib.__metadata("design:type", Function),
3324
+ tslib.__metadata("design:paramtypes", [Array, Object, String]),
3325
+ tslib.__metadata("design:returntype", Promise)
3326
+ ], CategoryFirestoreRepository.prototype, "getCategoriesForHome", null);
3327
+ tslib.__decorate([
3328
+ Log(),
3329
+ tslib.__metadata("design:type", Function),
3330
+ tslib.__metadata("design:paramtypes", [Category, Object]),
3331
+ tslib.__metadata("design:returntype", Promise)
3332
+ ], CategoryFirestoreRepository.prototype, "mountCategory", null);
3313
3333
 
3314
- class HomeFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3334
+ class ProductFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3315
3335
  constructor({ firestore, interceptors }) {
3316
3336
  super({
3317
3337
  firestore,
3318
- collectionName: 'dms',
3319
- model: Home,
3338
+ collectionName: 'productsErpVitrine',
3339
+ model: Product,
3320
3340
  interceptors,
3321
3341
  });
3322
- this.homeCategoryGroupToPlain = (homeCategoryGroup) => {
3323
- var _a, _b, _c;
3324
- return ({
3325
- category: ((_a = homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category) === null || _a === void 0 ? void 0 : _a.toPlain)
3326
- ? (_b = homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category) === null || _b === void 0 ? void 0 : _b.toPlain()
3327
- : homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category,
3328
- 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)) || [],
3329
- });
3330
- };
3331
- this.plainToHomeCategoryGroup = (homeCategoryGroup) => {
3332
- var _a;
3333
- return ({
3334
- category: Category.toInstance(homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category),
3335
- products: (_a = homeCategoryGroup.products) === null || _a === void 0 ? void 0 : _a.map((product) => Product.toInstance(product)),
3336
- });
3337
- };
3342
+ this.reviews = {};
3338
3343
  }
3339
- buildModelInstance() {
3340
- const { fromFirestore, toFirestore } = super.buildModelInstance();
3341
- return {
3342
- toFirestore: (data) => {
3343
- const modifiedData = this.homeToFirestore(data);
3344
- return toFirestore(modifiedData);
3345
- },
3346
- fromFirestore: (snap) => {
3347
- const instance = fromFirestore(snap);
3348
- return this.homeFromFirestore(instance);
3344
+ fetchProductReviews(filters) {
3345
+ throw new Error('Method not implemented.');
3346
+ }
3347
+ async getBySlug(slug) {
3348
+ var _a;
3349
+ const result = await this.find({
3350
+ filters: {
3351
+ slug: { operator: exports.Where.EQUALS, value: slug },
3349
3352
  },
3350
- };
3353
+ });
3354
+ return (_a = result === null || result === void 0 ? void 0 : result.data) === null || _a === void 0 ? void 0 : _a.shift();
3351
3355
  }
3352
- homeToFirestore(home) {
3353
- var _a, _b, _c, _d;
3354
- if ((_a = home.data) === null || _a === void 0 ? void 0 : _a.data) {
3355
- home.data.data.discoverProducts = ((_b = home.data.data.discoverProducts) === null || _b === void 0 ? void 0 : _b.map(this.homeCategoryGroupToPlain)) || [];
3356
- home.data.data.featuredProducts = ((_c = home.data.data.featuredProducts) === null || _c === void 0 ? void 0 : _c.map(this.homeCategoryGroupToPlain)) || [];
3357
- home.data.data.verticalProducts = ((_d = home.data.data.verticalProducts) === null || _d === void 0 ? void 0 : _d.map(this.homeCategoryGroupToPlain)) || [];
3358
- }
3359
- return home;
3356
+ async fetchReviews(status) {
3357
+ const { data: products } = await this.find();
3358
+ products.forEach((product) => {
3359
+ var _a;
3360
+ if ([undefined, 0].includes((_a = product.reviews) === null || _a === void 0 ? void 0 : _a.length))
3361
+ return;
3362
+ const productInfo = {
3363
+ productId: product.id,
3364
+ productName: product.name,
3365
+ productSku: product.sku,
3366
+ };
3367
+ this.reviews.pending = [];
3368
+ this.reviews.approved = [];
3369
+ this.reviews.rejected = [];
3370
+ product.reviews.forEach((review) => {
3371
+ if ([null, undefined].includes(review.status))
3372
+ return this.reviews.pending.push(Object.assign(Object.assign({}, review), productInfo));
3373
+ if (review.status === false)
3374
+ return this.reviews.rejected.push(Object.assign(Object.assign({}, review), productInfo));
3375
+ if (!!review.status)
3376
+ return this.reviews.approved.push(Object.assign(Object.assign({}, review), productInfo));
3377
+ return review;
3378
+ });
3379
+ });
3380
+ return this.reviews[status];
3381
+ }
3382
+ cleanShoppingCountFromIds() {
3383
+ return;
3360
3384
  }
3361
- homeFromFirestore(home) {
3362
- var _a;
3363
- if ((_a = home.data) === null || _a === void 0 ? void 0 : _a.data) {
3364
- home.data.data.discoverProducts = home.data.data.discoverProducts.map(this.plainToHomeCategoryGroup);
3365
- home.data.data.featuredProducts = home.data.data.featuredProducts.map(this.plainToHomeCategoryGroup);
3366
- home.data.data.verticalProducts = home.data.data.verticalProducts.map(this.plainToHomeCategoryGroup);
3367
- home.data.createdAt =
3368
- home.data.createdAt instanceof firestore.Timestamp ? home.data.createdAt.toDate() : home.data.createdAt;
3369
- home.data.expiresAt =
3370
- home.data.expiresAt instanceof firestore.Timestamp ? home.data.expiresAt.toDate() : home.data.expiresAt;
3371
- }
3372
- return home;
3385
+ findCatalog(params) {
3386
+ return this.find(params);
3387
+ }
3388
+ async fetchPaginatedReviews() {
3389
+ return Promise.resolve([]);
3373
3390
  }
3374
3391
  }
3392
+ tslib.__decorate([
3393
+ Log(),
3394
+ tslib.__metadata("design:type", Function),
3395
+ tslib.__metadata("design:paramtypes", [String]),
3396
+ tslib.__metadata("design:returntype", Promise)
3397
+ ], ProductFirestoreRepository.prototype, "getBySlug", null);
3398
+ tslib.__decorate([
3399
+ Log(),
3400
+ tslib.__metadata("design:type", Function),
3401
+ tslib.__metadata("design:paramtypes", [String]),
3402
+ tslib.__metadata("design:returntype", Promise)
3403
+ ], ProductFirestoreRepository.prototype, "fetchReviews", null);
3375
3404
 
3376
- class ShopMenuFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3377
- constructor({ firestore, interceptors }) {
3405
+ class ProductVariantFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
3406
+ constructor({ firestore, interceptors }, parentRepository) {
3378
3407
  super({
3379
3408
  firestore,
3380
- collectionName: 'shopMenus',
3381
- model: ShopMenu,
3409
+ collectionName: 'variants',
3410
+ parentIdField: 'productId',
3411
+ model: Variant,
3382
3412
  interceptors,
3383
3413
  });
3414
+ this.parentRepository = parentRepository;
3384
3415
  }
3385
3416
  }
3386
3417
 
3387
- class ShopSettingsFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3388
- constructor({ firestore, interceptors, }) {
3418
+ class SubscriptionProductFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3419
+ constructor({ firestore, interceptors }) {
3389
3420
  super({
3390
3421
  firestore,
3391
- collectionName: 'shopSettings',
3392
- model: ShopSettings,
3422
+ collectionName: 'subscriptionProducts',
3423
+ model: Product,
3393
3424
  interceptors,
3394
3425
  });
3395
3426
  }
@@ -3525,47 +3556,6 @@ class LegacyOrderFirestoreRepository extends OrderFirestoreRepository {
3525
3556
  }
3526
3557
  }
3527
3558
 
3528
- class OrderBlockedFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3529
- constructor({ firestore, interceptors, }) {
3530
- super({
3531
- firestore,
3532
- collectionName: 'paymentBlockedAttempts',
3533
- model: OrderBlocked,
3534
- interceptors,
3535
- });
3536
- }
3537
- async createBlockedOrderOrPayment(checkout, blockType, type, limiteRange, card = null) {
3538
- var _a, _b, _c, _d, _e, _f, _g, _h;
3539
- return this.create(OrderBlocked.toInstance({
3540
- customer: {
3541
- name: ((_a = checkout.user) === null || _a === void 0 ? void 0 : _a.displayName) || '',
3542
- cpf: ((_b = checkout.user) === null || _b === void 0 ? void 0 : _b.cpf) || '',
3543
- id: (_c = checkout.user) === null || _c === void 0 ? void 0 : _c.id,
3544
- email: ((_d = checkout.user) === null || _d === void 0 ? void 0 : _d.email) || '',
3545
- phoneNumber: '+55' + ((_e = checkout.user) === null || _e === void 0 ? void 0 : _e.phone),
3546
- isSubscriber: (_f = checkout.user) === null || _f === void 0 ? void 0 : _f.isSubscriber,
3547
- subscriptionPlan: ((_g = checkout.user) === null || _g === void 0 ? void 0 : _g.subscriptionPlan) || '',
3548
- shippingAddress: Object.assign(Object.assign({}, checkout.shippingAddress), { zip: this.formatZip((_h = checkout.shippingAddress) === null || _h === void 0 ? void 0 : _h.zip) }),
3549
- },
3550
- blockType,
3551
- limiteRange,
3552
- type,
3553
- card,
3554
- checkout: {
3555
- id: checkout.id,
3556
- shop: checkout.shop,
3557
- total: checkout.totalPrice,
3558
- },
3559
- date: new Date(),
3560
- }));
3561
- }
3562
- formatZip(zip) {
3563
- if (zip.length === 8)
3564
- return zip.substring(0, 5) + '-' + zip.substring(5, 8);
3565
- return zip;
3566
- }
3567
- }
3568
-
3569
3559
  class PaymentFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3570
3560
  constructor({ firestore, interceptors }) {
3571
3561
  super({
@@ -3588,177 +3578,87 @@ class SubscriptionPlanFirestoreRepository extends withCrudFirestore(withHelpers(
3588
3578
  }
3589
3579
  }
3590
3580
 
3591
- class LeadFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3592
- constructor({ firestore, interceptors }) {
3593
- super({
3594
- firestore,
3595
- collectionName: 'leads',
3596
- model: Lead,
3597
- interceptors,
3598
- });
3599
- }
3600
- }
3601
-
3602
- class SubscriptionEditionFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
3603
- constructor({ firestore, interceptors }, parentRepository) {
3604
- super({
3605
- firestore,
3606
- collectionName: 'editions',
3607
- parentIdField: 'subscriptionId',
3608
- model: Edition,
3609
- interceptors,
3610
- });
3611
- this.parentRepository = parentRepository;
3612
- }
3613
- }
3614
-
3615
- class SubscriptionFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3616
- constructor({ firestore, interceptors, }) {
3617
- super({
3618
- firestore,
3619
- collectionName: 'subscription',
3620
- model: Subscription,
3621
- interceptors,
3622
- });
3623
- }
3624
- }
3625
-
3626
- class SubscriptionMaterializationFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3627
- constructor({ firestore, interceptors }) {
3628
- super({
3629
- firestore,
3630
- collectionName: 'subscriptionMaterialization',
3631
- model: SubscriptionMaterialization,
3632
- interceptors,
3633
- });
3634
- }
3635
- }
3636
-
3637
- class SubscriptionPaymentFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
3638
- constructor({ firestore, interceptors }, parentRepository) {
3639
- super({
3640
- firestore,
3641
- collectionName: 'payments',
3642
- parentIdField: 'subscriptionId',
3643
- model: SubscriptionPayment,
3644
- interceptors,
3645
- });
3646
- this.parentRepository = parentRepository;
3647
- }
3648
- }
3649
-
3650
- class SubscriptionSummaryFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3651
- constructor({ firestore, interceptors, }) {
3652
- super({
3653
- firestore,
3654
- collectionName: 'subscriptionSummary',
3655
- model: SubscriptionSummary,
3656
- interceptors,
3657
- });
3658
- }
3659
- }
3660
-
3661
- class UserAddressFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
3662
- constructor({ firestore, interceptors }, parentRepository) {
3663
- super({
3664
- firestore,
3665
- collectionName: 'address',
3666
- parentIdField: 'userId',
3667
- model: UserAddress,
3668
- interceptors,
3669
- });
3670
- this.parentRepository = parentRepository;
3671
- }
3672
- }
3673
-
3674
- class UserBeautyProfileFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
3675
- constructor({ firestore, interceptors }, parentRepository) {
3676
- super({
3677
- firestore,
3678
- collectionName: 'CX',
3679
- parentIdField: 'userId',
3680
- model: BeautyProfile,
3681
- interceptors,
3682
- });
3683
- this.parentRepository = parentRepository;
3684
- }
3685
- }
3686
-
3687
- class UserFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3581
+ class HomeFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3688
3582
  constructor({ firestore, interceptors }) {
3689
3583
  super({
3690
3584
  firestore,
3691
- collectionName: 'users',
3692
- model: User,
3585
+ collectionName: 'dms',
3586
+ model: Home,
3693
3587
  interceptors,
3694
3588
  });
3695
- }
3696
- async get(identifiers) {
3697
- const user = await super.get({ id: identifiers.id });
3698
- user.beautyProfile = await this.getBeautyProfile(user.id);
3699
- user.isSubscriber = await this.checkIfIsSubscriber(user.id);
3700
- return user;
3701
- }
3702
- async checkIfExistsByField(field, value) {
3703
- const result = await this.find({ filters: { [field]: value } });
3704
- return result.count > 0;
3589
+ this.homeCategoryGroupToPlain = (homeCategoryGroup) => {
3590
+ var _a, _b, _c;
3591
+ return ({
3592
+ category: ((_a = homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category) === null || _a === void 0 ? void 0 : _a.toPlain)
3593
+ ? (_b = homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category) === null || _b === void 0 ? void 0 : _b.toPlain()
3594
+ : homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category,
3595
+ 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)) || [],
3596
+ });
3597
+ };
3598
+ this.plainToHomeCategoryGroup = (homeCategoryGroup) => {
3599
+ var _a;
3600
+ return ({
3601
+ category: Category.toInstance(homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category),
3602
+ products: (_a = homeCategoryGroup.products) === null || _a === void 0 ? void 0 : _a.map((product) => Product.toInstance(product)),
3603
+ });
3604
+ };
3705
3605
  }
3706
3606
  buildModelInstance() {
3707
3607
  const { fromFirestore, toFirestore } = super.buildModelInstance();
3708
3608
  return {
3709
3609
  toFirestore: (data) => {
3710
- const plain = toFirestore(data);
3711
- delete plain.isSubscriber;
3712
- return plain;
3610
+ const modifiedData = this.homeToFirestore(data);
3611
+ return toFirestore(modifiedData);
3612
+ },
3613
+ fromFirestore: (snap) => {
3614
+ const instance = fromFirestore(snap);
3615
+ return this.homeFromFirestore(instance);
3713
3616
  },
3714
- fromFirestore,
3715
3617
  };
3716
3618
  }
3717
- async getBeautyProfile(userId) {
3718
- const beautyProfile = await this.firestore
3719
- .getCollection(`${this.collectionName}/${userId}/CX`)
3720
- .withConverter(this.buildBeautyProfileModelInstance())
3721
- .getDoc('beautyProfile')
3722
- .get();
3723
- return beautyProfile.data();
3724
- }
3725
- async checkIfIsSubscriber(userId) {
3726
- const docs = await this.collection('subscription')
3727
- .where('user.id', '==', userId)
3728
- .where('status', '==', 'active')
3729
- .getDocs();
3730
- return !!docs && !!docs.size;
3619
+ homeToFirestore(home) {
3620
+ var _a, _b, _c, _d;
3621
+ if ((_a = home.data) === null || _a === void 0 ? void 0 : _a.data) {
3622
+ home.data.data.discoverProducts = ((_b = home.data.data.discoverProducts) === null || _b === void 0 ? void 0 : _b.map(this.homeCategoryGroupToPlain)) || [];
3623
+ home.data.data.featuredProducts = ((_c = home.data.data.featuredProducts) === null || _c === void 0 ? void 0 : _c.map(this.homeCategoryGroupToPlain)) || [];
3624
+ home.data.data.verticalProducts = ((_d = home.data.data.verticalProducts) === null || _d === void 0 ? void 0 : _d.map(this.homeCategoryGroupToPlain)) || [];
3625
+ }
3626
+ return home;
3731
3627
  }
3732
- buildBeautyProfileModelInstance() {
3733
- return {
3734
- toFirestore: (data) => data.toPlain(),
3735
- fromFirestore: (snap) => BeautyProfile.toInstance(snap.data()),
3736
- };
3628
+ homeFromFirestore(home) {
3629
+ var _a;
3630
+ if ((_a = home.data) === null || _a === void 0 ? void 0 : _a.data) {
3631
+ home.data.data.discoverProducts = home.data.data.discoverProducts.map(this.plainToHomeCategoryGroup);
3632
+ home.data.data.featuredProducts = home.data.data.featuredProducts.map(this.plainToHomeCategoryGroup);
3633
+ home.data.data.verticalProducts = home.data.data.verticalProducts.map(this.plainToHomeCategoryGroup);
3634
+ home.data.createdAt =
3635
+ home.data.createdAt instanceof firestore.Timestamp ? home.data.createdAt.toDate() : home.data.createdAt;
3636
+ home.data.expiresAt =
3637
+ home.data.expiresAt instanceof firestore.Timestamp ? home.data.expiresAt.toDate() : home.data.expiresAt;
3638
+ }
3639
+ return home;
3640
+ }
3641
+ }
3642
+
3643
+ class ShopMenuFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3644
+ constructor({ firestore, interceptors }) {
3645
+ super({
3646
+ firestore,
3647
+ collectionName: 'shopMenus',
3648
+ model: ShopMenu,
3649
+ interceptors,
3650
+ });
3737
3651
  }
3738
3652
  }
3739
- tslib.__decorate([
3740
- Log(),
3741
- tslib.__metadata("design:type", Function),
3742
- tslib.__metadata("design:paramtypes", [Object]),
3743
- tslib.__metadata("design:returntype", Promise)
3744
- ], UserFirestoreRepository.prototype, "get", null);
3745
- tslib.__decorate([
3746
- Log(),
3747
- tslib.__metadata("design:type", Function),
3748
- tslib.__metadata("design:paramtypes", [String, String]),
3749
- tslib.__metadata("design:returntype", Promise)
3750
- ], UserFirestoreRepository.prototype, "checkIfExistsByField", null);
3751
3653
 
3752
- class UserPaymentMethodFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
3753
- constructor({ firestore, interceptors }, parentRepository) {
3654
+ class ShopSettingsFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3655
+ constructor({ firestore, interceptors, }) {
3754
3656
  super({
3755
3657
  firestore,
3756
- collectionName: 'payment_method',
3757
- parentIdField: 'userId',
3758
- model: UserPaymentMethod,
3658
+ collectionName: 'shopSettings',
3659
+ model: ShopSettings,
3759
3660
  interceptors,
3760
3661
  });
3761
- this.parentRepository = parentRepository;
3762
3662
  }
3763
3663
  }
3764
3664
 
@@ -4311,7 +4211,7 @@ const withHasuraGraphQL = (MixinBase) => {
4311
4211
  const response = await axios__default["default"](request);
4312
4212
  if (!lodash.isNil(response.data.errors)) {
4313
4213
  this.logger.error({ req: request, res: response.data.errors });
4314
- throw new Error(JSON.stringify(response.data.errors));
4214
+ throw new Error(response.data.errors);
4315
4215
  }
4316
4216
  this.logger.log({ req: request, res: response.data });
4317
4217
  return response.data.data;
@@ -4452,7 +4352,6 @@ const withFindHasuraGraphQL = (MixinBase) => {
4452
4352
  return class FindHasuraGraphQLMixin extends MixinBase {
4453
4353
  constructor() {
4454
4354
  super(...arguments);
4455
- this.lastDistinct = {};
4456
4355
  this.bindOrderByAttributes = (orderBy, fields) => Object.keys(orderBy).reduce((acc, current) => [
4457
4356
  ...acc,
4458
4357
  {
@@ -4488,10 +4387,9 @@ const withFindHasuraGraphQL = (MixinBase) => {
4488
4387
  });
4489
4388
  }
4490
4389
  async find(params) {
4491
- var _a, _b, _c, _d, _e, _f, _g;
4390
+ var _a, _b, _c, _d, _e, _f, _g, _h;
4492
4391
  this.logger = DebugHelper.from(this, 'find');
4493
4392
  const { filters, limits, orderBy, options } = params || {};
4494
- const tableFiltersNamed = `${this.tableName}:${JSON.stringify(filters)}`;
4495
4393
  const enableCount = (_a = options === null || options === void 0 ? void 0 : options.enableCount) !== null && _a !== void 0 ? _a : true;
4496
4394
  const variablesFilters = lodash.isNil(filters)
4497
4395
  ? {}
@@ -4542,8 +4440,8 @@ const withFindHasuraGraphQL = (MixinBase) => {
4542
4440
  },
4543
4441
  ]
4544
4442
  : []),
4545
- ...((!this.lastDistinct[tableFiltersNamed] &&
4546
- ((_c = (_b = params.options) === null || _b === void 0 ? void 0 : _b.distinct) === null || _c === void 0 ? void 0 : _c.map((distinct) => {
4443
+ ...((!((_b = params.limits) === null || _b === void 0 ? void 0 : _b.offset) &&
4444
+ ((_d = (_c = params.options) === null || _c === void 0 ? void 0 : _c.distinct) === null || _d === void 0 ? void 0 : _d.map((distinct) => {
4547
4445
  var _a, _b;
4548
4446
  const distinctOption = (_a = this.fields.find((fieldOption) => fieldOption === distinct)) !== null && _a !== void 0 ? _a : this.fields.find((fieldOption) => Object.keys(fieldOption).shift() === distinct);
4549
4447
  const fieldName = ((_b = Object.values(distinctOption).shift()) === null || _b === void 0 ? void 0 : _b.columnName) || distinct;
@@ -4564,27 +4462,28 @@ const withFindHasuraGraphQL = (MixinBase) => {
4564
4462
  []),
4565
4463
  ]);
4566
4464
  const data = result[this.tableName].map((row) => this.convertDataFromHasura(row));
4567
- 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)
4465
+ 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)
4568
4466
  ? {
4569
4467
  minimal: options.minimal.reduce((minimals, current) => {
4570
4468
  var _a;
4571
4469
  return (Object.assign(Object.assign({}, minimals), lodash.set(minimals, current, result[`${this.tableName}_aggregate`].aggregate.min[((_a = AttributeOptionHelper.FindByAttribute(current.toString().split('.').pop(), this.fields)) === null || _a === void 0 ? void 0 : _a.columnName) || current])));
4572
4470
  }, {}),
4573
4471
  }
4574
- : {})), (((_e = options === null || options === void 0 ? void 0 : options.maximum) === null || _e === void 0 ? void 0 : _e.length)
4472
+ : {})), (((_f = options === null || options === void 0 ? void 0 : options.maximum) === null || _f === void 0 ? void 0 : _f.length)
4575
4473
  ? {
4576
4474
  maximum: options.maximum.reduce((maximums, current) => {
4577
4475
  var _a;
4578
4476
  return (Object.assign(Object.assign({}, maximums), lodash.set(maximums, current, result[`${this.tableName}_aggregate`].aggregate.max[((_a = AttributeOptionHelper.FindByAttribute(current.toString().split('.').pop(), this.fields)) === null || _a === void 0 ? void 0 : _a.columnName) || current])));
4579
4477
  }, {}),
4580
4478
  }
4581
- : {})), (((_f = options === null || options === void 0 ? void 0 : options.distinct) === null || _f === void 0 ? void 0 : _f.length) && {
4582
- 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) => {
4479
+ : {})), (!((_g = params.limits) === null || _g === void 0 ? void 0 : _g.offset) &&
4480
+ ((_h = options === null || options === void 0 ? void 0 : options.distinct) === null || _h === void 0 ? void 0 : _h.length) && {
4481
+ distinct: options === null || options === void 0 ? void 0 : options.distinct.reduce((distinct, current) => {
4583
4482
  var _a, _b;
4584
4483
  const distinctOption = (_a = this.fields.find((fieldOption) => fieldOption === current)) !== null && _a !== void 0 ? _a : this.fields.find((fieldOption) => Object.keys(fieldOption).shift() === current);
4585
4484
  const fieldName = ((_b = Object.values(distinctOption).shift()) === null || _b === void 0 ? void 0 : _b.columnName) || current;
4586
4485
  return Object.assign(Object.assign({}, distinct), { [current.toString()]: result[`${this.tableName}_${current.toString()}_distinct`].map((obj) => obj[fieldName]) });
4587
- }, {})),
4486
+ }, {}),
4588
4487
  }));
4589
4488
  }
4590
4489
  };
@@ -4679,7 +4578,6 @@ class CategoryFilterHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHa
4679
4578
  fields: [
4680
4579
  'id',
4681
4580
  'description',
4682
- 'title',
4683
4581
  'slug',
4684
4582
  'enabled',
4685
4583
  { createdAt: { columnName: 'created_at' } },
@@ -4791,7 +4689,6 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
4791
4689
  'name',
4792
4690
  'description',
4793
4691
  'image',
4794
- { images: { columnName: 'images', type: HasuraGraphQLColumnType.Jsonb } },
4795
4692
  'published',
4796
4693
  'shop',
4797
4694
  { shops: { columnName: 'shops', type: HasuraGraphQLColumnType.Jsonb } },
@@ -4824,11 +4721,11 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
4824
4721
  filters: {
4825
4722
  columnName: 'filters',
4826
4723
  foreignKeyColumn: { filter_id: 'id' },
4827
- fields: [{ filter: ['id', 'title', 'description', 'slug', 'enabled'] }],
4724
+ fields: [{ filter: ['id', 'description', 'slug', 'enabled'] }],
4828
4725
  bindPersistData: (value) => ({
4829
4726
  filters: { data: value.map((filter) => ({ filter_id: filter.id })) },
4830
4727
  }),
4831
- 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)) || [],
4728
+ from: (filters) => (filters === null || filters === void 0 ? void 0 : filters.map((filter) => filter === null || filter === void 0 ? void 0 : filter.filter)) || [],
4832
4729
  },
4833
4730
  },
4834
4731
  { createdAt: { columnName: 'created_at' } },
@@ -4847,21 +4744,12 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
4847
4744
  {
4848
4745
  metadata: {
4849
4746
  columnName: 'metadata',
4850
- fields: ['shop', 'title', 'description'],
4747
+ fields: ['title', 'description'],
4851
4748
  bindPersistData: (value) => ({
4852
4749
  metadata: { data: value },
4853
4750
  }),
4854
4751
  },
4855
4752
  },
4856
- {
4857
- metadatas: {
4858
- columnName: 'metadatas',
4859
- fields: ['shop', 'title', 'description'],
4860
- bindPersistData: (value) => ({
4861
- metadatas: { data: value },
4862
- }),
4863
- },
4864
- },
4865
4753
  { isCollection: { columnName: 'is_collection' } },
4866
4754
  { isWishlist: { columnName: 'is_wishlist' } },
4867
4755
  'reference',
@@ -4876,29 +4764,14 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
4876
4764
  'theme',
4877
4765
  { bannerUrl: { columnName: 'banner_url' } },
4878
4766
  { mostRelevant: { columnName: 'most_relevant', type: HasuraGraphQLColumnType.Jsonb } },
4879
- { mostRelevants: { columnName: 'most_relevants', type: HasuraGraphQLColumnType.Jsonb } },
4880
4767
  ],
4881
4768
  });
4882
4769
  this.productRepository = productRepository;
4883
4770
  this.categoryFilterRepository = categoryFilterRepository;
4884
4771
  }
4885
4772
  async create(params) {
4886
- const { images, mostRelevants, metadatas } = params, data = tslib.__rest(params, ["images", "mostRelevants", "metadatas"]);
4887
- return super.create(Object.assign(Object.assign({}, data), { isWishlist: false, metadatas: metadatas || [{ shop: null, description: null, title: null }], mostRelevants: mostRelevants || {
4888
- [exports.Shops.GLAMSHOP]: null,
4889
- [exports.Shops.MENSMARKET]: null,
4890
- }, images: images || {
4891
- [exports.Shops.GLAMSHOP]: {
4892
- brandBanner: null,
4893
- brandBannerMobile: null,
4894
- image: null,
4895
- },
4896
- [exports.Shops.MENSMARKET]: {
4897
- brandBanner: null,
4898
- brandBannerMobile: null,
4899
- image: null,
4900
- },
4901
- } }));
4773
+ const { metadata } = params, data = tslib.__rest(params, ["metadata"]);
4774
+ return super.create(Object.assign(Object.assign({}, data), { isWishlist: false, metadata: metadata || { description: null, title: null } }));
4902
4775
  }
4903
4776
  async get(identifiers) {
4904
4777
  var _a;
@@ -4907,12 +4780,12 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
4907
4780
  : super.get(identifiers);
4908
4781
  }
4909
4782
  async update(params) {
4910
- const { products, id: checkId, metadatas, filters } = params, data = tslib.__rest(params, ["products", "id", "metadatas", "filters"]);
4783
+ const { products, id: checkId, metadata, filters } = params, data = tslib.__rest(params, ["products", "id", "metadata", "filters"]);
4911
4784
  const plainData = this.paramsToPlain({ id: checkId });
4912
4785
  const id = await this.getId(plainData.id);
4913
4786
  const category = await super.update(Object.assign(Object.assign({ id }, data), { isWishlist: false }));
4914
4787
  category.products = products && (await this.updateProducts(+id, { products }));
4915
- category.metadatas = metadatas && (await this.updateMetadata(+id, { metadatas }));
4788
+ category.metadata = metadata && (await this.updateMetadata(+id, { metadata }));
4916
4789
  category.filters = filters && (await this.updateFilters(+id, { filters }));
4917
4790
  return category;
4918
4791
  }
@@ -4950,7 +4823,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
4950
4823
  });
4951
4824
  return data;
4952
4825
  }
4953
- async getCategoriesForHome(categoryIds, shop, limit = 4) {
4826
+ async getCategoriesForHome(categoryIds, limit = 4, gender) {
4954
4827
  if (!(categoryIds === null || categoryIds === void 0 ? void 0 : categoryIds.length))
4955
4828
  return [];
4956
4829
  const categoriesFirestore = categoryIds.filter((categoryId) => Number.isNaN(+categoryId));
@@ -4962,32 +4835,22 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
4962
4835
  }).then(({ data }) => data)));
4963
4836
  if (categoriesHasura.length)
4964
4837
  categories.push(...(await this.find({
4965
- filters: {
4966
- id: { operator: exports.Where.IN, value: categoriesHasura.filter(Boolean) },
4967
- published: true,
4968
- },
4838
+ filters: { id: { operator: exports.Where.IN, value: categoriesHasura.filter(Boolean) }, published: true },
4969
4839
  }).then(({ data }) => data)));
4970
4840
  if (!categories.length)
4971
4841
  return [];
4972
4842
  const homeSections = await Promise.all(categories.map(async (category) => ({
4973
4843
  category,
4974
- products: await this.mountCategory(category, shop, { limit, hasStock: true }),
4844
+ products: await this.mountCategory(category, { limit, hasStock: true, gender }),
4975
4845
  })));
4976
4846
  return homeSections;
4977
4847
  }
4978
- async mountCategory(category, shop, options) {
4848
+ async mountCategory(category, options) {
4979
4849
  var _a;
4980
4850
  if (!((_a = category === null || category === void 0 ? void 0 : category.products) === null || _a === void 0 ? void 0 : _a.length))
4981
4851
  return [];
4982
- const mostRelevants = category.getMostRelevantByShop(shop);
4983
- const mostRelevantProductsIds = [...new Set(mostRelevants.concat(category.products))];
4984
4852
  const products = [];
4985
- const { data: productsData } = await this.productRepository.findCatalog({
4986
- filters: {
4987
- id: { operator: exports.Where.IN, value: mostRelevantProductsIds },
4988
- published: true,
4989
- },
4990
- fields: [
4853
+ const { data: productsData } = await this.productRepository.find(Object.assign(Object.assign({ filters: Object.assign(Object.assign({ id: { operator: exports.Where.IN, value: category.products }, published: true }, ((options === null || options === void 0 ? void 0 : options.hasStock) ? { stock: { quantity: { operator: exports.Where.GT, value: 0 } } } : {})), ((options === null || options === void 0 ? void 0 : options.gender) ? { tags: { operator: exports.Where.IN, value: [options === null || options === void 0 ? void 0 : options.gender] } } : {})), fields: [
4991
4854
  'id',
4992
4855
  'name',
4993
4856
  'slug',
@@ -5013,29 +4876,12 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
5013
4876
  'shoppingCount',
5014
4877
  'gender',
5015
4878
  'createdAt',
5016
- ],
5017
- options: { enableCount: false },
5018
- orderBy: {
5019
- shoppingCount: 'desc',
5020
- rate: 'desc',
5021
- stock: 'desc',
5022
- name: 'asc',
5023
- },
5024
- }, shop === exports.Shops.MENSMARKET ? 'male' : 'female');
5025
- const mostRelevantWithouyStock = productsData.filter((product) => mostRelevants.includes(product.id) && product.stock.quantity <= 0);
5026
- const firstProducts = productsData
5027
- .filter((product) => mostRelevants.includes(product.id) && product.stock.quantity > 0)
5028
- .sort((a, b) => mostRelevants.indexOf(a.id) - mostRelevants.indexOf(b.id));
5029
- const lastProducts = productsData
5030
- .filter((product) => !mostRelevants.includes(product.id) && product.stock.quantity > 0)
5031
- .concat(mostRelevantWithouyStock);
5032
- const categoryMostRelevants = firstProducts.concat(lastProducts);
5033
- const resultFinal = categoryMostRelevants.slice(0, options.limit);
5034
- products.push(...resultFinal);
4879
+ ] }, ((options === null || options === void 0 ? void 0 : options.limit) ? { limits: { limit: options === null || options === void 0 ? void 0 : options.limit } } : {})), { options: { enableCount: false } }));
4880
+ products.push(...productsData);
5035
4881
  return products;
5036
4882
  }
5037
4883
  async getChildren(parentId) {
5038
- const { category_tree } = await this.query('category_tree', ['id', 'name', 'parent_id', 'slug', 'reference', 'published', 'shops'], {
4884
+ const { category_tree } = await this.query('category_tree', ['id', 'name', 'parent_id', 'slug', 'reference'], {
5039
4885
  args: {
5040
4886
  type: 'category_tree_args',
5041
4887
  value: { parentid: parentId },
@@ -5115,36 +4961,23 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
5115
4961
  });
5116
4962
  return plainData.products;
5117
4963
  }
5118
- async updateMetadata(categoryId, { metadatas }) {
5119
- if (Array.isArray(metadatas) && !metadatas.length)
5120
- return [];
5121
- if (Array.isArray(metadatas) && metadatas.length) {
5122
- await this.mutation('delete_category_metadata', ['affected_rows'], {
5123
- where: {
5124
- type: 'category_metadata_bool_exp',
5125
- required: true,
5126
- value: { category_id: { _eq: categoryId } },
5127
- },
5128
- });
5129
- await this.mutation('insert_category_metadata', ['affected_rows'], {
5130
- objects: {
5131
- type: '[category_metadata_insert_input!]',
5132
- required: true,
5133
- value: metadatas.map((m) => (Object.assign({ category_id: categoryId }, m))),
5134
- },
5135
- });
5136
- return metadatas;
5137
- }
5138
- if ('action' in metadatas && metadatas.action === 'remove' && metadatas.value.length) {
5139
- await this.mutation('delete_category_metadata', ['affected_rows'], {
5140
- where: {
5141
- type: 'category_metadata_bool_exp',
5142
- required: true,
5143
- value: { category_id: { _eq: categoryId } },
5144
- },
5145
- });
5146
- return [];
5147
- }
4964
+ async updateMetadata(categoryId, { metadata }) {
4965
+ const plainData = this.paramsToPlain({ metadata });
4966
+ if (!plainData.metadata)
4967
+ return null;
4968
+ await this.mutation('update_category_metadata_by_pk', ['category_id'], {
4969
+ pk_columns: {
4970
+ value: { category_id: categoryId },
4971
+ type: 'category_metadata_pk_columns_input',
4972
+ required: true,
4973
+ },
4974
+ _set: {
4975
+ value: lodash.omit(metadata, ['category_id']),
4976
+ type: 'category_metadata_set_input',
4977
+ required: true,
4978
+ },
4979
+ });
4980
+ return plainData.metadata;
5148
4981
  }
5149
4982
  async updateFilters(categoryId, { filters }) {
5150
4983
  if ('action' in filters && filters.action === 'remove' && filters.value.length) {
@@ -5206,13 +5039,13 @@ tslib.__decorate([
5206
5039
  tslib.__decorate([
5207
5040
  Log(),
5208
5041
  tslib.__metadata("design:type", Function),
5209
- tslib.__metadata("design:paramtypes", [Array, String, Object]),
5042
+ tslib.__metadata("design:paramtypes", [Array, Object, String]),
5210
5043
  tslib.__metadata("design:returntype", Promise)
5211
5044
  ], CategoryHasuraGraphQLRepository.prototype, "getCategoriesForHome", null);
5212
5045
  tslib.__decorate([
5213
5046
  Log(),
5214
5047
  tslib.__metadata("design:type", Function),
5215
- tslib.__metadata("design:paramtypes", [Category, String, Object]),
5048
+ tslib.__metadata("design:paramtypes", [Category, Object]),
5216
5049
  tslib.__metadata("design:returntype", Promise)
5217
5050
  ], CategoryHasuraGraphQLRepository.prototype, "mountCategory", null);
5218
5051
  tslib.__decorate([
@@ -5238,7 +5071,6 @@ class FilterHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGrap
5238
5071
  interceptors,
5239
5072
  fields: [
5240
5073
  'id',
5241
- 'title',
5242
5074
  'description',
5243
5075
  'slug',
5244
5076
  'enabled',
@@ -5494,7 +5326,6 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
5494
5326
  { subscriberPrice: { columnName: 'subscriber_price' } },
5495
5327
  'published',
5496
5328
  'outlet',
5497
- 'label',
5498
5329
  'sku',
5499
5330
  {
5500
5331
  stock: {
@@ -5627,8 +5458,6 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
5627
5458
  enableCount: false,
5628
5459
  },
5629
5460
  });
5630
- if (!result.data.length)
5631
- return null;
5632
5461
  const product = (_a = result === null || result === void 0 ? void 0 : result.data) === null || _a === void 0 ? void 0 : _a.shift();
5633
5462
  RoundProductPricesHelper.roundProductPrices(product);
5634
5463
  return product;
@@ -5928,24 +5757,6 @@ class ProductReviewsHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHa
5928
5757
  ],
5929
5758
  });
5930
5759
  }
5931
- async updateManyStatus(reviews) {
5932
- return await this.mutation('update_product_review_many', ['affected_rows'], {
5933
- updates: {
5934
- type: '[product_review_updates!]',
5935
- required: true,
5936
- value: [
5937
- {
5938
- _set: { status: true },
5939
- where: { id: { _in: reviews.filter((review) => review.status).map((review) => review.id) } },
5940
- },
5941
- {
5942
- _set: { status: false },
5943
- where: { id: { _in: reviews.filter((review) => !review.status).map((review) => review.id) } },
5944
- },
5945
- ],
5946
- },
5947
- });
5948
- }
5949
5760
  aproveReview(id) {
5950
5761
  return this.update({ id, status: true });
5951
5762
  }
@@ -6000,31 +5811,6 @@ class ProductStockNotificationHasuraGraphQLRepository extends withCrudHasuraGrap
6000
5811
  email,
6001
5812
  });
6002
5813
  }
6003
- async getNotificationsReport(params, orderBy, pagination) {
6004
- 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 } }));
6005
- const orderByField = {
6006
- [orderBy.field]: orderBy.direction,
6007
- };
6008
- const { report_stock_notification } = await this.query('report_stock_notification', ['product_id', 'ean', 'sku', 'name', 'stock', 'category_id', 'category', 'reference', 'emails_registered'], {
6009
- where: {
6010
- type: 'report_stock_notification_bool_exp',
6011
- value: query,
6012
- required: true,
6013
- },
6014
- order_by: {
6015
- type: '[report_stock_notification_order_by]',
6016
- value: orderByField,
6017
- required: true,
6018
- },
6019
- });
6020
- const data = (pagination === null || pagination === void 0 ? void 0 : pagination.limit)
6021
- ? 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))
6022
- : report_stock_notification;
6023
- return {
6024
- data,
6025
- count: report_stock_notification.length,
6026
- };
6027
- }
6028
5814
  }
6029
5815
 
6030
5816
  class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
@@ -6133,14 +5919,11 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
6133
5919
  }
6134
5920
  }
6135
5921
 
6136
- class WishlistHasuraGraphQL extends Wishlist {
6137
- }
6138
-
6139
5922
  class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
6140
5923
  constructor({ endpoint, authOptions, interceptors, }, categoryFilterRepository) {
6141
5924
  super({
6142
5925
  tableName: 'category',
6143
- model: WishlistHasuraGraphQL,
5926
+ model: Wishlist,
6144
5927
  endpoint,
6145
5928
  authOptions,
6146
5929
  interceptors,
@@ -6201,21 +5984,12 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
6201
5984
  {
6202
5985
  metadata: {
6203
5986
  columnName: 'metadata',
6204
- fields: ['shop', 'title', 'description'],
5987
+ fields: ['title', 'description'],
6205
5988
  bindPersistData: (value) => ({
6206
5989
  metadata: { data: value },
6207
5990
  }),
6208
5991
  },
6209
5992
  },
6210
- {
6211
- metadatas: {
6212
- columnName: 'metadatas',
6213
- fields: ['shop', 'title', 'description'],
6214
- bindPersistData: (value) => ({
6215
- metadatas: { data: value },
6216
- }),
6217
- },
6218
- },
6219
5993
  { isCollection: { columnName: 'is_collection' } },
6220
5994
  { isWishlist: { columnName: 'is_wishlist' } },
6221
5995
  'reference',
@@ -6230,34 +6004,15 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
6230
6004
  { personId: { columnName: 'person_id' } },
6231
6005
  { personName: { columnName: 'person_name' } },
6232
6006
  { personPhoto: { columnName: 'person_photo' } },
6233
- { personType: { columnName: 'person_type' } },
6234
- { personIsSubscriber: { columnName: 'person_is_subscriber' } },
6235
6007
  'theme',
6236
6008
  { bannerUrl: { columnName: 'banner_url' } },
6237
- { personHasPhoto: { columnName: 'person_has_photo' } },
6238
- { mostRelevants: { columnName: 'most_relevants', type: HasuraGraphQLColumnType.Jsonb } },
6239
6009
  ],
6240
6010
  });
6241
6011
  this.categoryFilterRepository = categoryFilterRepository;
6242
6012
  }
6243
6013
  async create(params) {
6244
- var _a;
6245
- const { images, mostRelevants, metadatas } = params, data = tslib.__rest(params, ["images", "mostRelevants", "metadatas"]);
6246
- 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 || {
6247
- [exports.Shops.GLAMSHOP]: null,
6248
- [exports.Shops.MENSMARKET]: null,
6249
- }, images: images || {
6250
- [exports.Shops.GLAMSHOP]: {
6251
- brandBanner: null,
6252
- brandBannerMobile: null,
6253
- image: null,
6254
- },
6255
- [exports.Shops.MENSMARKET]: {
6256
- brandBanner: null,
6257
- brandBannerMobile: null,
6258
- image: null,
6259
- },
6260
- } }));
6014
+ const { metadata } = params, data = tslib.__rest(params, ["metadata"]);
6015
+ return super.create(Object.assign(Object.assign({}, data), { isWishlist: true, isCollection: true, brandCategory: false, metadata: metadata || { description: data.description, title: data.name } }));
6261
6016
  }
6262
6017
  async get(identifiers) {
6263
6018
  const data = await super.get(identifiers);
@@ -6270,12 +6025,12 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
6270
6025
  return await super.find(Object.assign(Object.assign({}, rest), { filters: Object.assign(Object.assign({}, filters), { isWishlist: { operator: exports.Where.EQUALS, value: true } }) }));
6271
6026
  }
6272
6027
  async update(params) {
6273
- const { products, id: checkId, metadatas, filters } = params, data = tslib.__rest(params, ["products", "id", "metadatas", "filters"]);
6028
+ const { products, id: checkId, metadata, filters } = params, data = tslib.__rest(params, ["products", "id", "metadata", "filters"]);
6274
6029
  const plainData = this.paramsToPlain({ id: checkId });
6275
6030
  const id = plainData.id;
6276
6031
  const category = await super.update(Object.assign(Object.assign({ id }, data), { isWishlist: true, isCollection: true, brandCategory: false }));
6277
6032
  category.products = products && (await this.updateProducts(+id, { products }));
6278
- category.metadatas = metadatas && (await this.updateMetadata(+id, { metadatas }));
6033
+ category.metadata = metadata && (await this.updateMetadata(+id, { metadata }));
6279
6034
  return category;
6280
6035
  }
6281
6036
  async getWishlistBySlug(slug) {
@@ -6307,18 +6062,12 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
6307
6062
  options: {
6308
6063
  enableCount: false,
6309
6064
  },
6310
- orderBy: {
6311
- id: 'asc',
6312
- },
6313
- limits: {
6314
- limit: 1,
6315
- },
6316
6065
  });
6317
6066
  if (!data.length)
6318
6067
  throw new NotFoundError(`Wishlists from person ${personId} not found`);
6319
6068
  return data;
6320
6069
  }
6321
- async getCategoryBySlug(slug, _shop) {
6070
+ getCategoryBySlug(slug, _shop) {
6322
6071
  return this.getWishlistBySlug(slug);
6323
6072
  }
6324
6073
  async getCategoryByShop(shop) {
@@ -6336,17 +6085,10 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
6336
6085
  });
6337
6086
  return data;
6338
6087
  }
6339
- async findBfluOrGlamgirlWishlists(params, shops) {
6340
- var _a, _b;
6341
- return this.find(Object.assign(Object.assign({}, params), { filters: Object.assign(Object.assign({}, params.filters), { published: true, shops: { operator: exports.Where.LIKE, value: shops }, personType: (_b = (_a = params.filters) === null || _a === void 0 ? void 0 : _a.personType) !== null && _b !== void 0 ? _b : {
6342
- operator: exports.Where.IN,
6343
- value: [exports.PersonTypes.BFLU, exports.PersonTypes.GLAMGIRL],
6344
- } }), orderBy: Object.assign({ personHasPhoto: 'desc' }, lodash.omit(params.orderBy, ['personHasPhoto'])) }));
6345
- }
6346
- getCategoriesForHome(categoryIds, gender, limit) {
6088
+ getCategoriesForHome(categoryIds, limit, gender) {
6347
6089
  return;
6348
6090
  }
6349
- mountCategory(category, shop, options) {
6091
+ mountCategory(category, options) {
6350
6092
  return;
6351
6093
  }
6352
6094
  getChildren(parentId) {
@@ -6393,40 +6135,23 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
6393
6135
  });
6394
6136
  return plainData.products;
6395
6137
  }
6396
- async updateMetadata(categoryId, { metadatas }) {
6397
- if (Array.isArray(metadatas) && !metadatas.length)
6398
- return [];
6399
- if (Array.isArray(metadatas) && metadatas.length) {
6400
- const metadataUpdated = [];
6401
- for (const data of metadatas) {
6402
- const update = await this.mutation('update_category_metadata_by_pk', ['category_id', 'shop'], {
6403
- pk_columns: {
6404
- value: { category_id: categoryId, shop: data.shop },
6405
- type: 'category_metadata_pk_columns_input',
6406
- required: true,
6407
- },
6408
- _set: {
6409
- value: lodash.omit(data, ['category_id', 'shop']),
6410
- type: 'category_metadata_set_input',
6411
- required: true,
6412
- },
6413
- });
6414
- metadataUpdated.push(update);
6415
- }
6416
- return metadataUpdated;
6417
- }
6418
- if ('action' in metadatas && metadatas.action === 'remove' && metadatas.value.length) {
6419
- for (let i = 0; i < metadatas.value.length; i++) {
6420
- await this.mutation('delete_category_metadata', ['affected_rows'], {
6421
- where: {
6422
- type: 'category_metadata_bool_exp',
6423
- required: true,
6424
- value: { category_id: { _eq: categoryId }, shop: metadatas.value[i].shop },
6425
- },
6426
- });
6427
- }
6428
- return [];
6429
- }
6138
+ async updateMetadata(categoryId, { metadata }) {
6139
+ const plainData = this.paramsToPlain({ metadata });
6140
+ if (!plainData.metadata)
6141
+ return;
6142
+ await this.mutation('update_category_metadata_by_pk', ['category_id'], {
6143
+ pk_columns: {
6144
+ value: { category_id: categoryId },
6145
+ type: 'category_metadata_pk_columns_input',
6146
+ required: true,
6147
+ },
6148
+ _set: {
6149
+ value: lodash.omit(metadata, ['category_id']),
6150
+ type: 'category_metadata_set_input',
6151
+ required: true,
6152
+ },
6153
+ });
6154
+ return plainData.metadata;
6430
6155
  }
6431
6156
  }
6432
6157
  tslib.__decorate([
@@ -6447,165 +6172,6 @@ tslib.__decorate([
6447
6172
  tslib.__metadata("design:paramtypes", [String]),
6448
6173
  tslib.__metadata("design:returntype", Promise)
6449
6174
  ], WishlistHasuraGraphQLRepository.prototype, "getCategoryByShop", null);
6450
- tslib.__decorate([
6451
- Log(),
6452
- tslib.__metadata("design:type", Function),
6453
- tslib.__metadata("design:paramtypes", [Object, Array]),
6454
- tslib.__metadata("design:returntype", Promise)
6455
- ], WishlistHasuraGraphQLRepository.prototype, "findBfluOrGlamgirlWishlists", null);
6456
-
6457
- class VertexAxiosAdapter {
6458
- constructor(config) {
6459
- this.config = config;
6460
- this.logger = DebugHelper.from(this);
6461
- }
6462
- async query(term, total, gender) {
6463
- const logger = this.logger.with('query');
6464
- const req = {
6465
- url: `${this.config.url}/search`,
6466
- method: 'POST',
6467
- responseType: 'json',
6468
- headers: {
6469
- Accept: 'application/json',
6470
- },
6471
- data: { term, total, gender },
6472
- };
6473
- try {
6474
- const { data } = await axios__default["default"](req);
6475
- return data;
6476
- }
6477
- catch (error) {
6478
- logger.error({ req, res: error });
6479
- throw error;
6480
- }
6481
- }
6482
- async get(id) {
6483
- const logger = this.logger.with('update');
6484
- const req = {
6485
- url: `${this.config.url}/${id}`,
6486
- method: 'GET',
6487
- responseType: 'json',
6488
- headers: {
6489
- Accept: 'application/json',
6490
- },
6491
- };
6492
- try {
6493
- const { data } = await axios__default["default"](req);
6494
- return data;
6495
- }
6496
- catch (error) {
6497
- logger.error({ req, res: error });
6498
- throw error;
6499
- }
6500
- }
6501
- async save(data) {
6502
- const logger = this.logger.with('save');
6503
- const req = {
6504
- url: `${this.config.url}/sync`,
6505
- method: 'POST',
6506
- responseType: 'json',
6507
- headers: {
6508
- Accept: 'application/json',
6509
- },
6510
- data,
6511
- };
6512
- try {
6513
- const { data } = await axios__default["default"](req);
6514
- return data;
6515
- }
6516
- catch (error) {
6517
- logger.error({ req, res: error });
6518
- throw error;
6519
- }
6520
- }
6521
- async update(id, data) {
6522
- const logger = this.logger.with('update');
6523
- const req = {
6524
- url: `${this.config.url}/${id}`,
6525
- method: 'PUT',
6526
- responseType: 'json',
6527
- headers: {
6528
- Accept: 'application/json',
6529
- },
6530
- data,
6531
- };
6532
- try {
6533
- const { data } = await axios__default["default"](req);
6534
- return data;
6535
- }
6536
- catch (error) {
6537
- logger.error({ req, res: error });
6538
- throw error;
6539
- }
6540
- }
6541
- async delete(id) {
6542
- const logger = this.logger.with('delete');
6543
- const req = {
6544
- url: `${this.config.url}/${id}`,
6545
- method: 'DELETE',
6546
- responseType: 'json',
6547
- headers: {
6548
- Accept: 'application/json',
6549
- },
6550
- };
6551
- try {
6552
- const { data } = await axios__default["default"](req);
6553
- return data;
6554
- }
6555
- catch (error) {
6556
- logger.error({ req, res: error });
6557
- throw error;
6558
- }
6559
- }
6560
- bulkProducts(products) {
6561
- return;
6562
- }
6563
- }
6564
-
6565
- class ProductsVertexSearch {
6566
- constructor(adapter) {
6567
- this.adapter = adapter;
6568
- }
6569
- async getById(id) {
6570
- const data = await this.adapter.get(id);
6571
- return data;
6572
- }
6573
- async search(searchTerm, total, gender) {
6574
- try {
6575
- const result = await this.adapter.query(searchTerm, total, gender);
6576
- return result;
6577
- }
6578
- catch (error) {
6579
- console.error(error);
6580
- }
6581
- }
6582
- async save(product) {
6583
- try {
6584
- const _a = product.toPlain(), { createdAt, updatedAt, kitProducts } = _a, data = tslib.__rest(_a, ["createdAt", "updatedAt", "kitProducts"]);
6585
- const newProduct = Product.toInstance(data);
6586
- await this.adapter.save(newProduct);
6587
- }
6588
- catch (error) {
6589
- console.error(error);
6590
- }
6591
- }
6592
- async update(product) {
6593
- try {
6594
- await this.adapter.update(product.id, product);
6595
- }
6596
- catch (error) {
6597
- console.error(error);
6598
- }
6599
- }
6600
- async delete(id) {
6601
- try {
6602
- await this.adapter.delete(id);
6603
- }
6604
- catch (error) {
6605
- console.error(error);
6606
- }
6607
- }
6608
- }
6609
6175
 
6610
6176
  Object.defineProperty(exports, 'add', {
6611
6177
  enumerable: true,
@@ -6778,13 +6344,9 @@ exports.LeadFirestoreRepository = LeadFirestoreRepository;
6778
6344
  exports.LegacyOrderFirestoreRepository = LegacyOrderFirestoreRepository;
6779
6345
  exports.LineItem = LineItem;
6780
6346
  exports.Log = Log;
6781
- exports.LogDocument = LogDocument;
6782
- exports.LogFirestoreRepository = LogFirestoreRepository;
6783
6347
  exports.Logger = Logger;
6784
6348
  exports.NotFoundError = NotFoundError;
6785
6349
  exports.Order = Order;
6786
- exports.OrderBlocked = OrderBlocked;
6787
- exports.OrderBlockedFirestoreRepository = OrderBlockedFirestoreRepository;
6788
6350
  exports.OrderFirestoreRepository = OrderFirestoreRepository;
6789
6351
  exports.Payment = Payment;
6790
6352
  exports.PaymentFirestoreRepository = PaymentFirestoreRepository;
@@ -6798,7 +6360,6 @@ exports.ProductStockNotification = ProductStockNotification;
6798
6360
  exports.ProductStockNotificationHasuraGraphQLRepository = ProductStockNotificationHasuraGraphQLRepository;
6799
6361
  exports.ProductVariantFirestoreRepository = ProductVariantFirestoreRepository;
6800
6362
  exports.ProductsIndex = ProductsIndex;
6801
- exports.ProductsVertexSearch = ProductsVertexSearch;
6802
6363
  exports.RecoveryPassword = RecoveryPassword;
6803
6364
  exports.ReflectHelper = ReflectHelper;
6804
6365
  exports.Register = Register;
@@ -6837,7 +6398,6 @@ exports.UserPaymentMethodFirestoreRepository = UserPaymentMethodFirestoreReposit
6837
6398
  exports.Variant = Variant;
6838
6399
  exports.VariantHasuraGraphQL = VariantHasuraGraphQL;
6839
6400
  exports.VariantHasuraGraphQLRepository = VariantHasuraGraphQLRepository;
6840
- exports.VertexAxiosAdapter = VertexAxiosAdapter;
6841
6401
  exports.WeakPasswordError = WeakPasswordError;
6842
6402
  exports.Wishlist = Wishlist;
6843
6403
  exports.WishlistHasuraGraphQLRepository = WishlistHasuraGraphQLRepository;