@infrab4a/connect 4.9.7-beta.35 → 4.9.7-beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/index.cjs.js +597 -1036
  2. package/index.esm.js +598 -1029
  3. package/package.json +1 -1
  4. package/src/domain/catalog/models/category-base.d.ts +3 -5
  5. package/src/domain/catalog/models/enums/index.d.ts +0 -2
  6. package/src/domain/catalog/models/filter.d.ts +0 -1
  7. package/src/domain/catalog/models/index.d.ts +0 -1
  8. package/src/domain/catalog/models/product-base.d.ts +1 -4
  9. package/src/domain/catalog/models/types/index.d.ts +1 -3
  10. package/src/domain/catalog/models/variant.d.ts +0 -4
  11. package/src/domain/catalog/models/wishlist.d.ts +0 -3
  12. package/src/domain/catalog/repositories/category.repository.d.ts +3 -3
  13. package/src/domain/catalog/repositories/index.d.ts +0 -1
  14. package/src/domain/catalog/repositories/product-reviews.repository.d.ts +0 -1
  15. package/src/domain/catalog/repositories/product-stock-notification.repository.d.ts +1 -9
  16. package/src/domain/catalog/repositories/product.repository.d.ts +1 -2
  17. package/src/domain/catalog/repositories/wishlist.repository.d.ts +1 -6
  18. package/src/domain/general/index.d.ts +0 -3
  19. package/src/domain/shopping/index.d.ts +0 -1
  20. package/src/domain/shopping/models/buy-2-win.d.ts +0 -2
  21. package/src/domain/shopping/models/coupons/coupon.d.ts +4 -8
  22. package/src/domain/shopping/models/coupons/enums/coupon-types.enum.d.ts +1 -2
  23. package/src/domain/shopping/models/coupons/enums/index.d.ts +1 -3
  24. package/src/domain/shopping/models/index.d.ts +0 -1
  25. package/src/domain/shopping/models/order.d.ts +0 -4
  26. package/src/domain/shopping/repositories/index.d.ts +0 -1
  27. package/src/domain/users/models/enums/index.d.ts +0 -1
  28. package/src/domain/users/models/index.d.ts +2 -3
  29. package/src/infra/elasticsearch/indexes/products-index.d.ts +1 -39
  30. package/src/infra/firebase/firestore/mixins/with-helpers.mixin.d.ts +1 -1
  31. package/src/infra/firebase/firestore/repositories/catalog/category-firestore.repository.d.ts +2 -2
  32. package/src/infra/firebase/firestore/repositories/catalog/product-firestore.repository.d.ts +1 -2
  33. package/src/infra/firebase/firestore/repositories/index.d.ts +2 -3
  34. package/src/infra/firebase/firestore/repositories/shopping/index.d.ts +0 -1
  35. package/src/infra/hasura-graphql/mixins/with-find-hasura-graphql.mixin.d.ts +0 -1
  36. package/src/infra/hasura-graphql/repositories/catalog/category-hasura-graphql.repository.d.ts +2 -2
  37. package/src/infra/hasura-graphql/repositories/catalog/index.d.ts +0 -1
  38. package/src/infra/hasura-graphql/repositories/catalog/product-hasura-graphql.repository.d.ts +2 -2
  39. package/src/infra/hasura-graphql/repositories/catalog/product-review-hasura-graphql.repository.d.ts +0 -1
  40. package/src/infra/hasura-graphql/repositories/catalog/product-stock-notification-hasura-graphql.repository.d.ts +1 -8
  41. package/src/infra/hasura-graphql/repositories/catalog/wishlist-hasura-graphql.repository.d.ts +15 -18
  42. package/src/infra/index.d.ts +0 -1
  43. package/src/domain/catalog/models/category-product.d.ts +0 -8
  44. package/src/domain/catalog/models/enums/product-label.enum.d.ts +0 -6
  45. package/src/domain/catalog/models/enums/wishlist-log.enum.d.ts +0 -7
  46. package/src/domain/catalog/models/types/product-label.type.d.ts +0 -2
  47. package/src/domain/catalog/models/types/product-variant-report.type.d.ts +0 -46
  48. package/src/domain/catalog/models/types/report-stock-notification.type.d.ts +0 -21
  49. package/src/domain/catalog/repositories/category-product.repository.d.ts +0 -6
  50. package/src/domain/general/models/index.d.ts +0 -1
  51. package/src/domain/general/models/log-document.d.ts +0 -15
  52. package/src/domain/general/repositories/index.d.ts +0 -1
  53. package/src/domain/general/repositories/log.repository.d.ts +0 -4
  54. package/src/domain/general/search/index.d.ts +0 -1
  55. package/src/domain/general/search/product-search-index.d.ts +0 -3
  56. package/src/domain/shopping/models/coupons/enums/coupon-category.enum.d.ts +0 -41
  57. package/src/domain/shopping/models/coupons/enums/coupon-channels.enum.d.ts +0 -10
  58. package/src/domain/shopping/models/coupons/types/coupon-category.type.d.ts +0 -2
  59. package/src/domain/shopping/models/coupons/types/coupon-channel.type.d.ts +0 -2
  60. package/src/domain/shopping/models/coupons/types/index.d.ts +0 -2
  61. package/src/domain/shopping/models/order-blocked.d.ts +0 -26
  62. package/src/domain/shopping/repositories/order-blocked.repository.d.ts +0 -6
  63. package/src/domain/shopping/types/index.d.ts +0 -2
  64. package/src/domain/shopping/types/order-tracking-events.type.d.ts +0 -14
  65. package/src/domain/shopping/types/payment-card-info.type.d.ts +0 -4
  66. package/src/domain/users/models/enums/person-types.enum.d.ts +0 -5
  67. package/src/domain/users/models/types/index.d.ts +0 -1
  68. package/src/domain/users/models/types/person.type.d.ts +0 -2
  69. package/src/infra/firebase/firestore/repositories/general/index.d.ts +0 -1
  70. package/src/infra/firebase/firestore/repositories/general/log-firestore.repository.d.ts +0 -7
  71. package/src/infra/firebase/firestore/repositories/shopping/order-blocked-firestore.repository.ts.d.ts +0 -9
  72. package/src/infra/hasura-graphql/models/wishlist-hasura-graphql.d.ts +0 -4
  73. package/src/infra/hasura-graphql/repositories/catalog/category-product-hasura-graphql.repository.d.ts +0 -11
  74. package/src/infra/vertex-ai/adapters/index.d.ts +0 -2
  75. package/src/infra/vertex-ai/adapters/vertex-ai-search.adapter.d.ts +0 -10
  76. package/src/infra/vertex-ai/adapters/vertex-axios.adapter.d.ts +0 -15
  77. package/src/infra/vertex-ai/index.d.ts +0 -3
  78. package/src/infra/vertex-ai/indexes/index.d.ts +0 -1
  79. package/src/infra/vertex-ai/indexes/products-vertex-search.d.ts +0 -13
  80. package/src/infra/vertex-ai/types/axios-vertex-search-config.d.ts +0 -4
  81. package/src/infra/vertex-ai/types/index.d.ts +0 -3
  82. package/src/infra/vertex-ai/types/product-bulk.d.ts +0 -4
  83. package/src/infra/vertex-ai/types/product-search.d.ts +0 -21
package/index.esm.js CHANGED
@@ -43,14 +43,6 @@ var GenderDestination;
43
43
  GenderDestination["UNISEX"] = "unisex";
44
44
  })(GenderDestination || (GenderDestination = {}));
45
45
 
46
- var ProductLabelEnum;
47
- (function (ProductLabelEnum) {
48
- ProductLabelEnum["ON_SALE"] = "on-sale";
49
- ProductLabelEnum["OUTLET"] = "outlet";
50
- ProductLabelEnum["LAST_UNITS"] = "last-units";
51
- ProductLabelEnum["GLAMSTAR"] = "glamstar";
52
- })(ProductLabelEnum || (ProductLabelEnum = {}));
53
-
54
46
  var Shops;
55
47
  (function (Shops) {
56
48
  Shops["MENSMARKET"] = "mensmarket";
@@ -59,15 +51,6 @@ var Shops;
59
51
  Shops["ALL"] = "ALL";
60
52
  })(Shops || (Shops = {}));
61
53
 
