@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.cjs.js CHANGED
@@ -49,14 +49,6 @@ exports.GenderDestination = void 0;
49
49
  GenderDestination["UNISEX"] = "unisex";
50
50
  })(exports.GenderDestination || (exports.GenderDestination = {}));
51
51
 
52
- exports.ProductLabelEnum = void 0;
53
- (function (ProductLabelEnum) {
54
- ProductLabelEnum["ON_SALE"] = "on-sale";
55
- ProductLabelEnum["OUTLET"] = "outlet";
56
- ProductLabelEnum["LAST_UNITS"] = "last-units";
57
- ProductLabelEnum["GLAMSTAR"] = "glamstar";
58
- })(exports.ProductLabelEnum || (exports.ProductLabelEnum = {}));
59
-
60
52
  exports.Shops = void 0;
61
53
  (function (Shops) {
62
54
  Shops["MENSMARKET"] = "mensmarket";
@@ -65,15 +57,6 @@ exports.Shops = void 0;
65
57
  Shops["ALL"] = "ALL";
66
58
  })(exports.Shops || (exports.Shops = {}));
67
59
 
68
- exports.WishlistLogType = void 0;
69
- (function (WishlistLogType) {
70
- WishlistLogType["CREATE"] = "create";
71
- WishlistLogType["UPDATE"] = "update";
72
- WishlistLogType["DELETE"] = "delete";
73
- WishlistLogType["ADD_PRODUCT"] = "add_product";
74
- WishlistLogType["REMOVE_PRODUCT"] = "remove_product";
75
- })(exports.WishlistLogType || (exports.WishlistLogType = {}));
76
-
77
60
  class Filter extends BaseModel {
78
61
  static get identifiersFields() {
79
62
  return ['id'];
@@ -89,31 +72,19 @@ class CategoryBase extends BaseModel {
89
72
  return ['id'];
90
73
  }
91
74
  get glamImages() {
92
- return this.images && this.images[exports.Shops.GLAMSHOP]
93
- ? this.images[exports.Shops.GLAMSHOP]
94
- : {
95
- brandBanner: null,
96
- brandBannerMobile: null,
97
- image: null,
98
- };
75
+ return this.images[exports.Shops.GLAMSHOP];
99
76
  }
100
77
  get mensImages() {
101
- return this.images && this.images[exports.Shops.MENSMARKET]
102
- ? this.images[exports.Shops.MENSMARKET]
103
- : {
104
- brandBanner: null,
105
- brandBannerMobile: null,
106
- image: null,
107
- };
78
+ return this.images[exports.Shops.MENSMARKET];
108
79
  }
109
80
  get glamMetadata() {
110
- return this.metadatas.find((metadata) => metadata.shop === exports.Shops.GLAMSHOP);
81
+ return this.metadata.find((metadata) => metadata.shop === exports.Shops.GLAMSHOP);
111
82
  }
112
83
  get mensMetadata() {
113
- return this.metadatas.find((metadata) => metadata.shop === exports.Shops.MENSMARKET);
84
+ return this.metadata.find((metadata) => metadata.shop === exports.Shops.MENSMARKET);
114
85
  }
115
- getMostRelevantByShop(shop) {
116
- return this.mostRelevants && this.mostRelevants[shop] ? this.mostRelevants[shop] : [];
86
+ glamMostRelevantByShop(shop) {
87
+ return this.mostRelevant[shop];
117
88
  }
118
89
  }
119
90
  tslib.__decorate([
@@ -223,12 +194,6 @@ tslib.__decorate([
223
194
  tslib.__metadata("design:type", Category)
224
195
  ], CategoryFilter.prototype, "category", void 0);
225
196
 
226
- class CategoryProduct extends BaseModel {
227
- static get identifiersFields() {
228
- return ['categoryId', 'productId'];
229
- }
230
- }
231
-
232
197
  class FilterOption extends BaseModel {
233
198
  static get identifiersFields() {
234
199
  return ['id'];
@@ -321,17 +286,6 @@ class CampaignHashtag extends BaseModel {
321
286
  }
322
287
  }
323
288
 
324
- class BeautyProfile extends BaseModel {
325
- toPlain() {
326
- const plain = super.toPlain();
327
- delete plain.id;
328
- return plain;
329
- }
330
- static get identifiersFields() {
331
- return ['id', 'userId'];
332
- }
333
- }
334
-
335
289
  exports.AccessoryImportances = void 0;
336
290
  (function (AccessoryImportances) {
337
291
  AccessoryImportances["NOT_INTERESTED"] = "N\u00E3o tenho interesse";
@@ -508,13 +462,6 @@ exports.OfficePosition = void 0;
508
462
  OfficePosition["Director"] = "Diretor";
509
463
  })(exports.OfficePosition || (exports.OfficePosition = {}));
510
464
 
511
- exports.PersonTypes = void 0;
512
- (function (PersonTypes) {
513
- PersonTypes["GLAMGIRL"] = "glamgirl";
514
- PersonTypes["BFLU"] = "bflu";
515
- PersonTypes["NONE"] = "none";
516
- })(exports.PersonTypes || (exports.PersonTypes = {}));
517
-
518
465
  exports.ProductSpents = void 0;
519
466
  (function (ProductSpents) {
520
467
  ProductSpents["UNTIL_50"] = "At\u00E9 R$50";
@@ -535,12 +482,6 @@ exports.UserType = void 0;
535
482
  UserType["Influencer"] = "Influencer";
536
483
  })(exports.UserType || (exports.UserType = {}));
537
484
 
538
- class Lead extends BaseModel {
539
- static get identifiersFields() {
540
- return ['id'];
541
- }
542
- }
543
-
544
485
  class Edition extends BaseModel {
545
486
  static get identifiersFields() {
546
487
  return ['id', 'subscriptionId'];
@@ -1866,6 +1807,40 @@ const parseDateTime = (value) => {
1866
1807
  return date;
1867
1808
  };
1868
1809
 
1810
+ exports.CheckoutTypes = void 0;
1811
+ (function (CheckoutTypes) {
1812
+ CheckoutTypes[CheckoutTypes["ECOMMERCE"] = 1] = "ECOMMERCE";
1813
+ CheckoutTypes[CheckoutTypes["SUBSCRIPTION"] = 2] = "SUBSCRIPTION";
1814
+ CheckoutTypes[CheckoutTypes["ALL"] = 3] = "ALL";
1815
+ })(exports.CheckoutTypes || (exports.CheckoutTypes = {}));
1816
+
1817
+ exports.CouponTypes = void 0;
1818
+ (function (CouponTypes) {
1819
+ CouponTypes[CouponTypes["ABSOLUTE"] = 1] = "ABSOLUTE";
1820
+ CouponTypes[CouponTypes["PERCENTAGE"] = 2] = "PERCENTAGE";
1821
+ // FINANCIAL = 1,
1822
+ // PRODUCT,
1823
+ // GIFTCARD,
1824
+ // VOUCHER,
1825
+ })(exports.CouponTypes || (exports.CouponTypes = {}));
1826
+
1827
+ exports.CouponSubtypes = void 0;
1828
+ (function (CouponSubtypes) {
1829
+ CouponSubtypes[CouponSubtypes["ABSOLUTE"] = 1] = "ABSOLUTE";
1830
+ CouponSubtypes[CouponSubtypes["PERCENTAGE"] = 2] = "PERCENTAGE";
1831
+ })(exports.CouponSubtypes || (exports.CouponSubtypes = {}));
1832
+
1833
+ exports.Exclusivities = void 0;
1834
+ (function (Exclusivities) {
1835
+ Exclusivities[Exclusivities["ALL_USERS"] = 1] = "ALL_USERS";
1836
+ Exclusivities[Exclusivities["SPECIFIC_USER"] = 2] = "SPECIFIC_USER";
1837
+ Exclusivities[Exclusivities["COLLABORATORS"] = 3] = "COLLABORATORS";
1838
+ Exclusivities[Exclusivities["ACTIVE_SUBSCRIBER"] = 4] = "ACTIVE_SUBSCRIBER";
1839
+ Exclusivities[Exclusivities["INACTIVE_SUBSCRIBER"] = 5] = "INACTIVE_SUBSCRIBER";
1840
+ Exclusivities[Exclusivities["NON_SUBSCRIBER"] = 6] = "NON_SUBSCRIBER";
1841
+ })(exports.Exclusivities || (exports.Exclusivities = {}));
1842
+
1843
+ const COUPON_EXPIRATION = +1000 * 60 * 60 * 24 * 30;
1869
1844
  class Coupon extends BaseModel {
1870
1845
  get isInfluencer() {
1871
1846
  return !lodash.isNil(this.influencerEmail);
@@ -1873,6 +1848,30 @@ class Coupon extends BaseModel {
1873
1848
  static get identifiersFields() {
1874
1849
  return ['id'];
1875
1850
  }
1851
+ static createCoupon(userId) {
1852
+ return this.toInstance({
1853
+ nickname: `${Date.now()}`,
1854
+ checkoutType: exports.CheckoutTypes.ECOMMERCE,
1855
+ discount: {
1856
+ subscriber: {
1857
+ type: exports.CouponTypes.ABSOLUTE,
1858
+ value: 10,
1859
+ },
1860
+ non_subscriber: {
1861
+ type: exports.CouponTypes.ABSOLUTE,
1862
+ value: 10,
1863
+ },
1864
+ subscription: {
1865
+ type: exports.CouponTypes.ABSOLUTE,
1866
+ value: 10,
1867
+ },
1868
+ },
1869
+ user: userId,
1870
+ createdAt: new Date(Date.now()),
1871
+ beginAt: new Date(Date.now()),
1872
+ expiresIn: new Date(Date.now() + COUPON_EXPIRATION),
1873
+ });
1874
+ }
1876
1875
  }
1877
1876
 
1878
1877
  class SubscriptionPlan extends BaseModel {
@@ -1881,6 +1880,17 @@ class SubscriptionPlan extends BaseModel {
1881
1880
  }
1882
1881
  }
1883
1882
 
1883
+ class BeautyProfile extends BaseModel {
1884
+ toPlain() {
1885
+ const plain = super.toPlain();
1886
+ delete plain.id;
1887
+ return plain;
1888
+ }
1889
+ static get identifiersFields() {
1890
+ return ['id', 'userId'];
1891
+ }
1892
+ }
1893
+
1884
1894
  class User extends BaseModel {
1885
1895
  static toInstance(data) {
1886
1896
  const instance = super.toInstance(data);
@@ -1994,6 +2004,12 @@ class UserPaymentMethod extends BaseModel {
1994
2004
  }
1995
2005
  }
1996
2006
 
2007
+ class Lead extends BaseModel {
2008
+ static get identifiersFields() {
2009
+ return ['id'];
2010
+ }
2011
+ }
2012
+
1997
2013
  class UnauthorizedError extends tsCustomError.CustomError {
1998
2014
  constructor(message) {
1999
2015
  super(message);
@@ -2147,93 +2163,6 @@ tslib.__decorate([
2147
2163
  tslib.__metadata("design:type", Coupon)
2148
2164
  ], Checkout.prototype, "coupon", void 0);
2149
2165
 
2150
- exports.CouponCategory = void 0;
2151
- (function (CouponCategory) {
2152
- CouponCategory["Reembolso"] = "Reembolso";
2153
- CouponCategory["Desculpas"] = "Desculpas";
2154
- CouponCategory["BFlu"] = "BFlu";
2155
- CouponCategory["ROYAL"] = "Royal";
2156
- CouponCategory["Glamqueens"] = "Glamqueens";
2157
- CouponCategory["Glampartner"] = "Glampartner";
2158
- CouponCategory["Glamgirls"] = "Glamgirls";
2159
- CouponCategory["Glamdiva"] = "Glamdiva";
2160
- CouponCategory["Impulsionamento"] = "Impulsionamento";
2161
- CouponCategory["PaidMedia"] = "Paid Media";
2162
- CouponCategory["Organic"] = "Organic";
2163
- CouponCategory["Direct"] = "Direct";
2164
- CouponCategory["CRM"] = "CRM";
2165
- CouponCategory["LOJAUNICO"] = "Loja \u00FAnico";
2166
- CouponCategory["Outros"] = "Outros";
2167
- })(exports.CouponCategory || (exports.CouponCategory = {}));
2168
- exports.CouponOldCategories = void 0;
2169
- (function (CouponOldCategories) {
2170
- CouponOldCategories["Reembolso"] = "Reembolso";
2171
- CouponOldCategories["Desculpas"] = "Desculpas";
2172
- CouponOldCategories["BFlu"] = "BFlu";
2173
- CouponOldCategories["ROYAL"] = "Royal";
2174
- CouponOldCategories["Glamqueens"] = "Glamqueens";
2175
- CouponOldCategories["Glampartner"] = "Glampartner";
2176
- CouponOldCategories["Glamgirls"] = "Glamgirls";
2177
- CouponOldCategories["Glamdiva"] = "Glamdiva";
2178
- CouponOldCategories["Impulsionamento"] = "Impulsionamento";
2179
- CouponOldCategories["PaidMedia"] = "Paid Media";
2180
- CouponOldCategories["Organic"] = "Organic";
2181
- CouponOldCategories["Direct"] = "Direct";
2182
- CouponOldCategories["CRM"] = "CRM";
2183
- CouponOldCategories["LOJAUNICO"] = "Loja \u00FAnico";
2184
- CouponOldCategories["Outros"] = "Outros";
2185
- })(exports.CouponOldCategories || (exports.CouponOldCategories = {}));
2186
- exports.CouponCategories = void 0;
2187
- (function (CouponCategories) {
2188
- CouponCategories["API_001"] = "API-001";
2189
- CouponCategories["COMPRE_E_GANHE"] = "COMPRE E GANHE";
2190
- CouponCategories["DESCONTO"] = "DESCONTO";
2191
- CouponCategories["REEMBOLSO"] = "REEMBOLSO";
2192
- CouponCategories["DESCULPAS"] = "DESCULPAS";
2193
- })(exports.CouponCategories || (exports.CouponCategories = {}));
2194
-
2195
- exports.CouponChannels = void 0;
2196
- (function (CouponChannels) {
2197
- CouponChannels["BANNER"] = "7";
2198
- CouponChannels["BFLUENCE"] = "3";
2199
- CouponChannels["CRM"] = "2";
2200
- CouponChannels["GLAMGIRL"] = "0";
2201
- CouponChannels["PAID"] = "4";
2202
- CouponChannels["ROYAL"] = "1";
2203
- CouponChannels["SAC"] = "8";
2204
- CouponChannels["SOCIAL"] = "5";
2205
- })(exports.CouponChannels || (exports.CouponChannels = {}));
2206
-
2207
- exports.CouponSubtypes = void 0;
2208
- (function (CouponSubtypes) {
2209
- CouponSubtypes[CouponSubtypes["ABSOLUTE"] = 1] = "ABSOLUTE";
2210
- CouponSubtypes[CouponSubtypes["PERCENTAGE"] = 2] = "PERCENTAGE";
2211
- })(exports.CouponSubtypes || (exports.CouponSubtypes = {}));
2212
-
2213
- exports.CouponTypes = void 0;
2214
- (function (CouponTypes) {
2215
- CouponTypes[CouponTypes["ABSOLUTE"] = 1] = "ABSOLUTE";
2216
- CouponTypes[CouponTypes["PERCENTAGE"] = 2] = "PERCENTAGE";
2217
- CouponTypes[CouponTypes["SHIPPING"] = 3] = "SHIPPING";
2218
- })(exports.CouponTypes || (exports.CouponTypes = {}));
2219
-
2220
- exports.Exclusivities = void 0;
2221
- (function (Exclusivities) {
2222
- Exclusivities[Exclusivities["ALL_USERS"] = 1] = "ALL_USERS";
2223
- Exclusivities[Exclusivities["SPECIFIC_USER"] = 2] = "SPECIFIC_USER";
2224
- Exclusivities[Exclusivities["COLLABORATORS"] = 3] = "COLLABORATORS";
2225
- Exclusivities[Exclusivities["ACTIVE_SUBSCRIBER"] = 4] = "ACTIVE_SUBSCRIBER";
2226
- Exclusivities[Exclusivities["INACTIVE_SUBSCRIBER"] = 5] = "INACTIVE_SUBSCRIBER";
2227
- Exclusivities[Exclusivities["NON_SUBSCRIBER"] = 6] = "NON_SUBSCRIBER";
2228
- })(exports.Exclusivities || (exports.Exclusivities = {}));
2229
-
2230
- exports.CheckoutTypes = void 0;
2231
- (function (CheckoutTypes) {
2232
- CheckoutTypes[CheckoutTypes["ECOMMERCE"] = 1] = "ECOMMERCE";
2233
- CheckoutTypes[CheckoutTypes["SUBSCRIPTION"] = 2] = "SUBSCRIPTION";
2234
- CheckoutTypes[CheckoutTypes["ALL"] = 3] = "ALL";
2235
- })(exports.CheckoutTypes || (exports.CheckoutTypes = {}));
2236
-
2237
2166
  exports.OrderStatus = void 0;
2238
2167
  (function (OrderStatus) {
2239
2168
  OrderStatus["AGUARDANDO_PAGAMENTO"] = "Aguardando pagamento";
@@ -2253,12 +2182,6 @@ tslib.__decorate([
2253
2182
  tslib.__metadata("design:type", Payment)
2254
2183
  ], Order.prototype, "payment", void 0);
2255
2184
 
2256
- class OrderBlocked extends BaseModel {
2257
- static get identifiersFields() {
2258
- return ['id'];
2259
- }
2260
- }
2261
-
2262
2185
  class CheckoutSubscription extends BaseModel {
2263
2186
  static get identifiersFields() {
2264
2187
  return ['id'];
@@ -2295,12 +2218,6 @@ class RoundProductPricesHelper {
2295
2218
  }
2296
2219
  }
2297
2220
 
2298
- class LogDocument extends BaseModel {
2299
- static get identifiersFields() {
2300
- return ['id'];
2301
- }
2302
- }
2303
-
2304
2221
  exports.FilterType = void 0;
2305
2222
  (function (FilterType) {
2306
2223
  FilterType["ACCESSORY_IMPORTANCE"] = "accessoryImportance";
@@ -2599,6 +2516,8 @@ class ProductsIndex {
2599
2516
  'rate',
2600
2517
  ];
2601
2518
  const filter = [{ term: { published: true } }];
2519
+ if (shop && shop !== exports.Shops.ALL)
2520
+ filter.push({ term: { tags: shop == exports.Shops.GLAMSHOP ? 'feminino' : 'masculino' } });
2602
2521
  if (size > 9)
2603
2522
  fields.push(...['pricePaid', 'isGift', 'stock', 'weight', 'tags']);
2604
2523
  const query = {
@@ -2654,9 +2573,7 @@ class ProductsIndex {
2654
2573
  RoundProductPricesHelper.roundProductPrices(hit._source);
2655
2574
  return hit;
2656
2575
  });
2657
- return search.hits.map((hit) => {
2658
- return Object.assign(Object.assign({}, hit._source), { stock: hit._source.stock.quantity });
2659
- });
2576
+ return search;
2660
2577
  }
2661
2578
  async save(product) {
2662
2579
  try {
@@ -3090,8 +3007,6 @@ const withUpdateFirestore = (MixinBase) => {
3090
3007
  try {
3091
3008
  const identifiers = getValueFromParams(data, keyField);
3092
3009
  const docRef = this.collection(collectionName).getDoc(identifiers.toString());
3093
- if (!(await docRef.get()).data())
3094
- throw new NotFoundError(`Document '${collectionName}/${Object.values(identifiers.toString())}' not found`);
3095
3010
  const plainFromData = this.model.toInstance(this.paramsToPlain(data));
3096
3011
  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 }));
3097
3012
  const builded = (intercepted === null || intercepted === void 0 ? void 0 : intercepted.instance) || plainFromData;
@@ -3168,118 +3083,292 @@ const withCrudFirestore = (MixinBase) => {
3168
3083
  };
3169
3084
  };
3170
3085
 
3171
- class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3086
+ class LeadFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3172
3087
  constructor({ firestore, interceptors }) {
3173
3088
  super({
3174
3089
  firestore,
3175
- collectionName: 'categories',
3176
- model: Category,
3090
+ collectionName: 'leads',
3091
+ model: Lead,
3177
3092
  interceptors,
3178
3093
  });
3179
3094
  }
3180
- async getCategoryBySlug(slug, shop) {
3181
- const categoryDocs = await this.collection(this.collectionName)
3182
- .where('slug', '==', slug)
3183
- .where('shop', '==', shop)
3184
- .where('published', '==', true)
3185
- .getDocs();
3186
- if (categoryDocs.size > 1)
3187
- throw new DuplicatedResultsError('Query returned duplicated values');
3188
- if (categoryDocs.empty)
3189
- throw new NotFoundError(`Document with slug ${slug} not found`);
3190
- return categoryDocs.docs[0].data();
3191
- }
3192
- async getCategoriesForHome(categoryIds, shop, limit = 4) {
3193
- const categorySnap = await this.collection(this.collectionName)
3194
- .where('id', 'in', categoryIds.filter(Boolean))
3195
- .where('published', '==', true)
3196
- .getDocs();
3197
- if (categorySnap.empty)
3198
- throw new NotFoundError('Categories not found');
3199
- const categories = categorySnap.docs.map((doc) => doc.data());
3200
- const homeSections = await Promise.all(categories.map(async (category) => ({
3201
- category,
3202
- products: await this.mountCategory(category, shop, { limit, hasStock: true }),
3203
- })));
3204
- return homeSections;
3205
- }
3206
- async mountCategory(category, shop, options) {
3207
- if (!category.products)
3208
- throw new RequiredArgumentError(['Category products is empty']);
3209
- const chunks = lodash.chunk(category.products, 10);
3210
- const products = [];
3211
- const wheres = [];
3212
- for (const productIds of chunks) {
3213
- if ((options === null || options === void 0 ? void 0 : options.limit) && products.length >= (options === null || options === void 0 ? void 0 : options.limit))
3214
- break;
3215
- wheres.push(['published', '==', true], ['id', 'in', productIds]);
3216
- if (options === null || options === void 0 ? void 0 : options.hasStock)
3217
- wheres.push(['stock.quantity', '>', 0]);
3218
- if (options === null || options === void 0 ? void 0 : options.gender)
3219
- wheres.push(['tags', 'array-contains', options === null || options === void 0 ? void 0 : options.gender]);
3220
- const productSnap = await wheres
3221
- .reduce((collection, where) => collection.where(...where), (options === null || options === void 0 ? void 0 : options.limit)
3222
- ? this.collection('productsErpVitrine').limit(options.limit)
3223
- : this.collection('productsErpVitrine'))
3224
- .getDocs();
3225
- if (productSnap.empty)
3226
- continue;
3227
- products.push(...productSnap.docs);
3228
- }
3229
- return is(products);
3230
- }
3231
- getCategoryByShop(shop) {
3232
- return;
3233
- }
3234
- getChildren(parentId) {
3235
- return;
3095
+ }
3096
+
3097
+ class SubscriptionEditionFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
3098
+ constructor({ firestore, interceptors }, parentRepository) {
3099
+ super({
3100
+ firestore,
3101
+ collectionName: 'editions',
3102
+ parentIdField: 'subscriptionId',
3103
+ model: Edition,
3104
+ interceptors,
3105
+ });
3106
+ this.parentRepository = parentRepository;
3236
3107
  }
3237
- isChild(id, parentId) {
3238
- return;
3108
+ }
3109
+
3110
+ class SubscriptionFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3111
+ constructor({ firestore, interceptors, }) {
3112
+ super({
3113
+ firestore,
3114
+ collectionName: 'subscription',
3115
+ model: Subscription,
3116
+ interceptors,
3117
+ });
3239
3118
  }
3240
3119
  }
3241
- tslib.__decorate([
3242
- Log(),
3243
- tslib.__metadata("design:type", Function),
3244
- tslib.__metadata("design:paramtypes", [String, String]),
3245
- tslib.__metadata("design:returntype", Promise)
3246
- ], CategoryFirestoreRepository.prototype, "getCategoryBySlug", null);
3247
- tslib.__decorate([
3248
- Log(),
3249
- tslib.__metadata("design:type", Function),
3250
- tslib.__metadata("design:paramtypes", [Array, String, Object]),
3251
- tslib.__metadata("design:returntype", Promise)
3252
- ], CategoryFirestoreRepository.prototype, "getCategoriesForHome", null);
3253
- tslib.__decorate([
3254
- Log(),
3255
- tslib.__metadata("design:type", Function),
3256
- tslib.__metadata("design:paramtypes", [Category, String, Object]),
3257
- tslib.__metadata("design:returntype", Promise)
3258
- ], CategoryFirestoreRepository.prototype, "mountCategory", null);
3259
3120
 
3260
- class ProductFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3121
+ class SubscriptionMaterializationFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3261
3122
  constructor({ firestore, interceptors }) {
3262
3123
  super({
3263
3124
  firestore,
3264
- collectionName: 'productsErpVitrine',
3265
- model: Product,
3125
+ collectionName: 'subscriptionMaterialization',
3126
+ model: SubscriptionMaterialization,
3266
3127
  interceptors,
3267
3128
  });
3268
- this.reviews = {};
3269
3129
  }
3270
- fetchProductReviews(filters) {
3271
- throw new Error('Method not implemented.');
3130
+ }
3131
+
3132
+ class SubscriptionPaymentFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
3133
+ constructor({ firestore, interceptors }, parentRepository) {
3134
+ super({
3135
+ firestore,
3136
+ collectionName: 'payments',
3137
+ parentIdField: 'subscriptionId',
3138
+ model: SubscriptionPayment,
3139
+ interceptors,
3140
+ });
3141
+ this.parentRepository = parentRepository;
3272
3142
  }
3273
- async getBySlug(slug) {
3274
- var _a;
3275
- const result = await this.find({
3276
- filters: {
3277
- slug: { operator: exports.Where.EQUALS, value: slug },
3278
- },
3143
+ }
3144
+
3145
+ class SubscriptionSummaryFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3146
+ constructor({ firestore, interceptors, }) {
3147
+ super({
3148
+ firestore,
3149
+ collectionName: 'subscriptionSummary',
3150
+ model: SubscriptionSummary,
3151
+ interceptors,
3279
3152
  });
3280
- return (_a = result === null || result === void 0 ? void 0 : result.data) === null || _a === void 0 ? void 0 : _a.shift();
3281
3153
  }
3282
- async fetchReviews(status) {
3154
+ }
3155
+
3156
+ class UserAddressFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
3157
+ constructor({ firestore, interceptors }, parentRepository) {
3158
+ super({
3159
+ firestore,
3160
+ collectionName: 'address',
3161
+ parentIdField: 'userId',
3162
+ model: UserAddress,
3163
+ interceptors,
3164
+ });
3165
+ this.parentRepository = parentRepository;
3166
+ }
3167
+ }
3168
+
3169
+ class UserBeautyProfileFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
3170
+ constructor({ firestore, interceptors }, parentRepository) {
3171
+ super({
3172
+ firestore,
3173
+ collectionName: 'CX',
3174
+ parentIdField: 'userId',
3175
+ model: BeautyProfile,
3176
+ interceptors,
3177
+ });
3178
+ this.parentRepository = parentRepository;
3179
+ }
3180
+ }
3181
+
3182
+ class UserFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3183
+ constructor({ firestore, interceptors }) {
3184
+ super({
3185
+ firestore,
3186
+ collectionName: 'users',
3187
+ model: User,
3188
+ interceptors,
3189
+ });
3190
+ }
3191
+ async get(identifiers) {
3192
+ const user = await super.get({ id: identifiers.id });
3193
+ user.beautyProfile = await this.getBeautyProfile(user.id);
3194
+ user.isSubscriber = await this.checkIfIsSubscriber(user.id);
3195
+ return user;
3196
+ }
3197
+ async checkIfExistsByField(field, value) {
3198
+ const result = await this.find({ filters: { [field]: value } });
3199
+ return result.count > 0;
3200
+ }
3201
+ buildModelInstance() {
3202
+ const { fromFirestore, toFirestore } = super.buildModelInstance();
3203
+ return {
3204
+ toFirestore: (data) => {
3205
+ const plain = toFirestore(data);
3206
+ delete plain.isSubscriber;
3207
+ return plain;
3208
+ },
3209
+ fromFirestore,
3210
+ };
3211
+ }
3212
+ async getBeautyProfile(userId) {
3213
+ const beautyProfile = await this.firestore
3214
+ .getCollection(`${this.collectionName}/${userId}/CX`)
3215
+ .withConverter(this.buildBeautyProfileModelInstance())
3216
+ .getDoc('beautyProfile')
3217
+ .get();
3218
+ return beautyProfile.data();
3219
+ }
3220
+ async checkIfIsSubscriber(userId) {
3221
+ const docs = await this.collection('subscription')
3222
+ .where('user.id', '==', userId)
3223
+ .where('status', '==', 'active')
3224
+ .getDocs();
3225
+ return !!docs && !!docs.size;
3226
+ }
3227
+ buildBeautyProfileModelInstance() {
3228
+ return {
3229
+ toFirestore: (data) => data.toPlain(),
3230
+ fromFirestore: (snap) => BeautyProfile.toInstance(snap.data()),
3231
+ };
3232
+ }
3233
+ }
3234
+ tslib.__decorate([
3235
+ Log(),
3236
+ tslib.__metadata("design:type", Function),
3237
+ tslib.__metadata("design:paramtypes", [Object]),
3238
+ tslib.__metadata("design:returntype", Promise)
3239
+ ], UserFirestoreRepository.prototype, "get", null);
3240
+ tslib.__decorate([
3241
+ Log(),
3242
+ tslib.__metadata("design:type", Function),
3243
+ tslib.__metadata("design:paramtypes", [String, String]),
3244
+ tslib.__metadata("design:returntype", Promise)
3245
+ ], UserFirestoreRepository.prototype, "checkIfExistsByField", null);
3246
+
3247
+ class UserPaymentMethodFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
3248
+ constructor({ firestore, interceptors }, parentRepository) {
3249
+ super({
3250
+ firestore,
3251
+ collectionName: 'payment_method',
3252
+ parentIdField: 'userId',
3253
+ model: UserPaymentMethod,
3254
+ interceptors,
3255
+ });
3256
+ this.parentRepository = parentRepository;
3257
+ }
3258
+ }
3259
+
3260
+ class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3261
+ constructor({ firestore, interceptors }) {
3262
+ super({
3263
+ firestore,
3264
+ collectionName: 'categories',
3265
+ model: Category,
3266
+ interceptors,
3267
+ });
3268
+ }
3269
+ async getCategoryBySlug(slug, shop) {
3270
+ const categoryDocs = await this.collection(this.collectionName)
3271
+ .where('slug', '==', slug)
3272
+ .where('shop', '==', shop)
3273
+ .where('published', '==', true)
3274
+ .getDocs();
3275
+ if (categoryDocs.size > 1)
3276
+ throw new DuplicatedResultsError('Query returned duplicated values');
3277
+ if (categoryDocs.empty)
3278
+ throw new NotFoundError(`Document with slug ${slug} not found`);
3279
+ return categoryDocs.docs[0].data();
3280
+ }
3281
+ async getCategoriesForHome(categoryIds, limit = 4, gender) {
3282
+ const categorySnap = await this.collection(this.collectionName)
3283
+ .where('id', 'in', categoryIds.filter(Boolean))
3284
+ .where('published', '==', true)
3285
+ .getDocs();
3286
+ if (categorySnap.empty)
3287
+ throw new NotFoundError('Categories not found');
3288
+ const categories = categorySnap.docs.map((doc) => doc.data());
3289
+ const homeSections = await Promise.all(categories.map(async (category) => ({
3290
+ category,
3291
+ products: await this.mountCategory(category, { limit, hasStock: true, gender }),
3292
+ })));
3293
+ return homeSections;
3294
+ }
3295
+ async mountCategory(category, options) {
3296
+ if (!category.products)
3297
+ throw new RequiredArgumentError(['Category products is empty']);
3298
+ const chunks = lodash.chunk(category.products, 10);
3299
+ const products = [];
3300
+ const wheres = [];
3301
+ for (const productIds of chunks) {
3302
+ if ((options === null || options === void 0 ? void 0 : options.limit) && products.length >= (options === null || options === void 0 ? void 0 : options.limit))
3303
+ break;
3304
+ wheres.push(['published', '==', true], ['id', 'in', productIds]);
3305
+ if (options === null || options === void 0 ? void 0 : options.hasStock)
3306
+ wheres.push(['stock.quantity', '>', 0]);
3307
+ if (options === null || options === void 0 ? void 0 : options.gender)
3308
+ wheres.push(['tags', 'array-contains', options === null || options === void 0 ? void 0 : options.gender]);
3309
+ const productSnap = await wheres
3310
+ .reduce((collection, where) => collection.where(...where), (options === null || options === void 0 ? void 0 : options.limit)
3311
+ ? this.collection('productsErpVitrine').limit(options.limit)
3312
+ : this.collection('productsErpVitrine'))
3313
+ .getDocs();
3314
+ if (productSnap.empty)
3315
+ continue;
3316
+ products.push(...productSnap.docs);
3317
+ }
3318
+ return is(products);
3319
+ }
3320
+ getCategoryByShop(shop) {
3321
+ return;
3322
+ }
3323
+ getChildren(parentId) {
3324
+ return;
3325
+ }
3326
+ isChild(id, parentId) {
3327
+ return;
3328
+ }
3329
+ }
3330
+ tslib.__decorate([
3331
+ Log(),
3332
+ tslib.__metadata("design:type", Function),
3333
+ tslib.__metadata("design:paramtypes", [String, String]),
3334
+ tslib.__metadata("design:returntype", Promise)
3335
+ ], CategoryFirestoreRepository.prototype, "getCategoryBySlug", null);
3336
+ tslib.__decorate([
3337
+ Log(),
3338
+ tslib.__metadata("design:type", Function),
3339
+ tslib.__metadata("design:paramtypes", [Array, Object, String]),
3340
+ tslib.__metadata("design:returntype", Promise)
3341
+ ], CategoryFirestoreRepository.prototype, "getCategoriesForHome", null);
3342
+ tslib.__decorate([
3343
+ Log(),
3344
+ tslib.__metadata("design:type", Function),
3345
+ tslib.__metadata("design:paramtypes", [Category, Object]),
3346
+ tslib.__metadata("design:returntype", Promise)
3347
+ ], CategoryFirestoreRepository.prototype, "mountCategory", null);
3348
+
3349
+ class ProductFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3350
+ constructor({ firestore, interceptors }) {
3351
+ super({
3352
+ firestore,
3353
+ collectionName: 'productsErpVitrine',
3354
+ model: Product,
3355
+ interceptors,
3356
+ });
3357
+ this.reviews = {};
3358
+ }
3359
+ fetchProductReviews(filters) {
3360
+ throw new Error('Method not implemented.');
3361
+ }
3362
+ async getBySlug(slug) {
3363
+ var _a;
3364
+ const result = await this.find({
3365
+ filters: {
3366
+ slug: { operator: exports.Where.EQUALS, value: slug },
3367
+ },
3368
+ });
3369
+ return (_a = result === null || result === void 0 ? void 0 : result.data) === null || _a === void 0 ? void 0 : _a.shift();
3370
+ }
3371
+ async fetchReviews(status) {
3283
3372
  const { data: products } = await this.find();
3284
3373
  products.forEach((product) => {
3285
3374
  var _a;
@@ -3314,9 +3403,6 @@ class ProductFirestoreRepository extends withCrudFirestore(withHelpers(withFires
3314
3403
  async fetchPaginatedReviews() {
3315
3404
  return Promise.resolve([]);
3316
3405
  }
3317
- productVariantFullReport() {
3318
- return;
3319
- }
3320
3406
  }
3321
3407
  tslib.__decorate([
3322
3408
  Log(),
@@ -3355,101 +3441,6 @@ class SubscriptionProductFirestoreRepository extends withCrudFirestore(withHelpe
3355
3441
  }
3356
3442
  }
3357
3443
 
3358
- class LogFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3359
- constructor({ firestore, interceptors, }) {
3360
- super({
3361
- firestore,
3362
- collectionName: 'logs',
3363
- model: LogDocument,
3364
- interceptors,
3365
- });
3366
- }
3367
- }
3368
-
3369
- class HomeFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3370
- constructor({ firestore, interceptors }) {
3371
- super({
3372
- firestore,
3373
- collectionName: 'dms',
3374
- model: Home,
3375
- interceptors,
3376
- });
3377
- this.homeCategoryGroupToPlain = (homeCategoryGroup) => {
3378
- var _a, _b, _c;
3379
- return ({
3380
- category: ((_a = homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category) === null || _a === void 0 ? void 0 : _a.toPlain)
3381
- ? (_b = homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category) === null || _b === void 0 ? void 0 : _b.toPlain()
3382
- : homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category,
3383
- 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)) || [],
3384
- });
3385
- };
3386
- this.plainToHomeCategoryGroup = (homeCategoryGroup) => {
3387
- var _a;
3388
- return ({
3389
- category: Category.toInstance(homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category),
3390
- products: (_a = homeCategoryGroup.products) === null || _a === void 0 ? void 0 : _a.map((product) => Product.toInstance(product)),
3391
- });
3392
- };
3393
- }
3394
- buildModelInstance() {
3395
- const { fromFirestore, toFirestore } = super.buildModelInstance();
3396
- return {
3397
- toFirestore: (data) => {
3398
- const modifiedData = this.homeToFirestore(data);
3399
- return toFirestore(modifiedData);
3400
- },
3401
- fromFirestore: (snap) => {
3402
- const instance = fromFirestore(snap);
3403
- return this.homeFromFirestore(instance);
3404
- },
3405
- };
3406
- }
3407
- homeToFirestore(home) {
3408
- var _a, _b, _c, _d;
3409
- if ((_a = home.data) === null || _a === void 0 ? void 0 : _a.data) {
3410
- home.data.data.discoverProducts = ((_b = home.data.data.discoverProducts) === null || _b === void 0 ? void 0 : _b.map(this.homeCategoryGroupToPlain)) || [];
3411
- home.data.data.featuredProducts = ((_c = home.data.data.featuredProducts) === null || _c === void 0 ? void 0 : _c.map(this.homeCategoryGroupToPlain)) || [];
3412
- home.data.data.verticalProducts = ((_d = home.data.data.verticalProducts) === null || _d === void 0 ? void 0 : _d.map(this.homeCategoryGroupToPlain)) || [];
3413
- }
3414
- return home;
3415
- }
3416
- homeFromFirestore(home) {
3417
- var _a;
3418
- if ((_a = home.data) === null || _a === void 0 ? void 0 : _a.data) {
3419
- home.data.data.discoverProducts = home.data.data.discoverProducts.map(this.plainToHomeCategoryGroup);
3420
- home.data.data.featuredProducts = home.data.data.featuredProducts.map(this.plainToHomeCategoryGroup);
3421
- home.data.data.verticalProducts = home.data.data.verticalProducts.map(this.plainToHomeCategoryGroup);
3422
- home.data.createdAt =
3423
- home.data.createdAt instanceof firestore.Timestamp ? home.data.createdAt.toDate() : home.data.createdAt;
3424
- home.data.expiresAt =
3425
- home.data.expiresAt instanceof firestore.Timestamp ? home.data.expiresAt.toDate() : home.data.expiresAt;
3426
- }
3427
- return home;
3428
- }
3429
- }
3430
-
3431
- class ShopMenuFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3432
- constructor({ firestore, interceptors }) {
3433
- super({
3434
- firestore,
3435
- collectionName: 'shopMenus',
3436
- model: ShopMenu,
3437
- interceptors,
3438
- });
3439
- }
3440
- }
3441
-
3442
- class ShopSettingsFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3443
- constructor({ firestore, interceptors, }) {
3444
- super({
3445
- firestore,
3446
- collectionName: 'shopSettings',
3447
- model: ShopSettings,
3448
- interceptors,
3449
- });
3450
- }
3451
- }
3452
-
3453
3444
  class Buy2WinFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3454
3445
  constructor({ firestore, interceptors }) {
3455
3446
  super({
@@ -3561,259 +3552,128 @@ class OrderFirestoreRepository extends withCrudFirestore(withHelpers(withFiresto
3561
3552
  buildModelInstance() {
3562
3553
  const { fromFirestore, toFirestore } = super.buildModelInstance();
3563
3554
  return {
3564
- toFirestore: (data) => toFirestore((data === null || data === void 0 ? void 0 : data.toPlain) ? data.toPlain() : data),
3565
- fromFirestore: (snap) => {
3566
- const instance = fromFirestore(snap);
3567
- return this.orderFromFirestore(instance);
3568
- },
3569
- };
3570
- }
3571
- }
3572
-
3573
- class LegacyOrderFirestoreRepository extends OrderFirestoreRepository {
3574
- constructor({ firestore, interceptors }) {
3575
- super({
3576
- firestore,
3577
- interceptors,
3578
- });
3579
- this.collectionName = 'legacyOrders';
3580
- }
3581
- }
3582
-
3583
- class OrderBlockedFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3584
- constructor({ firestore, interceptors, }) {
3585
- super({
3586
- firestore,
3587
- collectionName: 'paymentBlockedAttempts',
3588
- model: OrderBlocked,
3589
- interceptors,
3590
- });
3591
- }
3592
- async createBlockedOrderOrPayment(checkout, blockType, type, limiteRange, card = null) {
3593
- var _a, _b, _c, _d, _e, _f, _g, _h;
3594
- return this.create(OrderBlocked.toInstance({
3595
- customer: {
3596
- name: ((_a = checkout.user) === null || _a === void 0 ? void 0 : _a.displayName) || '',
3597
- cpf: ((_b = checkout.user) === null || _b === void 0 ? void 0 : _b.cpf) || '',
3598
- id: (_c = checkout.user) === null || _c === void 0 ? void 0 : _c.id,
3599
- email: ((_d = checkout.user) === null || _d === void 0 ? void 0 : _d.email) || '',
3600
- phoneNumber: '+55' + ((_e = checkout.user) === null || _e === void 0 ? void 0 : _e.phone),
3601
- isSubscriber: (_f = checkout.user) === null || _f === void 0 ? void 0 : _f.isSubscriber,
3602
- subscriptionPlan: ((_g = checkout.user) === null || _g === void 0 ? void 0 : _g.subscriptionPlan) || '',
3603
- shippingAddress: Object.assign(Object.assign({}, checkout.shippingAddress), { zip: this.formatZip((_h = checkout.shippingAddress) === null || _h === void 0 ? void 0 : _h.zip) }),
3604
- },
3605
- blockType,
3606
- limiteRange,
3607
- type,
3608
- card,
3609
- checkout: {
3610
- id: checkout.id,
3611
- shop: checkout.shop,
3612
- total: checkout.totalPrice,
3613
- },
3614
- date: new Date(),
3615
- }));
3616
- }
3617
- formatZip(zip) {
3618
- if (zip.length === 8)
3619
- return zip.substring(0, 5) + '-' + zip.substring(5, 8);
3620
- return zip;
3621
- }
3622
- }
3623
-
3624
- class PaymentFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3625
- constructor({ firestore, interceptors }) {
3626
- super({
3627
- firestore,
3628
- collectionName: 'payments',
3629
- model: Payment,
3630
- interceptors,
3631
- });
3632
- }
3633
- }
3634
-
3635
- class SubscriptionPlanFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3636
- constructor({ firestore, interceptors, }) {
3637
- super({
3638
- firestore,
3639
- collectionName: 'subscriptionPlans',
3640
- model: SubscriptionPlan,
3641
- interceptors,
3642
- });
3643
- }
3644
- }
3645
-
3646
- class LeadFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3647
- constructor({ firestore, interceptors }) {
3648
- super({
3649
- firestore,
3650
- collectionName: 'leads',
3651
- model: Lead,
3652
- interceptors,
3653
- });
3654
- }
3655
- }
3656
-
3657
- class SubscriptionEditionFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
3658
- constructor({ firestore, interceptors }, parentRepository) {
3659
- super({
3660
- firestore,
3661
- collectionName: 'editions',
3662
- parentIdField: 'subscriptionId',
3663
- model: Edition,
3664
- interceptors,
3665
- });
3666
- this.parentRepository = parentRepository;
3667
- }
3668
- }
3669
-
3670
- class SubscriptionFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3671
- constructor({ firestore, interceptors, }) {
3672
- super({
3673
- firestore,
3674
- collectionName: 'subscription',
3675
- model: Subscription,
3676
- interceptors,
3677
- });
3555
+ toFirestore: (data) => toFirestore((data === null || data === void 0 ? void 0 : data.toPlain) ? data.toPlain() : data),
3556
+ fromFirestore: (snap) => {
3557
+ const instance = fromFirestore(snap);
3558
+ return this.orderFromFirestore(instance);
3559
+ },
3560
+ };
3678
3561
  }
3679
3562
  }
3680
3563
 
3681
- class SubscriptionMaterializationFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3564
+ class LegacyOrderFirestoreRepository extends OrderFirestoreRepository {
3682
3565
  constructor({ firestore, interceptors }) {
3683
3566
  super({
3684
3567
  firestore,
3685
- collectionName: 'subscriptionMaterialization',
3686
- model: SubscriptionMaterialization,
3687
3568
  interceptors,
3688
3569
  });
3570
+ this.collectionName = 'legacyOrders';
3689
3571
  }
3690
3572
  }
3691
3573
 
3692
- class SubscriptionPaymentFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
3693
- constructor({ firestore, interceptors }, parentRepository) {
3574
+ class PaymentFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3575
+ constructor({ firestore, interceptors }) {
3694
3576
  super({
3695
3577
  firestore,
3696
3578
  collectionName: 'payments',
3697
- parentIdField: 'subscriptionId',
3698
- model: SubscriptionPayment,
3579
+ model: Payment,
3699
3580
  interceptors,
3700
3581
  });
3701
- this.parentRepository = parentRepository;
3702
3582
  }
3703
3583
  }
3704
3584
 
3705
- class SubscriptionSummaryFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3585
+ class SubscriptionPlanFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3706
3586
  constructor({ firestore, interceptors, }) {
3707
3587
  super({
3708
3588
  firestore,
3709
- collectionName: 'subscriptionSummary',
3710
- model: SubscriptionSummary,
3711
- interceptors,
3712
- });
3713
- }
3714
- }
3715
-
3716
- class UserAddressFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
3717
- constructor({ firestore, interceptors }, parentRepository) {
3718
- super({
3719
- firestore,
3720
- collectionName: 'address',
3721
- parentIdField: 'userId',
3722
- model: UserAddress,
3723
- interceptors,
3724
- });
3725
- this.parentRepository = parentRepository;
3726
- }
3727
- }
3728
-
3729
- class UserBeautyProfileFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
3730
- constructor({ firestore, interceptors }, parentRepository) {
3731
- super({
3732
- firestore,
3733
- collectionName: 'CX',
3734
- parentIdField: 'userId',
3735
- model: BeautyProfile,
3589
+ collectionName: 'subscriptionPlans',
3590
+ model: SubscriptionPlan,
3736
3591
  interceptors,
3737
3592
  });
3738
- this.parentRepository = parentRepository;
3739
3593
  }
3740
3594
  }
3741
3595
 
3742
- class UserFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3596
+ class HomeFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3743
3597
  constructor({ firestore, interceptors }) {
3744
3598
  super({
3745
3599
  firestore,
3746
- collectionName: 'users',
3747
- model: User,
3600
+ collectionName: 'dms',
3601
+ model: Home,
3748
3602
  interceptors,
3749
3603
  });
3750
- }
3751
- async get(identifiers) {
3752
- const user = await super.get({ id: identifiers.id });
3753
- user.beautyProfile = await this.getBeautyProfile(user.id);
3754
- user.isSubscriber = await this.checkIfIsSubscriber(user.id);
3755
- return user;
3756
- }
3757
- async checkIfExistsByField(field, value) {
3758
- const result = await this.find({ filters: { [field]: value } });
3759
- return result.count > 0;
3604
+ this.homeCategoryGroupToPlain = (homeCategoryGroup) => {
3605
+ var _a, _b, _c;
3606
+ return ({
3607
+ category: ((_a = homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category) === null || _a === void 0 ? void 0 : _a.toPlain)
3608
+ ? (_b = homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category) === null || _b === void 0 ? void 0 : _b.toPlain()
3609
+ : homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category,
3610
+ 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)) || [],
3611
+ });
3612
+ };
3613
+ this.plainToHomeCategoryGroup = (homeCategoryGroup) => {
3614
+ var _a;
3615
+ return ({
3616
+ category: Category.toInstance(homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category),
3617
+ products: (_a = homeCategoryGroup.products) === null || _a === void 0 ? void 0 : _a.map((product) => Product.toInstance(product)),
3618
+ });
3619
+ };
3760
3620
  }
3761
3621
  buildModelInstance() {
3762
3622
  const { fromFirestore, toFirestore } = super.buildModelInstance();
3763
3623
  return {
3764
3624
  toFirestore: (data) => {
3765
- const plain = toFirestore(data);
3766
- delete plain.isSubscriber;
3767
- return plain;
3625
+ const modifiedData = this.homeToFirestore(data);
3626
+ return toFirestore(modifiedData);
3627
+ },
3628
+ fromFirestore: (snap) => {
3629
+ const instance = fromFirestore(snap);
3630
+ return this.homeFromFirestore(instance);
3768
3631
  },
3769
- fromFirestore,
3770
3632
  };
3771
3633
  }
3772
- async getBeautyProfile(userId) {
3773
- const beautyProfile = await this.firestore
3774
- .getCollection(`${this.collectionName}/${userId}/CX`)
3775
- .withConverter(this.buildBeautyProfileModelInstance())
3776
- .getDoc('beautyProfile')
3777
- .get();
3778
- return beautyProfile.data();
3634
+ homeToFirestore(home) {
3635
+ var _a, _b, _c, _d;
3636
+ if ((_a = home.data) === null || _a === void 0 ? void 0 : _a.data) {
3637
+ home.data.data.discoverProducts = ((_b = home.data.data.discoverProducts) === null || _b === void 0 ? void 0 : _b.map(this.homeCategoryGroupToPlain)) || [];
3638
+ home.data.data.featuredProducts = ((_c = home.data.data.featuredProducts) === null || _c === void 0 ? void 0 : _c.map(this.homeCategoryGroupToPlain)) || [];
3639
+ home.data.data.verticalProducts = ((_d = home.data.data.verticalProducts) === null || _d === void 0 ? void 0 : _d.map(this.homeCategoryGroupToPlain)) || [];
3640
+ }
3641
+ return home;
3779
3642
  }
3780
- async checkIfIsSubscriber(userId) {
3781
- const docs = await this.collection('subscription')
3782
- .where('user.id', '==', userId)
3783
- .where('status', '==', 'active')
3784
- .getDocs();
3785
- return !!docs && !!docs.size;
3643
+ homeFromFirestore(home) {
3644
+ var _a;
3645
+ if ((_a = home.data) === null || _a === void 0 ? void 0 : _a.data) {
3646
+ home.data.data.discoverProducts = home.data.data.discoverProducts.map(this.plainToHomeCategoryGroup);
3647
+ home.data.data.featuredProducts = home.data.data.featuredProducts.map(this.plainToHomeCategoryGroup);
3648
+ home.data.data.verticalProducts = home.data.data.verticalProducts.map(this.plainToHomeCategoryGroup);
3649
+ home.data.createdAt =
3650
+ home.data.createdAt instanceof firestore.Timestamp ? home.data.createdAt.toDate() : home.data.createdAt;
3651
+ home.data.expiresAt =
3652
+ home.data.expiresAt instanceof firestore.Timestamp ? home.data.expiresAt.toDate() : home.data.expiresAt;
3653
+ }
3654
+ return home;
3786
3655
  }
3787
- buildBeautyProfileModelInstance() {
3788
- return {
3789
- toFirestore: (data) => data.toPlain(),
3790
- fromFirestore: (snap) => BeautyProfile.toInstance(snap.data()),
3791
- };
3656
+ }
3657
+
3658
+ class ShopMenuFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3659
+ constructor({ firestore, interceptors }) {
3660
+ super({
3661
+ firestore,
3662
+ collectionName: 'shopMenus',
3663
+ model: ShopMenu,
3664
+ interceptors,
3665
+ });
3792
3666
  }
3793
3667
  }
3794
- tslib.__decorate([
3795
- Log(),
3796
- tslib.__metadata("design:type", Function),
3797
- tslib.__metadata("design:paramtypes", [Object]),
3798
- tslib.__metadata("design:returntype", Promise)
3799
- ], UserFirestoreRepository.prototype, "get", null);
3800
- tslib.__decorate([
3801
- Log(),
3802
- tslib.__metadata("design:type", Function),
3803
- tslib.__metadata("design:paramtypes", [String, String]),
3804
- tslib.__metadata("design:returntype", Promise)
3805
- ], UserFirestoreRepository.prototype, "checkIfExistsByField", null);
3806
3668
 
3807
- class UserPaymentMethodFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
3808
- constructor({ firestore, interceptors }, parentRepository) {
3669
+ class ShopSettingsFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3670
+ constructor({ firestore, interceptors, }) {
3809
3671
  super({
3810
3672
  firestore,
3811
- collectionName: 'payment_method',
3812
- parentIdField: 'userId',
3813
- model: UserPaymentMethod,
3673
+ collectionName: 'shopSettings',
3674
+ model: ShopSettings,
3814
3675
  interceptors,
3815
3676
  });
3816
- this.parentRepository = parentRepository;
3817
3677
  }
3818
3678
  }
3819
3679
 
@@ -4366,7 +4226,7 @@ const withHasuraGraphQL = (MixinBase) => {
4366
4226
  const response = await axios__default["default"](request);
4367
4227
  if (!lodash.isNil(response.data.errors)) {
4368
4228
  this.logger.error({ req: request, res: response.data.errors });
4369
- throw new Error(JSON.stringify(response.data.errors));
4229
+ throw new Error(response.data.errors);
4370
4230
  }
4371
4231
  this.logger.log({ req: request, res: response.data });
4372
4232
  return response.data.data;
@@ -4507,7 +4367,6 @@ const withFindHasuraGraphQL = (MixinBase) => {
4507
4367
  return class FindHasuraGraphQLMixin extends MixinBase {
4508
4368
  constructor() {
4509
4369
  super(...arguments);
4510
- this.lastDistinct = {};
4511
4370
  this.bindOrderByAttributes = (orderBy, fields) => Object.keys(orderBy).reduce((acc, current) => [
4512
4371
  ...acc,
4513
4372
  {
@@ -4543,10 +4402,9 @@ const withFindHasuraGraphQL = (MixinBase) => {
4543
4402
  });
4544
4403
  }
4545
4404
  async find(params) {
4546
- var _a, _b, _c, _d, _e, _f, _g;
4405
+ var _a, _b, _c, _d, _e, _f, _g, _h;
4547
4406
  this.logger = DebugHelper.from(this, 'find');
4548
4407
  const { filters, limits, orderBy, options } = params || {};
4549
- const tableFiltersNamed = `${this.tableName}:${JSON.stringify(filters)}`;
4550
4408
  const enableCount = (_a = options === null || options === void 0 ? void 0 : options.enableCount) !== null && _a !== void 0 ? _a : true;
4551
4409
  const variablesFilters = lodash.isNil(filters)
4552
4410
  ? {}
@@ -4597,8 +4455,8 @@ const withFindHasuraGraphQL = (MixinBase) => {
4597
4455
  },
4598
4456
  ]
4599
4457
  : []),
4600
- ...((!this.lastDistinct[tableFiltersNamed] &&
4601
- ((_c = (_b = params.options) === null || _b === void 0 ? void 0 : _b.distinct) === null || _c === void 0 ? void 0 : _c.map((distinct) => {
4458
+ ...((!((_b = params.limits) === null || _b === void 0 ? void 0 : _b.offset) &&
4459
+ ((_d = (_c = params.options) === null || _c === void 0 ? void 0 : _c.distinct) === null || _d === void 0 ? void 0 : _d.map((distinct) => {
4602
4460
  var _a, _b;
4603
4461
  const distinctOption = (_a = this.fields.find((fieldOption) => fieldOption === distinct)) !== null && _a !== void 0 ? _a : this.fields.find((fieldOption) => Object.keys(fieldOption).shift() === distinct);
4604
4462
  const fieldName = ((_b = Object.values(distinctOption).shift()) === null || _b === void 0 ? void 0 : _b.columnName) || distinct;
@@ -4619,27 +4477,28 @@ const withFindHasuraGraphQL = (MixinBase) => {
4619
4477
  []),
4620
4478
  ]);
4621
4479
  const data = result[this.tableName].map((row) => this.convertDataFromHasura(row));
4622
- 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)
4480
+ 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)
4623
4481
  ? {
4624
4482
  minimal: options.minimal.reduce((minimals, current) => {
4625
4483
  var _a;
4626
4484
  return (Object.assign(Object.assign({}, minimals), lodash.set(minimals, current, result[`${this.tableName}_aggregate`].aggregate.min[((_a = AttributeOptionHelper.FindByAttribute(current.toString().split('.').pop(), this.fields)) === null || _a === void 0 ? void 0 : _a.columnName) || current])));
4627
4485
  }, {}),
4628
4486
  }
4629
- : {})), (((_e = options === null || options === void 0 ? void 0 : options.maximum) === null || _e === void 0 ? void 0 : _e.length)
4487
+ : {})), (((_f = options === null || options === void 0 ? void 0 : options.maximum) === null || _f === void 0 ? void 0 : _f.length)
4630
4488
  ? {
4631
4489
  maximum: options.maximum.reduce((maximums, current) => {
4632
4490
  var _a;
4633
4491
  return (Object.assign(Object.assign({}, maximums), lodash.set(maximums, current, result[`${this.tableName}_aggregate`].aggregate.max[((_a = AttributeOptionHelper.FindByAttribute(current.toString().split('.').pop(), this.fields)) === null || _a === void 0 ? void 0 : _a.columnName) || current])));
4634
4492
  }, {}),
4635
4493
  }
4636
- : {})), (((_f = options === null || options === void 0 ? void 0 : options.distinct) === null || _f === void 0 ? void 0 : _f.length) && {
4637
- 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) => {
4494
+ : {})), (!((_g = params.limits) === null || _g === void 0 ? void 0 : _g.offset) &&
4495
+ ((_h = options === null || options === void 0 ? void 0 : options.distinct) === null || _h === void 0 ? void 0 : _h.length) && {
4496
+ distinct: options === null || options === void 0 ? void 0 : options.distinct.reduce((distinct, current) => {
4638
4497
  var _a, _b;
4639
4498
  const distinctOption = (_a = this.fields.find((fieldOption) => fieldOption === current)) !== null && _a !== void 0 ? _a : this.fields.find((fieldOption) => Object.keys(fieldOption).shift() === current);
4640
4499
  const fieldName = ((_b = Object.values(distinctOption).shift()) === null || _b === void 0 ? void 0 : _b.columnName) || current;
4641
4500
  return Object.assign(Object.assign({}, distinct), { [current.toString()]: result[`${this.tableName}_${current.toString()}_distinct`].map((obj) => obj[fieldName]) });
4642
- }, {})),
4501
+ }, {}),
4643
4502
  }));
4644
4503
  }
4645
4504
  };
@@ -4734,7 +4593,6 @@ class CategoryFilterHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHa
4734
4593
  fields: [
4735
4594
  'id',
4736
4595
  'description',
4737
- 'title',
4738
4596
  'slug',
4739
4597
  'enabled',
4740
4598
  { createdAt: { columnName: 'created_at' } },
@@ -4879,11 +4737,11 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
4879
4737
  filters: {
4880
4738
  columnName: 'filters',
4881
4739
  foreignKeyColumn: { filter_id: 'id' },
4882
- fields: [{ filter: ['id', 'title', 'description', 'slug', 'enabled'] }],
4740
+ fields: [{ filter: ['id', 'description', 'slug', 'enabled'] }],
4883
4741
  bindPersistData: (value) => ({
4884
4742
  filters: { data: value.map((filter) => ({ filter_id: filter.id })) },
4885
4743
  }),
4886
- 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)) || [],
4744
+ from: (filters) => (filters === null || filters === void 0 ? void 0 : filters.map((filter) => filter === null || filter === void 0 ? void 0 : filter.filter)) || [],
4887
4745
  },
4888
4746
  },
4889
4747
  { createdAt: { columnName: 'created_at' } },
@@ -4908,15 +4766,6 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
4908
4766
  }),