62
- var WishlistLogType;
63
- (function (WishlistLogType) {
64
- WishlistLogType["CREATE"] = "create";
65
- WishlistLogType["UPDATE"] = "update";
66
- WishlistLogType["DELETE"] = "delete";
67
- WishlistLogType["ADD_PRODUCT"] = "add_product";
68
- WishlistLogType["REMOVE_PRODUCT"] = "remove_product";
69
- })(WishlistLogType || (WishlistLogType = {}));
70
-
71
54
  class Filter extends BaseModel {
72
55
  static get identifiersFields() {
73
56
  return ['id'];
@@ -83,31 +66,19 @@ class CategoryBase extends BaseModel {
83
66
  return ['id'];
84
67
  }
85
68
  get glamImages() {
86
- return this.images && this.images[Shops.GLAMSHOP]
87
- ? this.images[Shops.GLAMSHOP]
88
- : {
89
- brandBanner: null,
90
- brandBannerMobile: null,
91
- image: null,
92
- };
69
+ return this.images[Shops.GLAMSHOP];
93
70
  }
94
71
  get mensImages() {
95
- return this.images && this.images[Shops.MENSMARKET]
96
- ? this.images[Shops.MENSMARKET]
97
- : {
98
- brandBanner: null,
99
- brandBannerMobile: null,
100
- image: null,
101
- };
72
+ return this.images[Shops.MENSMARKET];
102
73
  }
103
74
  get glamMetadata() {
104
- return this.metadatas.find((metadata) => metadata.shop === Shops.GLAMSHOP);
75
+ return this.metadata.find((metadata) => metadata.shop === Shops.GLAMSHOP);
105
76
  }
106
77
  get mensMetadata() {
107
- return this.metadatas.find((metadata) => metadata.shop === Shops.MENSMARKET);
78
+ return this.metadata.find((metadata) => metadata.shop === Shops.MENSMARKET);
108
79
  }
109
- getMostRelevantByShop(shop) {
110
- return this.mostRelevants && this.mostRelevants[shop] ? this.mostRelevants[shop] : [];
80
+ glamMostRelevantByShop(shop) {
81
+ return this.mostRelevant[shop];
111
82
  }
112
83
  }
113
84
  __decorate([
@@ -217,12 +188,6 @@ __decorate([
217
188
  __metadata("design:type", Category)
218
189
  ], CategoryFilter.prototype, "category", void 0);
219
190
 
220
- class CategoryProduct extends BaseModel {
221
- static get identifiersFields() {
222
- return ['categoryId', 'productId'];
223
- }
224
- }
225
-
226
191
  class FilterOption extends BaseModel {
227
192
  static get identifiersFields() {
228
193
  return ['id'];
@@ -315,17 +280,6 @@ class CampaignHashtag extends BaseModel {
315
280
  }
316
281
  }
317
282
 
318
- class BeautyProfile extends BaseModel {
319
- toPlain() {
320
- const plain = super.toPlain();
321
- delete plain.id;
322
- return plain;
323
- }
324
- static get identifiersFields() {
325
- return ['id', 'userId'];
326
- }
327
- }
328
-
329
283
  var AccessoryImportances;
330
284
  (function (AccessoryImportances) {
331
285
  AccessoryImportances["NOT_INTERESTED"] = "N\u00E3o tenho interesse";
@@ -502,13 +456,6 @@ var OfficePosition;
502
456
  OfficePosition["Director"] = "Diretor";
503
457
  })(OfficePosition || (OfficePosition = {}));
504
458
 
505
- var PersonTypes;
506
- (function (PersonTypes) {
507
- PersonTypes["GLAMGIRL"] = "glamgirl";
508
- PersonTypes["BFLU"] = "bflu";
509
- PersonTypes["NONE"] = "none";
510
- })(PersonTypes || (PersonTypes = {}));
511
-
512
459
  var ProductSpents;
513
460
  (function (ProductSpents) {
514
461
  ProductSpents["UNTIL_50"] = "At\u00E9 R$50";
@@ -529,12 +476,6 @@ var UserType;
529
476
  UserType["Influencer"] = "Influencer";
530
477
  })(UserType || (UserType = {}));
531
478
 
532
- class Lead extends BaseModel {
533
- static get identifiersFields() {
534
- return ['id'];
535
- }
536
- }
537
-
538
479
  class Edition extends BaseModel {
539
480
  static get identifiersFields() {
540
481
  return ['id', 'subscriptionId'];
@@ -1860,6 +1801,40 @@ const parseDateTime = (value) => {
1860
1801
  return date;
1861
1802
  };
1862
1803
 
1804
+ var CheckoutTypes;
1805
+ (function (CheckoutTypes) {
1806
+ CheckoutTypes[CheckoutTypes["ECOMMERCE"] = 1] = "ECOMMERCE";
1807
+ CheckoutTypes[CheckoutTypes["SUBSCRIPTION"] = 2] = "SUBSCRIPTION";
1808
+ CheckoutTypes[CheckoutTypes["ALL"] = 3] = "ALL";
1809
+ })(CheckoutTypes || (CheckoutTypes = {}));
1810
+
1811
+ var CouponTypes;
1812
+ (function (CouponTypes) {
1813
+ CouponTypes[CouponTypes["ABSOLUTE"] = 1] = "ABSOLUTE";
1814
+ CouponTypes[CouponTypes["PERCENTAGE"] = 2] = "PERCENTAGE";
1815
+ // FINANCIAL = 1,
1816
+ // PRODUCT,
1817
+ // GIFTCARD,
1818
+ // VOUCHER,
1819
+ })(CouponTypes || (CouponTypes = {}));
1820
+
1821
+ var CouponSubtypes;
1822
+ (function (CouponSubtypes) {
1823
+ CouponSubtypes[CouponSubtypes["ABSOLUTE"] = 1] = "ABSOLUTE";
1824
+ CouponSubtypes[CouponSubtypes["PERCENTAGE"] = 2] = "PERCENTAGE";
1825
+ })(CouponSubtypes || (CouponSubtypes = {}));
1826
+
1827
+ var Exclusivities;
1828
+ (function (Exclusivities) {
1829
+ Exclusivities[Exclusivities["ALL_USERS"] = 1] = "ALL_USERS";
1830
+ Exclusivities[Exclusivities["SPECIFIC_USER"] = 2] = "SPECIFIC_USER";
1831
+ Exclusivities[Exclusivities["COLLABORATORS"] = 3] = "COLLABORATORS";
1832
+ Exclusivities[Exclusivities["ACTIVE_SUBSCRIBER"] = 4] = "ACTIVE_SUBSCRIBER";
1833
+ Exclusivities[Exclusivities["INACTIVE_SUBSCRIBER"] = 5] = "INACTIVE_SUBSCRIBER";
1834
+ Exclusivities[Exclusivities["NON_SUBSCRIBER"] = 6] = "NON_SUBSCRIBER";
1835
+ })(Exclusivities || (Exclusivities = {}));
1836
+
1837
+ const COUPON_EXPIRATION = +1000 * 60 * 60 * 24 * 30;
1863
1838
  class Coupon extends BaseModel {
1864
1839
  get isInfluencer() {
1865
1840
  return !isNil(this.influencerEmail);
@@ -1867,6 +1842,30 @@ class Coupon extends BaseModel {
1867
1842
  static get identifiersFields() {
1868
1843
  return ['id'];
1869
1844
  }
1845
+ static createCoupon(userId) {
1846
+ return this.toInstance({
1847
+ nickname: `${Date.now()}`,
1848
+ checkoutType: CheckoutTypes.ECOMMERCE,
1849
+ discount: {
1850
+ subscriber: {
1851
+ type: CouponTypes.ABSOLUTE,
1852
+ value: 10,
1853
+ },
1854
+ non_subscriber: {
1855
+ type: CouponTypes.ABSOLUTE,
1856
+ value: 10,
1857
+ },
1858
+ subscription: {
1859
+ type: CouponTypes.ABSOLUTE,
1860
+ value: 10,
1861
+ },
1862
+ },
1863
+ user: userId,
1864
+ createdAt: new Date(Date.now()),
1865
+ beginAt: new Date(Date.now()),
1866
+ expiresIn: new Date(Date.now() + COUPON_EXPIRATION),
1867
+ });
1868
+ }
1870
1869
  }
1871
1870
 
1872
1871
  class SubscriptionPlan extends BaseModel {
@@ -1875,6 +1874,17 @@ class SubscriptionPlan extends BaseModel {
1875
1874
  }
1876
1875
  }
1877
1876
 
1877
+ class BeautyProfile extends BaseModel {
1878
+ toPlain() {
1879
+ const plain = super.toPlain();
1880
+ delete plain.id;
1881
+ return plain;
1882
+ }
1883
+ static get identifiersFields() {
1884
+ return ['id', 'userId'];
1885
+ }
1886
+ }
1887
+
1878
1888
  class User extends BaseModel {
1879
1889
  static toInstance(data) {
1880
1890
  const instance = super.toInstance(data);
@@ -1988,6 +1998,12 @@ class UserPaymentMethod extends BaseModel {
1988
1998
  }
1989
1999
  }
1990
2000
 
2001
+ class Lead extends BaseModel {
2002
+ static get identifiersFields() {
2003
+ return ['id'];
2004
+ }
2005
+ }
2006
+
1991
2007
  class UnauthorizedError extends CustomError {
1992
2008
  constructor(message) {
1993
2009
  super(message);
@@ -2141,93 +2157,6 @@ __decorate([
2141
2157
  __metadata("design:type", Coupon)
2142
2158
  ], Checkout.prototype, "coupon", void 0);
2143
2159
 
2144
- var CouponCategory;
2145
- (function (CouponCategory) {
2146
- CouponCategory["Reembolso"] = "Reembolso";
2147
- CouponCategory["Desculpas"] = "Desculpas";
2148
- CouponCategory["BFlu"] = "BFlu";
2149
- CouponCategory["ROYAL"] = "Royal";
2150
- CouponCategory["Glamqueens"] = "Glamqueens";
2151
- CouponCategory["Glampartner"] = "Glampartner";
2152
- CouponCategory["Glamgirls"] = "Glamgirls";
2153
- CouponCategory["Glamdiva"] = "Glamdiva";
2154
- CouponCategory["Impulsionamento"] = "Impulsionamento";
2155
- CouponCategory["PaidMedia"] = "Paid Media";
2156
- CouponCategory["Organic"] = "Organic";
2157
- CouponCategory["Direct"] = "Direct";
2158
- CouponCategory["CRM"] = "CRM";
2159
- CouponCategory["LOJAUNICO"] = "Loja \u00FAnico";
2160
- CouponCategory["Outros"] = "Outros";
2161
- })(CouponCategory || (CouponCategory = {}));
2162
- var CouponOldCategories;
2163
- (function (CouponOldCategories) {
2164
- CouponOldCategories["Reembolso"] = "Reembolso";
2165
- CouponOldCategories["Desculpas"] = "Desculpas";
2166
- CouponOldCategories["BFlu"] = "BFlu";
2167
- CouponOldCategories["ROYAL"] = "Royal";
2168
- CouponOldCategories["Glamqueens"] = "Glamqueens";
2169
- CouponOldCategories["Glampartner"] = "Glampartner";
2170
- CouponOldCategories["Glamgirls"] = "Glamgirls";
2171
- CouponOldCategories["Glamdiva"] = "Glamdiva";
2172
- CouponOldCategories["Impulsionamento"] = "Impulsionamento";
2173
- CouponOldCategories["PaidMedia"] = "Paid Media";
2174
- CouponOldCategories["Organic"] = "Organic";
2175
- CouponOldCategories["Direct"] = "Direct";
2176
- CouponOldCategories["CRM"] = "CRM";
2177
- CouponOldCategories["LOJAUNICO"] = "Loja \u00FAnico";
2178
- CouponOldCategories["Outros"] = "Outros";
2179
- })(CouponOldCategories || (CouponOldCategories = {}));
2180
- var CouponCategories;
2181
- (function (CouponCategories) {
2182
- CouponCategories["API_001"] = "API-001";
2183
- CouponCategories["COMPRE_E_GANHE"] = "COMPRE E GANHE";
2184
- CouponCategories["DESCONTO"] = "DESCONTO";
2185
- CouponCategories["REEMBOLSO"] = "REEMBOLSO";
2186
- CouponCategories["DESCULPAS"] = "DESCULPAS";
2187
- })(CouponCategories || (CouponCategories = {}));
2188
-
2189
- var CouponChannels;
2190
- (function (CouponChannels) {
2191
- CouponChannels["BANNER"] = "7";
2192
- CouponChannels["BFLUENCE"] = "3";
2193
- CouponChannels["CRM"] = "2";
2194
- CouponChannels["GLAMGIRL"] = "0";
2195
- CouponChannels["PAID"] = "4";
2196
- CouponChannels["ROYAL"] = "1";
2197
- CouponChannels["SAC"] = "8";
2198
- CouponChannels["SOCIAL"] = "5";
2199
- })(CouponChannels || (CouponChannels = {}));
2200
-
2201
- var CouponSubtypes;
2202
- (function (CouponSubtypes) {
2203
- CouponSubtypes[CouponSubtypes["ABSOLUTE"] = 1] = "ABSOLUTE";
2204
- CouponSubtypes[CouponSubtypes["PERCENTAGE"] = 2] = "PERCENTAGE";
2205
- })(CouponSubtypes || (CouponSubtypes = {}));
2206
-
2207
- var CouponTypes;
2208
- (function (CouponTypes) {
2209
- CouponTypes[CouponTypes["ABSOLUTE"] = 1] = "ABSOLUTE";
2210
- CouponTypes[CouponTypes["PERCENTAGE"] = 2] = "PERCENTAGE";
2211
- CouponTypes[CouponTypes["SHIPPING"] = 3] = "SHIPPING";
2212
- })(CouponTypes || (CouponTypes = {}));
2213
-
2214
- var Exclusivities;
2215
- (function (Exclusivities) {
2216
- Exclusivities[Exclusivities["ALL_USERS"] = 1] = "ALL_USERS";
2217
- Exclusivities[Exclusivities["SPECIFIC_USER"] = 2] = "SPECIFIC_USER";
2218
- Exclusivities[Exclusivities["COLLABORATORS"] = 3] = "COLLABORATORS";
2219
- Exclusivities[Exclusivities["ACTIVE_SUBSCRIBER"] = 4] = "ACTIVE_SUBSCRIBER";
2220
- Exclusivities[Exclusivities["INACTIVE_SUBSCRIBER"] = 5] = "INACTIVE_SUBSCRIBER";
2221
- Exclusivities[Exclusivities["NON_SUBSCRIBER"] = 6] = "NON_SUBSCRIBER";
2222
- })(Exclusivities || (Exclusivities = {}));
2223
-
2224
- var CheckoutTypes;
2225
- (function (CheckoutTypes) {
2226
- CheckoutTypes[CheckoutTypes["ECOMMERCE"] = 1] = "ECOMMERCE";
2227
- CheckoutTypes[CheckoutTypes["SUBSCRIPTION"] = 2] = "SUBSCRIPTION";
2228
- CheckoutTypes[CheckoutTypes["ALL"] = 3] = "ALL";
2229
- })(CheckoutTypes || (CheckoutTypes = {}));
2230
-
2231
2160
  var OrderStatus;
2232
2161
  (function (OrderStatus) {
2233
2162
  OrderStatus["AGUARDANDO_PAGAMENTO"] = "Aguardando pagamento";
@@ -2247,12 +2176,6 @@ __decorate([
2247
2176
  __metadata("design:type", Payment)
2248
2177
  ], Order.prototype, "payment", void 0);
2249
2178
 
2250
- class OrderBlocked extends BaseModel {
2251
- static get identifiersFields() {
2252
- return ['id'];
2253
- }
2254
- }
2255
-
2256
2179
  class CheckoutSubscription extends BaseModel {
2257
2180
  static get identifiersFields() {
2258
2181
  return ['id'];
@@ -2289,12 +2212,6 @@ class RoundProductPricesHelper {
2289
2212
  }
2290
2213
  }
2291
2214
 
2292
- class LogDocument extends BaseModel {
2293
- static get identifiersFields() {
2294
- return ['id'];
2295
- }
2296
- }
2297
-
2298
2215
  var FilterType;
2299
2216
  (function (FilterType) {
2300
2217
  FilterType["ACCESSORY_IMPORTANCE"] = "accessoryImportance";
@@ -2593,6 +2510,8 @@ class ProductsIndex {
2593
2510
  'rate',
2594
2511
  ];
2595
2512
  const filter = [{ term: { published: true } }];
2513
+ if (shop && shop !== Shops.ALL)
2514
+ filter.push({ term: { tags: shop == Shops.GLAMSHOP ? 'feminino' : 'masculino' } });
2596
2515
  if (size > 9)
2597
2516
  fields.push(...['pricePaid', 'isGift', 'stock', 'weight', 'tags']);
2598
2517
  const query = {
@@ -2648,9 +2567,7 @@ class ProductsIndex {
2648
2567
  RoundProductPricesHelper.roundProductPrices(hit._source);
2649
2568
  return hit;
2650
2569
  });
2651
- return search.hits.map((hit) => {
2652
- return Object.assign(Object.assign({}, hit._source), { stock: hit._source.stock.quantity });
2653
- });
2570
+ return search;
2654
2571
  }
2655
2572
  async save(product) {
2656
2573
  try {
@@ -3084,8 +3001,6 @@ const withUpdateFirestore = (MixinBase) => {
3084
3001
  try {
3085
3002
  const identifiers = getValueFromParams(data, keyField);
3086
3003
  const docRef = this.collection(collectionName).getDoc(identifiers.toString());
3087
- if (!(await docRef.get()).data())
3088
- throw new NotFoundError(`Document '${collectionName}/${Object.values(identifiers.toString())}' not found`);
3089
3004
  const plainFromData = this.model.toInstance(this.paramsToPlain(data));
3090
3005
  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 }));
3091
3006
  const builded = (intercepted === null || intercepted === void 0 ? void 0 : intercepted.instance) || plainFromData;
@@ -3162,118 +3077,292 @@ const withCrudFirestore = (MixinBase) => {
3162
3077
  };
3163
3078
  };
3164
3079
 
3165
- class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3080
+ class LeadFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3166
3081
  constructor({ firestore, interceptors }) {
3167
3082
  super({
3168
3083
  firestore,
3169
- collectionName: 'categories',
3170
- model: Category,
3084
+ collectionName: 'leads',
3085
+ model: Lead,
3171
3086
  interceptors,
3172
3087
  });
3173
3088
  }
3174
- async getCategoryBySlug(slug, shop) {
3175
- const categoryDocs = await this.collection(this.collectionName)
3176
- .where('slug', '==', slug)
3177
- .where('shop', '==', shop)
3178
- .where('published', '==', true)
3179
- .getDocs();
3180
- if (categoryDocs.size > 1)
3181
- throw new DuplicatedResultsError('Query returned duplicated values');
3182
- if (categoryDocs.empty)
3183
- throw new NotFoundError(`Document with slug ${slug} not found`);
3184
- return categoryDocs.docs[0].data();
3185
- }
3186
- async getCategoriesForHome(categoryIds, shop, limit = 4) {
3187
- const categorySnap = await this.collection(this.collectionName)
3188
- .where('id', 'in', categoryIds.filter(Boolean))
3189
- .where('published', '==', true)
3190
- .getDocs();
3191
- if (categorySnap.empty)
3192
- throw new NotFoundError('Categories not found');
3193
- const categories = categorySnap.docs.map((doc) => doc.data());
3194
- const homeSections = await Promise.all(categories.map(async (category) => ({
3195
- category,
3196
- products: await this.mountCategory(category, shop, { limit, hasStock: true }),
3197
- })));
3198
- return homeSections;
3199
- }
3200
- async mountCategory(category, shop, options) {
3201
- if (!category.products)
3202
- throw new RequiredArgumentError(['Category products is empty']);
3203
- const chunks = chunk(category.products, 10);
3204
- const products = [];
3205
- const wheres = [];
3206
- for (const productIds of chunks) {
3207
- if ((options === null || options === void 0 ? void 0 : options.limit) && products.length >= (options === null || options === void 0 ? void 0 : options.limit))
3208
- break;
3209
- wheres.push(['published', '==', true], ['id', 'in', productIds]);
3210
- if (options === null || options === void 0 ? void 0 : options.hasStock)
3211
- wheres.push(['stock.quantity', '>', 0]);
3212
- if (options === null || options === void 0 ? void 0 : options.gender)
3213
- wheres.push(['tags', 'array-contains', options === null || options === void 0 ? void 0 : options.gender]);
3214
- const productSnap = await wheres
3215
- .reduce((collection, where) => collection.where(...where), (options === null || options === void 0 ? void 0 : options.limit)
3216
- ? this.collection('productsErpVitrine').limit(options.limit)
3217
- : this.collection('productsErpVitrine'))
3218
- .getDocs();
3219
- if (productSnap.empty)
3220
- continue;
3221
- products.push(...productSnap.docs);
3222
- }
3223
- return is(products);
3224
- }
3225
- getCategoryByShop(shop) {
3226
- return;
3227
- }
3228
- getChildren(parentId) {
3229
- return;
3089
+ }
3090
+
3091
+ class SubscriptionEditionFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
3092
+ constructor({ firestore, interceptors }, parentRepository) {
3093
+ super({
3094
+ firestore,
3095
+ collectionName: 'editions',
3096
+ parentIdField: 'subscriptionId',
3097
+ model: Edition,
3098
+ interceptors,
3099
+ });
3100
+ this.parentRepository = parentRepository;
3230
3101
  }
3231
- isChild(id, parentId) {
3232
- return;
3102
+ }
3103
+
3104
+ class SubscriptionFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3105
+ constructor({ firestore, interceptors, }) {
3106
+ super({
3107
+ firestore,
3108
+ collectionName: 'subscription',
3109
+ model: Subscription,
3110
+ interceptors,
3111
+ });
3233
3112
  }
3234
3113
  }
3235
- __decorate([
3236
- Log(),
3237
- __metadata("design:type", Function),
3238
- __metadata("design:paramtypes", [String, String]),
3239
- __metadata("design:returntype", Promise)
3240
- ], CategoryFirestoreRepository.prototype, "getCategoryBySlug", null);
3241
- __decorate([
3242
- Log(),
3243
- __metadata("design:type", Function),
3244
- __metadata("design:paramtypes", [Array, String, Object]),
3245
- __metadata("design:returntype", Promise)
3246
- ], CategoryFirestoreRepository.prototype, "getCategoriesForHome", null);
3247
- __decorate([
3248
- Log(),
3249
- __metadata("design:type", Function),
3250
- __metadata("design:paramtypes", [Category, String, Object]),
3251
- __metadata("design:returntype", Promise)
3252
- ], CategoryFirestoreRepository.prototype, "mountCategory", null);
3253
3114
 
3254
- class ProductFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3115
+ class SubscriptionMaterializationFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3255
3116
  constructor({ firestore, interceptors }) {
3256
3117
  super({
3257
3118
  firestore,
3258
- collectionName: 'productsErpVitrine',
3259
- model: Product,
3119
+ collectionName: 'subscriptionMaterialization',
3120
+ model: SubscriptionMaterialization,
3260
3121
  interceptors,
3261
3122
  });
3262
- this.reviews = {};
3263
3123
  }
3264
- fetchProductReviews(filters) {
3265
- throw new Error('Method not implemented.');
3124
+ }
3125
+
3126
+ class SubscriptionPaymentFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
3127
+ constructor({ firestore, interceptors }, parentRepository) {
3128
+ super({
3129
+ firestore,
3130
+ collectionName: 'payments',
3131
+ parentIdField: 'subscriptionId',
3132
+ model: SubscriptionPayment,
3133
+ interceptors,
3134
+ });
3135
+ this.parentRepository = parentRepository;
3266
3136
  }
3267
- async getBySlug(slug) {
3268
- var _a;
3269
- const result = await this.find({
3270
- filters: {
3271
- slug: { operator: Where.EQUALS, value: slug },
3272
- },
3137
+ }
3138
+
3139
+ class SubscriptionSummaryFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3140
+ constructor({ firestore, interceptors, }) {
3141
+ super({
3142
+ firestore,
3143
+ collectionName: 'subscriptionSummary',
3144
+ model: SubscriptionSummary,
3145
+ interceptors,
3273
3146
  });
3274
- return (_a = result === null || result === void 0 ? void 0 : result.data) === null || _a === void 0 ? void 0 : _a.shift();
3275
3147
  }
3276
- async fetchReviews(status) {
3148
+ }
3149
+
3150
+ class UserAddressFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
3151
+ constructor({ firestore, interceptors }, parentRepository) {
3152
+ super({
3153
+ firestore,
3154
+ collectionName: 'address',
3155
+ parentIdField: 'userId',
3156
+ model: UserAddress,
3157
+ interceptors,
3158
+ });
3159
+ this.parentRepository = parentRepository;
3160
+ }
3161
+ }
3162
+
3163
+ class UserBeautyProfileFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
3164
+ constructor({ firestore, interceptors }, parentRepository) {
3165
+ super({
3166
+ firestore,
3167
+ collectionName: 'CX',
3168
+ parentIdField: 'userId',
3169
+ model: BeautyProfile,
3170
+ interceptors,
3171
+ });
3172
+ this.parentRepository = parentRepository;
3173
+ }
3174
+ }
3175
+
3176
+ class UserFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3177
+ constructor({ firestore, interceptors }) {
3178
+ super({
3179
+ firestore,
3180
+ collectionName: 'users',
3181
+ model: User,
3182
+ interceptors,
3183
+ });
3184
+ }
3185
+ async get(identifiers) {
3186
+ const user = await super.get({ id: identifiers.id });
3187
+ user.beautyProfile = await this.getBeautyProfile(user.id);
3188
+ user.isSubscriber = await this.checkIfIsSubscriber(user.id);
3189
+ return user;
3190
+ }
3191
+ async checkIfExistsByField(field, value) {
3192
+ const result = await this.find({ filters: { [field]: value } });
3193
+ return result.count > 0;
3194
+ }
3195
+ buildModelInstance() {
3196
+ const { fromFirestore, toFirestore } = super.buildModelInstance();
3197
+ return {
3198
+ toFirestore: (data) => {
3199
+ const plain = toFirestore(data);
3200
+ delete plain.isSubscriber;
3201
+ return plain;
3202
+ },
3203
+ fromFirestore,
3204
+ };
3205
+ }
3206
+ async getBeautyProfile(userId) {
3207
+ const beautyProfile = await this.firestore
3208
+ .getCollection(`${this.collectionName}/${userId}/CX`)
3209
+ .withConverter(this.buildBeautyProfileModelInstance())
3210
+ .getDoc('beautyProfile')
3211
+ .get();
3212
+ return beautyProfile.data();
3213
+ }
3214
+ async checkIfIsSubscriber(userId) {
3215
+ const docs = await this.collection('subscription')
3216
+ .where('user.id', '==', userId)
3217
+ .where('status', '==', 'active')
3218
+ .getDocs();
3219
+ return !!docs && !!docs.size;
3220
+ }
3221
+ buildBeautyProfileModelInstance() {
3222
+ return {
3223
+ toFirestore: (data) => data.toPlain(),
3224
+ fromFirestore: (snap) => BeautyProfile.toInstance(snap.data()),
3225
+ };
3226
+ }
3227
+ }
3228
+ __decorate([
3229
+ Log(),
3230
+ __metadata("design:type", Function),
3231
+ __metadata("design:paramtypes", [Object]),
3232
+ __metadata("design:returntype", Promise)
3233
+ ], UserFirestoreRepository.prototype, "get", null);
3234
+ __decorate([
3235
+ Log(),
3236
+ __metadata("design:type", Function),
3237
+ __metadata("design:paramtypes", [String, String]),
3238
+ __metadata("design:returntype", Promise)
3239
+ ], UserFirestoreRepository.prototype, "checkIfExistsByField", null);
3240
+
3241
+ class UserPaymentMethodFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
3242
+ constructor({ firestore, interceptors }, parentRepository) {
3243
+ super({
3244
+ firestore,
3245
+ collectionName: 'payment_method',
3246
+ parentIdField: 'userId',
3247
+ model: UserPaymentMethod,
3248
+ interceptors,
3249
+ });
3250
+ this.parentRepository = parentRepository;
3251
+ }
3252
+ }
3253
+
3254
+ class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3255
+ constructor({ firestore, interceptors }) {
3256
+ super({
3257
+ firestore,
3258
+ collectionName: 'categories',
3259
+ model: Category,
3260
+ interceptors,
3261
+ });
3262
+ }
3263
+ async getCategoryBySlug(slug, shop) {
3264
+ const categoryDocs = await this.collection(this.collectionName)
3265
+ .where('slug', '==', slug)
3266
+ .where('shop', '==', shop)
3267
+ .where('published', '==', true)
3268
+ .getDocs();
3269
+ if (categoryDocs.size > 1)
3270
+ throw new DuplicatedResultsError('Query returned duplicated values');
3271
+ if (categoryDocs.empty)
3272
+ throw new NotFoundError(`Document with slug ${slug} not found`);
3273
+ return categoryDocs.docs[0].data();
3274
+ }
3275
+ async getCategoriesForHome(categoryIds, limit = 4, gender) {
3276
+ const categorySnap = await this.collection(this.collectionName)
3277
+ .where('id', 'in', categoryIds.filter(Boolean))
3278
+ .where('published', '==', true)
3279
+ .getDocs();
3280
+ if (categorySnap.empty)
3281
+ throw new NotFoundError('Categories not found');
3282
+ const categories = categorySnap.docs.map((doc) => doc.data());
3283
+ const homeSections = await Promise.all(categories.map(async (category) => ({
3284
+ category,
3285
+ products: await this.mountCategory(category, { limit, hasStock: true, gender }),
3286
+ })));
3287
+ return homeSections;
3288
+ }
3289
+ async mountCategory(category, options) {
3290
+ if (!category.products)
3291
+ throw new RequiredArgumentError(['Category products is empty']);
3292
+ const chunks = chunk(category.products, 10);
3293
+ const products = [];
3294
+ const wheres = [];
3295
+ for (const productIds of chunks) {
3296
+ if ((options === null || options === void 0 ? void 0 : options.limit) && products.length >= (options === null || options === void 0 ? void 0 : options.limit))
3297
+ break;
3298
+ wheres.push(['published', '==', true], ['id', 'in', productIds]);
3299
+ if (options === null || options === void 0 ? void 0 : options.hasStock)
3300
+ wheres.push(['stock.quantity', '>', 0]);
3301
+ if (options === null || options === void 0 ? void 0 : options.gender)
3302
+ wheres.push(['tags', 'array-contains', options === null || options === void 0 ? void 0 : options.gender]);
3303
+ const productSnap = await wheres
3304
+ .reduce((collection, where) => collection.where(...where), (options === null || options === void 0 ? void 0 : options.limit)
3305
+ ? this.collection('productsErpVitrine').limit(options.limit)
3306
+ : this.collection('productsErpVitrine'))
3307
+ .getDocs();
3308
+ if (productSnap.empty)
3309
+ continue;
3310
+ products.push(...productSnap.docs);
3311
+ }
3312
+ return is(products);
3313
+ }
3314
+ getCategoryByShop(shop) {
3315
+ return;
3316
+ }
3317
+ getChildren(parentId) {
3318
+ return;
3319
+ }
3320
+ isChild(id, parentId) {
3321
+ return;
3322
+ }
3323
+ }
3324
+ __decorate([
3325
+ Log(),
3326
+ __metadata("design:type", Function),
3327
+ __metadata("design:paramtypes", [String, String]),
3328
+ __metadata("design:returntype", Promise)
3329
+ ], CategoryFirestoreRepository.prototype, "getCategoryBySlug", null);
3330
+ __decorate([
3331
+ Log(),
3332
+ __metadata("design:type", Function),
3333
+ __metadata("design:paramtypes", [Array, Object, String]),
3334
+ __metadata("design:returntype", Promise)
3335
+ ], CategoryFirestoreRepository.prototype, "getCategoriesForHome", null);
3336
+ __decorate([
3337
+ Log(),
3338
+ __metadata("design:type", Function),
3339
+ __metadata("design:paramtypes", [Category, Object]),
3340
+ __metadata("design:returntype", Promise)
3341
+ ], CategoryFirestoreRepository.prototype, "mountCategory", null);
3342
+
3343
+ class ProductFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3344
+ constructor({ firestore, interceptors }) {
3345
+ super({
3346
+ firestore,
3347
+ collectionName: 'productsErpVitrine',
3348
+ model: Product,
3349
+ interceptors,
3350
+ });
3351
+ this.reviews = {};
3352
+ }
3353
+ fetchProductReviews(filters) {
3354
+ throw new Error('Method not implemented.');
3355
+ }
3356
+ async getBySlug(slug) {
3357
+ var _a;
3358
+ const result = await this.find({
3359
+ filters: {
3360
+ slug: { operator: Where.EQUALS, value: slug },
3361
+ },
3362
+ });
3363
+ return (_a = result === null || result === void 0 ? void 0 : result.data) === null || _a === void 0 ? void 0 : _a.shift();
3364
+ }
3365
+ async fetchReviews(status) {
3277
3366
  const { data: products } = await this.find();
3278
3367
  products.forEach((product) => {
3279
3368
  var _a;
@@ -3308,9 +3397,6 @@ class ProductFirestoreRepository extends withCrudFirestore(withHelpers(withFires
3308
3397
  async fetchPaginatedReviews() {
3309
3398
  return Promise.resolve([]);
3310
3399
  }
3311
- productVariantFullReport() {
3312
- return;
3313
- }
3314
3400
  }
3315
3401
  __decorate([
3316
3402
  Log(),
@@ -3349,101 +3435,6 @@ class SubscriptionProductFirestoreRepository extends withCrudFirestore(withHelpe
3349
3435
  }
3350
3436
  }
3351
3437
 
3352
- class LogFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3353
- constructor({ firestore, interceptors, }) {
3354
- super({
3355
- firestore,
3356
- collectionName: 'logs',
3357
- model: LogDocument,
3358
- interceptors,
3359
- });
3360
- }
3361
- }
3362
-
3363
- class HomeFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3364
- constructor({ firestore, interceptors }) {
3365
- super({
3366
- firestore,
3367
- collectionName: 'dms',
3368
- model: Home,
3369
- interceptors,
3370
- });
3371
- this.homeCategoryGroupToPlain = (homeCategoryGroup) => {
3372
- var _a, _b, _c;
3373
- return ({
3374
- category: ((_a = homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category) === null || _a === void 0 ? void 0 : _a.toPlain)
3375
- ? (_b = homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category) === null || _b === void 0 ? void 0 : _b.toPlain()
3376
- : homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category,
3377
- 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)) || [],
3378
- });
3379
- };
3380
- this.plainToHomeCategoryGroup = (homeCategoryGroup) => {
3381
- var _a;
3382
- return ({
3383
- category: Category.toInstance(homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category),
3384
- products: (_a = homeCategoryGroup.products) === null || _a === void 0 ? void 0 : _a.map((product) => Product.toInstance(product)),
3385
- });
3386
- };
3387
- }
3388
- buildModelInstance() {
3389
- const { fromFirestore, toFirestore } = super.buildModelInstance();
3390
- return {
3391
- toFirestore: (data) => {
3392
- const modifiedData = this.homeToFirestore(data);
3393
- return toFirestore(modifiedData);
3394
- },
3395
- fromFirestore: (snap) => {
3396
- const instance = fromFirestore(snap);
3397
- return this.homeFromFirestore(instance);
3398
- },
3399
- };
3400
- }
3401
- homeToFirestore(home) {
3402
- var _a, _b, _c, _d;
3403
- if ((_a = home.data) === null || _a === void 0 ? void 0 : _a.data) {
3404
- home.data.data.discoverProducts = ((_b = home.data.data.discoverProducts) === null || _b === void 0 ? void 0 : _b.map(this.homeCategoryGroupToPlain)) || [];
3405
- home.data.data.featuredProducts = ((_c = home.data.data.featuredProducts) === null || _c === void 0 ? void 0 : _c.map(this.homeCategoryGroupToPlain)) || [];
3406
- home.data.data.verticalProducts = ((_d = home.data.data.verticalProducts) === null || _d === void 0 ? void 0 : _d.map(this.homeCategoryGroupToPlain)) || [];
3407
- }
3408
- return home;
3409
- }
3410
- homeFromFirestore(home) {
3411
- var _a;
3412
- if ((_a = home.data) === null || _a === void 0 ? void 0 : _a.data) {
3413
- home.data.data.discoverProducts = home.data.data.discoverProducts.map(this.plainToHomeCategoryGroup);
3414
- home.data.data.featuredProducts = home.data.data.featuredProducts.map(this.plainToHomeCategoryGroup);
3415
- home.data.data.verticalProducts = home.data.data.verticalProducts.map(this.plainToHomeCategoryGroup);
3416
- home.data.createdAt =
3417
- home.data.createdAt instanceof Timestamp ? home.data.createdAt.toDate() : home.data.createdAt;
3418
- home.data.expiresAt =
3419
- home.data.expiresAt instanceof Timestamp ? home.data.expiresAt.toDate() : home.data.expiresAt;
3420
- }
3421
- return home;
3422
- }
3423
- }
3424
-
3425
- class ShopMenuFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3426
- constructor({ firestore, interceptors }) {
3427
- super({
3428
- firestore,
3429
- collectionName: 'shopMenus',
3430
- model: ShopMenu,
3431
- interceptors,
3432
- });
3433
- }
3434
- }
3435
-
3436
- class ShopSettingsFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3437
- constructor({ firestore, interceptors, }) {
3438
- super({
3439
- firestore,
3440
- collectionName: 'shopSettings',
3441
- model: ShopSettings,
3442
- interceptors,
3443
- });
3444
- }
3445
- }
3446
-
3447
3438
  class Buy2WinFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3448
3439
  constructor({ firestore, interceptors }) {
3449
3440
  super({
@@ -3555,259 +3546,128 @@ class OrderFirestoreRepository extends withCrudFirestore(withHelpers(withFiresto
3555
3546
  buildModelInstance() {
3556
3547
  const { fromFirestore, toFirestore } = super.buildModelInstance();
3557
3548
  return {
3558
- toFirestore: (data) => toFirestore((data === null || data === void 0 ? void 0 : data.toPlain) ? data.toPlain() : data),
3559
- fromFirestore: (snap) => {
3560
- const instance = fromFirestore(snap);
3561
- return this.orderFromFirestore(instance);
3562
- },
3563
- };
3564
- }
3565
- }
3566
-
3567
- class LegacyOrderFirestoreRepository extends OrderFirestoreRepository {
3568
- constructor({ firestore, interceptors }) {
3569
- super({
3570
- firestore,
3571
- interceptors,
3572
- });
3573
- this.collectionName = 'legacyOrders';
3574
- }
3575
- }
3576
-
3577
- class OrderBlockedFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3578
- constructor({ firestore, interceptors, }) {
3579
- super({
3580
- firestore,
3581
- collectionName: 'paymentBlockedAttempts',
3582
- model: OrderBlocked,
3583
- interceptors,
3584
- });
3585
- }
3586
- async createBlockedOrderOrPayment(checkout, blockType, type, limiteRange, card = null) {
3587
- var _a, _b, _c, _d, _e, _f, _g, _h;
3588
- return this.create(OrderBlocked.toInstance({
3589
- customer: {
3590
- name: ((_a = checkout.user) === null || _a === void 0 ? void 0 : _a.displayName) || '',
3591
- cpf: ((_b = checkout.user) === null || _b === void 0 ? void 0 : _b.cpf) || '',
3592
- id: (_c = checkout.user) === null || _c === void 0 ? void 0 : _c.id,
3593
- email: ((_d = checkout.user) === null || _d === void 0 ? void 0 : _d.email) || '',
3594
- phoneNumber: '+55' + ((_e = checkout.user) === null || _e === void 0 ? void 0 : _e.phone),
3595
- isSubscriber: (_f = checkout.user) === null || _f === void 0 ? void 0 : _f.isSubscriber,
3596
- subscriptionPlan: ((_g = checkout.user) === null || _g === void 0 ? void 0 : _g.subscriptionPlan) || '',
3597
- shippingAddress: Object.assign(Object.assign({}, checkout.shippingAddress), { zip: this.formatZip((_h = checkout.shippingAddress) === null || _h === void 0 ? void 0 : _h.zip) }),
3598
- },
3599
- blockType,
3600
- limiteRange,
3601
- type,
3602
- card,
3603
- checkout: {
3604
- id: checkout.id,
3605
- shop: checkout.shop,
3606
- total: checkout.totalPrice,
3607
- },
3608
- date: new Date(),
3609
- }));
3610
- }
3611
- formatZip(zip) {
3612
- if (zip.length === 8)
3613
- return zip.substring(0, 5) + '-' + zip.substring(5, 8);
3614
- return zip;
3615
- }
3616
- }
3617
-
3618
- class PaymentFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3619
- constructor({ firestore, interceptors }) {
3620
- super({
3621
- firestore,
3622
- collectionName: 'payments',
3623
- model: Payment,
3624
- interceptors,
3625
- });
3626
- }
3627
- }
3628
-
3629
- class SubscriptionPlanFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3630
- constructor({ firestore, interceptors, }) {
3631
- super({
3632
- firestore,
3633
- collectionName: 'subscriptionPlans',
3634
- model: SubscriptionPlan,
3635
- interceptors,
3636
- });
3637
- }
3638
- }
3639
-
3640
- class LeadFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3641
- constructor({ firestore, interceptors }) {
3642
- super({
3643
- firestore,
3644
- collectionName: 'leads',
3645
- model: Lead,
3646
- interceptors,
3647
- });
3648
- }
3649
- }
3650
-
3651
- class SubscriptionEditionFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
3652
- constructor({ firestore, interceptors }, parentRepository) {
3653
- super({
3654
- firestore,
3655
- collectionName: 'editions',
3656
- parentIdField: 'subscriptionId',
3657
- model: Edition,
3658
- interceptors,
3659
- });
3660
- this.parentRepository = parentRepository;
3661
- }
3662
- }
3663
-
3664
- class SubscriptionFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3665
- constructor({ firestore, interceptors, }) {
3666
- super({
3667
- firestore,
3668
- collectionName: 'subscription',
3669
- model: Subscription,
3670
- interceptors,
3671
- });
3549
+ toFirestore: (data) => toFirestore((data === null || data === void 0 ? void 0 : data.toPlain) ? data.toPlain() : data),
3550
+ fromFirestore: (snap) => {
3551
+ const instance = fromFirestore(snap);
3552
+ return this.orderFromFirestore(instance);
3553
+ },
3554
+ };
3672
3555
  }
3673
3556
  }
3674
3557
 
3675
- class SubscriptionMaterializationFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3558
+ class LegacyOrderFirestoreRepository extends OrderFirestoreRepository {
3676
3559
  constructor({ firestore, interceptors }) {
3677
3560
  super({
3678
3561
  firestore,
3679
- collectionName: 'subscriptionMaterialization',
3680
- model: SubscriptionMaterialization,
3681
3562
  interceptors,
3682
3563
  });
3564
+ this.collectionName = 'legacyOrders';
3683
3565
  }
3684
3566
  }
3685
3567
 
3686
- class SubscriptionPaymentFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
3687
- constructor({ firestore, interceptors }, parentRepository) {
3568
+ class PaymentFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3569
+ constructor({ firestore, interceptors }) {
3688
3570
  super({
3689
3571
  firestore,
3690
3572
  collectionName: 'payments',
3691
- parentIdField: 'subscriptionId',
3692
- model: SubscriptionPayment,
3573
+ model: Payment,
3693
3574
  interceptors,
3694
3575
  });
3695
- this.parentRepository = parentRepository;
3696
3576
  }
3697
3577
  }
3698
3578
 
3699
- class SubscriptionSummaryFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3579
+ class SubscriptionPlanFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3700
3580
  constructor({ firestore, interceptors, }) {
3701
3581
  super({
3702
3582
  firestore,
3703
- collectionName: 'subscriptionSummary',
3704
- model: SubscriptionSummary,
3705
- interceptors,
3706
- });
3707
- }
3708
- }
3709
-
3710
- class UserAddressFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
3711
- constructor({ firestore, interceptors }, parentRepository) {
3712
- super({
3713
- firestore,
3714
- collectionName: 'address',
3715
- parentIdField: 'userId',
3716
- model: UserAddress,
3717
- interceptors,
3718
- });
3719
- this.parentRepository = parentRepository;
3720
- }
3721
- }
3722
-
3723
- class UserBeautyProfileFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
3724
- constructor({ firestore, interceptors }, parentRepository) {
3725
- super({
3726
- firestore,
3727
- collectionName: 'CX',
3728
- parentIdField: 'userId',
3729
- model: BeautyProfile,
3583
+ collectionName: 'subscriptionPlans',
3584
+ model: SubscriptionPlan,
3730
3585
  interceptors,
3731
3586
  });
3732
- this.parentRepository = parentRepository;
3733
3587
  }
3734
3588
  }
3735
3589
 
3736
- class UserFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3590
+ class HomeFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3737
3591
  constructor({ firestore, interceptors }) {
3738
3592
  super({
3739
3593
  firestore,
3740
- collectionName: 'users',
3741
- model: User,
3594
+ collectionName: 'dms',
3595
+ model: Home,
3742
3596
  interceptors,
3743
3597
  });
3744
- }
3745
- async get(identifiers) {
3746
- const user = await super.get({ id: identifiers.id });
3747
- user.beautyProfile = await this.getBeautyProfile(user.id);
3748
- user.isSubscriber = await this.checkIfIsSubscriber(user.id);
3749
- return user;
3750
- }
3751
- async checkIfExistsByField(field, value) {
3752
- const result = await this.find({ filters: { [field]: value } });
3753
- return result.count > 0;
3598
+ this.homeCategoryGroupToPlain = (homeCategoryGroup) => {
3599
+ var _a, _b, _c;
3600
+ return ({
3601
+ category: ((_a = homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category) === null || _a === void 0 ? void 0 : _a.toPlain)
3602
+ ? (_b = homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category) === null || _b === void 0 ? void 0 : _b.toPlain()
3603
+ : homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category,
3604
+ 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)) || [],
3605
+ });
3606
+ };
3607
+ this.plainToHomeCategoryGroup = (homeCategoryGroup) => {
3608
+ var _a;
3609
+ return ({
3610
+ category: Category.toInstance(homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category),
3611
+ products: (_a = homeCategoryGroup.products) === null || _a === void 0 ? void 0 : _a.map((product) => Product.toInstance(product)),
3612
+ });
3613
+ };
3754
3614
  }
3755
3615
  buildModelInstance() {
3756
3616
  const { fromFirestore, toFirestore } = super.buildModelInstance();
3757
3617
  return {
3758
3618
  toFirestore: (data) => {
3759
- const plain = toFirestore(data);
3760
- delete plain.isSubscriber;
3761
- return plain;
3619
+ const modifiedData = this.homeToFirestore(data);
3620
+ return toFirestore(modifiedData);
3621
+ },
3622
+ fromFirestore: (snap) => {
3623
+ const instance = fromFirestore(snap);
3624
+ return this.homeFromFirestore(instance);
3762
3625
  },
3763
- fromFirestore,
3764
3626
  };
3765
3627
  }
3766
- async getBeautyProfile(userId) {
3767
- const beautyProfile = await this.firestore
3768
- .getCollection(`${this.collectionName}/${userId}/CX`)
3769
- .withConverter(this.buildBeautyProfileModelInstance())
3770
- .getDoc('beautyProfile')
3771
- .get();
3772
- return beautyProfile.data();
3628
+ homeToFirestore(home) {
3629
+ var _a, _b, _c, _d;
3630
+ if ((_a = home.data) === null || _a === void 0 ? void 0 : _a.data) {
3631
+ home.data.data.discoverProducts = ((_b = home.data.data.discoverProducts) === null || _b === void 0 ? void 0 : _b.map(this.homeCategoryGroupToPlain)) || [];
3632
+ home.data.data.featuredProducts = ((_c = home.data.data.featuredProducts) === null || _c === void 0 ? void 0 : _c.map(this.homeCategoryGroupToPlain)) || [];
3633
+ home.data.data.verticalProducts = ((_d = home.data.data.verticalProducts) === null || _d === void 0 ? void 0 : _d.map(this.homeCategoryGroupToPlain)) || [];
3634
+ }
3635
+ return home;
3773
3636
  }
3774
- async checkIfIsSubscriber(userId) {
3775
- const docs = await this.collection('subscription')
3776
- .where('user.id', '==', userId)
3777
- .where('status', '==', 'active')
3778
- .getDocs();
3779
- return !!docs && !!docs.size;
3637
+ homeFromFirestore(home) {
3638
+ var _a;
3639
+ if ((_a = home.data) === null || _a === void 0 ? void 0 : _a.data) {
3640
+ home.data.data.discoverProducts = home.data.data.discoverProducts.map(this.plainToHomeCategoryGroup);
3641
+ home.data.data.featuredProducts = home.data.data.featuredProducts.map(this.plainToHomeCategoryGroup);
3642
+ home.data.data.verticalProducts = home.data.data.verticalProducts.map(this.plainToHomeCategoryGroup);
3643
+ home.data.createdAt =
3644
+ home.data.createdAt instanceof Timestamp ? home.data.createdAt.toDate() : home.data.createdAt;
3645
+ home.data.expiresAt =
3646
+ home.data.expiresAt instanceof Timestamp ? home.data.expiresAt.toDate() : home.data.expiresAt;
3647
+ }
3648
+ return home;
3780
3649
  }
3781
- buildBeautyProfileModelInstance() {
3782
- return {
3783
- toFirestore: (data) => data.toPlain(),
3784
- fromFirestore: (snap) => BeautyProfile.toInstance(snap.data()),
3785
- };
3650
+ }
3651
+
3652
+ class ShopMenuFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3653
+ constructor({ firestore, interceptors }) {
3654
+ super({
3655
+ firestore,
3656
+ collectionName: 'shopMenus',
3657
+ model: ShopMenu,
3658
+ interceptors,
3659
+ });
3786
3660
  }
3787
3661
  }
3788
- __decorate([
3789
- Log(),
3790
- __metadata("design:type", Function),
3791
- __metadata("design:paramtypes", [Object]),
3792
- __metadata("design:returntype", Promise)
3793
- ], UserFirestoreRepository.prototype, "get", null);
3794
- __decorate([
3795
- Log(),
3796
- __metadata("design:type", Function),
3797
- __metadata("design:paramtypes", [String, String]),
3798
- __metadata("design:returntype", Promise)
3799
- ], UserFirestoreRepository.prototype, "checkIfExistsByField", null);
3800
3662
 
3801
- class UserPaymentMethodFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
3802
- constructor({ firestore, interceptors }, parentRepository) {
3663
+ class ShopSettingsFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3664
+ constructor({ firestore, interceptors, }) {
3803
3665
  super({
3804
3666
  firestore,
3805
- collectionName: 'payment_method',
3806
- parentIdField: 'userId',
3807
- model: UserPaymentMethod,
3667
+ collectionName: 'shopSettings',
3668
+ model: ShopSettings,
3808
3669
  interceptors,
3809
3670
  });
3810
- this.parentRepository = parentRepository;
3811
3671
  }
3812
3672
  }
3813
3673
 
@@ -4360,7 +4220,7 @@ const withHasuraGraphQL = (MixinBase) => {
4360
4220
  const response = await axios(request);
4361
4221
  if (!isNil(response.data.errors)) {
4362
4222
  this.logger.error({ req: request, res: response.data.errors });
4363
- throw new Error(JSON.stringify(response.data.errors));
4223
+ throw new Error(response.data.errors);
4364
4224
  }
4365
4225
  this.logger.log({ req: request, res: response.data });
4366
4226
  return response.data.data;
@@ -4501,7 +4361,6 @@ const withFindHasuraGraphQL = (MixinBase) => {
4501
4361
  return class FindHasuraGraphQLMixin extends MixinBase {
4502
4362
  constructor() {
4503
4363
  super(...arguments);
4504
- this.lastDistinct = {};
4505
4364
  this.bindOrderByAttributes = (orderBy, fields) => Object.keys(orderBy).reduce((acc, current) => [
4506
4365
  ...acc,
4507
4366
  {
@@ -4537,10 +4396,9 @@ const withFindHasuraGraphQL = (MixinBase) => {
4537
4396
  });
4538
4397
  }
4539
4398
  async find(params) {
4540
- var _a, _b, _c, _d, _e, _f, _g;
4399
+ var _a, _b, _c, _d, _e, _f, _g, _h;
4541
4400
  this.logger = DebugHelper.from(this, 'find');
4542
4401
  const { filters, limits, orderBy, options } = params || {};
4543
- const tableFiltersNamed = `${this.tableName}:${JSON.stringify(filters)}`;
4544
4402
  const enableCount = (_a = options === null || options === void 0 ? void 0 : options.enableCount) !== null && _a !== void 0 ? _a : true;
4545
4403
  const variablesFilters = isNil(filters)
4546
4404
  ? {}
@@ -4591,8 +4449,8 @@ const withFindHasuraGraphQL = (MixinBase) => {
4591
4449
  },
4592
4450
  ]
4593
4451
  : []),
4594
- ...((!this.lastDistinct[tableFiltersNamed] &&
4595
- ((_c = (_b = params.options) === null || _b === void 0 ? void 0 : _b.distinct) === null || _c === void 0 ? void 0 : _c.map((distinct) => {
4452
+ ...((!((_b = params.limits) === null || _b === void 0 ? void 0 : _b.offset) &&
4453
+ ((_d = (_c = params.options) === null || _c === void 0 ? void 0 : _c.distinct) === null || _d === void 0 ? void 0 : _d.map((distinct) => {
4596
4454
  var _a, _b;
4597
4455
  const distinctOption = (_a = this.fields.find((fieldOption) => fieldOption === distinct)) !== null && _a !== void 0 ? _a : this.fields.find((fieldOption) => Object.keys(fieldOption).shift() === distinct);
4598
4456
  const fieldName = ((_b = Object.values(distinctOption).shift()) === null || _b === void 0 ? void 0 : _b.columnName) || distinct;
@@ -4613,27 +4471,28 @@ const withFindHasuraGraphQL = (MixinBase) => {
4613
4471
  []),
4614
4472
  ]);
4615
4473
  const data = result[this.tableName].map((row) => this.convertDataFromHasura(row));
4616
- 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)
4474
+ 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)
4617
4475
  ? {
4618
4476
  minimal: options.minimal.reduce((minimals, current) => {
4619
4477
  var _a;
4620
4478
  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])));
4621
4479
  }, {}),
4622
4480
  }
4623
- : {})), (((_e = options === null || options === void 0 ? void 0 : options.maximum) === null || _e === void 0 ? void 0 : _e.length)
4481
+ : {})), (((_f = options === null || options === void 0 ? void 0 : options.maximum) === null || _f === void 0 ? void 0 : _f.length)
4624
4482
  ? {
4625
4483
  maximum: options.maximum.reduce((maximums, current) => {
4626
4484
  var _a;
4627
4485
  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])));
4628
4486
  }, {}),
4629
4487
  }
4630
- : {})), (((_f = options === null || options === void 0 ? void 0 : options.distinct) === null || _f === void 0 ? void 0 : _f.length) && {
4631
- 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) => {
4488
+ : {})), (!((_g = params.limits) === null || _g === void 0 ? void 0 : _g.offset) &&
4489
+ ((_h = options === null || options === void 0 ? void 0 : options.distinct) === null || _h === void 0 ? void 0 : _h.length) && {
4490
+ distinct: options === null || options === void 0 ? void 0 : options.distinct.reduce((distinct, current) => {
4632
4491
  var _a, _b;
4633
4492
  const distinctOption = (_a = this.fields.find((fieldOption) => fieldOption === current)) !== null && _a !== void 0 ? _a : this.fields.find((fieldOption) => Object.keys(fieldOption).shift() === current);
4634
4493
  const fieldName = ((_b = Object.values(distinctOption).shift()) === null || _b === void 0 ? void 0 : _b.columnName) || current;
4635
4494
  return Object.assign(Object.assign({}, distinct), { [current.toString()]: result[`${this.tableName}_${current.toString()}_distinct`].map((obj) => obj[fieldName]) });
4636
- }, {})),
4495
+ }, {}),
4637
4496
  }));