4909
4767
  },
4910
4768
  },
4911
- {
4912
- metadatas: {
4913
- columnName: 'metadatas',
4914
- fields: ['shop', 'title', 'description'],
4915
- bindPersistData: (value) => ({
4916
- metadatas: { data: value },
4917
- }),
4918
- },
4919
- },
4920
4769
  { isCollection: { columnName: 'is_collection' } },
4921
4770
  { isWishlist: { columnName: 'is_wishlist' } },
4922
4771
  'reference',
@@ -4931,29 +4780,14 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
4931
4780
  'theme',
4932
4781
  { bannerUrl: { columnName: 'banner_url' } },
4933
4782
  { mostRelevant: { columnName: 'most_relevant', type: HasuraGraphQLColumnType.Jsonb } },
4934
- { mostRelevants: { columnName: 'most_relevants', type: HasuraGraphQLColumnType.Jsonb } },
4935
4783
  ],
4936
4784
  });
4937
4785
  this.productRepository = productRepository;
4938
4786
  this.categoryFilterRepository = categoryFilterRepository;
4939
4787
  }
4940
4788
  async create(params) {
4941
- const { images, mostRelevants, metadatas } = params, data = tslib.__rest(params, ["images", "mostRelevants", "metadatas"]);
4942
- return super.create(Object.assign(Object.assign({}, data), { isWishlist: false, metadatas: metadatas || [{ shop: null, description: null, title: null }], mostRelevants: mostRelevants || {
4943
- [exports.Shops.GLAMSHOP]: null,
4944
- [exports.Shops.MENSMARKET]: null,
4945
- }, images: images || {
4946
- [exports.Shops.GLAMSHOP]: {
4947
- brandBanner: null,
4948
- brandBannerMobile: null,
4949
- image: null,
4950
- },
4951
- [exports.Shops.MENSMARKET]: {
4952
- brandBanner: null,
4953
- brandBannerMobile: null,
4954
- image: null,
4955
- },
4956
- } }));
4789
+ const { metadata } = params, data = tslib.__rest(params, ["metadata"]);
4790
+ return super.create(Object.assign(Object.assign({}, data), { isWishlist: false, metadata: metadata || [{ shop: null, description: null, title: null }] }));
4957
4791
  }
4958
4792
  async get(identifiers) {
4959
4793
  var _a;
@@ -4962,12 +4796,12 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
4962
4796
  : super.get(identifiers);
4963
4797
  }
4964
4798
  async update(params) {
4965
- const { products, id: checkId, metadatas, filters } = params, data = tslib.__rest(params, ["products", "id", "metadatas", "filters"]);
4799
+ const { products, id: checkId, metadata, filters } = params, data = tslib.__rest(params, ["products", "id", "metadata", "filters"]);
4966
4800
  const plainData = this.paramsToPlain({ id: checkId });
4967
4801
  const id = await this.getId(plainData.id);
4968
4802
  const category = await super.update(Object.assign(Object.assign({ id }, data), { isWishlist: false }));
4969
4803
  category.products = products && (await this.updateProducts(+id, { products }));
4970
- category.metadatas = metadatas && (await this.updateMetadata(+id, { metadatas }));
4804
+ category.metadata = metadata && (await this.updateMetadata(+id, { metadata }));
4971
4805
  category.filters = filters && (await this.updateFilters(+id, { filters }));
4972
4806
  return category;
4973
4807
  }
@@ -5005,7 +4839,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
5005
4839
  });
5006
4840
  return data;
5007
4841
  }
5008
- async getCategoriesForHome(categoryIds, shop, limit = 4) {
4842
+ async getCategoriesForHome(categoryIds, limit = 4, gender) {
5009
4843
  if (!(categoryIds === null || categoryIds === void 0 ? void 0 : categoryIds.length))
5010
4844
  return [];
5011
4845
  const categoriesFirestore = categoryIds.filter((categoryId) => Number.isNaN(+categoryId));
@@ -5017,32 +4851,22 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
5017
4851
  }).then(({ data }) => data)));