4638
4497
  }
4639
4498
  };
@@ -4728,7 +4587,6 @@ class CategoryFilterHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHa
4728
4587
  fields: [
4729
4588
  'id',
4730
4589
  'description',
4731
- 'title',
4732
4590
  'slug',
4733
4591
  'enabled',
4734
4592
  { createdAt: { columnName: 'created_at' } },
@@ -4873,11 +4731,11 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
4873
4731
  filters: {
4874
4732
  columnName: 'filters',
4875
4733
  foreignKeyColumn: { filter_id: 'id' },
4876
- fields: [{ filter: ['id', 'title', 'description', 'slug', 'enabled'] }],
4734
+ fields: [{ filter: ['id', 'description', 'slug', 'enabled'] }],
4877
4735
  bindPersistData: (value) => ({
4878
4736
  filters: { data: value.map((filter) => ({ filter_id: filter.id })) },
4879
4737
  }),
4880
- 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)) || [],
4738
+ from: (filters) => (filters === null || filters === void 0 ? void 0 : filters.map((filter) => filter === null || filter === void 0 ? void 0 : filter.filter)) || [],
4881
4739
  },
4882
4740
  },
4883
4741
  { createdAt: { columnName: 'created_at' } },
@@ -4902,15 +4760,6 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
4902
4760
  }),
4903
4761
  },
4904
4762
  },
4905
- {
4906
- metadatas: {
4907
- columnName: 'metadatas',
4908
- fields: ['shop', 'title', 'description'],
4909
- bindPersistData: (value) => ({
4910
- metadatas: { data: value },
4911
- }),
4912
- },
4913
- },
4914
4763
  { isCollection: { columnName: 'is_collection' } },
4915
4764
  { isWishlist: { columnName: 'is_wishlist' } },
4916
4765
  'reference',
@@ -4925,29 +4774,14 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
4925
4774
  'theme',
4926
4775
  { bannerUrl: { columnName: 'banner_url' } },
4927
4776
  { mostRelevant: { columnName: 'most_relevant', type: HasuraGraphQLColumnType.Jsonb } },
4928
- { mostRelevants: { columnName: 'most_relevants', type: HasuraGraphQLColumnType.Jsonb } },
4929
4777
  ],
4930
4778
  });
4931
4779
  this.productRepository = productRepository;
4932
4780
  this.categoryFilterRepository = categoryFilterRepository;
4933
4781
  }
4934
4782
  async create(params) {
4935
- const { images, mostRelevants, metadatas } = params, data = __rest(params, ["images", "mostRelevants", "metadatas"]);
4936
- return super.create(Object.assign(Object.assign({}, data), { isWishlist: false, metadatas: metadatas || [{ shop: null, description: null, title: null }], mostRelevants: mostRelevants || {
4937
- [Shops.GLAMSHOP]: null,
4938
- [Shops.MENSMARKET]: null,
4939
- }, images: images || {
4940
- [Shops.GLAMSHOP]: {
4941
- brandBanner: null,
4942
- brandBannerMobile: null,
4943
- image: null,
4944
- },
4945
- [Shops.MENSMARKET]: {
4946
- brandBanner: null,
4947
- brandBannerMobile: null,
4948
- image: null,
4949
- },
4950
- } }));
4783
+ const { metadata } = params, data = __rest(params, ["metadata"]);
4784
+ return super.create(Object.assign(Object.assign({}, data), { isWishlist: false, metadata: metadata || [{ shop: null, description: null, title: null }] }));
4951
4785
  }