5018
4852
  if (categoriesHasura.length)
5019
4853
  categories.push(...(await this.find({
5020
- filters: {
5021
- id: { operator: exports.Where.IN, value: categoriesHasura.filter(Boolean) },
5022
- published: true,
5023
- },
4854
+ filters: { id: { operator: exports.Where.IN, value: categoriesHasura.filter(Boolean) }, published: true },
5024
4855
  }).then(({ data }) => data)));
5025
4856
  if (!categories.length)
5026
4857
  return [];
5027
4858
  const homeSections = await Promise.all(categories.map(async (category) => ({
5028
4859
  category,
5029
- products: await this.mountCategory(category, shop, { limit, hasStock: true }),
4860
+ products: await this.mountCategory(category, { limit, hasStock: true, gender }),
5030
4861
  })));
5031
4862
  return homeSections;
5032
4863
  }
5033
- async mountCategory(category, shop, options) {
4864
+ async mountCategory(category, options) {
5034
4865
  var _a;
5035
4866
  if (!((_a = category === null || category === void 0 ? void 0 : category.products) === null || _a === void 0 ? void 0 : _a.length))
5036
4867
  return [];
5037
- const mostRelevants = category.getMostRelevantByShop(shop);
5038
- const mostRelevantProductsIds = [...new Set(mostRelevants.concat(category.products))];
5039
4868
  const products = [];
5040
- const { data: productsData } = await this.productRepository.findCatalog({
5041
- filters: {
5042
- id: { operator: exports.Where.IN, value: mostRelevantProductsIds },
5043
- published: true,
5044
- },
5045
- fields: [
4869
+ const { data: productsData } = await this.productRepository.find(Object.assign(Object.assign({ filters: Object.assign(Object.assign({ id: { operator: exports.Where.IN, value: category.products }, published: true }, ((options === null || options === void 0 ? void 0 : options.hasStock) ? { stock: { quantity: { operator: exports.Where.GT, value: 0 } } } : {})), ((options === null || options === void 0 ? void 0 : options.gender) ? { tags: { operator: exports.Where.IN, value: [options === null || options === void 0 ? void 0 : options.gender] } } : {})), fields: [
5046
4870
  'id',
5047
4871
  'name',
5048
4872
  'slug',
@@ -5068,25 +4892,8 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
5068
4892
  'shoppingCount',
5069
4893
  'gender',
5070
4894
  'createdAt',
5071
- ],
5072
- options: { enableCount: false },
5073
- orderBy: {
5074
- shoppingCount: 'desc',
5075
- rate: 'desc',
5076
- stock: 'desc',
5077
- name: 'asc',
5078
- },
5079
- }, shop === exports.Shops.MENSMARKET ? 'male' : 'female');
5080
- const mostRelevantWithouyStock = productsData.filter((product) => mostRelevants.includes(product.id) && product.stock.quantity <= 0);
5081
- const firstProducts = productsData
5082
- .filter((product) => mostRelevants.includes(product.id) && product.stock.quantity > 0)
5083
- .sort((a, b) => mostRelevants.indexOf(a.id) - mostRelevants.indexOf(b.id));
5084
- const lastProducts = productsData
5085
- .filter((product) => !mostRelevants.includes(product.id) && product.stock.quantity > 0)
5086
- .concat(mostRelevantWithouyStock);
5087
- const categoryMostRelevants = firstProducts.concat(lastProducts);
5088
- const resultFinal = categoryMostRelevants.slice(0, options.limit);
5089
- products.push(...resultFinal);
4895
+ ] }, ((options === null || options === void 0 ? void 0 : options.limit) ? { limits: { limit: options === null || options === void 0 ? void 0 : options.limit } } : {})), { options: { enableCount: false } }));
4896
+ products.push(...productsData);
5090
4897
  return products;
5091
4898
  }
5092
4899
  async getChildren(parentId) {
@@ -5123,6 +4930,29 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
5123
4930
  });
5124
4931
  return [];
5125
4932
  }
4933
+ const plainData = this.paramsToPlain({ products });
4934
+ if (!plainData.products || plainData.products.length <= 0)
4935
+ return [];
4936
+ const category = await this.get({ id: categoryId.toString() });
4937
+ await this.mutation('delete_category_product', ['affected_rows'], {
4938
+ where: {
4939
+ type: 'category_product_bool_exp',
4940
+ required: true,
4941
+ value: {
4942
+ category_id: { _eq: categoryId },
4943
+ product_id: { _in: category.products.filter((productId) => !plainData.products.includes(productId)) },
4944
+ },
4945
+ },
4946
+ });
4947
+ await this.mutation('insert_category_product', ['affected_rows'], {
4948
+ objects: {
4949
+ type: '[category_product_insert_input!]',
4950
+ required: true,
4951
+ value: plainData.products
4952
+ .filter((productId) => !category.products.includes(productId))
4953
+ .map((productId) => ({ category_id: categoryId, product_id: productId })),
4954
+ },
4955
+ });
5126
4956
  const productsOrder = products.map((product, index) => {
5127
4957
  return {
5128
4958
  id: product,
@@ -5131,7 +4961,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
5131
4961
  });
5132
4962
  const updateQueries = productsOrder.map((product) => ({
5133
4963
  where: {
5134
- category_id: { _eq: categoryId },
4964
+ category_id: { _eq: category.id },
5135
4965
  product_id: { _eq: product.id },
5136
4966
  },
5137
4967
  _set: {
@@ -5145,13 +4975,13 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
5145
4975
  required: true,
5146
4976
  },
5147
4977
  });
5148
- const plainData = this.paramsToPlain({ products });
5149
4978
  return plainData.products;
5150
4979
  }
5151
- async updateMetadata(categoryId, { metadatas }) {
5152
- if (Array.isArray(metadatas) && !metadatas.length)
4980
+ async updateMetadata(categoryId, { metadata }) {
4981
+ if (Array.isArray(metadata) && !metadata.length)
5153
4982
  return [];
5154
- if (Array.isArray(metadatas) && metadatas.length) {
4983
+ if (Array.isArray(metadata) && metadata.length) {
4984
+ const metadataUpdated = [];
5155
4985
  await this.mutation('delete_category_metadata', ['affected_rows'], {
5156
4986
  where: {
5157
4987
  type: 'category_metadata_bool_exp',
@@ -5159,16 +4989,24 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
5159
4989
  value: { category_id: { _eq: categoryId } },
5160
4990
  },
5161
4991
  });
5162
- await this.mutation('insert_category_metadata', ['affected_rows'], {
5163
- objects: {
5164
- type: '[category_metadata_insert_input!]',
5165
- required: true,
5166
- value: metadatas.map((m) => (Object.assign({ category_id: categoryId }, m))),
5167
- },
5168
- });
5169
- return metadatas;
4992
+ for (const data of metadata) {
4993
+ const update = await this.mutation('update_category_metadata_by_pk', ['category_id', 'shop'], {
4994
+ pk_columns: {
4995
+ value: { category_id: categoryId, shop: data.shop },
4996
+ type: 'category_metadata_pk_columns_input',
4997
+ required: true,
4998
+ },
4999
+ _set: {
5000
+ value: lodash.omit(data, ['category_id', 'shop']),
5001
+ type: 'category_metadata_set_input',
5002
+ required: true,
5003
+ },
5004
+ });
5005
+ metadataUpdated.push(update);
5006
+ }
5007
+ return metadataUpdated;
5170
5008
  }
5171
- if ('action' in metadatas && metadatas.action === 'remove' && metadatas.value.length) {
5009
+ if ('action' in metadata && metadata.action === 'remove' && metadata.value.length) {
5172
5010
  await this.mutation('delete_category_metadata', ['affected_rows'], {
5173
5011
  where: {
5174
5012
  type: 'category_metadata_bool_exp',
@@ -5239,61 +5077,27 @@ tslib.__decorate([
5239
5077
  tslib.__decorate([
5240
5078
  Log(),
5241
5079
  tslib.__metadata("design:type", Function),
5242
- tslib.__metadata("design:paramtypes", [Array, String, Object]),
5080
+ tslib.__metadata("design:paramtypes", [Array, Object, String]),
5243
5081
  tslib.__metadata("design:returntype", Promise)
5244
5082
  ], CategoryHasuraGraphQLRepository.prototype, "getCategoriesForHome", null);
5245
5083
  tslib.__decorate([
5246
5084
  Log(),
5247
5085
  tslib.__metadata("design:type", Function),
5248
- tslib.__metadata("design:paramtypes", [Category, String, Object]),
5086
+ tslib.__metadata("design:paramtypes", [Category, Object]),
5249
5087
  tslib.__metadata("design:returntype", Promise)
5250
5088
  ], CategoryHasuraGraphQLRepository.prototype, "mountCategory", null);
5251
5089
  tslib.__decorate([
5252
5090
  Log(),
5253
- tslib.__metadata("design:type", Function),
5254
- tslib.__metadata("design:paramtypes", [Number]),
5255
- tslib.__metadata("design:returntype", Promise)
5256
- ], CategoryHasuraGraphQLRepository.prototype, "getChildren", null);
5257
- tslib.__decorate([
5258
- Log(),
5259
- tslib.__metadata("design:type", Function),
5260
- tslib.__metadata("design:paramtypes", [Number, Number]),
5261
- tslib.__metadata("design:returntype", Promise)
5262
- ], CategoryHasuraGraphQLRepository.prototype, "isChild", null);
5263
-
5264
- class CategoryProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
5265
- constructor({ endpoint, authOptions, interceptors, }) {
5266
- super({
5267
- tableName: 'category_product',
5268
- model: CategoryProduct,
5269
- endpoint,
5270
- authOptions,
5271
- interceptors,
5272
- fields: [{ productId: { columnName: 'product_id' } }, { categoryId: { columnName: 'category_id' } }, 'order'],
5273
- });
5274
- }
5275
- async removeProductFromCategory(categoryId, productId) {
5276
- await this.mutation('delete_category_product', ['affected_rows'], {
5277
- where: {
5278
- type: 'category_product_bool_exp',
5279
- required: true,
5280
- value: {
5281
- product_id: { _eq: productId },
5282
- category_id: { _eq: categoryId },
5283
- },
5284
- },
5285
- });
5286
- }
5287
- async addProductToCategory(categoryId, productId) {
5288
- await this.mutation('insert_category_product', ['affected_rows'], {
5289
- objects: {
5290
- type: '[category_product_insert_input!]',
5291
- required: true,
5292
- value: [{ category_id: categoryId, product_id: productId }],
5293
- },
5294
- });
5295
- }
5296
- }
5091
+ tslib.__metadata("design:type", Function),
5092
+ tslib.__metadata("design:paramtypes", [Number]),
5093
+ tslib.__metadata("design:returntype", Promise)
5094
+ ], CategoryHasuraGraphQLRepository.prototype, "getChildren", null);
5095
+ tslib.__decorate([
5096
+ Log(),
5097
+ tslib.__metadata("design:type", Function),
5098
+ tslib.__metadata("design:paramtypes", [Number, Number]),
5099
+ tslib.__metadata("design:returntype", Promise)
5100
+ ], CategoryHasuraGraphQLRepository.prototype, "isChild", null);
5297
5101
 
5298
5102
  class FilterHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
5299
5103
  constructor({ endpoint, authOptions, interceptors, }, filterOptionRepository, categoryFilterRepository) {
@@ -5305,7 +5109,6 @@ class FilterHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGrap
5305
5109
  interceptors,
5306
5110
  fields: [
5307
5111
  'id',
5308
- 'title',
5309
5112
  'description',
5310
5113
  'slug',
5311
5114
  'enabled',
@@ -5561,7 +5364,6 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
5561
5364
  { subscriberPrice: { columnName: 'subscriber_price' } },
5562
5365
  'published',
5563
5366
  'outlet',
5564
- 'label',
5565
5367
  'sku',
5566
5368
  {
5567
5369
  stock: {
@@ -5593,8 +5395,6 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
5593
5395
  fields: ['id', 'name', 'reference', 'slug'],
5594
5396
  },
5595
5397
  },
5596
- 'group',
5597
- 'validity',
5598
5398
  ];
5599
5399
  this.fields = [
5600
5400
  ...commonFields,
@@ -5696,8 +5496,6 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
5696
5496
  enableCount: false,
5697
5497
  },
5698
5498
  });
5699
- if (!result.data.length)
5700
- return null;
5701
5499
  const product = (_a = result === null || result === void 0 ? void 0 : result.data) === null || _a === void 0 ? void 0 : _a.shift();
5702
5500
  RoundProductPricesHelper.roundProductPrices(product);
5703
5501
  return product;
@@ -5707,6 +5505,7 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
5707
5505
  const plainData = this.paramsToPlain({ id: checkId });
5708
5506
  const id = await this.getId(plainData.id);
5709
5507
  const product = await super.update(Object.assign({ id }, data));
5508
+ product.categories = categories && (await this.updateCategories(+id, { categories }));
5710
5509
  product.kitProducts = kitProducts && (await this.updateKitProducts(+id, { kitProducts }));
5711
5510
  product.reviews = reviews && (await this.updateReviews(+id, { reviews }));
5712
5511
  product.metadata = metadata && (await this.updateMetadata(+id, { metadata }));
@@ -5770,6 +5569,42 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
5770
5569
  getReviewStatus(review) {
5771
5570
  return review.status === true ? 'approved' : review.status === false ? 'rejected' : 'pending';
5772
5571
  }
5572
+ async updateCategories(productId, { categories }) {
5573
+ if ('action' in categories && categories.action === 'remove') {
5574
+ await this.mutation('delete_category_product', ['affected_rows'], {
5575
+ where: {
5576
+ type: 'category_product_bool_exp',
5577
+ required: true,
5578
+ value: { product_id: { _eq: productId } },
5579
+ },
5580
+ });
5581
+ return [];
5582
+ }
5583
+ const plainData = this.paramsToPlain({ categories });
5584
+ if (!plainData.categories || plainData.categories.length <= 0)
5585
+ return [];
5586
+ const product = await this.get({ id: productId.toString() });
5587
+ await this.mutation('delete_category_product', ['affected_rows'], {
5588
+ where: {
5589
+ type: 'category_product_bool_exp',
5590
+ required: true,
5591
+ value: {
5592
+ product_id: { _eq: productId },
5593
+ category_id: { _in: product.categories.filter((categoryId) => !plainData.categories.includes(categoryId)) },
5594
+ },
5595
+ },
5596
+ });
5597
+ await this.mutation('insert_category_product', ['affected_rows'], {
5598
+ objects: {
5599
+ type: '[category_product_insert_input!]',
5600
+ required: true,
5601
+ value: plainData.categories
5602
+ .filter((categoryId) => !product.categories.includes(categoryId))
5603
+ .map((categoryId) => ({ category_id: categoryId, product_id: productId })),
5604
+ },
5605
+ });
5606
+ return plainData.categories;
5607
+ }
5773
5608
  async updateKitProducts(productId, { kitProducts }) {
5774
5609
  const plainData = this.paramsToPlain({ kitProducts });
5775
5610
  await this.mutation('delete_product_kit', ['affected_rows'], {
@@ -5901,56 +5736,6 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
5901
5736
  });
5902
5737
  return data && data[0] && this.bindReviewToModel(data[0]);
5903
5738
  }
5904
- async productVariantFullReport() {
5905
- const fields = [
5906
- 'id',
5907
- 'name',
5908
- 'description',
5909
- 'slug',
5910
- 'sku',
5911
- 'ean',
5912
- 'cest',
5913
- 'ncm',
5914
- 'has_variants',
5915
- 'is_variant',
5916
- 'grade',
5917
- 'type',
5918
- 'is_kit',
5919
- 'tags',
5920
- 'published',
5921
- 'stock',
5922
- 'brand',
5923
- 'brand_description',
5924
- 'images',
5925
- 'miniatures',
5926
- 'video',
5927
- 'weight',
5928
- 'cost_price',
5929
- 'full_price',
5930
- 'price',
5931
- 'subscriber_discount_percentage',
5932
- 'subscriber_price',
5933
- 'how_to_use',
5934
- 'who_must_use',
5935
- 'differentials',
5936
- 'ingredients',
5937
- 'purpose',
5938
- 'filters',
5939
- 'category_id',
5940
- 'outlet',
5941
- 'label',
5942
- 'group',
5943
- 'validity',
5944
- 'gender',
5945
- 'shopping_count',
5946
- 'rating',
5947
- 'reviews_total',
5948
- 'created_at',
5949
- 'updated_at',
5950
- ];
5951
- const { product_variant_report_query: data } = await this.query('product_variant_report_query', fields);
5952
- return data;
5953
- }
5954
5739
  }
5955
5740
  tslib.__decorate([
5956
5741
  Log(),
@@ -6010,24 +5795,6 @@ class ProductReviewsHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHa
6010
5795
  ],
6011
5796
  });
6012
5797
  }
6013
- async updateManyStatus(reviews) {
6014
- return await this.mutation('update_product_review_many', ['affected_rows'], {
6015
- updates: {
6016
- type: '[product_review_updates!]',
6017
- required: true,
6018
- value: [
6019
- {
6020
- _set: { status: true },
6021
- where: { id: { _in: reviews.filter((review) => review.status).map((review) => review.id) } },
6022
- },
6023
- {
6024
- _set: { status: false },
6025
- where: { id: { _in: reviews.filter((review) => !review.status).map((review) => review.id) } },
6026
- },
6027
- ],
6028
- },
6029
- });
6030
- }
6031
5798
  aproveReview(id) {
6032
5799
  return this.update({ id, status: true });
6033
5800
  }
@@ -6082,31 +5849,6 @@ class ProductStockNotificationHasuraGraphQLRepository extends withCrudHasuraGrap
6082
5849
  email,
6083
5850
  });
6084
5851
  }
6085
- async getNotificationsReport(params, orderBy, pagination) {
6086
- 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 } }));
6087
- const orderByField = {
6088
- [orderBy.field]: orderBy.direction,
6089
- };
6090
- const { report_stock_notification } = await this.query('report_stock_notification', ['product_id', 'ean', 'sku', 'name', 'stock', 'category_id', 'category', 'reference', 'emails_registered'], {
6091
- where: {
6092
- type: 'report_stock_notification_bool_exp',
6093
- value: query,
6094
- required: true,
6095
- },
6096
- order_by: {
6097
- type: '[report_stock_notification_order_by]',
6098
- value: orderByField,
6099
- required: true,
6100
- },
6101
- });
6102
- const data = (pagination === null || pagination === void 0 ? void 0 : pagination.limit)
6103
- ? 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))
6104
- : report_stock_notification;
6105
- return {
6106
- data,
6107
- count: report_stock_notification.length,
6108
- };
6109
- }
6110
5852
  }