4952
4786
  async get(identifiers) {
4953
4787
  var _a;
@@ -4956,12 +4790,12 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
4956
4790
  : super.get(identifiers);
4957
4791
  }
4958
4792
  async update(params) {
4959
- const { products, id: checkId, metadatas, filters } = params, data = __rest(params, ["products", "id", "metadatas", "filters"]);
4793
+ const { products, id: checkId, metadata, filters } = params, data = __rest(params, ["products", "id", "metadata", "filters"]);
4960
4794
  const plainData = this.paramsToPlain({ id: checkId });
4961
4795
  const id = await this.getId(plainData.id);
4962
4796
  const category = await super.update(Object.assign(Object.assign({ id }, data), { isWishlist: false }));
4963
4797
  category.products = products && (await this.updateProducts(+id, { products }));
4964
- category.metadatas = metadatas && (await this.updateMetadata(+id, { metadatas }));
4798
+ category.metadata = metadata && (await this.updateMetadata(+id, { metadata }));
4965
4799
  category.filters = filters && (await this.updateFilters(+id, { filters }));
4966
4800
  return category;
4967
4801
  }
@@ -4999,7 +4833,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
4999
4833
  });
5000
4834
  return data;
5001
4835
  }
5002
- async getCategoriesForHome(categoryIds, shop, limit = 4) {
4836
+ async getCategoriesForHome(categoryIds, limit = 4, gender) {
5003
4837
  if (!(categoryIds === null || categoryIds === void 0 ? void 0 : categoryIds.length))
5004
4838
  return [];
5005
4839
  const categoriesFirestore = categoryIds.filter((categoryId) => Number.isNaN(+categoryId));
@@ -5011,32 +4845,22 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
5011
4845
  }).then(({ data }) => data)));