6111
5853
 
6112
5854
  class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
@@ -6180,10 +5922,6 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
6180
5922
  type: HasuraGraphQLColumnType.Jsonb,
6181
5923
  },
6182
5924
  },
6183
- 'group',
6184
- 'validity',
6185
- { tags: { columnName: 'tags', type: HasuraGraphQLColumnType.Jsonb } },
6186
- 'published',
6187
5925
  ],
6188
5926
  });
6189
5927
  }
@@ -6219,14 +5957,11 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
6219
5957
  }
6220
5958
  }
6221
5959
 
6222
- class WishlistHasuraGraphQL extends Wishlist {
6223
- }
6224
-
6225
5960
  class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
6226
- constructor({ endpoint, authOptions, interceptors, }, categoryProductRepository) {
5961
+ constructor({ endpoint, authOptions, interceptors, }, categoryFilterRepository) {
6227
5962
  super({
6228
5963
  tableName: 'category',
6229
- model: WishlistHasuraGraphQL,
5964
+ model: Wishlist,
6230
5965
  endpoint,
6231
5966
  authOptions,
6232
5967
  interceptors,
@@ -6293,15 +6028,6 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
6293
6028
  }),
6294
6029
  },
6295
6030
  },
6296
- {
6297
- metadatas: {
6298
- columnName: 'metadatas',
6299
- fields: ['shop', 'title', 'description'],
6300
- bindPersistData: (value) => ({
6301
- metadatas: { data: value },
6302
- }),
6303
- },
6304
- },
6305
6031
  { isCollection: { columnName: 'is_collection' } },
6306
6032
  { isWishlist: { columnName: 'is_wishlist' } },
6307
6033
  'reference',
@@ -6316,34 +6042,16 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
6316
6042
  { personId: { columnName: 'person_id' } },
6317
6043
  { personName: { columnName: 'person_name' } },
6318
6044
  { personPhoto: { columnName: 'person_photo' } },
6319
- { personType: { columnName: 'person_type' } },
6320
- { personIsSubscriber: { columnName: 'person_is_subscriber' } },
6321
6045
  'theme',
6322
6046
  { bannerUrl: { columnName: 'banner_url' } },
6323
- { personHasPhoto: { columnName: 'person_has_photo' } },
6324
- { mostRelevants: { columnName: 'most_relevants', type: HasuraGraphQLColumnType.Jsonb } },
6325
6047
  ],
6326
6048
  });
6327
- this.categoryProductRepository = categoryProductRepository;
6049
+ this.categoryFilterRepository = categoryFilterRepository;
6328
6050
  }
6329
6051
  async create(params) {
6330
6052
  var _a;
6331
- const { images, mostRelevants, metadatas } = params, data = tslib.__rest(params, ["images", "mostRelevants", "metadatas"]);
6332
- 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 || {
6333
- [exports.Shops.GLAMSHOP]: null,
6334
- [exports.Shops.MENSMARKET]: null,
6335
- }, images: images || {
6336
- [exports.Shops.GLAMSHOP]: {
6337
- brandBanner: null,
6338
- brandBannerMobile: null,
6339
- image: null,
6340
- },
6341
- [exports.Shops.MENSMARKET]: {
6342
- brandBanner: null,
6343
- brandBannerMobile: null,
6344
- image: null,
6345
- },
6346
- } }));
6053
+ const { metadata } = params, data = tslib.__rest(params, ["metadata"]);
6054
+ 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 }] }));
6347
6055
  }
6348
6056
  async get(identifiers) {
6349
6057
  const data = await super.get(identifiers);
@@ -6356,11 +6064,12 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
6356
6064
  return await super.find(Object.assign(Object.assign({}, rest), { filters: Object.assign(Object.assign({}, filters), { isWishlist: { operator: exports.Where.EQUALS, value: true } }) }));
6357
6065
  }
6358
6066
  async update(params) {
6359
- const { products, id: checkId, metadatas, filters } = params, data = tslib.__rest(params, ["products", "id", "metadatas", "filters"]);
6067
+ const { products, id: checkId, metadata, filters } = params, data = tslib.__rest(params, ["products", "id", "metadata", "filters"]);
6360
6068
  const plainData = this.paramsToPlain({ id: checkId });
6361
6069
  const id = plainData.id;
6362
6070
  const category = await super.update(Object.assign(Object.assign({ id }, data), { isWishlist: true, isCollection: true, brandCategory: false }));
6363
- category.metadatas = metadatas && (await this.updateMetadata(+id, { metadatas }));
6071
+ category.products = products && (await this.updateProducts(+id, { products }));
6072
+ category.metadata = metadata && (await this.updateMetadata(+id, { metadata }));
6364
6073
  return category;
6365
6074
  }
6366
6075
  async getWishlistBySlug(slug) {
@@ -6392,18 +6101,12 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
6392
6101
  options: {
6393
6102
  enableCount: false,
6394
6103
  },
6395
- orderBy: {
6396
- id: 'asc',
6397
- },
6398
- limits: {
6399
- limit: 1,
6400
- },
6401
6104
  });
6402
6105
  if (!data.length)
6403
6106
  throw new NotFoundError(`Wishlists from person ${personId} not found`);
6404
6107
  return data;
6405
6108
  }
6406
- async getCategoryBySlug(slug, _shop) {
6109
+ getCategoryBySlug(slug, _shop) {
6407
6110
  return this.getWishlistBySlug(slug);
6408
6111
  }
6409
6112
  async getCategoryByShop(shop) {
@@ -6421,17 +6124,10 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
6421
6124
  });
6422
6125
  return data;
6423
6126
  }