5012
4846
  if (categoriesHasura.length)
5013
4847
  categories.push(...(await this.find({
5014
- filters: {
5015
- id: { operator: Where.IN, value: categoriesHasura.filter(Boolean) },
5016
- published: true,
5017
- },
4848
+ filters: { id: { operator: Where.IN, value: categoriesHasura.filter(Boolean) }, published: true },
5018
4849
  }).then(({ data }) => data)));
5019
4850
  if (!categories.length)
5020
4851
  return [];
5021
4852
  const homeSections = await Promise.all(categories.map(async (category) => ({
5022
4853
  category,
5023
- products: await this.mountCategory(category, shop, { limit, hasStock: true }),
4854
+ products: await this.mountCategory(category, { limit, hasStock: true, gender }),
5024
4855
  })));
5025
4856
  return homeSections;
5026
4857
  }
5027
- async mountCategory(category, shop, options) {
4858
+ async mountCategory(category, options) {
5028
4859
  var _a;
5029
4860
  if (!((_a = category === null || category === void 0 ? void 0 : category.products) === null || _a === void 0 ? void 0 : _a.length))
5030
4861
  return [];
5031
- const mostRelevants = category.getMostRelevantByShop(shop);
5032
- const mostRelevantProductsIds = [...new Set(mostRelevants.concat(category.products))];
5033
4862
  const products = [];
5034
- const { data: productsData } = await this.productRepository.findCatalog({
5035
- filters: {
5036
- id: { operator: Where.IN, value: mostRelevantProductsIds },
5037
- published: true,
5038
- },
5039
- fields: [
4863
+ 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: [
5040
4864
  'id',
5041
4865
  'name',
5042
4866
  'slug',
@@ -5062,25 +4886,8 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
5062
4886
  'shoppingCount',
5063
4887
  'gender',
5064
4888
  'createdAt',
5065
- ],
5066
- options: { enableCount: false },
5067
- orderBy: {
5068
- shoppingCount: 'desc',
5069
- rate: 'desc',
5070
- stock: 'desc',
5071
- name: 'asc',
5072
- },
5073
- }, shop === Shops.MENSMARKET ? 'male' : 'female');
5074
- const mostRelevantWithouyStock = productsData.filter((product) => mostRelevants.includes(product.id) && product.stock.quantity <= 0);
5075
- const firstProducts = productsData
5076
- .filter((product) => mostRelevants.includes(product.id) && product.stock.quantity > 0)
5077
- .sort((a, b) => mostRelevants.indexOf(a.id) - mostRelevants.indexOf(b.id));
5078
- const lastProducts = productsData
5079
- .filter((product) => !mostRelevants.includes(product.id) && product.stock.quantity > 0)
5080
- .concat(mostRelevantWithouyStock);
5081
- const categoryMostRelevants = firstProducts.concat(lastProducts);
5082
- const resultFinal = categoryMostRelevants.slice(0, options.limit);
5083
- products.push(...resultFinal);
4889
+ ] }, ((options === null || options === void 0 ? void 0 : options.limit) ? { limits: { limit: options === null || options === void 0 ? void 0 : options.limit } } : {})), { options: { enableCount: false } }));
4890
+ products.push(...productsData);
5084
4891
  return products;
5085
4892
  }
5086
4893
  async getChildren(parentId) {
@@ -5117,6 +4924,29 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
5117
4924
  });
5118
4925
  return [];
5119
4926
  }
4927
+ const plainData = this.paramsToPlain({ products });
4928
+ if (!plainData.products || plainData.products.length <= 0)
4929
+ return [];
4930
+ const category = await this.get({ id: categoryId.toString() });
4931
+ await this.mutation('delete_category_product', ['affected_rows'], {
4932
+ where: {
4933
+ type: 'category_product_bool_exp',
4934
+ required: true,
4935
+ value: {
4936
+ category_id: { _eq: categoryId },
4937
+ product_id: { _in: category.products.filter((productId) => !plainData.products.includes(productId)) },
4938
+ },
4939
+ },
4940
+ });
4941
+ await this.mutation('insert_category_product', ['affected_rows'], {
4942
+ objects: {
4943
+ type: '[category_product_insert_input!]',
4944
+ required: true,
4945
+ value: plainData.products
4946
+ .filter((productId) => !category.products.includes(productId))
4947
+ .map((productId) => ({ category_id: categoryId, product_id: productId })),
4948
+ },
4949
+ });
5120
4950
  const productsOrder = products.map((product, index) => {
5121
4951
  return {
5122
4952
  id: product,
@@ -5125,7 +4955,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
5125
4955
  });
5126
4956
  const updateQueries = productsOrder.map((product) => ({
5127
4957
  where: {
5128
- category_id: { _eq: categoryId },
4958
+ category_id: { _eq: category.id },
5129
4959
  product_id: { _eq: product.id },
5130
4960
  },
5131
4961
  _set: {
@@ -5139,13 +4969,13 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
5139
4969
  required: true,
5140
4970
  },
5141
4971
  });
5142
- const plainData = this.paramsToPlain({ products });
5143
4972
  return plainData.products;
5144
4973
  }
5145
- async updateMetadata(categoryId, { metadatas }) {
5146
- if (Array.isArray(metadatas) && !metadatas.length)
4974
+ async updateMetadata(categoryId, { metadata }) {
4975
+ if (Array.isArray(metadata) && !metadata.length)
5147
4976
  return [];
5148
- if (Array.isArray(metadatas) && metadatas.length) {
4977
+ if (Array.isArray(metadata) && metadata.length) {
4978
+ const metadataUpdated = [];
5149
4979
  await this.mutation('delete_category_metadata', ['affected_rows'], {
5150
4980
  where: {
5151
4981
  type: 'category_metadata_bool_exp',
@@ -5153,16 +4983,24 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
5153
4983
  value: { category_id: { _eq: categoryId } },
5154
4984
  },
5155
4985
  });
5156
- await this.mutation('insert_category_metadata', ['affected_rows'], {
5157
- objects: {
5158
- type: '[category_metadata_insert_input!]',
5159
- required: true,
5160
- value: metadatas.map((m) => (Object.assign({ category_id: categoryId }, m))),
5161
- },
5162
- });
5163
- return metadatas;
4986
+ for (const data of metadata) {
4987
+ const update = await this.mutation('update_category_metadata_by_pk', ['category_id', 'shop'], {
4988
+ pk_columns: {
4989
+ value: { category_id: categoryId, shop: data.shop },
4990
+ type: 'category_metadata_pk_columns_input',
4991
+ required: true,
4992
+ },
4993
+ _set: {
4994
+ value: omit(data, ['category_id', 'shop']),
4995
+ type: 'category_metadata_set_input',
4996
+ required: true,
4997
+ },
4998
+ });
4999
+ metadataUpdated.push(update);
5000
+ }
5001
+ return metadataUpdated;
5164
5002
  }
5165
- if ('action' in metadatas && metadatas.action === 'remove' && metadatas.value.length) {
5003
+ if ('action' in metadata && metadata.action === 'remove' && metadata.value.length) {
5166
5004
  await this.mutation('delete_category_metadata', ['affected_rows'], {
5167
5005
  where: {
5168
5006
  type: 'category_metadata_bool_exp',
@@ -5233,61 +5071,27 @@ __decorate([
5233
5071
  __decorate([
5234
5072
  Log(),
5235
5073
  __metadata("design:type", Function),
5236
- __metadata("design:paramtypes", [Array, String, Object]),
5074
+ __metadata("design:paramtypes", [Array, Object, String]),
5237
5075
  __metadata("design:returntype", Promise)
5238
5076
  ], CategoryHasuraGraphQLRepository.prototype, "getCategoriesForHome", null);
5239
5077
  __decorate([
5240
5078
  Log(),
5241
5079
  __metadata("design:type", Function),
5242
- __metadata("design:paramtypes", [Category, String, Object]),
5080
+ __metadata("design:paramtypes", [Category, Object]),
5243
5081
  __metadata("design:returntype", Promise)
5244
5082
  ], CategoryHasuraGraphQLRepository.prototype, "mountCategory", null);
5245
5083
  __decorate([
5246
5084
  Log(),
5247
- __metadata("design:type", Function),
5248
- __metadata("design:paramtypes", [Number]),
5249
- __metadata("design:returntype", Promise)
5250
- ], CategoryHasuraGraphQLRepository.prototype, "getChildren", null);
5251
- __decorate([
5252
- Log(),
5253
- __metadata("design:type", Function),
5254
- __metadata("design:paramtypes", [Number, Number]),
5255
- __metadata("design:returntype", Promise)
5256
- ], CategoryHasuraGraphQLRepository.prototype, "isChild", null);
5257
-
5258
- class CategoryProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
5259
- constructor({ endpoint, authOptions, interceptors, }) {
5260
- super({
5261
- tableName: 'category_product',
5262
- model: CategoryProduct,
5263
- endpoint,
5264
- authOptions,
5265
- interceptors,
5266
- fields: [{ productId: { columnName: 'product_id' } }, { categoryId: { columnName: 'category_id' } }, 'order'],
5267
- });
5268
- }
5269
- async removeProductFromCategory(categoryId, productId) {
5270
- await this.mutation('delete_category_product', ['affected_rows'], {
5271
- where: {
5272
- type: 'category_product_bool_exp',
5273
- required: true,
5274
- value: {
5275
- product_id: { _eq: productId },
5276
- category_id: { _eq: categoryId },
5277
- },
5278
- },
5279
- });
5280
- }
5281
- async addProductToCategory(categoryId, productId) {
5282
- await this.mutation('insert_category_product', ['affected_rows'], {
5283
- objects: {
5284
- type: '[category_product_insert_input!]',
5285
- required: true,
5286
- value: [{ category_id: categoryId, product_id: productId }],
5287
- },
5288
- });
5289
- }
5290
- }
5085
+ __metadata("design:type", Function),
5086
+ __metadata("design:paramtypes", [Number]),
5087
+ __metadata("design:returntype", Promise)
5088
+ ], CategoryHasuraGraphQLRepository.prototype, "getChildren", null);
5089
+ __decorate([
5090
+ Log(),
5091
+ __metadata("design:type", Function),
5092
+ __metadata("design:paramtypes", [Number, Number]),
5093
+ __metadata("design:returntype", Promise)
5094
+ ], CategoryHasuraGraphQLRepository.prototype, "isChild", null);
5291
5095
 
5292
5096
  class FilterHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
5293
5097
  constructor({ endpoint, authOptions, interceptors, }, filterOptionRepository, categoryFilterRepository) {
@@ -5299,7 +5103,6 @@ class FilterHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGrap
5299
5103
  interceptors,
5300
5104
  fields: [
5301
5105
  'id',
5302
- 'title',
5303
5106
  'description',
5304
5107
  'slug',
5305
5108
  'enabled',
@@ -5555,7 +5358,6 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
5555
5358
  { subscriberPrice: { columnName: 'subscriber_price' } },
5556
5359
  'published',
5557
5360
  'outlet',
5558
- 'label',
5559
5361
  'sku',
5560
5362
  {
5561
5363
  stock: {
@@ -5587,8 +5389,6 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
5587
5389
  fields: ['id', 'name', 'reference', 'slug'],
5588
5390
  },
5589
5391
  },
5590
- 'group',
5591
- 'validity',
5592
5392
  ];
5593
5393
  this.fields = [
5594
5394
  ...commonFields,
@@ -5690,8 +5490,6 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
5690
5490
  enableCount: false,
5691
5491
  },
5692
5492
  });
5693
- if (!result.data.length)
5694
- return null;
5695
5493
  const product = (_a = result === null || result === void 0 ? void 0 : result.data) === null || _a === void 0 ? void 0 : _a.shift();
5696
5494
  RoundProductPricesHelper.roundProductPrices(product);
5697
5495
  return product;
@@ -5701,6 +5499,7 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
5701
5499
  const plainData = this.paramsToPlain({ id: checkId });
5702
5500
  const id = await this.getId(plainData.id);
5703
5501
  const product = await super.update(Object.assign({ id }, data));
5502
+ product.categories = categories && (await this.updateCategories(+id, { categories }));
5704
5503
  product.kitProducts = kitProducts && (await this.updateKitProducts(+id, { kitProducts }));
5705
5504
  product.reviews = reviews && (await this.updateReviews(+id, { reviews }));
5706
5505
  product.metadata = metadata && (await this.updateMetadata(+id, { metadata }));
@@ -5764,6 +5563,42 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
5764
5563
  getReviewStatus(review) {
5765
5564
  return review.status === true ? 'approved' : review.status === false ? 'rejected' : 'pending';
5766
5565
  }
5566
+ async updateCategories(productId, { categories }) {
5567
+ if ('action' in categories && categories.action === 'remove') {
5568
+ await this.mutation('delete_category_product', ['affected_rows'], {
5569
+ where: {
5570
+ type: 'category_product_bool_exp',
5571
+ required: true,
5572
+ value: { product_id: { _eq: productId } },
5573
+ },
5574
+ });
5575
+ return [];
5576
+ }
5577
+ const plainData = this.paramsToPlain({ categories });
5578
+ if (!plainData.categories || plainData.categories.length <= 0)
5579
+ return [];
5580
+ const product = await this.get({ id: productId.toString() });
5581
+ await this.mutation('delete_category_product', ['affected_rows'], {
5582
+ where: {
5583
+ type: 'category_product_bool_exp',
5584
+ required: true,
5585
+ value: {
5586
+ product_id: { _eq: productId },
5587
+ category_id: { _in: product.categories.filter((categoryId) => !plainData.categories.includes(categoryId)) },
5588
+ },
5589
+ },
5590
+ });
5591
+ await this.mutation('insert_category_product', ['affected_rows'], {
5592
+ objects: {
5593
+ type: '[category_product_insert_input!]',
5594
+ required: true,
5595
+ value: plainData.categories
5596
+ .filter((categoryId) => !product.categories.includes(categoryId))
5597
+ .map((categoryId) => ({ category_id: categoryId, product_id: productId })),
5598
+ },
5599
+ });
5600
+ return plainData.categories;
5601
+ }
5767
5602
  async updateKitProducts(productId, { kitProducts }) {
5768
5603
  const plainData = this.paramsToPlain({ kitProducts });
5769
5604
  await this.mutation('delete_product_kit', ['affected_rows'], {
@@ -5895,56 +5730,6 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
5895
5730
  });
5896
5731
  return data && data[0] && this.bindReviewToModel(data[0]);
5897
5732
  }
5898
- async productVariantFullReport() {
5899
- const fields = [
5900
- 'id',
5901
- 'name',
5902
- 'description',
5903
- 'slug',
5904
- 'sku',
5905
- 'ean',
5906
- 'cest',
5907
- 'ncm',
5908
- 'has_variants',
5909
- 'is_variant',
5910
- 'grade',
5911
- 'type',
5912
- 'is_kit',
5913
- 'tags',
5914
- 'published',
5915
- 'stock',
5916
- 'brand',
5917
- 'brand_description',
5918
- 'images',
5919
- 'miniatures',
5920
- 'video',
5921
- 'weight',
5922
- 'cost_price',
5923
- 'full_price',
5924
- 'price',
5925
- 'subscriber_discount_percentage',
5926
- 'subscriber_price',
5927
- 'how_to_use',
5928
- 'who_must_use',
5929
- 'differentials',
5930
- 'ingredients',
5931
- 'purpose',
5932
- 'filters',
5933
- 'category_id',
5934
- 'outlet',
5935
- 'label',
5936
- 'group',
5937
- 'validity',
5938
- 'gender',
5939
- 'shopping_count',
5940
- 'rating',
5941
- 'reviews_total',
5942
- 'created_at',
5943
- 'updated_at',
5944
- ];
5945
- const { product_variant_report_query: data } = await this.query('product_variant_report_query', fields);
5946
- return data;
5947
- }
5948
5733
  }
5949
5734
  __decorate([
5950
5735
  Log(),
@@ -6004,24 +5789,6 @@ class ProductReviewsHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHa
6004
5789
  ],
6005
5790
  });
6006
5791
  }
6007
- async updateManyStatus(reviews) {
6008
- return await this.mutation('update_product_review_many', ['affected_rows'], {
6009
- updates: {
6010
- type: '[product_review_updates!]',
6011
- required: true,
6012
- value: [
6013
- {
6014
- _set: { status: true },
6015
- where: { id: { _in: reviews.filter((review) => review.status).map((review) => review.id) } },
6016
- },
6017
- {
6018
- _set: { status: false },
6019
- where: { id: { _in: reviews.filter((review) => !review.status).map((review) => review.id) } },
6020
- },
6021
- ],
6022
- },
6023
- });
6024
- }
6025
5792
  aproveReview(id) {
6026
5793
  return this.update({ id, status: true });
6027
5794
  }
@@ -6076,31 +5843,6 @@ class ProductStockNotificationHasuraGraphQLRepository extends withCrudHasuraGrap
6076
5843
  email,
6077
5844
  });
6078
5845
  }
6079
- async getNotificationsReport(params, orderBy, pagination) {
6080
- 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 } }));
6081
- const orderByField = {
6082
- [orderBy.field]: orderBy.direction,
6083
- };
6084
- const { report_stock_notification } = await this.query('report_stock_notification', ['product_id', 'ean', 'sku', 'name', 'stock', 'category_id', 'category', 'reference', 'emails_registered'], {
6085
- where: {
6086
- type: 'report_stock_notification_bool_exp',
6087
- value: query,
6088
- required: true,
6089
- },
6090
- order_by: {
6091
- type: '[report_stock_notification_order_by]',
6092
- value: orderByField,
6093
- required: true,
6094
- },
6095
- });
6096
- const data = (pagination === null || pagination === void 0 ? void 0 : pagination.limit)
6097
- ? 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))
6098
- : report_stock_notification;
6099
- return {
6100
- data,
6101
- count: report_stock_notification.length,
6102
- };
6103
- }
6104
5846
  }
6105
5847
 
6106
5848
  class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
@@ -6174,10 +5916,6 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
6174
5916
  type: HasuraGraphQLColumnType.Jsonb,
6175
5917
  },
6176
5918
  },
6177
- 'group',
6178
- 'validity',
6179
- { tags: { columnName: 'tags', type: HasuraGraphQLColumnType.Jsonb } },
6180
- 'published',
6181
5919
  ],
6182
5920
  });
6183
5921
  }
@@ -6213,14 +5951,11 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
6213
5951
  }
6214
5952
  }
6215
5953
 
6216
- class WishlistHasuraGraphQL extends Wishlist {
6217
- }
6218
-
6219
5954
  class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
6220
- constructor({ endpoint, authOptions, interceptors, }, categoryProductRepository) {
5955
+ constructor({ endpoint, authOptions, interceptors, }, categoryFilterRepository) {
6221
5956
  super({
6222
5957
  tableName: 'category',
6223
- model: WishlistHasuraGraphQL,
5958
+ model: Wishlist,
6224
5959
  endpoint,
6225
5960
  authOptions,
6226
5961
  interceptors,
@@ -6287,15 +6022,6 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
6287
6022
  }),
6288
6023
  },
6289
6024
  },
6290
- {
6291
- metadatas: {
6292
- columnName: 'metadatas',
6293
- fields: ['shop', 'title', 'description'],
6294
- bindPersistData: (value) => ({
6295
- metadatas: { data: value },
6296
- }),
6297
- },
6298
- },
6299
6025
  { isCollection: { columnName: 'is_collection' } },
6300
6026
  { isWishlist: { columnName: 'is_wishlist' } },
6301
6027
  'reference',
@@ -6310,34 +6036,16 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
6310
6036
  { personId: { columnName: 'person_id' } },
6311
6037
  { personName: { columnName: 'person_name' } },
6312
6038
  { personPhoto: { columnName: 'person_photo' } },
6313
- { personType: { columnName: 'person_type' } },
6314
- { personIsSubscriber: { columnName: 'person_is_subscriber' } },
6315
6039
  'theme',
6316
6040
  { bannerUrl: { columnName: 'banner_url' } },
6317
- { personHasPhoto: { columnName: 'person_has_photo' } },
6318
- { mostRelevants: { columnName: 'most_relevants', type: HasuraGraphQLColumnType.Jsonb } },
6319
6041
  ],
6320
6042
  });
6321
- this.categoryProductRepository = categoryProductRepository;
6043
+ this.categoryFilterRepository = categoryFilterRepository;
6322
6044
  }