6424
- async findBfluOrGlamgirlWishlists(params, shops) {
6425
- var _a, _b;
6426
- return this.find(Object.assign(Object.assign({}, params), { filters: Object.assign(Object.assign({}, params.filters), { published: true, shops: { operator: exports.Where.LIKE, value: shops }, personType: (_b = (_a = params.filters) === null || _a === void 0 ? void 0 : _a.personType) !== null && _b !== void 0 ? _b : {
6427
- operator: exports.Where.IN,
6428
- value: [exports.PersonTypes.BFLU, exports.PersonTypes.GLAMGIRL],
6429
- } }), orderBy: Object.assign({ personHasPhoto: 'desc' }, lodash.omit(params.orderBy, ['personHasPhoto'])) }));
6430
- }
6431
- getCategoriesForHome(categoryIds, gender, limit) {
6127
+ getCategoriesForHome(categoryIds, limit, gender) {
6432
6128
  return;
6433
6129
  }
6434
- mountCategory(category, shop, options) {
6130
+ mountCategory(category, options) {
6435
6131
  return;
6436
6132
  }
6437
6133
  getChildren(parentId) {
@@ -6440,12 +6136,50 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
6440
6136
  isChild(id, parentId) {
6441
6137
  return;
6442
6138
  }
6443
- async updateMetadata(categoryId, { metadatas }) {
6444
- if (Array.isArray(metadatas) && !metadatas.length)
6139
+ async updateProducts(categoryId, { products }) {
6140
+ if ('action' in products && products.action === 'remove') {
6141
+ await this.mutation('delete_category_product', ['affected_rows'], {
6142
+ where: {
6143
+ type: 'category_product_bool_exp',
6144
+ required: true,
6145
+ value: { category_id: { _eq: categoryId } },
6146
+ },
6147
+ });
6148
+ await this.categoryFilterRepository.deleteByCategory(categoryId);
6149
+ return [];
6150
+ }
6151
+ const plainData = this.paramsToPlain({ products });
6152
+ if (!plainData.products || plainData.products.length <= 0)
6153
+ return [];
6154
+ const category = await this.get({ id: categoryId.toString() });
6155
+ await this.categoryFilterRepository.deleteByCategory(categoryId);
6156
+ await this.mutation('delete_category_product', ['affected_rows'], {
6157
+ where: {
6158
+ type: 'category_product_bool_exp',
6159
+ required: true,
6160
+ value: {
6161
+ category_id: { _eq: categoryId },
6162
+ product_id: { _in: category.products.filter((productId) => !plainData.products.includes(productId)) },
6163
+ },
6164
+ },
6165
+ });
6166
+ await this.mutation('insert_category_product', ['affected_rows'], {
6167
+ objects: {
6168
+ type: '[category_product_insert_input!]',
6169
+ required: true,
6170
+ value: plainData.products
6171
+ .filter((productId) => !category.products.includes(productId))
6172
+ .map((productId) => ({ category_id: categoryId, product_id: productId })),
6173
+ },
6174
+ });
6175
+ return plainData.products;
6176
+ }
6177
+ async updateMetadata(categoryId, { metadata }) {
6178
+ if (Array.isArray(metadata) && !metadata.length)
6445
6179
  return [];
6446
- if (Array.isArray(metadatas) && metadatas.length) {
6180
+ if (Array.isArray(metadata) && metadata.length) {
6447
6181
  const metadataUpdated = [];
6448
- for (const data of metadatas) {
6182
+ for (const data of metadata) {
6449
6183
  const update = await this.mutation('update_category_metadata_by_pk', ['category_id', 'shop'], {
6450
6184
  pk_columns: {
6451
6185
  value: { category_id: categoryId, shop: data.shop },
@@ -6462,25 +6196,19 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
6462
6196
  }
6463
6197
  return metadataUpdated;
6464
6198
  }
6465
- if ('action' in metadatas && metadatas.action === 'remove' && metadatas.value.length) {
6466
- for (let i = 0; i < metadatas.value.length; i++) {
6199
+ if ('action' in metadata && metadata.action === 'remove' && metadata.value.length) {
6200
+ for (let i = 0; i < metadata.value.length; i++) {
6467
6201
  await this.mutation('delete_category_metadata', ['affected_rows'], {
6468
6202
  where: {
6469
6203
  type: 'category_metadata_bool_exp',
6470
6204
  required: true,
6471
- value: { category_id: { _eq: categoryId }, shop: metadatas.value[i].shop },
6205
+ value: { category_id: { _eq: categoryId }, shop: metadata.value[i].shop },
6472
6206
  },
6473
6207
  });
6474
6208
  }
6475
6209
  return [];
6476
6210
  }
6477
6211
  }
6478
- async addProduct(wishlistId, productId) {
6479
- return this.categoryProductRepository.addProductToCategory(wishlistId, productId);
6480
- }
6481
- async removeProduct(wishlistId, productId) {
6482
- return this.categoryProductRepository.removeProductFromCategory(wishlistId, productId);
6483
- }
6484
6212
  }
6485
6213
  tslib.__decorate([
6486
6214
  Log(),
@@ -6500,165 +6228,6 @@ tslib.__decorate([
6500
6228
  tslib.__metadata("design:paramtypes", [String]),
6501
6229
  tslib.__metadata("design:returntype", Promise)
6502
6230
  ], WishlistHasuraGraphQLRepository.prototype, "getCategoryByShop", null);
6503
- tslib.__decorate([
6504
- Log(),
6505
- tslib.__metadata("design:type", Function),
6506
- tslib.__metadata("design:paramtypes", [Object, Array]),
6507
- tslib.__metadata("design:returntype", Promise)
6508
- ], WishlistHasuraGraphQLRepository.prototype, "findBfluOrGlamgirlWishlists", null);
6509
-
6510
- class VertexAxiosAdapter {
6511
- constructor(config) {
6512
- this.config = config;
6513
- this.logger = DebugHelper.from(this);
6514
- }
6515
- async query(term, total, gender) {
6516
- const logger = this.logger.with('query');
6517
- const req = {
6518
- url: `${this.config.url}/search`,
6519
- method: 'POST',
6520
- responseType: 'json',
6521
- headers: {
6522
- Accept: 'application/json',
6523
- },
6524
- data: { term, total, gender },
6525
- };
6526
- try {
6527
- const { data } = await axios__default["default"](req);
6528
- return data;
6529
- }
6530
- catch (error) {
6531
- logger.error({ req, res: error });
6532
- throw error;
6533
- }
6534
- }
6535
- async get(id) {
6536
- const logger = this.logger.with('update');
6537
- const req = {
6538
- url: `${this.config.url}/${id}`,
6539
- method: 'GET',
6540
- responseType: 'json',
6541
- headers: {
6542
- Accept: 'application/json',
6543
- },
6544
- };
6545
- try {
6546
- const { data } = await axios__default["default"](req);
6547
- return data;
6548
- }
6549
- catch (error) {
6550
- logger.error({ req, res: error });
6551
- throw error;
6552
- }
6553
- }
6554
- async save(data) {
6555
- const logger = this.logger.with('save');
6556
- const req = {
6557
- url: `${this.config.url}/sync`,
6558
- method: 'POST',
6559
- responseType: 'json',
6560
- headers: {
6561
- Accept: 'application/json',
6562
- },
6563
- data,
6564
- };
6565
- try {
6566
- const { data } = await axios__default["default"](req);
6567
- return data;
6568
- }
6569
- catch (error) {
6570
- logger.error({ req, res: error });
6571
- throw error;
6572
- }
6573
- }
6574
- async update(id, data) {
6575
- const logger = this.logger.with('update');
6576
- const req = {
6577
- url: `${this.config.url}/${id}`,
6578
- method: 'PUT',
6579
- responseType: 'json',
6580
- headers: {
6581
- Accept: 'application/json',
6582
- },
6583
- data,
6584
- };
6585
- try {
6586
- const { data } = await axios__default["default"](req);
6587
- return data;
6588
- }
6589
- catch (error) {
6590
- logger.error({ req, res: error });
6591
- throw error;
6592
- }
6593
- }
6594
- async delete(id) {
6595
- const logger = this.logger.with('delete');
6596
- const req = {
6597
- url: `${this.config.url}/${id}`,
6598
- method: 'DELETE',
6599
- responseType: 'json',
6600
- headers: {
6601
- Accept: 'application/json',
6602
- },
6603
- };
6604
- try {
6605
- const { data } = await axios__default["default"](req);
6606
- return data;
6607
- }
6608
- catch (error) {
6609
- logger.error({ req, res: error });
6610
- throw error;
6611
- }
6612
- }
6613
- bulkProducts(products) {
6614
- return;
6615
- }
6616
- }
6617
-
6618
- class ProductsVertexSearch {
6619
- constructor(adapter) {
6620
- this.adapter = adapter;
6621
- }
6622
- async getById(id) {
6623
- const data = await this.adapter.get(id);
6624
- return data;
6625
- }
6626
- async search(searchTerm, total, gender) {
6627
- try {
6628
- const result = await this.adapter.query(searchTerm, total, gender);
6629
- return result;
6630
- }
6631
- catch (error) {
6632
- console.error(error);
6633
- }
6634
- }
6635
- async save(product) {
6636
- try {
6637
- const _a = product.toPlain(), { createdAt, updatedAt, kitProducts } = _a, data = tslib.__rest(_a, ["createdAt", "updatedAt", "kitProducts"]);
6638
- const newProduct = Product.toInstance(data);
6639
- await this.adapter.save(newProduct);
6640
- }
6641
- catch (error) {
6642
- console.error(error);
6643
- }
6644
- }
6645
- async update(product) {
6646
- try {
6647
- await this.adapter.update(product.id, product);
6648
- }
6649
- catch (error) {
6650
- console.error(error);
6651
- }
6652
- }
6653
- async delete(id) {
6654
- try {
6655
- await this.adapter.delete(id);
6656
- }
6657
- catch (error) {
6658
- console.error(error);
6659
- }
6660
- }
6661
- }
6662
6231
 
6663
6232
  Object.defineProperty(exports, 'add', {
6664
6233
  enumerable: true,
@@ -6800,8 +6369,6 @@ exports.CategoryFilterHasuraGraphQLRepository = CategoryFilterHasuraGraphQLRepos
6800
6369
  exports.CategoryFirestoreRepository = CategoryFirestoreRepository;
6801
6370
  exports.CategoryHasuraGraphQL = CategoryHasuraGraphQL;
6802
6371
  exports.CategoryHasuraGraphQLRepository = CategoryHasuraGraphQLRepository;
6803
- exports.CategoryProduct = CategoryProduct;
6804
- exports.CategoryProductHasuraGraphQLRepository = CategoryProductHasuraGraphQLRepository;
6805
6372
  exports.Checkout = Checkout;
6806
6373
  exports.CheckoutFirestoreRepository = CheckoutFirestoreRepository;
6807
6374
  exports.CheckoutSubscription = CheckoutSubscription;
@@ -6833,13 +6400,9 @@ exports.LeadFirestoreRepository = LeadFirestoreRepository;
6833
6400
  exports.LegacyOrderFirestoreRepository = LegacyOrderFirestoreRepository;
6834
6401
  exports.LineItem = LineItem;
6835
6402
  exports.Log = Log;
6836
- exports.LogDocument = LogDocument;
6837
- exports.LogFirestoreRepository = LogFirestoreRepository;
6838
6403
  exports.Logger = Logger;
6839
6404
  exports.NotFoundError = NotFoundError;
6840
6405
  exports.Order = Order;
6841
- exports.OrderBlocked = OrderBlocked;
6842
- exports.OrderBlockedFirestoreRepository = OrderBlockedFirestoreRepository;
6843
6406
  exports.OrderFirestoreRepository = OrderFirestoreRepository;
6844
6407
  exports.Payment = Payment;
6845
6408
  exports.PaymentFirestoreRepository = PaymentFirestoreRepository;
@@ -6853,7 +6416,6 @@ exports.ProductStockNotification = ProductStockNotification;
6853
6416
  exports.ProductStockNotificationHasuraGraphQLRepository = ProductStockNotificationHasuraGraphQLRepository;
6854
6417
  exports.ProductVariantFirestoreRepository = ProductVariantFirestoreRepository;
6855
6418
  exports.ProductsIndex = ProductsIndex;
6856
- exports.ProductsVertexSearch = ProductsVertexSearch;
6857
6419
  exports.RecoveryPassword = RecoveryPassword;
6858
6420
  exports.ReflectHelper = ReflectHelper;
6859
6421
  exports.Register = Register;
@@ -6892,7 +6454,6 @@ exports.UserPaymentMethodFirestoreRepository = UserPaymentMethodFirestoreReposit
6892
6454
  exports.Variant = Variant;
6893
6455
  exports.VariantHasuraGraphQL = VariantHasuraGraphQL;
6894
6456
  exports.VariantHasuraGraphQLRepository = VariantHasuraGraphQLRepository;
6895
- exports.VertexAxiosAdapter = VertexAxiosAdapter;
6896
6457
  exports.WeakPasswordError = WeakPasswordError;
6897
6458
  exports.Wishlist = Wishlist;
6898
6459
  exports.WishlistHasuraGraphQLRepository = WishlistHasuraGraphQLRepository;