6323
6045
  async create(params) {
6324
6046
  var _a;
6325
- const { images, mostRelevants, metadatas } = params, data = __rest(params, ["images", "mostRelevants", "metadatas"]);
6326
- 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 || {
6327
- [Shops.GLAMSHOP]: null,
6328
- [Shops.MENSMARKET]: null,
6329
- }, images: images || {
6330
- [Shops.GLAMSHOP]: {
6331
- brandBanner: null,
6332
- brandBannerMobile: null,
6333
- image: null,
6334
- },
6335
- [Shops.MENSMARKET]: {
6336
- brandBanner: null,
6337
- brandBannerMobile: null,
6338
- image: null,
6339
- },
6340
- } }));
6047
+ const { metadata } = params, data = __rest(params, ["metadata"]);
6048
+ return super.create(Object.assign(Object.assign({}, data), { isWishlist: true, isCollection: true, brandCategory: false, metadata: metadata || [{ shop: (_a = data.shop) !== null && _a !== void 0 ? _a : null, description: data.description, title: data.name }] }));
6341
6049
  }
6342
6050
  async get(identifiers) {
6343
6051
  const data = await super.get(identifiers);
@@ -6350,11 +6058,12 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
6350
6058
  return await super.find(Object.assign(Object.assign({}, rest), { filters: Object.assign(Object.assign({}, filters), { isWishlist: { operator: Where.EQUALS, value: true } }) }));
6351
6059
  }
6352
6060
  async update(params) {
6353
- const { products, id: checkId, metadatas, filters } = params, data = __rest(params, ["products", "id", "metadatas", "filters"]);
6061
+ const { products, id: checkId, metadata, filters } = params, data = __rest(params, ["products", "id", "metadata", "filters"]);
6354
6062
  const plainData = this.paramsToPlain({ id: checkId });
6355
6063
  const id = plainData.id;
6356
6064
  const category = await super.update(Object.assign(Object.assign({ id }, data), { isWishlist: true, isCollection: true, brandCategory: false }));
6357
- category.metadatas = metadatas && (await this.updateMetadata(+id, { metadatas }));
6065
+ category.products = products && (await this.updateProducts(+id, { products }));
6066
+ category.metadata = metadata && (await this.updateMetadata(+id, { metadata }));
6358
6067
  return category;
6359
6068
  }
6360
6069
  async getWishlistBySlug(slug) {
@@ -6386,18 +6095,12 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
6386
6095
  options: {
6387
6096
  enableCount: false,
6388
6097
  },
6389
- orderBy: {
6390
- id: 'asc',
6391
- },
6392
- limits: {
6393
- limit: 1,
6394
- },
6395
6098
  });
6396
6099
  if (!data.length)
6397
6100
  throw new NotFoundError(`Wishlists from person ${personId} not found`);
6398
6101
  return data;
6399
6102
  }
6400
- async getCategoryBySlug(slug, _shop) {
6103
+ getCategoryBySlug(slug, _shop) {
6401
6104
  return this.getWishlistBySlug(slug);
6402
6105
  }
6403
6106
  async getCategoryByShop(shop) {
@@ -6415,17 +6118,10 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
6415
6118
  });
6416
6119
  return data;
6417
6120
  }
6418
- async findBfluOrGlamgirlWishlists(params, shops) {
6419
- var _a, _b;
6420
- 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 : {
6421
- operator: Where.IN,
6422
- value: [PersonTypes.BFLU, PersonTypes.GLAMGIRL],
6423
- } }), orderBy: Object.assign({ personHasPhoto: 'desc' }, omit(params.orderBy, ['personHasPhoto'])) }));
6424
- }
6425
- getCategoriesForHome(categoryIds, gender, limit) {
6121
+ getCategoriesForHome(categoryIds, limit, gender) {
6426
6122
  return;
6427
6123
  }
6428
- mountCategory(category, shop, options) {
6124
+ mountCategory(category, options) {
6429
6125
  return;
6430
6126
  }
6431
6127
  getChildren(parentId) {
@@ -6434,12 +6130,50 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
6434
6130
  isChild(id, parentId) {
6435
6131
  return;
6436
6132
  }
6437
- async updateMetadata(categoryId, { metadatas }) {
6438
- if (Array.isArray(metadatas) && !metadatas.length)
6133
+ async updateProducts(categoryId, { products }) {
6134
+ if ('action' in products && products.action === 'remove') {
6135
+ await this.mutation('delete_category_product', ['affected_rows'], {
6136
+ where: {
6137
+ type: 'category_product_bool_exp',
6138
+ required: true,
6139
+ value: { category_id: { _eq: categoryId } },
6140
+ },
6141
+ });
6142
+ await this.categoryFilterRepository.deleteByCategory(categoryId);
6143
+ return [];
6144
+ }
6145
+ const plainData = this.paramsToPlain({ products });
6146
+ if (!plainData.products || plainData.products.length <= 0)
6147
+ return [];
6148
+ const category = await this.get({ id: categoryId.toString() });
6149
+ await this.categoryFilterRepository.deleteByCategory(categoryId);
6150
+ await this.mutation('delete_category_product', ['affected_rows'], {
6151
+ where: {
6152
+ type: 'category_product_bool_exp',
6153
+ required: true,
6154
+ value: {
6155
+ category_id: { _eq: categoryId },
6156
+ product_id: { _in: category.products.filter((productId) => !plainData.products.includes(productId)) },
6157
+ },
6158
+ },
6159
+ });
6160
+ await this.mutation('insert_category_product', ['affected_rows'], {
6161
+ objects: {
6162
+ type: '[category_product_insert_input!]',
6163
+ required: true,
6164
+ value: plainData.products
6165
+ .filter((productId) => !category.products.includes(productId))
6166
+ .map((productId) => ({ category_id: categoryId, product_id: productId })),
6167
+ },
6168
+ });
6169
+ return plainData.products;
6170
+ }
6171
+ async updateMetadata(categoryId, { metadata }) {
6172
+ if (Array.isArray(metadata) && !metadata.length)
6439
6173
  return [];
6440
- if (Array.isArray(metadatas) && metadatas.length) {
6174
+ if (Array.isArray(metadata) && metadata.length) {
6441
6175
  const metadataUpdated = [];
6442
- for (const data of metadatas) {
6176
+ for (const data of metadata) {
6443
6177
  const update = await this.mutation('update_category_metadata_by_pk', ['category_id', 'shop'], {
6444
6178
  pk_columns: {
6445
6179
  value: { category_id: categoryId, shop: data.shop },
@@ -6456,25 +6190,19 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
6456
6190
  }
6457
6191
  return metadataUpdated;
6458
6192
  }
6459
- if ('action' in metadatas && metadatas.action === 'remove' && metadatas.value.length) {
6460
- for (let i = 0; i < metadatas.value.length; i++) {
6193
+ if ('action' in metadata && metadata.action === 'remove' && metadata.value.length) {
6194
+ for (let i = 0; i < metadata.value.length; i++) {
6461
6195
  await this.mutation('delete_category_metadata', ['affected_rows'], {
6462
6196
  where: {
6463
6197
  type: 'category_metadata_bool_exp',
6464
6198
  required: true,
6465
- value: { category_id: { _eq: categoryId }, shop: metadatas.value[i].shop },
6199
+ value: { category_id: { _eq: categoryId }, shop: metadata.value[i].shop },
6466
6200
  },
6467
6201
  });
6468
6202
  }
6469
6203
  return [];
6470
6204
  }
6471
6205
  }
6472
- async addProduct(wishlistId, productId) {
6473
- return this.categoryProductRepository.addProductToCategory(wishlistId, productId);
6474
- }
6475
- async removeProduct(wishlistId, productId) {
6476
- return this.categoryProductRepository.removeProductFromCategory(wishlistId, productId);
6477
- }
6478
6206
  }
6479
6207
  __decorate([
6480
6208
  Log(),
@@ -6494,164 +6222,5 @@ __decorate([
6494
6222
  __metadata("design:paramtypes", [String]),
6495
6223
  __metadata("design:returntype", Promise)
6496
6224
  ], WishlistHasuraGraphQLRepository.prototype, "getCategoryByShop", null);
6497
- __decorate([
6498
- Log(),
6499
- __metadata("design:type", Function),
6500
- __metadata("design:paramtypes", [Object, Array]),
6501
- __metadata("design:returntype", Promise)
6502
- ], WishlistHasuraGraphQLRepository.prototype, "findBfluOrGlamgirlWishlists", null);
6503
-
6504
- class VertexAxiosAdapter {
6505
- constructor(config) {
6506
- this.config = config;
6507
- this.logger = DebugHelper.from(this);
6508
- }
6509
- async query(term, total, gender) {
6510
- const logger = this.logger.with('query');
6511
- const req = {
6512
- url: `${this.config.url}/search`,
6513
- method: 'POST',
6514
- responseType: 'json',
6515
- headers: {
6516
- Accept: 'application/json',
6517
- },
6518
- data: { term, total, gender },
6519
- };
6520
- try {
6521
- const { data } = await axios(req);
6522
- return data;
6523
- }
6524
- catch (error) {
6525
- logger.error({ req, res: error });
6526
- throw error;
6527
- }
6528
- }
6529
- async get(id) {
6530
- const logger = this.logger.with('update');
6531
- const req = {
6532
- url: `${this.config.url}/${id}`,
6533
- method: 'GET',
6534
- responseType: 'json',
6535
- headers: {
6536
- Accept: 'application/json',
6537
- },
6538
- };
6539
- try {
6540
- const { data } = await axios(req);
6541
- return data;
6542
- }
6543
- catch (error) {
6544
- logger.error({ req, res: error });
6545
- throw error;
6546
- }
6547
- }
6548
- async save(data) {
6549
- const logger = this.logger.with('save');
6550
- const req = {
6551
- url: `${this.config.url}/sync`,
6552
- method: 'POST',
6553
- responseType: 'json',
6554
- headers: {
6555
- Accept: 'application/json',
6556
- },
6557
- data,
6558
- };
6559
- try {
6560
- const { data } = await axios(req);
6561
- return data;
6562
- }
6563
- catch (error) {
6564
- logger.error({ req, res: error });
6565
- throw error;
6566
- }
6567
- }
6568
- async update(id, data) {
6569
- const logger = this.logger.with('update');
6570
- const req = {
6571
- url: `${this.config.url}/${id}`,
6572
- method: 'PUT',
6573
- responseType: 'json',
6574
- headers: {
6575
- Accept: 'application/json',
6576
- },
6577
- data,
6578
- };
6579
- try {
6580
- const { data } = await axios(req);
6581
- return data;
6582
- }
6583
- catch (error) {
6584
- logger.error({ req, res: error });
6585
- throw error;
6586
- }
6587
- }
6588
- async delete(id) {
6589
- const logger = this.logger.with('delete');
6590
- const req = {
6591
- url: `${this.config.url}/${id}`,
6592
- method: 'DELETE',
6593
- responseType: 'json',
6594
- headers: {
6595
- Accept: 'application/json',
6596
- },
6597
- };
6598
- try {
6599
- const { data } = await axios(req);
6600
- return data;
6601
- }
6602
- catch (error) {
6603
- logger.error({ req, res: error });
6604
- throw error;
6605
- }
6606
- }
6607
- bulkProducts(products) {
6608
- return;
6609
- }
6610
- }
6611
-
6612
- class ProductsVertexSearch {
6613
- constructor(adapter) {
6614
- this.adapter = adapter;
6615
- }
6616
- async getById(id) {
6617
- const data = await this.adapter.get(id);
6618
- return data;
6619
- }
6620
- async search(searchTerm, total, gender) {
6621
- try {
6622
- const result = await this.adapter.query(searchTerm, total, gender);
6623
- return result;
6624
- }
6625
- catch (error) {
6626
- console.error(error);
6627
- }
6628
- }
6629
- async save(product) {
6630
- try {
6631
- const _a = product.toPlain(), { createdAt, updatedAt, kitProducts } = _a, data = __rest(_a, ["createdAt", "updatedAt", "kitProducts"]);
6632
- const newProduct = Product.toInstance(data);
6633
- await this.adapter.save(newProduct);
6634
- }
6635
- catch (error) {
6636
- console.error(error);
6637
- }
6638
- }
6639
- async update(product) {
6640
- try {
6641
- await this.adapter.update(product.id, product);
6642
- }
6643
- catch (error) {
6644
- console.error(error);
6645
- }
6646
- }
6647
- async delete(id) {
6648
- try {
6649
- await this.adapter.delete(id);
6650
- }
6651
- catch (error) {
6652
- console.error(error);
6653
- }
6654
- }
6655
- }
6656
6225
 
6657
- 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, CategoryProduct, CategoryProductHasuraGraphQLRepository, Checkout, CheckoutFirestoreRepository, CheckoutSubscription, CheckoutSubscriptionFirestoreRepository, CheckoutTypes, ClassNameHelper, ConnectBaseDocumentSnapshot, ConnectCollectionService, ConnectDocumentService, ConnectFirestoreService, Coupon, CouponCategories, CouponCategory, CouponChannels, CouponFirestoreRepository, CouponOldCategories, 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, ProductLabelEnum, 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 };
6226
+ 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 };