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

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 +1059 -617
  2. package/index.esm.js +1052 -618
  3. package/package.json +1 -1
  4. package/src/domain/catalog/models/category-base.d.ts +17 -1
  5. package/src/domain/catalog/models/category-product.d.ts +8 -0
  6. package/src/domain/catalog/models/enums/index.d.ts +2 -0
  7. package/src/domain/catalog/models/enums/product-label.enum.d.ts +6 -0
  8. package/src/domain/catalog/models/enums/wishlist-log.enum.d.ts +7 -0
  9. package/src/domain/catalog/models/filter.d.ts +1 -0
  10. package/src/domain/catalog/models/index.d.ts +1 -0
  11. package/src/domain/catalog/models/product-base.d.ts +4 -1
  12. package/src/domain/catalog/models/types/category-images.type.d.ts +8 -0
  13. package/src/domain/catalog/models/types/category-metadata.type.d.ts +2 -0
  14. package/src/domain/catalog/models/types/category-most-relevant.type.d.ts +4 -0
  15. package/src/domain/catalog/models/types/index.d.ts +4 -1
  16. package/src/domain/catalog/models/types/product-label.type.d.ts +2 -0
  17. package/src/domain/catalog/models/types/report-stock-notification.type.d.ts +21 -0
  18. package/src/domain/catalog/models/variant.d.ts +4 -0
  19. package/src/domain/catalog/models/wishlist.d.ts +3 -0
  20. package/src/domain/catalog/repositories/category-product.repository.d.ts +6 -0
  21. package/src/domain/catalog/repositories/category.repository.d.ts +3 -3
  22. package/src/domain/catalog/repositories/index.d.ts +1 -0
  23. package/src/domain/catalog/repositories/product-reviews.repository.d.ts +1 -0
  24. package/src/domain/catalog/repositories/product-stock-notification.repository.d.ts +9 -1
  25. package/src/domain/catalog/repositories/wishlist.repository.d.ts +6 -1
  26. package/src/domain/general/index.d.ts +3 -0
  27. package/src/domain/general/models/index.d.ts +1 -0
  28. package/src/domain/general/models/log-document.d.ts +15 -0
  29. package/src/domain/general/repositories/index.d.ts +1 -0
  30. package/src/domain/general/repositories/log.repository.d.ts +4 -0
  31. package/src/domain/general/search/index.d.ts +1 -0
  32. package/src/domain/general/search/product-search-index.d.ts +3 -0
  33. package/src/domain/shopping/index.d.ts +1 -0
  34. package/src/domain/shopping/models/buy-2-win.d.ts +2 -0
  35. package/src/domain/shopping/models/coupons/coupon.d.ts +8 -4
  36. package/src/domain/shopping/models/coupons/enums/coupon-category.enum.d.ts +41 -0
  37. package/src/domain/shopping/models/coupons/enums/coupon-channels.enum.d.ts +10 -0
  38. package/src/domain/shopping/models/coupons/enums/coupon-types.enum.d.ts +2 -1
  39. package/src/domain/shopping/models/coupons/enums/index.d.ts +3 -1
  40. package/src/domain/shopping/models/coupons/types/coupon-category.type.d.ts +2 -0
  41. package/src/domain/shopping/models/coupons/types/coupon-channel.type.d.ts +2 -0
  42. package/src/domain/shopping/models/coupons/types/index.d.ts +2 -0
  43. package/src/domain/shopping/models/index.d.ts +1 -0
  44. package/src/domain/shopping/models/order-blocked.d.ts +26 -0
  45. package/src/domain/shopping/models/order.d.ts +4 -0
  46. package/src/domain/shopping/repositories/index.d.ts +1 -0
  47. package/src/domain/shopping/repositories/order-blocked.repository.d.ts +6 -0
  48. package/src/domain/shopping/types/index.d.ts +2 -0
  49. package/src/domain/shopping/types/order-tracking-events.type.d.ts +14 -0
  50. package/src/domain/shopping/types/payment-card-info.type.d.ts +4 -0
  51. package/src/domain/users/models/enums/index.d.ts +1 -0
  52. package/src/domain/users/models/enums/person-types.enum.d.ts +5 -0
  53. package/src/domain/users/models/index.d.ts +3 -2
  54. package/src/domain/users/models/types/index.d.ts +1 -0
  55. package/src/domain/users/models/types/person.type.d.ts +2 -0
  56. package/src/infra/elasticsearch/indexes/products-index.d.ts +39 -1
  57. package/src/infra/firebase/firestore/mixins/with-helpers.mixin.d.ts +1 -1
  58. package/src/infra/firebase/firestore/repositories/catalog/category-firestore.repository.d.ts +2 -2
  59. package/src/infra/firebase/firestore/repositories/general/index.d.ts +1 -0
  60. package/src/infra/firebase/firestore/repositories/general/log-firestore.repository.d.ts +7 -0
  61. package/src/infra/firebase/firestore/repositories/index.d.ts +3 -2
  62. package/src/infra/firebase/firestore/repositories/shopping/index.d.ts +1 -0
  63. package/src/infra/firebase/firestore/repositories/shopping/order-blocked-firestore.repository.ts.d.ts +9 -0
  64. package/src/infra/hasura-graphql/mixins/with-find-hasura-graphql.mixin.d.ts +1 -0
  65. package/src/infra/hasura-graphql/models/wishlist-hasura-graphql.d.ts +4 -0
  66. package/src/infra/hasura-graphql/repositories/catalog/category-hasura-graphql.repository.d.ts +2 -2
  67. package/src/infra/hasura-graphql/repositories/catalog/category-product-hasura-graphql.repository.d.ts +11 -0
  68. package/src/infra/hasura-graphql/repositories/catalog/index.d.ts +1 -0
  69. package/src/infra/hasura-graphql/repositories/catalog/product-hasura-graphql.repository.d.ts +0 -1
  70. package/src/infra/hasura-graphql/repositories/catalog/product-review-hasura-graphql.repository.d.ts +1 -0
  71. package/src/infra/hasura-graphql/repositories/catalog/product-stock-notification-hasura-graphql.repository.d.ts +8 -1
  72. package/src/infra/hasura-graphql/repositories/catalog/wishlist-hasura-graphql.repository.d.ts +18 -15
  73. package/src/infra/index.d.ts +1 -0
  74. package/src/infra/vertex-ai/adapters/index.d.ts +2 -0
  75. package/src/infra/vertex-ai/adapters/vertex-ai-search.adapter.d.ts +10 -0
  76. package/src/infra/vertex-ai/adapters/vertex-axios.adapter.d.ts +15 -0
  77. package/src/infra/vertex-ai/index.d.ts +3 -0
  78. package/src/infra/vertex-ai/indexes/index.d.ts +1 -0
  79. package/src/infra/vertex-ai/indexes/products-vertex-search.d.ts +13 -0
  80. package/src/infra/vertex-ai/types/axios-vertex-search-config.d.ts +4 -0
  81. package/src/infra/vertex-ai/types/index.d.ts +3 -0
  82. package/src/infra/vertex-ai/types/product-bulk.d.ts +4 -0
  83. package/src/infra/vertex-ai/types/product-search.d.ts +21 -0
package/index.cjs.js CHANGED
@@ -42,6 +42,38 @@ class BaseModel {
42
42
  }
43
43
  }
44
44
 
45
+ exports.GenderDestination = void 0;
46
+ (function (GenderDestination) {
47
+ GenderDestination["FEMALE"] = "female";
48
+ GenderDestination["MALE"] = "male";
49
+ GenderDestination["UNISEX"] = "unisex";
50
+ })(exports.GenderDestination || (exports.GenderDestination = {}));
51
+
52
+ exports.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
+ exports.Shops = void 0;
61
+ (function (Shops) {
62
+ Shops["MENSMARKET"] = "mensmarket";
63
+ Shops["GLAMSHOP"] = "Glamshop";
64
+ Shops["GLAMPOINTS"] = "Glampoints";
65
+ Shops["ALL"] = "ALL";
66
+ })(exports.Shops || (exports.Shops = {}));
67
+
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
+
45
77
  class Filter extends BaseModel {
46
78
  static get identifiersFields() {
47
79
  return ['id'];
@@ -56,6 +88,33 @@ class CategoryBase extends BaseModel {
56
88
  static get identifiersFields() {
57
89
  return ['id'];
58
90
  }
91
+ 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
+ };
99
+ }
100
+ 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
+ };
108
+ }
109
+ get glamMetadata() {
110
+ return this.metadatas.find((metadata) => metadata.shop === exports.Shops.GLAMSHOP);
111
+ }
112
+ get mensMetadata() {
113
+ return this.metadatas.find((metadata) => metadata.shop === exports.Shops.MENSMARKET);
114
+ }
115
+ getMostRelevantByShop(shop) {
116
+ return this.mostRelevants && this.mostRelevants[shop] ? this.mostRelevants[shop] : [];
117
+ }
59
118
  }
60
119
  tslib.__decorate([
61
120
  classTransformer.Type(() => CategoryBase),
@@ -164,20 +223,11 @@ tslib.__decorate([
164
223
  tslib.__metadata("design:type", Category)
165
224
  ], CategoryFilter.prototype, "category", void 0);
166
225
 
167
- exports.GenderDestination = void 0;
168
- (function (GenderDestination) {
169
- GenderDestination["FEMALE"] = "female";
170
- GenderDestination["MALE"] = "male";
171
- GenderDestination["UNISEX"] = "unisex";
172
- })(exports.GenderDestination || (exports.GenderDestination = {}));
173
-
174
- exports.Shops = void 0;
175
- (function (Shops) {
176
- Shops["MENSMARKET"] = "mensmarket";
177
- Shops["GLAMSHOP"] = "Glamshop";
178
- Shops["GLAMPOINTS"] = "Glampoints";
179
- Shops["ALL"] = "ALL";
180
- })(exports.Shops || (exports.Shops = {}));
226
+ class CategoryProduct extends BaseModel {
227
+ static get identifiersFields() {
228
+ return ['categoryId', 'productId'];
229
+ }
230
+ }
181
231
 
182
232
  class FilterOption extends BaseModel {
183
233
  static get identifiersFields() {
@@ -271,6 +321,17 @@ class CampaignHashtag extends BaseModel {
271
321
  }
272
322
  }
273
323
 
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
+
274
335
  exports.AccessoryImportances = void 0;
275
336
  (function (AccessoryImportances) {
276
337
  AccessoryImportances["NOT_INTERESTED"] = "N\u00E3o tenho interesse";
@@ -447,6 +508,13 @@ exports.OfficePosition = void 0;
447
508
  OfficePosition["Director"] = "Diretor";
448
509
  })(exports.OfficePosition || (exports.OfficePosition = {}));
449
510
 
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
+
450
518
  exports.ProductSpents = void 0;
451
519
  (function (ProductSpents) {
452
520
  ProductSpents["UNTIL_50"] = "At\u00E9 R$50";
@@ -467,6 +535,12 @@ exports.UserType = void 0;
467
535
  UserType["Influencer"] = "Influencer";
468
536
  })(exports.UserType || (exports.UserType = {}));
469
537
 
538
+ class Lead extends BaseModel {
539
+ static get identifiersFields() {
540
+ return ['id'];
541
+ }
542
+ }
543
+
470
544
  class Edition extends BaseModel {
471
545
  static get identifiersFields() {
472
546
  return ['id', 'subscriptionId'];
@@ -1792,40 +1866,6 @@ const parseDateTime = (value) => {
1792
1866
  return date;
1793
1867
  };
1794
1868
 
1795
- exports.CheckoutTypes = void 0;
1796
- (function (CheckoutTypes) {
1797
- CheckoutTypes[CheckoutTypes["ECOMMERCE"] = 1] = "ECOMMERCE";
1798
- CheckoutTypes[CheckoutTypes["SUBSCRIPTION"] = 2] = "SUBSCRIPTION";
1799
- CheckoutTypes[CheckoutTypes["ALL"] = 3] = "ALL";
1800
- })(exports.CheckoutTypes || (exports.CheckoutTypes = {}));
1801
-
1802
- exports.CouponTypes = void 0;
1803
- (function (CouponTypes) {
1804
- CouponTypes[CouponTypes["ABSOLUTE"] = 1] = "ABSOLUTE";
1805
- CouponTypes[CouponTypes["PERCENTAGE"] = 2] = "PERCENTAGE";
1806
- // FINANCIAL = 1,
1807
- // PRODUCT,
1808
- // GIFTCARD,
1809
- // VOUCHER,
1810
- })(exports.CouponTypes || (exports.CouponTypes = {}));
1811
-
1812
- exports.CouponSubtypes = void 0;
1813
- (function (CouponSubtypes) {
1814
- CouponSubtypes[CouponSubtypes["ABSOLUTE"] = 1] = "ABSOLUTE";
1815
- CouponSubtypes[CouponSubtypes["PERCENTAGE"] = 2] = "PERCENTAGE";
1816
- })(exports.CouponSubtypes || (exports.CouponSubtypes = {}));
1817
-
1818
- exports.Exclusivities = void 0;
1819
- (function (Exclusivities) {
1820
- Exclusivities[Exclusivities["ALL_USERS"] = 1] = "ALL_USERS";
1821
- Exclusivities[Exclusivities["SPECIFIC_USER"] = 2] = "SPECIFIC_USER";
1822
- Exclusivities[Exclusivities["COLLABORATORS"] = 3] = "COLLABORATORS";
1823
- Exclusivities[Exclusivities["ACTIVE_SUBSCRIBER"] = 4] = "ACTIVE_SUBSCRIBER";
1824
- Exclusivities[Exclusivities["INACTIVE_SUBSCRIBER"] = 5] = "INACTIVE_SUBSCRIBER";
1825
- Exclusivities[Exclusivities["NON_SUBSCRIBER"] = 6] = "NON_SUBSCRIBER";
1826
- })(exports.Exclusivities || (exports.Exclusivities = {}));
1827
-
1828
- const COUPON_EXPIRATION = +1000 * 60 * 60 * 24 * 30;
1829
1869
  class Coupon extends BaseModel {
1830
1870
  get isInfluencer() {
1831
1871
  return !lodash.isNil(this.influencerEmail);
@@ -1833,30 +1873,6 @@ class Coupon extends BaseModel {
1833
1873
  static get identifiersFields() {
1834
1874
  return ['id'];
1835
1875
  }
1836
- static createCoupon(userId) {
1837
- return this.toInstance({
1838
- nickname: `${Date.now()}`,
1839
- checkoutType: exports.CheckoutTypes.ECOMMERCE,
1840
- discount: {
1841
- subscriber: {
1842
- type: exports.CouponTypes.ABSOLUTE,
1843
- value: 10,
1844
- },
1845
- non_subscriber: {
1846
- type: exports.CouponTypes.ABSOLUTE,
1847
- value: 10,
1848
- },
1849
- subscription: {
1850
- type: exports.CouponTypes.ABSOLUTE,
1851
- value: 10,
1852
- },
1853
- },
1854
- user: userId,
1855
- createdAt: new Date(Date.now()),
1856
- beginAt: new Date(Date.now()),
1857
- expiresIn: new Date(Date.now() + COUPON_EXPIRATION),
1858
- });
1859
- }
1860
1876
  }
1861
1877
 
1862
1878
  class SubscriptionPlan extends BaseModel {
@@ -1865,17 +1881,6 @@ class SubscriptionPlan extends BaseModel {
1865
1881
  }
1866
1882
  }
1867
1883
 
1868
- class BeautyProfile extends BaseModel {
1869
- toPlain() {
1870
- const plain = super.toPlain();
1871
- delete plain.id;
1872
- return plain;
1873
- }
1874
- static get identifiersFields() {
1875
- return ['id', 'userId'];
1876
- }
1877
- }
1878
-
1879
1884
  class User extends BaseModel {
1880
1885
  static toInstance(data) {
1881
1886
  const instance = super.toInstance(data);
@@ -1989,12 +1994,6 @@ class UserPaymentMethod extends BaseModel {
1989
1994
  }
1990
1995
  }
1991
1996
 
1992
- class Lead extends BaseModel {
1993
- static get identifiersFields() {
1994
- return ['id'];
1995
- }
1996
- }
1997
-
1998
1997
  class UnauthorizedError extends tsCustomError.CustomError {
1999
1998
  constructor(message) {
2000
1999
  super(message);
@@ -2148,6 +2147,93 @@ tslib.__decorate([
2148
2147
  tslib.__metadata("design:type", Coupon)
2149
2148
  ], Checkout.prototype, "coupon", void 0);
2150
2149
 
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
+
2151
2237
  exports.OrderStatus = void 0;
2152
2238
  (function (OrderStatus) {
2153
2239
  OrderStatus["AGUARDANDO_PAGAMENTO"] = "Aguardando pagamento";
@@ -2167,6 +2253,12 @@ tslib.__decorate([
2167
2253
  tslib.__metadata("design:type", Payment)
2168
2254
  ], Order.prototype, "payment", void 0);
2169
2255
 
2256
+ class OrderBlocked extends BaseModel {
2257
+ static get identifiersFields() {
2258
+ return ['id'];
2259
+ }
2260
+ }
2261
+
2170
2262
  class CheckoutSubscription extends BaseModel {
2171
2263
  static get identifiersFields() {
2172
2264
  return ['id'];
@@ -2203,6 +2295,12 @@ class RoundProductPricesHelper {
2203
2295
  }
2204
2296
  }
2205
2297
 
2298
+ class LogDocument extends BaseModel {
2299
+ static get identifiersFields() {
2300
+ return ['id'];
2301
+ }
2302
+ }
2303
+
2206
2304
  exports.FilterType = void 0;
2207
2305
  (function (FilterType) {
2208
2306
  FilterType["ACCESSORY_IMPORTANCE"] = "accessoryImportance";
@@ -2501,8 +2599,6 @@ class ProductsIndex {
2501
2599
  'rate',
2502
2600
  ];
2503
2601
  const filter = [{ term: { published: true } }];
2504
- if (shop && shop !== exports.Shops.ALL)
2505
- filter.push({ term: { tags: shop == exports.Shops.GLAMSHOP ? 'feminino' : 'masculino' } });
2506
2602
  if (size > 9)
2507
2603
  fields.push(...['pricePaid', 'isGift', 'stock', 'weight', 'tags']);
2508
2604
  const query = {
@@ -2558,7 +2654,9 @@ class ProductsIndex {
2558
2654
  RoundProductPricesHelper.roundProductPrices(hit._source);
2559
2655
  return hit;
2560
2656
  });
2561
- return search;
2657
+ return search.hits.map((hit) => {
2658
+ return Object.assign(Object.assign({}, hit._source), { stock: hit._source.stock.quantity });
2659
+ });
2562
2660
  }
2563
2661
  async save(product) {
2564
2662
  try {
@@ -2992,6 +3090,8 @@ const withUpdateFirestore = (MixinBase) => {
2992
3090
  try {
2993
3091
  const identifiers = getValueFromParams(data, keyField);
2994
3092
  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`);
2995
3095
  const plainFromData = this.model.toInstance(this.paramsToPlain(data));
2996
3096
  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 }));
2997
3097
  const builded = (intercepted === null || intercepted === void 0 ? void 0 : intercepted.instance) || plainFromData;
@@ -3068,278 +3168,104 @@ const withCrudFirestore = (MixinBase) => {
3068
3168
  };
3069
3169
  };
3070
3170
 
3071
- class LeadFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3171
+ class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3072
3172
  constructor({ firestore, interceptors }) {
3073
3173
  super({
3074
3174
  firestore,
3075
- collectionName: 'leads',
3076
- model: Lead,
3175
+ collectionName: 'categories',
3176
+ model: Category,
3077
3177
  interceptors,
3078
3178
  });
3079
3179
  }
3080
- }
3081
-
3082
- class SubscriptionEditionFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
3083
- constructor({ firestore, interceptors }, parentRepository) {
3084
- super({
3085
- firestore,
3086
- collectionName: 'editions',
3087
- parentIdField: 'subscriptionId',
3088
- model: Edition,
3089
- interceptors,
3090
- });
3091
- this.parentRepository = parentRepository;
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;
3236
+ }
3237
+ isChild(id, parentId) {
3238
+ return;
3092
3239
  }
3093
3240
  }
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);
3094
3259
 
3095
- class SubscriptionFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3096
- constructor({ firestore, interceptors, }) {
3260
+ class ProductFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3261
+ constructor({ firestore, interceptors }) {
3097
3262
  super({
3098
3263
  firestore,
3099
- collectionName: 'subscription',
3100
- model: Subscription,
3264
+ collectionName: 'productsErpVitrine',
3265
+ model: Product,
3101
3266
  interceptors,
3102
3267
  });
3103
- }
3104
- }
3105
-
3106
- class SubscriptionMaterializationFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3107
- constructor({ firestore, interceptors }) {
3108
- super({
3109
- firestore,
3110
- collectionName: 'subscriptionMaterialization',
3111
- model: SubscriptionMaterialization,
3112
- interceptors,
3113
- });
3114
- }
3115
- }
3116
-
3117
- class SubscriptionPaymentFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
3118
- constructor({ firestore, interceptors }, parentRepository) {
3119
- super({
3120
- firestore,
3121
- collectionName: 'payments',
3122
- parentIdField: 'subscriptionId',
3123
- model: SubscriptionPayment,
3124
- interceptors,
3125
- });
3126
- this.parentRepository = parentRepository;
3127
- }
3128
- }
3129
-
3130
- class SubscriptionSummaryFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3131
- constructor({ firestore, interceptors, }) {
3132
- super({
3133
- firestore,
3134
- collectionName: 'subscriptionSummary',
3135
- model: SubscriptionSummary,
3136
- interceptors,
3137
- });
3138
- }
3139
- }
3140
-
3141
- class UserAddressFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
3142
- constructor({ firestore, interceptors }, parentRepository) {
3143
- super({
3144
- firestore,
3145
- collectionName: 'address',
3146
- parentIdField: 'userId',
3147
- model: UserAddress,
3148
- interceptors,
3149
- });
3150
- this.parentRepository = parentRepository;
3151
- }
3152
- }
3153
-
3154
- class UserBeautyProfileFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
3155
- constructor({ firestore, interceptors }, parentRepository) {
3156
- super({
3157
- firestore,
3158
- collectionName: 'CX',
3159
- parentIdField: 'userId',
3160
- model: BeautyProfile,
3161
- interceptors,
3162
- });
3163
- this.parentRepository = parentRepository;
3164
- }
3165
- }
3166
-
3167
- class UserFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3168
- constructor({ firestore, interceptors }) {
3169
- super({
3170
- firestore,
3171
- collectionName: 'users',
3172
- model: User,
3173
- interceptors,
3174
- });
3175
- }
3176
- async get(identifiers) {
3177
- const user = await super.get({ id: identifiers.id });
3178
- user.beautyProfile = await this.getBeautyProfile(user.id);
3179
- user.isSubscriber = await this.checkIfIsSubscriber(user.id);
3180
- return user;
3181
- }
3182
- async checkIfExistsByField(field, value) {
3183
- const result = await this.find({ filters: { [field]: value } });
3184
- return result.count > 0;
3185
- }
3186
- buildModelInstance() {
3187
- const { fromFirestore, toFirestore } = super.buildModelInstance();
3188
- return {
3189
- toFirestore: (data) => {
3190
- const plain = toFirestore(data);
3191
- delete plain.isSubscriber;
3192
- return plain;
3193
- },
3194
- fromFirestore,
3195
- };
3196
- }
3197
- async getBeautyProfile(userId) {
3198
- const beautyProfile = await this.firestore
3199
- .getCollection(`${this.collectionName}/${userId}/CX`)
3200
- .withConverter(this.buildBeautyProfileModelInstance())
3201
- .getDoc('beautyProfile')
3202
- .get();
3203
- return beautyProfile.data();
3204
- }
3205
- async checkIfIsSubscriber(userId) {
3206
- const docs = await this.collection('subscription')
3207
- .where('user.id', '==', userId)
3208
- .where('status', '==', 'active')
3209
- .getDocs();
3210
- return !!docs && !!docs.size;
3211
- }
3212
- buildBeautyProfileModelInstance() {
3213
- return {
3214
- toFirestore: (data) => data.toPlain(),
3215
- fromFirestore: (snap) => BeautyProfile.toInstance(snap.data()),
3216
- };
3217
- }
3218
- }
3219
- tslib.__decorate([
3220
- Log(),
3221
- tslib.__metadata("design:type", Function),
3222
- tslib.__metadata("design:paramtypes", [Object]),
3223
- tslib.__metadata("design:returntype", Promise)
3224
- ], UserFirestoreRepository.prototype, "get", null);
3225
- tslib.__decorate([
3226
- Log(),
3227
- tslib.__metadata("design:type", Function),
3228
- tslib.__metadata("design:paramtypes", [String, String]),
3229
- tslib.__metadata("design:returntype", Promise)
3230
- ], UserFirestoreRepository.prototype, "checkIfExistsByField", null);
3231
-
3232
- class UserPaymentMethodFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
3233
- constructor({ firestore, interceptors }, parentRepository) {
3234
- super({
3235
- firestore,
3236
- collectionName: 'payment_method',
3237
- parentIdField: 'userId',
3238
- model: UserPaymentMethod,
3239
- interceptors,
3240
- });
3241
- this.parentRepository = parentRepository;
3242
- }
3243
- }
3244
-
3245
- class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3246
- constructor({ firestore, interceptors }) {
3247
- super({
3248
- firestore,
3249
- collectionName: 'categories',
3250
- model: Category,
3251
- interceptors,
3252
- });
3253
- }
3254
- async getCategoryBySlug(slug, shop) {
3255
- const categoryDocs = await this.collection(this.collectionName)
3256
- .where('slug', '==', slug)
3257
- .where('shop', '==', shop)
3258
- .where('published', '==', true)
3259
- .getDocs();
3260
- if (categoryDocs.size > 1)
3261
- throw new DuplicatedResultsError('Query returned duplicated values');
3262
- if (categoryDocs.empty)
3263
- throw new NotFoundError(`Document with slug ${slug} not found`);
3264
- return categoryDocs.docs[0].data();
3265
- }
3266
- async getCategoriesForHome(categoryIds, limit = 4, gender) {
3267
- const categorySnap = await this.collection(this.collectionName)
3268
- .where('id', 'in', categoryIds.filter(Boolean))
3269
- .where('published', '==', true)
3270
- .getDocs();
3271
- if (categorySnap.empty)
3272
- throw new NotFoundError('Categories not found');
3273
- const categories = categorySnap.docs.map((doc) => doc.data());
3274
- const homeSections = await Promise.all(categories.map(async (category) => ({
3275
- category,
3276
- products: await this.mountCategory(category, { limit, hasStock: true, gender }),
3277
- })));
3278
- return homeSections;
3279
- }
3280
- async mountCategory(category, options) {
3281
- if (!category.products)
3282
- throw new RequiredArgumentError(['Category products is empty']);
3283
- const chunks = lodash.chunk(category.products, 10);
3284
- const products = [];
3285
- const wheres = [];
3286
- for (const productIds of chunks) {
3287
- if ((options === null || options === void 0 ? void 0 : options.limit) && products.length >= (options === null || options === void 0 ? void 0 : options.limit))
3288
- break;
3289
- wheres.push(['published', '==', true], ['id', 'in', productIds]);
3290
- if (options === null || options === void 0 ? void 0 : options.hasStock)
3291
- wheres.push(['stock.quantity', '>', 0]);
3292
- if (options === null || options === void 0 ? void 0 : options.gender)
3293
- wheres.push(['tags', 'array-contains', options === null || options === void 0 ? void 0 : options.gender]);
3294
- const productSnap = await wheres
3295
- .reduce((collection, where) => collection.where(...where), (options === null || options === void 0 ? void 0 : options.limit)
3296
- ? this.collection('productsErpVitrine').limit(options.limit)
3297
- : this.collection('productsErpVitrine'))
3298
- .getDocs();
3299
- if (productSnap.empty)
3300
- continue;
3301
- products.push(...productSnap.docs);
3302
- }
3303
- return is(products);
3304
- }
3305
- getCategoryByShop(shop) {
3306
- return;
3307
- }
3308
- getChildren(parentId) {
3309
- return;
3310
- }
3311
- isChild(id, parentId) {
3312
- return;
3313
- }
3314
- }
3315
- tslib.__decorate([
3316
- Log(),
3317
- tslib.__metadata("design:type", Function),
3318
- tslib.__metadata("design:paramtypes", [String, String]),
3319
- tslib.__metadata("design:returntype", Promise)
3320
- ], CategoryFirestoreRepository.prototype, "getCategoryBySlug", null);
3321
- tslib.__decorate([
3322
- Log(),
3323
- tslib.__metadata("design:type", Function),
3324
- tslib.__metadata("design:paramtypes", [Array, Object, String]),
3325
- tslib.__metadata("design:returntype", Promise)
3326
- ], CategoryFirestoreRepository.prototype, "getCategoriesForHome", null);
3327
- tslib.__decorate([
3328
- Log(),
3329
- tslib.__metadata("design:type", Function),
3330
- tslib.__metadata("design:paramtypes", [Category, Object]),
3331
- tslib.__metadata("design:returntype", Promise)
3332
- ], CategoryFirestoreRepository.prototype, "mountCategory", null);
3333
-
3334
- class ProductFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3335
- constructor({ firestore, interceptors }) {
3336
- super({
3337
- firestore,
3338
- collectionName: 'productsErpVitrine',
3339
- model: Product,
3340
- interceptors,
3341
- });
3342
- this.reviews = {};
3268
+ this.reviews = {};
3343
3269
  }
3344
3270
  fetchProductReviews(filters) {
3345
3271
  throw new Error('Method not implemented.');
@@ -3426,6 +3352,101 @@ class SubscriptionProductFirestoreRepository extends withCrudFirestore(withHelpe
3426
3352
  }
3427
3353
  }
3428
3354
 
3355
+ class LogFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3356
+ constructor({ firestore, interceptors, }) {
3357
+ super({
3358
+ firestore,
3359
+ collectionName: 'logs',
3360
+ model: LogDocument,
3361
+ interceptors,
3362
+ });
3363
+ }
3364
+ }
3365
+
3366
+ class HomeFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3367
+ constructor({ firestore, interceptors }) {
3368
+ super({
3369
+ firestore,
3370
+ collectionName: 'dms',
3371
+ model: Home,
3372
+ interceptors,
3373
+ });
3374
+ this.homeCategoryGroupToPlain = (homeCategoryGroup) => {
3375
+ var _a, _b, _c;
3376
+ return ({
3377
+ category: ((_a = homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category) === null || _a === void 0 ? void 0 : _a.toPlain)
3378
+ ? (_b = homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category) === null || _b === void 0 ? void 0 : _b.toPlain()
3379
+ : homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category,
3380
+ 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)) || [],
3381
+ });
3382
+ };
3383
+ this.plainToHomeCategoryGroup = (homeCategoryGroup) => {
3384
+ var _a;
3385
+ return ({
3386
+ category: Category.toInstance(homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category),
3387
+ products: (_a = homeCategoryGroup.products) === null || _a === void 0 ? void 0 : _a.map((product) => Product.toInstance(product)),
3388
+ });
3389
+ };
3390
+ }
3391
+ buildModelInstance() {
3392
+ const { fromFirestore, toFirestore } = super.buildModelInstance();
3393
+ return {
3394
+ toFirestore: (data) => {
3395
+ const modifiedData = this.homeToFirestore(data);
3396
+ return toFirestore(modifiedData);
3397
+ },
3398
+ fromFirestore: (snap) => {
3399
+ const instance = fromFirestore(snap);
3400
+ return this.homeFromFirestore(instance);
3401
+ },
3402
+ };
3403
+ }
3404
+ homeToFirestore(home) {
3405
+ var _a, _b, _c, _d;
3406
+ if ((_a = home.data) === null || _a === void 0 ? void 0 : _a.data) {
3407
+ home.data.data.discoverProducts = ((_b = home.data.data.discoverProducts) === null || _b === void 0 ? void 0 : _b.map(this.homeCategoryGroupToPlain)) || [];
3408
+ home.data.data.featuredProducts = ((_c = home.data.data.featuredProducts) === null || _c === void 0 ? void 0 : _c.map(this.homeCategoryGroupToPlain)) || [];
3409
+ home.data.data.verticalProducts = ((_d = home.data.data.verticalProducts) === null || _d === void 0 ? void 0 : _d.map(this.homeCategoryGroupToPlain)) || [];
3410
+ }
3411
+ return home;
3412
+ }
3413
+ homeFromFirestore(home) {
3414
+ var _a;
3415
+ if ((_a = home.data) === null || _a === void 0 ? void 0 : _a.data) {
3416
+ home.data.data.discoverProducts = home.data.data.discoverProducts.map(this.plainToHomeCategoryGroup);
3417
+ home.data.data.featuredProducts = home.data.data.featuredProducts.map(this.plainToHomeCategoryGroup);
3418
+ home.data.data.verticalProducts = home.data.data.verticalProducts.map(this.plainToHomeCategoryGroup);
3419
+ home.data.createdAt =
3420
+ home.data.createdAt instanceof firestore.Timestamp ? home.data.createdAt.toDate() : home.data.createdAt;
3421
+ home.data.expiresAt =
3422
+ home.data.expiresAt instanceof firestore.Timestamp ? home.data.expiresAt.toDate() : home.data.expiresAt;
3423
+ }
3424
+ return home;
3425
+ }
3426
+ }
3427
+
3428
+ class ShopMenuFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3429
+ constructor({ firestore, interceptors }) {
3430
+ super({
3431
+ firestore,
3432
+ collectionName: 'shopMenus',
3433
+ model: ShopMenu,
3434
+ interceptors,
3435
+ });
3436
+ }
3437
+ }
3438
+
3439
+ class ShopSettingsFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3440
+ constructor({ firestore, interceptors, }) {
3441
+ super({
3442
+ firestore,
3443
+ collectionName: 'shopSettings',
3444
+ model: ShopSettings,
3445
+ interceptors,
3446
+ });
3447
+ }
3448
+ }
3449
+
3429
3450
  class Buy2WinFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3430
3451
  constructor({ firestore, interceptors }) {
3431
3452
  super({
@@ -3513,152 +3534,283 @@ class OrderFirestoreRepository extends withCrudFirestore(withHelpers(withFiresto
3513
3534
  constructor({ firestore, interceptors }) {
3514
3535
  super({
3515
3536
  firestore,
3516
- collectionName: 'orders',
3517
- model: Order,
3537
+ collectionName: 'orders',
3538
+ model: Order,
3539
+ interceptors,
3540
+ fields: {
3541
+ status: FirestoreFieldType.String,
3542
+ },
3543
+ });
3544
+ this.orderFromFirestore = (order) => {
3545
+ var _a;
3546
+ if (!!((_a = order === null || order === void 0 ? void 0 : order.lineItems) === null || _a === void 0 ? void 0 : _a.length)) {
3547
+ order.lineItems = order.lineItems.map((lineItem) => {
3548
+ const prices = !!lineItem.price;
3549
+ const shopPrice = prices[order.shop];
3550
+ if (!!shopPrice)
3551
+ lineItem.price = shopPrice;
3552
+ return lineItem;
3553
+ });
3554
+ }
3555
+ return order;
3556
+ };
3557
+ }
3558
+ buildModelInstance() {
3559
+ const { fromFirestore, toFirestore } = super.buildModelInstance();
3560
+ return {
3561
+ toFirestore: (data) => toFirestore((data === null || data === void 0 ? void 0 : data.toPlain) ? data.toPlain() : data),
3562
+ fromFirestore: (snap) => {
3563
+ const instance = fromFirestore(snap);
3564
+ return this.orderFromFirestore(instance);
3565
+ },
3566
+ };
3567
+ }
3568
+ }
3569
+
3570
+ class LegacyOrderFirestoreRepository extends OrderFirestoreRepository {
3571
+ constructor({ firestore, interceptors }) {
3572
+ super({
3573
+ firestore,
3574
+ interceptors,
3575
+ });
3576
+ this.collectionName = 'legacyOrders';
3577
+ }
3578
+ }
3579
+
3580
+ class OrderBlockedFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3581
+ constructor({ firestore, interceptors, }) {
3582
+ super({
3583
+ firestore,
3584
+ collectionName: 'paymentBlockedAttempts',
3585
+ model: OrderBlocked,
3586
+ interceptors,
3587
+ });
3588
+ }
3589
+ async createBlockedOrderOrPayment(checkout, blockType, type, limiteRange, card = null) {
3590
+ var _a, _b, _c, _d, _e, _f, _g, _h;
3591
+ return this.create(OrderBlocked.toInstance({
3592
+ customer: {
3593
+ name: ((_a = checkout.user) === null || _a === void 0 ? void 0 : _a.displayName) || '',
3594
+ cpf: ((_b = checkout.user) === null || _b === void 0 ? void 0 : _b.cpf) || '',
3595
+ id: (_c = checkout.user) === null || _c === void 0 ? void 0 : _c.id,
3596
+ email: ((_d = checkout.user) === null || _d === void 0 ? void 0 : _d.email) || '',
3597
+ phoneNumber: '+55' + ((_e = checkout.user) === null || _e === void 0 ? void 0 : _e.phone),
3598
+ isSubscriber: (_f = checkout.user) === null || _f === void 0 ? void 0 : _f.isSubscriber,
3599
+ subscriptionPlan: ((_g = checkout.user) === null || _g === void 0 ? void 0 : _g.subscriptionPlan) || '',
3600
+ shippingAddress: Object.assign(Object.assign({}, checkout.shippingAddress), { zip: this.formatZip((_h = checkout.shippingAddress) === null || _h === void 0 ? void 0 : _h.zip) }),
3601
+ },
3602
+ blockType,
3603
+ limiteRange,
3604
+ type,
3605
+ card,
3606
+ checkout: {
3607
+ id: checkout.id,
3608
+ shop: checkout.shop,
3609
+ total: checkout.totalPrice,
3610
+ },
3611
+ date: new Date(),
3612
+ }));
3613
+ }
3614
+ formatZip(zip) {
3615
+ if (zip.length === 8)
3616
+ return zip.substring(0, 5) + '-' + zip.substring(5, 8);
3617
+ return zip;
3618
+ }
3619
+ }
3620
+
3621
+ class PaymentFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3622
+ constructor({ firestore, interceptors }) {
3623
+ super({
3624
+ firestore,
3625
+ collectionName: 'payments',
3626
+ model: Payment,
3627
+ interceptors,
3628
+ });
3629
+ }
3630
+ }
3631
+
3632
+ class SubscriptionPlanFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3633
+ constructor({ firestore, interceptors, }) {
3634
+ super({
3635
+ firestore,
3636
+ collectionName: 'subscriptionPlans',
3637
+ model: SubscriptionPlan,
3638
+ interceptors,
3639
+ });
3640
+ }
3641
+ }
3642
+
3643
+ class LeadFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3644
+ constructor({ firestore, interceptors }) {
3645
+ super({
3646
+ firestore,
3647
+ collectionName: 'leads',
3648
+ model: Lead,
3649
+ interceptors,
3650
+ });
3651
+ }
3652
+ }
3653
+
3654
+ class SubscriptionEditionFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
3655
+ constructor({ firestore, interceptors }, parentRepository) {
3656
+ super({
3657
+ firestore,
3658
+ collectionName: 'editions',
3659
+ parentIdField: 'subscriptionId',
3660
+ model: Edition,
3661
+ interceptors,
3662
+ });
3663
+ this.parentRepository = parentRepository;
3664
+ }
3665
+ }
3666
+
3667
+ class SubscriptionFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3668
+ constructor({ firestore, interceptors, }) {
3669
+ super({
3670
+ firestore,
3671
+ collectionName: 'subscription',
3672
+ model: Subscription,
3673
+ interceptors,
3674
+ });
3675
+ }
3676
+ }
3677
+
3678
+ class SubscriptionMaterializationFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3679
+ constructor({ firestore, interceptors }) {
3680
+ super({
3681
+ firestore,
3682
+ collectionName: 'subscriptionMaterialization',
3683
+ model: SubscriptionMaterialization,
3684
+ interceptors,
3685
+ });
3686
+ }
3687
+ }
3688
+
3689
+ class SubscriptionPaymentFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
3690
+ constructor({ firestore, interceptors }, parentRepository) {
3691
+ super({
3692
+ firestore,
3693
+ collectionName: 'payments',
3694
+ parentIdField: 'subscriptionId',
3695
+ model: SubscriptionPayment,
3518
3696
  interceptors,
3519
- fields: {
3520
- status: FirestoreFieldType.String,
3521
- },
3522
3697
  });
3523
- this.orderFromFirestore = (order) => {
3524
- var _a;
3525
- if (!!((_a = order === null || order === void 0 ? void 0 : order.lineItems) === null || _a === void 0 ? void 0 : _a.length)) {
3526
- order.lineItems = order.lineItems.map((lineItem) => {
3527
- const prices = !!lineItem.price;
3528
- const shopPrice = prices[order.shop];
3529
- if (!!shopPrice)
3530
- lineItem.price = shopPrice;
3531
- return lineItem;
3532
- });
3533
- }
3534
- return order;
3535
- };
3536
- }
3537
- buildModelInstance() {
3538
- const { fromFirestore, toFirestore } = super.buildModelInstance();
3539
- return {
3540
- toFirestore: (data) => toFirestore((data === null || data === void 0 ? void 0 : data.toPlain) ? data.toPlain() : data),
3541
- fromFirestore: (snap) => {
3542
- const instance = fromFirestore(snap);
3543
- return this.orderFromFirestore(instance);
3544
- },
3545
- };
3698
+ this.parentRepository = parentRepository;
3546
3699
  }
3547
3700
  }
3548
3701
 
3549
- class LegacyOrderFirestoreRepository extends OrderFirestoreRepository {
3550
- constructor({ firestore, interceptors }) {
3702
+ class SubscriptionSummaryFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3703
+ constructor({ firestore, interceptors, }) {
3551
3704
  super({
3552
3705
  firestore,
3706
+ collectionName: 'subscriptionSummary',
3707
+ model: SubscriptionSummary,
3553
3708
  interceptors,
3554
3709
  });
3555
- this.collectionName = 'legacyOrders';
3556
3710
  }
3557
3711
  }
3558
3712
 
3559
- class PaymentFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3560
- constructor({ firestore, interceptors }) {
3713
+ class UserAddressFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
3714
+ constructor({ firestore, interceptors }, parentRepository) {
3561
3715
  super({
3562
3716
  firestore,
3563
- collectionName: 'payments',
3564
- model: Payment,
3717
+ collectionName: 'address',
3718
+ parentIdField: 'userId',
3719
+ model: UserAddress,
3565
3720
  interceptors,
3566
3721
  });
3722
+ this.parentRepository = parentRepository;
3567
3723
  }
3568
3724
  }
3569
3725
 
3570
- class SubscriptionPlanFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3571
- constructor({ firestore, interceptors, }) {
3726
+ class UserBeautyProfileFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
3727
+ constructor({ firestore, interceptors }, parentRepository) {
3572
3728
  super({
3573
3729
  firestore,
3574
- collectionName: 'subscriptionPlans',
3575
- model: SubscriptionPlan,
3730
+ collectionName: 'CX',
3731
+ parentIdField: 'userId',
3732
+ model: BeautyProfile,
3576
3733
  interceptors,
3577
3734
  });
3735
+ this.parentRepository = parentRepository;
3578
3736
  }
3579
3737
  }
3580
3738
 
3581
- class HomeFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3739
+ class UserFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3582
3740
  constructor({ firestore, interceptors }) {
3583
3741
  super({
3584
3742
  firestore,
3585
- collectionName: 'dms',
3586
- model: Home,
3743
+ collectionName: 'users',
3744
+ model: User,
3587
3745
  interceptors,
3588
3746
  });
3589
- this.homeCategoryGroupToPlain = (homeCategoryGroup) => {
3590
- var _a, _b, _c;
3591
- return ({
3592
- category: ((_a = homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category) === null || _a === void 0 ? void 0 : _a.toPlain)
3593
- ? (_b = homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category) === null || _b === void 0 ? void 0 : _b.toPlain()
3594
- : homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category,
3595
- products: ((_c = homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.products) === null || _c === void 0 ? void 0 : _c.map((product) => ((product === null || product === void 0 ? void 0 : product.toPlain) ? product === null || product === void 0 ? void 0 : product.toPlain() : product)).filter(Boolean)) || [],
3596
- });
3597
- };
3598
- this.plainToHomeCategoryGroup = (homeCategoryGroup) => {
3599
- var _a;
3600
- return ({
3601
- category: Category.toInstance(homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category),
3602
- products: (_a = homeCategoryGroup.products) === null || _a === void 0 ? void 0 : _a.map((product) => Product.toInstance(product)),
3603
- });
3604
- };
3747
+ }
3748
+ async get(identifiers) {
3749
+ const user = await super.get({ id: identifiers.id });
3750
+ user.beautyProfile = await this.getBeautyProfile(user.id);
3751
+ user.isSubscriber = await this.checkIfIsSubscriber(user.id);
3752
+ return user;
3753
+ }
3754
+ async checkIfExistsByField(field, value) {
3755
+ const result = await this.find({ filters: { [field]: value } });
3756
+ return result.count > 0;
3605
3757
  }
3606
3758
  buildModelInstance() {
3607
3759
  const { fromFirestore, toFirestore } = super.buildModelInstance();
3608
3760
  return {
3609
3761
  toFirestore: (data) => {
3610
- const modifiedData = this.homeToFirestore(data);
3611
- return toFirestore(modifiedData);
3612
- },
3613
- fromFirestore: (snap) => {
3614
- const instance = fromFirestore(snap);
3615
- return this.homeFromFirestore(instance);
3762
+ const plain = toFirestore(data);
3763
+ delete plain.isSubscriber;
3764
+ return plain;
3616
3765
  },
3766
+ fromFirestore,
3617
3767
  };
3618
3768
  }
3619
- homeToFirestore(home) {
3620
- var _a, _b, _c, _d;
3621
- if ((_a = home.data) === null || _a === void 0 ? void 0 : _a.data) {
3622
- home.data.data.discoverProducts = ((_b = home.data.data.discoverProducts) === null || _b === void 0 ? void 0 : _b.map(this.homeCategoryGroupToPlain)) || [];
3623
- home.data.data.featuredProducts = ((_c = home.data.data.featuredProducts) === null || _c === void 0 ? void 0 : _c.map(this.homeCategoryGroupToPlain)) || [];
3624
- home.data.data.verticalProducts = ((_d = home.data.data.verticalProducts) === null || _d === void 0 ? void 0 : _d.map(this.homeCategoryGroupToPlain)) || [];
3625
- }
3626
- return home;
3769
+ async getBeautyProfile(userId) {
3770
+ const beautyProfile = await this.firestore
3771
+ .getCollection(`${this.collectionName}/${userId}/CX`)
3772
+ .withConverter(this.buildBeautyProfileModelInstance())
3773
+ .getDoc('beautyProfile')
3774
+ .get();
3775
+ return beautyProfile.data();
3627
3776
  }
3628
- homeFromFirestore(home) {
3629
- var _a;
3630
- if ((_a = home.data) === null || _a === void 0 ? void 0 : _a.data) {
3631
- home.data.data.discoverProducts = home.data.data.discoverProducts.map(this.plainToHomeCategoryGroup);
3632
- home.data.data.featuredProducts = home.data.data.featuredProducts.map(this.plainToHomeCategoryGroup);
3633
- home.data.data.verticalProducts = home.data.data.verticalProducts.map(this.plainToHomeCategoryGroup);
3634
- home.data.createdAt =
3635
- home.data.createdAt instanceof firestore.Timestamp ? home.data.createdAt.toDate() : home.data.createdAt;
3636
- home.data.expiresAt =
3637
- home.data.expiresAt instanceof firestore.Timestamp ? home.data.expiresAt.toDate() : home.data.expiresAt;
3638
- }
3639
- return home;
3777
+ async checkIfIsSubscriber(userId) {
3778
+ const docs = await this.collection('subscription')
3779
+ .where('user.id', '==', userId)
3780
+ .where('status', '==', 'active')
3781
+ .getDocs();
3782
+ return !!docs && !!docs.size;
3640
3783
  }
3641
- }
3642
-
3643
- class ShopMenuFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3644
- constructor({ firestore, interceptors }) {
3645
- super({
3646
- firestore,
3647
- collectionName: 'shopMenus',
3648
- model: ShopMenu,
3649
- interceptors,
3650
- });
3784
+ buildBeautyProfileModelInstance() {
3785
+ return {
3786
+ toFirestore: (data) => data.toPlain(),
3787
+ fromFirestore: (snap) => BeautyProfile.toInstance(snap.data()),
3788
+ };
3651
3789
  }
3652
3790
  }
3791
+ tslib.__decorate([
3792
+ Log(),
3793
+ tslib.__metadata("design:type", Function),
3794
+ tslib.__metadata("design:paramtypes", [Object]),
3795
+ tslib.__metadata("design:returntype", Promise)
3796
+ ], UserFirestoreRepository.prototype, "get", null);
3797
+ tslib.__decorate([
3798
+ Log(),
3799
+ tslib.__metadata("design:type", Function),
3800
+ tslib.__metadata("design:paramtypes", [String, String]),
3801
+ tslib.__metadata("design:returntype", Promise)
3802
+ ], UserFirestoreRepository.prototype, "checkIfExistsByField", null);
3653
3803
 
3654
- class ShopSettingsFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3655
- constructor({ firestore, interceptors, }) {
3804
+ class UserPaymentMethodFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
3805
+ constructor({ firestore, interceptors }, parentRepository) {
3656
3806
  super({
3657
3807
  firestore,
3658
- collectionName: 'shopSettings',
3659
- model: ShopSettings,
3808
+ collectionName: 'payment_method',
3809
+ parentIdField: 'userId',
3810
+ model: UserPaymentMethod,
3660
3811
  interceptors,
3661
3812
  });
3813
+ this.parentRepository = parentRepository;
3662
3814
  }
3663
3815
  }
3664
3816
 
@@ -4211,7 +4363,7 @@ const withHasuraGraphQL = (MixinBase) => {
4211
4363
  const response = await axios__default["default"](request);
4212
4364
  if (!lodash.isNil(response.data.errors)) {
4213
4365
  this.logger.error({ req: request, res: response.data.errors });
4214
- throw new Error(response.data.errors);
4366
+ throw new Error(JSON.stringify(response.data.errors));
4215
4367
  }
4216
4368
  this.logger.log({ req: request, res: response.data });
4217
4369
  return response.data.data;
@@ -4352,6 +4504,7 @@ const withFindHasuraGraphQL = (MixinBase) => {
4352
4504
  return class FindHasuraGraphQLMixin extends MixinBase {
4353
4505
  constructor() {
4354
4506
  super(...arguments);
4507
+ this.lastDistinct = {};
4355
4508
  this.bindOrderByAttributes = (orderBy, fields) => Object.keys(orderBy).reduce((acc, current) => [
4356
4509
  ...acc,
4357
4510
  {
@@ -4387,9 +4540,10 @@ const withFindHasuraGraphQL = (MixinBase) => {
4387
4540
  });
4388
4541
  }
4389
4542
  async find(params) {
4390
- var _a, _b, _c, _d, _e, _f, _g, _h;
4543
+ var _a, _b, _c, _d, _e, _f, _g;
4391
4544
  this.logger = DebugHelper.from(this, 'find');
4392
4545
  const { filters, limits, orderBy, options } = params || {};
4546
+ const tableFiltersNamed = `${this.tableName}:${JSON.stringify(filters)}`;
4393
4547
  const enableCount = (_a = options === null || options === void 0 ? void 0 : options.enableCount) !== null && _a !== void 0 ? _a : true;
4394
4548
  const variablesFilters = lodash.isNil(filters)
4395
4549
  ? {}
@@ -4440,8 +4594,8 @@ const withFindHasuraGraphQL = (MixinBase) => {
4440
4594
  },
4441
4595
  ]
4442
4596
  : []),
4443
- ...((!((_b = params.limits) === null || _b === void 0 ? void 0 : _b.offset) &&
4444
- ((_d = (_c = params.options) === null || _c === void 0 ? void 0 : _c.distinct) === null || _d === void 0 ? void 0 : _d.map((distinct) => {
4597
+ ...((!this.lastDistinct[tableFiltersNamed] &&
4598
+ ((_c = (_b = params.options) === null || _b === void 0 ? void 0 : _b.distinct) === null || _c === void 0 ? void 0 : _c.map((distinct) => {
4445
4599
  var _a, _b;
4446
4600
  const distinctOption = (_a = this.fields.find((fieldOption) => fieldOption === distinct)) !== null && _a !== void 0 ? _a : this.fields.find((fieldOption) => Object.keys(fieldOption).shift() === distinct);
4447
4601
  const fieldName = ((_b = Object.values(distinctOption).shift()) === null || _b === void 0 ? void 0 : _b.columnName) || distinct;
@@ -4462,28 +4616,27 @@ const withFindHasuraGraphQL = (MixinBase) => {
4462
4616
  []),
4463
4617
  ]);
4464
4618
  const data = result[this.tableName].map((row) => this.convertDataFromHasura(row));
4465
- return Object.assign(Object.assign(Object.assign({ data, count: enableCount ? result[`${this.tableName}_aggregate`].aggregate.count : Infinity }, (((_e = options === null || options === void 0 ? void 0 : options.minimal) === null || _e === void 0 ? void 0 : _e.length)
4619
+ 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)
4466
4620
  ? {
4467
4621
  minimal: options.minimal.reduce((minimals, current) => {
4468
4622
  var _a;
4469
4623
  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])));
4470
4624
  }, {}),
4471
4625
  }
4472
- : {})), (((_f = options === null || options === void 0 ? void 0 : options.maximum) === null || _f === void 0 ? void 0 : _f.length)
4626
+ : {})), (((_e = options === null || options === void 0 ? void 0 : options.maximum) === null || _e === void 0 ? void 0 : _e.length)
4473
4627
  ? {
4474
4628
  maximum: options.maximum.reduce((maximums, current) => {
4475
4629
  var _a;
4476
4630
  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])));
4477
4631
  }, {}),
4478
4632
  }
4479
- : {})), (!((_g = params.limits) === null || _g === void 0 ? void 0 : _g.offset) &&
4480
- ((_h = options === null || options === void 0 ? void 0 : options.distinct) === null || _h === void 0 ? void 0 : _h.length) && {
4481
- distinct: options === null || options === void 0 ? void 0 : options.distinct.reduce((distinct, current) => {
4633
+ : {})), (((_f = options === null || options === void 0 ? void 0 : options.distinct) === null || _f === void 0 ? void 0 : _f.length) && {
4634
+ 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) => {
4482
4635
  var _a, _b;
4483
4636
  const distinctOption = (_a = this.fields.find((fieldOption) => fieldOption === current)) !== null && _a !== void 0 ? _a : this.fields.find((fieldOption) => Object.keys(fieldOption).shift() === current);
4484
4637
  const fieldName = ((_b = Object.values(distinctOption).shift()) === null || _b === void 0 ? void 0 : _b.columnName) || current;
4485
4638
  return Object.assign(Object.assign({}, distinct), { [current.toString()]: result[`${this.tableName}_${current.toString()}_distinct`].map((obj) => obj[fieldName]) });
4486
- }, {}),
4639
+ }, {})),
4487
4640
  }));
4488
4641
  }
4489
4642
  };
@@ -4578,6 +4731,7 @@ class CategoryFilterHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHa
4578
4731
  fields: [
4579
4732
  'id',
4580
4733
  'description',
4734
+ 'title',
4581
4735
  'slug',
4582
4736
  'enabled',
4583
4737
  { createdAt: { columnName: 'created_at' } },
@@ -4689,6 +4843,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
4689
4843
  'name',
4690
4844
  'description',
4691
4845
  'image',
4846
+ { images: { columnName: 'images', type: HasuraGraphQLColumnType.Jsonb } },
4692
4847
  'published',
4693
4848
  'shop',
4694
4849
  { shops: { columnName: 'shops', type: HasuraGraphQLColumnType.Jsonb } },
@@ -4721,11 +4876,11 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
4721
4876
  filters: {
4722
4877
  columnName: 'filters',
4723
4878
  foreignKeyColumn: { filter_id: 'id' },
4724
- fields: [{ filter: ['id', 'description', 'slug', 'enabled'] }],
4879
+ fields: [{ filter: ['id', 'title', 'description', 'slug', 'enabled'] }],
4725
4880
  bindPersistData: (value) => ({
4726
4881
  filters: { data: value.map((filter) => ({ filter_id: filter.id })) },
4727
4882
  }),
4728
- from: (filters) => (filters === null || filters === void 0 ? void 0 : filters.map((filter) => filter === null || filter === void 0 ? void 0 : filter.filter)) || [],
4883
+ 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)) || [],
4729
4884
  },
4730
4885
  },
4731
4886
  { createdAt: { columnName: 'created_at' } },
@@ -4744,12 +4899,21 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
4744
4899
  {
4745
4900
  metadata: {
4746
4901
  columnName: 'metadata',
4747
- fields: ['title', 'description'],
4902
+ fields: ['shop', 'title', 'description'],
4748
4903
  bindPersistData: (value) => ({
4749
4904
  metadata: { data: value },
4750
4905
  }),
4751
4906
  },
4752
4907
  },
4908
+ {
4909
+ metadatas: {
4910
+ columnName: 'metadatas',
4911
+ fields: ['shop', 'title', 'description'],
4912
+ bindPersistData: (value) => ({
4913
+ metadatas: { data: value },
4914
+ }),
4915
+ },
4916
+ },
4753
4917
  { isCollection: { columnName: 'is_collection' } },
4754
4918
  { isWishlist: { columnName: 'is_wishlist' } },
4755
4919
  'reference',
@@ -4764,14 +4928,29 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
4764
4928
  'theme',
4765
4929
  { bannerUrl: { columnName: 'banner_url' } },
4766
4930
  { mostRelevant: { columnName: 'most_relevant', type: HasuraGraphQLColumnType.Jsonb } },
4931
+ { mostRelevants: { columnName: 'most_relevants', type: HasuraGraphQLColumnType.Jsonb } },
4767
4932
  ],
4768
4933
  });
4769
4934
  this.productRepository = productRepository;
4770
4935
  this.categoryFilterRepository = categoryFilterRepository;
4771
4936
  }
4772
4937
  async create(params) {
4773
- const { metadata } = params, data = tslib.__rest(params, ["metadata"]);
4774
- return super.create(Object.assign(Object.assign({}, data), { isWishlist: false, metadata: metadata || { description: null, title: null } }));
4938
+ const { images, mostRelevants, metadatas } = params, data = tslib.__rest(params, ["images", "mostRelevants", "metadatas"]);
4939
+ return super.create(Object.assign(Object.assign({}, data), { isWishlist: false, metadatas: metadatas || [{ shop: null, description: null, title: null }], mostRelevants: mostRelevants || {
4940
+ [exports.Shops.GLAMSHOP]: null,
4941
+ [exports.Shops.MENSMARKET]: null,
4942
+ }, images: images || {
4943
+ [exports.Shops.GLAMSHOP]: {
4944
+ brandBanner: null,
4945
+ brandBannerMobile: null,
4946
+ image: null,
4947
+ },
4948
+ [exports.Shops.MENSMARKET]: {
4949
+ brandBanner: null,
4950
+ brandBannerMobile: null,
4951
+ image: null,
4952
+ },
4953
+ } }));
4775
4954
  }
4776
4955
  async get(identifiers) {
4777
4956
  var _a;
@@ -4780,12 +4959,12 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
4780
4959
  : super.get(identifiers);
4781
4960
  }
4782
4961
  async update(params) {
4783
- const { products, id: checkId, metadata, filters } = params, data = tslib.__rest(params, ["products", "id", "metadata", "filters"]);
4962
+ const { products, id: checkId, metadatas, filters } = params, data = tslib.__rest(params, ["products", "id", "metadatas", "filters"]);
4784
4963
  const plainData = this.paramsToPlain({ id: checkId });
4785
4964
  const id = await this.getId(plainData.id);
4786
4965
  const category = await super.update(Object.assign(Object.assign({ id }, data), { isWishlist: false }));
4787
4966
  category.products = products && (await this.updateProducts(+id, { products }));
4788
- category.metadata = metadata && (await this.updateMetadata(+id, { metadata }));
4967
+ category.metadatas = metadatas && (await this.updateMetadata(+id, { metadatas }));
4789
4968
  category.filters = filters && (await this.updateFilters(+id, { filters }));
4790
4969
  return category;
4791
4970
  }
@@ -4823,7 +5002,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
4823
5002
  });
4824
5003
  return data;
4825
5004
  }
4826
- async getCategoriesForHome(categoryIds, limit = 4, gender) {
5005
+ async getCategoriesForHome(categoryIds, shop, limit = 4) {
4827
5006
  if (!(categoryIds === null || categoryIds === void 0 ? void 0 : categoryIds.length))
4828
5007
  return [];
4829
5008
  const categoriesFirestore = categoryIds.filter((categoryId) => Number.isNaN(+categoryId));
@@ -4835,22 +5014,32 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
4835
5014
  }).then(({ data }) => data)));
4836
5015
  if (categoriesHasura.length)
4837
5016
  categories.push(...(await this.find({
4838
- filters: { id: { operator: exports.Where.IN, value: categoriesHasura.filter(Boolean) }, published: true },
5017
+ filters: {
5018
+ id: { operator: exports.Where.IN, value: categoriesHasura.filter(Boolean) },
5019
+ published: true,
5020
+ },
4839
5021
  }).then(({ data }) => data)));
4840
5022
  if (!categories.length)
4841
5023
  return [];
4842
5024
  const homeSections = await Promise.all(categories.map(async (category) => ({
4843
5025
  category,
4844
- products: await this.mountCategory(category, { limit, hasStock: true, gender }),
5026
+ products: await this.mountCategory(category, shop, { limit, hasStock: true }),
4845
5027
  })));
4846
5028
  return homeSections;
4847
5029
  }
4848
- async mountCategory(category, options) {
5030
+ async mountCategory(category, shop, options) {
4849
5031
  var _a;
4850
5032
  if (!((_a = category === null || category === void 0 ? void 0 : category.products) === null || _a === void 0 ? void 0 : _a.length))
4851
5033
  return [];
5034
+ const mostRelevants = category.getMostRelevantByShop(shop);
5035
+ const mostRelevantProductsIds = [...new Set(mostRelevants.concat(category.products))];
4852
5036
  const products = [];
4853
- const { data: productsData } = await this.productRepository.find(Object.assign(Object.assign({ filters: Object.assign(Object.assign({ id: { operator: exports.Where.IN, value: category.products }, published: true }, ((options === null || options === void 0 ? void 0 : options.hasStock) ? { stock: { quantity: { operator: exports.Where.GT, value: 0 } } } : {})), ((options === null || options === void 0 ? void 0 : options.gender) ? { tags: { operator: exports.Where.IN, value: [options === null || options === void 0 ? void 0 : options.gender] } } : {})), fields: [
5037
+ const { data: productsData } = await this.productRepository.findCatalog({
5038
+ filters: {
5039
+ id: { operator: exports.Where.IN, value: mostRelevantProductsIds },
5040
+ published: true,
5041
+ },
5042
+ fields: [
4854
5043
  'id',
4855
5044
  'name',
4856
5045
  'slug',
@@ -4876,12 +5065,29 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
4876
5065
  'shoppingCount',
4877
5066
  'gender',
4878
5067
  'createdAt',
4879
- ] }, ((options === null || options === void 0 ? void 0 : options.limit) ? { limits: { limit: options === null || options === void 0 ? void 0 : options.limit } } : {})), { options: { enableCount: false } }));
4880
- products.push(...productsData);
5068
+ ],
5069
+ options: { enableCount: false },
5070
+ orderBy: {
5071
+ shoppingCount: 'desc',
5072
+ rate: 'desc',
5073
+ stock: 'desc',
5074
+ name: 'asc',
5075
+ },
5076
+ }, shop === exports.Shops.MENSMARKET ? 'male' : 'female');
5077
+ const mostRelevantWithouyStock = productsData.filter((product) => mostRelevants.includes(product.id) && product.stock.quantity <= 0);
5078
+ const firstProducts = productsData
5079
+ .filter((product) => mostRelevants.includes(product.id) && product.stock.quantity > 0)
5080
+ .sort((a, b) => mostRelevants.indexOf(a.id) - mostRelevants.indexOf(b.id));
5081
+ const lastProducts = productsData
5082
+ .filter((product) => !mostRelevants.includes(product.id) && product.stock.quantity > 0)
5083
+ .concat(mostRelevantWithouyStock);
5084
+ const categoryMostRelevants = firstProducts.concat(lastProducts);
5085
+ const resultFinal = categoryMostRelevants.slice(0, options.limit);
5086
+ products.push(...resultFinal);
4881
5087
  return products;
4882
5088
  }
4883
5089
  async getChildren(parentId) {
4884
- const { category_tree } = await this.query('category_tree', ['id', 'name', 'parent_id', 'slug', 'reference'], {
5090
+ const { category_tree } = await this.query('category_tree', ['id', 'name', 'parent_id', 'slug', 'reference', 'published', 'shops'], {
4885
5091
  args: {
4886
5092
  type: 'category_tree_args',
4887
5093
  value: { parentid: parentId },
@@ -4914,29 +5120,6 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
4914
5120
  });
4915
5121
  return [];
4916
5122
  }
4917
- const plainData = this.paramsToPlain({ products });
4918
- if (!plainData.products || plainData.products.length <= 0)
4919
- return [];
4920
- const category = await this.get({ id: categoryId.toString() });
4921
- await this.mutation('delete_category_product', ['affected_rows'], {
4922
- where: {
4923
- type: 'category_product_bool_exp',
4924
- required: true,
4925
- value: {
4926
- category_id: { _eq: categoryId },
4927
- product_id: { _in: category.products.filter((productId) => !plainData.products.includes(productId)) },
4928
- },
4929
- },
4930
- });
4931
- await this.mutation('insert_category_product', ['affected_rows'], {
4932
- objects: {
4933
- type: '[category_product_insert_input!]',
4934
- required: true,
4935
- value: plainData.products
4936
- .filter((productId) => !category.products.includes(productId))
4937
- .map((productId) => ({ category_id: categoryId, product_id: productId })),
4938
- },
4939
- });
4940
5123
  const productsOrder = products.map((product, index) => {
4941
5124
  return {
4942
5125
  id: product,
@@ -4945,7 +5128,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
4945
5128
  });
4946
5129
  const updateQueries = productsOrder.map((product) => ({
4947
5130
  where: {
4948
- category_id: { _eq: category.id },
5131
+ category_id: { _eq: categoryId },
4949
5132
  product_id: { _eq: product.id },
4950
5133
  },
4951
5134
  _set: {
@@ -4959,25 +5142,39 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
4959
5142
  required: true,
4960
5143
  },
4961
5144
  });
5145
+ const plainData = this.paramsToPlain({ products });
4962
5146
  return plainData.products;
4963
5147
  }
4964
- async updateMetadata(categoryId, { metadata }) {
4965
- const plainData = this.paramsToPlain({ metadata });
4966
- if (!plainData.metadata)
4967
- return null;
4968
- await this.mutation('update_category_metadata_by_pk', ['category_id'], {
4969
- pk_columns: {
4970
- value: { category_id: categoryId },
4971
- type: 'category_metadata_pk_columns_input',
4972
- required: true,
4973
- },
4974
- _set: {
4975
- value: lodash.omit(metadata, ['category_id']),
4976
- type: 'category_metadata_set_input',
4977
- required: true,
4978
- },
4979
- });
4980
- return plainData.metadata;
5148
+ async updateMetadata(categoryId, { metadatas }) {
5149
+ if (Array.isArray(metadatas) && !metadatas.length)
5150
+ return [];
5151
+ if (Array.isArray(metadatas) && metadatas.length) {
5152
+ await this.mutation('delete_category_metadata', ['affected_rows'], {
5153
+ where: {
5154
+ type: 'category_metadata_bool_exp',
5155
+ required: true,
5156
+ value: { category_id: { _eq: categoryId } },
5157
+ },
5158
+ });
5159
+ await this.mutation('insert_category_metadata', ['affected_rows'], {
5160
+ objects: {
5161
+ type: '[category_metadata_insert_input!]',
5162
+ required: true,
5163
+ value: metadatas.map((m) => (Object.assign({ category_id: categoryId }, m))),
5164
+ },
5165
+ });
5166
+ return metadatas;
5167
+ }
5168
+ if ('action' in metadatas && metadatas.action === 'remove' && metadatas.value.length) {
5169
+ await this.mutation('delete_category_metadata', ['affected_rows'], {
5170
+ where: {
5171
+ type: 'category_metadata_bool_exp',
5172
+ required: true,
5173
+ value: { category_id: { _eq: categoryId } },
5174
+ },
5175
+ });
5176
+ return [];
5177
+ }
4981
5178
  }
4982
5179
  async updateFilters(categoryId, { filters }) {
4983
5180
  if ('action' in filters && filters.action === 'remove' && filters.value.length) {
@@ -5039,13 +5236,13 @@ tslib.__decorate([
5039
5236
  tslib.__decorate([
5040
5237
  Log(),
5041
5238
  tslib.__metadata("design:type", Function),
5042
- tslib.__metadata("design:paramtypes", [Array, Object, String]),
5239
+ tslib.__metadata("design:paramtypes", [Array, String, Object]),
5043
5240
  tslib.__metadata("design:returntype", Promise)
5044
5241
  ], CategoryHasuraGraphQLRepository.prototype, "getCategoriesForHome", null);
5045
5242
  tslib.__decorate([
5046
5243
  Log(),
5047
5244
  tslib.__metadata("design:type", Function),
5048
- tslib.__metadata("design:paramtypes", [Category, Object]),
5245
+ tslib.__metadata("design:paramtypes", [Category, String, Object]),
5049
5246
  tslib.__metadata("design:returntype", Promise)
5050
5247
  ], CategoryHasuraGraphQLRepository.prototype, "mountCategory", null);
5051
5248
  tslib.__decorate([
@@ -5061,6 +5258,40 @@ tslib.__decorate([
5061
5258
  tslib.__metadata("design:returntype", Promise)
5062
5259
  ], CategoryHasuraGraphQLRepository.prototype, "isChild", null);
5063
5260
 
5261
+ class CategoryProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
5262
+ constructor({ endpoint, authOptions, interceptors, }) {
5263
+ super({
5264
+ tableName: 'category_product',
5265
+ model: CategoryProduct,
5266
+ endpoint,
5267
+ authOptions,
5268
+ interceptors,
5269
+ fields: [{ productId: { columnName: 'product_id' } }, { categoryId: { columnName: 'category_id' } }, 'order'],
5270
+ });
5271
+ }
5272
+ async removeProductFromCategory(categoryId, productId) {
5273
+ await this.mutation('delete_category_product', ['affected_rows'], {
5274
+ where: {
5275
+ type: 'category_product_bool_exp',
5276
+ required: true,
5277
+ value: {
5278
+ product_id: { _eq: productId },
5279
+ category_id: { _eq: categoryId },
5280
+ },
5281
+ },
5282
+ });
5283
+ }
5284
+ async addProductToCategory(categoryId, productId) {
5285
+ await this.mutation('insert_category_product', ['affected_rows'], {
5286
+ objects: {
5287
+ type: '[category_product_insert_input!]',
5288
+ required: true,
5289
+ value: [{ category_id: categoryId, product_id: productId }],
5290
+ },
5291
+ });
5292
+ }
5293
+ }
5294
+
5064
5295
  class FilterHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
5065
5296
  constructor({ endpoint, authOptions, interceptors, }, filterOptionRepository, categoryFilterRepository) {
5066
5297
  super({
@@ -5071,6 +5302,7 @@ class FilterHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGrap
5071
5302
  interceptors,
5072
5303
  fields: [
5073
5304
  'id',
5305
+ 'title',
5074
5306
  'description',
5075
5307
  'slug',
5076
5308
  'enabled',
@@ -5326,6 +5558,7 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
5326
5558
  { subscriberPrice: { columnName: 'subscriber_price' } },
5327
5559
  'published',
5328
5560
  'outlet',
5561
+ 'label',
5329
5562
  'sku',
5330
5563
  {
5331
5564
  stock: {
@@ -5357,6 +5590,8 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
5357
5590
  fields: ['id', 'name', 'reference', 'slug'],
5358
5591
  },
5359
5592
  },
5593
+ 'group',
5594
+ 'validity',
5360
5595
  ];
5361
5596
  this.fields = [
5362
5597
  ...commonFields,
@@ -5458,6 +5693,8 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
5458
5693
  enableCount: false,
5459
5694
  },
5460
5695
  });
5696
+ if (!result.data.length)
5697
+ return null;
5461
5698
  const product = (_a = result === null || result === void 0 ? void 0 : result.data) === null || _a === void 0 ? void 0 : _a.shift();
5462
5699
  RoundProductPricesHelper.roundProductPrices(product);
5463
5700
  return product;
@@ -5467,7 +5704,6 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
5467
5704
  const plainData = this.paramsToPlain({ id: checkId });
5468
5705
  const id = await this.getId(plainData.id);
5469
5706
  const product = await super.update(Object.assign({ id }, data));
5470
- product.categories = categories && (await this.updateCategories(+id, { categories }));
5471
5707
  product.kitProducts = kitProducts && (await this.updateKitProducts(+id, { kitProducts }));
5472
5708
  product.reviews = reviews && (await this.updateReviews(+id, { reviews }));
5473
5709
  product.metadata = metadata && (await this.updateMetadata(+id, { metadata }));
@@ -5531,42 +5767,6 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
5531
5767
  getReviewStatus(review) {
5532
5768
  return review.status === true ? 'approved' : review.status === false ? 'rejected' : 'pending';
5533
5769
  }
5534
- async updateCategories(productId, { categories }) {
5535
- if ('action' in categories && categories.action === 'remove') {
5536
- await this.mutation('delete_category_product', ['affected_rows'], {
5537
- where: {
5538
- type: 'category_product_bool_exp',
5539
- required: true,
5540
- value: { product_id: { _eq: productId } },
5541
- },
5542
- });
5543
- return [];
5544
- }
5545
- const plainData = this.paramsToPlain({ categories });
5546
- if (!plainData.categories || plainData.categories.length <= 0)
5547
- return [];
5548
- const product = await this.get({ id: productId.toString() });
5549
- await this.mutation('delete_category_product', ['affected_rows'], {
5550
- where: {
5551
- type: 'category_product_bool_exp',
5552
- required: true,
5553
- value: {
5554
- product_id: { _eq: productId },
5555
- category_id: { _in: product.categories.filter((categoryId) => !plainData.categories.includes(categoryId)) },
5556
- },
5557
- },
5558
- });
5559
- await this.mutation('insert_category_product', ['affected_rows'], {
5560
- objects: {
5561
- type: '[category_product_insert_input!]',
5562
- required: true,
5563
- value: plainData.categories
5564
- .filter((categoryId) => !product.categories.includes(categoryId))
5565
- .map((categoryId) => ({ category_id: categoryId, product_id: productId })),
5566
- },
5567
- });
5568
- return plainData.categories;
5569
- }
5570
5770
  async updateKitProducts(productId, { kitProducts }) {
5571
5771
  const plainData = this.paramsToPlain({ kitProducts });
5572
5772
  await this.mutation('delete_product_kit', ['affected_rows'], {
@@ -5757,6 +5957,24 @@ class ProductReviewsHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHa
5757
5957
  ],
5758
5958
  });
5759
5959
  }
5960
+ async updateManyStatus(reviews) {
5961
+ return await this.mutation('update_product_review_many', ['affected_rows'], {
5962
+ updates: {
5963
+ type: '[product_review_updates!]',
5964
+ required: true,
5965
+ value: [
5966
+ {
5967
+ _set: { status: true },
5968
+ where: { id: { _in: reviews.filter((review) => review.status).map((review) => review.id) } },
5969
+ },
5970
+ {
5971
+ _set: { status: false },
5972
+ where: { id: { _in: reviews.filter((review) => !review.status).map((review) => review.id) } },
5973
+ },
5974
+ ],
5975
+ },
5976
+ });
5977
+ }
5760
5978
  aproveReview(id) {
5761
5979
  return this.update({ id, status: true });
5762
5980
  }
@@ -5811,6 +6029,31 @@ class ProductStockNotificationHasuraGraphQLRepository extends withCrudHasuraGrap
5811
6029
  email,
5812
6030
  });
5813
6031
  }
6032
+ async getNotificationsReport(params, orderBy, pagination) {
6033
+ 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 } }));
6034
+ const orderByField = {
6035
+ [orderBy.field]: orderBy.direction,
6036
+ };
6037
+ const { report_stock_notification } = await this.query('report_stock_notification', ['product_id', 'ean', 'sku', 'name', 'stock', 'category_id', 'category', 'reference', 'emails_registered'], {
6038
+ where: {
6039
+ type: 'report_stock_notification_bool_exp',
6040
+ value: query,
6041
+ required: true,
6042
+ },
6043
+ order_by: {
6044
+ type: '[report_stock_notification_order_by]',
6045
+ value: orderByField,
6046
+ required: true,
6047
+ },
6048
+ });
6049
+ const data = (pagination === null || pagination === void 0 ? void 0 : pagination.limit)
6050
+ ? 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))
6051
+ : report_stock_notification;
6052
+ return {
6053
+ data,
6054
+ count: report_stock_notification.length,
6055
+ };
6056
+ }
5814
6057
  }
5815
6058
 
5816
6059
  class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
@@ -5884,6 +6127,10 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
5884
6127
  type: HasuraGraphQLColumnType.Jsonb,
5885
6128
  },
5886
6129
  },
6130
+ 'group',
6131
+ 'validity',
6132
+ { tags: { columnName: 'tags', type: HasuraGraphQLColumnType.Jsonb } },
6133
+ 'published',
5887
6134
  ],
5888
6135
  });
5889
6136
  }
@@ -5919,11 +6166,14 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
5919
6166
  }
5920
6167
  }
5921
6168
 
6169
+ class WishlistHasuraGraphQL extends Wishlist {
6170
+ }
6171
+
5922
6172
  class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
5923
- constructor({ endpoint, authOptions, interceptors, }, categoryFilterRepository) {
6173
+ constructor({ endpoint, authOptions, interceptors, }, categoryProductRepository) {
5924
6174
  super({
5925
6175
  tableName: 'category',
5926
- model: Wishlist,
6176
+ model: WishlistHasuraGraphQL,
5927
6177
  endpoint,
5928
6178
  authOptions,
5929
6179
  interceptors,
@@ -5984,12 +6234,21 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
5984
6234
  {
5985
6235
  metadata: {
5986
6236
  columnName: 'metadata',
5987
- fields: ['title', 'description'],
6237
+ fields: ['shop', 'title', 'description'],
5988
6238
  bindPersistData: (value) => ({
5989
6239
  metadata: { data: value },
5990
6240
  }),
5991
6241
  },
5992
6242
  },
6243
+ {
6244
+ metadatas: {
6245
+ columnName: 'metadatas',
6246
+ fields: ['shop', 'title', 'description'],
6247
+ bindPersistData: (value) => ({
6248
+ metadatas: { data: value },
6249
+ }),
6250
+ },
6251
+ },
5993
6252
  { isCollection: { columnName: 'is_collection' } },
5994
6253
  { isWishlist: { columnName: 'is_wishlist' } },
5995
6254
  'reference',
@@ -6004,15 +6263,34 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
6004
6263
  { personId: { columnName: 'person_id' } },
6005
6264
  { personName: { columnName: 'person_name' } },
6006
6265
  { personPhoto: { columnName: 'person_photo' } },
6266
+ { personType: { columnName: 'person_type' } },
6267
+ { personIsSubscriber: { columnName: 'person_is_subscriber' } },
6007
6268
  'theme',
6008
6269
  { bannerUrl: { columnName: 'banner_url' } },
6270
+ { personHasPhoto: { columnName: 'person_has_photo' } },
6271
+ { mostRelevants: { columnName: 'most_relevants', type: HasuraGraphQLColumnType.Jsonb } },
6009
6272
  ],
6010
6273
  });
6011
- this.categoryFilterRepository = categoryFilterRepository;
6274
+ this.categoryProductRepository = categoryProductRepository;
6012
6275
  }
6013
6276
  async create(params) {
6014
- const { metadata } = params, data = tslib.__rest(params, ["metadata"]);
6015
- return super.create(Object.assign(Object.assign({}, data), { isWishlist: true, isCollection: true, brandCategory: false, metadata: metadata || { description: data.description, title: data.name } }));
6277
+ var _a;
6278
+ const { images, mostRelevants, metadatas } = params, data = tslib.__rest(params, ["images", "mostRelevants", "metadatas"]);
6279
+ 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 || {
6280
+ [exports.Shops.GLAMSHOP]: null,
6281
+ [exports.Shops.MENSMARKET]: null,
6282
+ }, images: images || {
6283
+ [exports.Shops.GLAMSHOP]: {
6284
+ brandBanner: null,
6285
+ brandBannerMobile: null,
6286
+ image: null,
6287
+ },
6288
+ [exports.Shops.MENSMARKET]: {
6289
+ brandBanner: null,
6290
+ brandBannerMobile: null,
6291
+ image: null,
6292
+ },
6293
+ } }));
6016
6294
  }
6017
6295
  async get(identifiers) {
6018
6296
  const data = await super.get(identifiers);
@@ -6025,12 +6303,11 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
6025
6303
  return await super.find(Object.assign(Object.assign({}, rest), { filters: Object.assign(Object.assign({}, filters), { isWishlist: { operator: exports.Where.EQUALS, value: true } }) }));
6026
6304
  }
6027
6305
  async update(params) {
6028
- const { products, id: checkId, metadata, filters } = params, data = tslib.__rest(params, ["products", "id", "metadata", "filters"]);
6306
+ const { products, id: checkId, metadatas, filters } = params, data = tslib.__rest(params, ["products", "id", "metadatas", "filters"]);
6029
6307
  const plainData = this.paramsToPlain({ id: checkId });
6030
6308
  const id = plainData.id;
6031
6309
  const category = await super.update(Object.assign(Object.assign({ id }, data), { isWishlist: true, isCollection: true, brandCategory: false }));
6032
- category.products = products && (await this.updateProducts(+id, { products }));
6033
- category.metadata = metadata && (await this.updateMetadata(+id, { metadata }));
6310
+ category.metadatas = metadatas && (await this.updateMetadata(+id, { metadatas }));
6034
6311
  return category;
6035
6312
  }
6036
6313
  async getWishlistBySlug(slug) {
@@ -6062,12 +6339,18 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
6062
6339
  options: {
6063
6340
  enableCount: false,
6064
6341
  },
6342
+ orderBy: {
6343
+ id: 'asc',
6344
+ },
6345
+ limits: {
6346
+ limit: 1,
6347
+ },
6065
6348
  });
6066
6349
  if (!data.length)
6067
6350
  throw new NotFoundError(`Wishlists from person ${personId} not found`);
6068
6351
  return data;
6069
6352
  }
6070
- getCategoryBySlug(slug, _shop) {
6353
+ async getCategoryBySlug(slug, _shop) {
6071
6354
  return this.getWishlistBySlug(slug);
6072
6355
  }
6073
6356
  async getCategoryByShop(shop) {
@@ -6085,10 +6368,17 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
6085
6368
  });
6086
6369
  return data;
6087
6370
  }
6088
- getCategoriesForHome(categoryIds, limit, gender) {
6371
+ async findBfluOrGlamgirlWishlists(params, shops) {
6372
+ var _a, _b;
6373
+ 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 : {
6374
+ operator: exports.Where.IN,
6375
+ value: [exports.PersonTypes.BFLU, exports.PersonTypes.GLAMGIRL],
6376
+ } }), orderBy: Object.assign({ personHasPhoto: 'desc' }, lodash.omit(params.orderBy, ['personHasPhoto'])) }));
6377
+ }
6378
+ getCategoriesForHome(categoryIds, gender, limit) {
6089
6379
  return;
6090
6380
  }
6091
- mountCategory(category, options) {
6381
+ mountCategory(category, shop, options) {
6092
6382
  return;
6093
6383
  }
6094
6384
  getChildren(parentId) {
@@ -6097,61 +6387,46 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
6097
6387
  isChild(id, parentId) {
6098
6388
  return;
6099
6389
  }
6100
- async updateProducts(categoryId, { products }) {
6101
- if ('action' in products && products.action === 'remove') {
6102
- await this.mutation('delete_category_product', ['affected_rows'], {
6103
- where: {
6104
- type: 'category_product_bool_exp',
6105
- required: true,
6106
- value: { category_id: { _eq: categoryId } },
6107
- },
6108
- });
6109
- await this.categoryFilterRepository.deleteByCategory(categoryId);
6390
+ async updateMetadata(categoryId, { metadatas }) {
6391
+ if (Array.isArray(metadatas) && !metadatas.length)
6110
6392
  return [];
6393
+ if (Array.isArray(metadatas) && metadatas.length) {
6394
+ const metadataUpdated = [];
6395
+ for (const data of metadatas) {
6396
+ const update = await this.mutation('update_category_metadata_by_pk', ['category_id', 'shop'], {
6397
+ pk_columns: {
6398
+ value: { category_id: categoryId, shop: data.shop },
6399
+ type: 'category_metadata_pk_columns_input',
6400
+ required: true,
6401
+ },
6402
+ _set: {
6403
+ value: lodash.omit(data, ['category_id', 'shop']),
6404
+ type: 'category_metadata_set_input',
6405
+ required: true,
6406
+ },
6407
+ });
6408
+ metadataUpdated.push(update);
6409
+ }
6410
+ return metadataUpdated;
6111
6411
  }
6112
- const plainData = this.paramsToPlain({ products });
6113
- if (!plainData.products || plainData.products.length <= 0)
6412
+ if ('action' in metadatas && metadatas.action === 'remove' && metadatas.value.length) {
6413
+ for (let i = 0; i < metadatas.value.length; i++) {
6414
+ await this.mutation('delete_category_metadata', ['affected_rows'], {
6415
+ where: {
6416
+ type: 'category_metadata_bool_exp',
6417
+ required: true,
6418
+ value: { category_id: { _eq: categoryId }, shop: metadatas.value[i].shop },
6419
+ },
6420
+ });
6421
+ }
6114
6422
  return [];
6115
- const category = await this.get({ id: categoryId.toString() });
6116
- await this.categoryFilterRepository.deleteByCategory(categoryId);
6117
- await this.mutation('delete_category_product', ['affected_rows'], {
6118
- where: {
6119
- type: 'category_product_bool_exp',
6120
- required: true,
6121
- value: {
6122
- category_id: { _eq: categoryId },
6123
- product_id: { _in: category.products.filter((productId) => !plainData.products.includes(productId)) },
6124
- },
6125
- },
6126
- });
6127
- await this.mutation('insert_category_product', ['affected_rows'], {
6128
- objects: {
6129
- type: '[category_product_insert_input!]',
6130
- required: true,
6131
- value: plainData.products
6132
- .filter((productId) => !category.products.includes(productId))
6133
- .map((productId) => ({ category_id: categoryId, product_id: productId })),
6134
- },
6135
- });
6136
- return plainData.products;
6423
+ }
6137
6424
  }
6138
- async updateMetadata(categoryId, { metadata }) {
6139
- const plainData = this.paramsToPlain({ metadata });
6140
- if (!plainData.metadata)
6141
- return;
6142
- await this.mutation('update_category_metadata_by_pk', ['category_id'], {
6143
- pk_columns: {
6144
- value: { category_id: categoryId },
6145
- type: 'category_metadata_pk_columns_input',
6146
- required: true,
6147
- },
6148
- _set: {
6149
- value: lodash.omit(metadata, ['category_id']),
6150
- type: 'category_metadata_set_input',
6151
- required: true,
6152
- },
6153
- });
6154
- return plainData.metadata;
6425
+ async addProduct(wishlistId, productId) {
6426
+ return this.categoryProductRepository.addProductToCategory(wishlistId, productId);
6427
+ }
6428
+ async removeProduct(wishlistId, productId) {
6429
+ return this.categoryProductRepository.removeProductFromCategory(wishlistId, productId);
6155
6430
  }
6156
6431
  }
6157
6432
  tslib.__decorate([
@@ -6172,6 +6447,165 @@ tslib.__decorate([
6172
6447
  tslib.__metadata("design:paramtypes", [String]),
6173
6448
  tslib.__metadata("design:returntype", Promise)
6174
6449
  ], WishlistHasuraGraphQLRepository.prototype, "getCategoryByShop", null);
6450
+ tslib.__decorate([
6451
+ Log(),
6452
+ tslib.__metadata("design:type", Function),
6453
+ tslib.__metadata("design:paramtypes", [Object, Array]),
6454
+ tslib.__metadata("design:returntype", Promise)
6455
+ ], WishlistHasuraGraphQLRepository.prototype, "findBfluOrGlamgirlWishlists", null);
6456
+
6457
+ class VertexAxiosAdapter {
6458
+ constructor(config) {
6459
+ this.config = config;
6460
+ this.logger = DebugHelper.from(this);
6461
+ }
6462
+ async query(term, total, gender) {
6463
+ const logger = this.logger.with('query');
6464
+ const req = {
6465
+ url: `${this.config.url}/search`,
6466
+ method: 'POST',
6467
+ responseType: 'json',
6468
+ headers: {
6469
+ Accept: 'application/json',
6470
+ },
6471
+ data: { term, total, gender },
6472
+ };
6473
+ try {
6474
+ const { data } = await axios__default["default"](req);
6475
+ return data;
6476
+ }
6477
+ catch (error) {
6478
+ logger.error({ req, res: error });
6479
+ throw error;
6480
+ }
6481
+ }
6482
+ async get(id) {
6483
+ const logger = this.logger.with('update');
6484
+ const req = {
6485
+ url: `${this.config.url}/${id}`,
6486
+ method: 'GET',
6487
+ responseType: 'json',
6488
+ headers: {
6489
+ Accept: 'application/json',
6490
+ },
6491
+ };
6492
+ try {
6493
+ const { data } = await axios__default["default"](req);
6494
+ return data;
6495
+ }
6496
+ catch (error) {
6497
+ logger.error({ req, res: error });
6498
+ throw error;
6499
+ }
6500
+ }
6501
+ async save(data) {
6502
+ const logger = this.logger.with('save');
6503
+ const req = {
6504
+ url: `${this.config.url}/sync`,
6505
+ method: 'POST',
6506
+ responseType: 'json',
6507
+ headers: {
6508
+ Accept: 'application/json',
6509
+ },
6510
+ data,
6511
+ };
6512
+ try {
6513
+ const { data } = await axios__default["default"](req);
6514
+ return data;
6515
+ }
6516
+ catch (error) {
6517
+ logger.error({ req, res: error });
6518
+ throw error;
6519
+ }
6520
+ }
6521
+ async update(id, data) {
6522
+ const logger = this.logger.with('update');
6523
+ const req = {
6524
+ url: `${this.config.url}/${id}`,
6525
+ method: 'PUT',
6526
+ responseType: 'json',
6527
+ headers: {
6528
+ Accept: 'application/json',
6529
+ },
6530
+ data,
6531
+ };
6532
+ try {
6533
+ const { data } = await axios__default["default"](req);
6534
+ return data;
6535
+ }
6536
+ catch (error) {
6537
+ logger.error({ req, res: error });
6538
+ throw error;
6539
+ }
6540
+ }
6541
+ async delete(id) {
6542
+ const logger = this.logger.with('delete');
6543
+ const req = {
6544
+ url: `${this.config.url}/${id}`,
6545
+ method: 'DELETE',
6546
+ responseType: 'json',
6547
+ headers: {
6548
+ Accept: 'application/json',
6549
+ },
6550
+ };
6551
+ try {
6552
+ const { data } = await axios__default["default"](req);
6553
+ return data;
6554
+ }
6555
+ catch (error) {
6556
+ logger.error({ req, res: error });
6557
+ throw error;
6558
+ }
6559
+ }
6560
+ bulkProducts(products) {
6561
+ return;
6562
+ }
6563
+ }
6564
+
6565
+ class ProductsVertexSearch {
6566
+ constructor(adapter) {
6567
+ this.adapter = adapter;
6568
+ }
6569
+ async getById(id) {
6570
+ const data = await this.adapter.get(id);
6571
+ return data;
6572
+ }
6573
+ async search(searchTerm, total, gender) {
6574
+ try {
6575
+ const result = await this.adapter.query(searchTerm, total, gender);
6576
+ return result;
6577
+ }
6578
+ catch (error) {
6579
+ console.error(error);
6580
+ }
6581
+ }
6582
+ async save(product) {
6583
+ try {
6584
+ const _a = product.toPlain(), { createdAt, updatedAt, kitProducts } = _a, data = tslib.__rest(_a, ["createdAt", "updatedAt", "kitProducts"]);
6585
+ const newProduct = Product.toInstance(data);
6586
+ await this.adapter.save(newProduct);
6587
+ }
6588
+ catch (error) {
6589
+ console.error(error);
6590
+ }
6591
+ }
6592
+ async update(product) {
6593
+ try {
6594
+ await this.adapter.update(product.id, product);
6595
+ }
6596
+ catch (error) {
6597
+ console.error(error);
6598
+ }
6599
+ }
6600
+ async delete(id) {
6601
+ try {
6602
+ await this.adapter.delete(id);
6603
+ }
6604
+ catch (error) {
6605
+ console.error(error);
6606
+ }
6607
+ }
6608
+ }
6175
6609
 
6176
6610
  Object.defineProperty(exports, 'add', {
6177
6611
  enumerable: true,
@@ -6313,6 +6747,8 @@ exports.CategoryFilterHasuraGraphQLRepository = CategoryFilterHasuraGraphQLRepos
6313
6747
  exports.CategoryFirestoreRepository = CategoryFirestoreRepository;
6314
6748
  exports.CategoryHasuraGraphQL = CategoryHasuraGraphQL;
6315
6749
  exports.CategoryHasuraGraphQLRepository = CategoryHasuraGraphQLRepository;
6750
+ exports.CategoryProduct = CategoryProduct;
6751
+ exports.CategoryProductHasuraGraphQLRepository = CategoryProductHasuraGraphQLRepository;
6316
6752
  exports.Checkout = Checkout;
6317
6753
  exports.CheckoutFirestoreRepository = CheckoutFirestoreRepository;
6318
6754
  exports.CheckoutSubscription = CheckoutSubscription;
@@ -6344,9 +6780,13 @@ exports.LeadFirestoreRepository = LeadFirestoreRepository;
6344
6780
  exports.LegacyOrderFirestoreRepository = LegacyOrderFirestoreRepository;
6345
6781
  exports.LineItem = LineItem;
6346
6782
  exports.Log = Log;
6783
+ exports.LogDocument = LogDocument;
6784
+ exports.LogFirestoreRepository = LogFirestoreRepository;
6347
6785
  exports.Logger = Logger;
6348
6786
  exports.NotFoundError = NotFoundError;
6349
6787
  exports.Order = Order;
6788
+ exports.OrderBlocked = OrderBlocked;
6789
+ exports.OrderBlockedFirestoreRepository = OrderBlockedFirestoreRepository;
6350
6790
  exports.OrderFirestoreRepository = OrderFirestoreRepository;
6351
6791
  exports.Payment = Payment;
6352
6792
  exports.PaymentFirestoreRepository = PaymentFirestoreRepository;
@@ -6360,6 +6800,7 @@ exports.ProductStockNotification = ProductStockNotification;
6360
6800
  exports.ProductStockNotificationHasuraGraphQLRepository = ProductStockNotificationHasuraGraphQLRepository;
6361
6801
  exports.ProductVariantFirestoreRepository = ProductVariantFirestoreRepository;
6362
6802
  exports.ProductsIndex = ProductsIndex;
6803
+ exports.ProductsVertexSearch = ProductsVertexSearch;
6363
6804
  exports.RecoveryPassword = RecoveryPassword;
6364
6805
  exports.ReflectHelper = ReflectHelper;
6365
6806
  exports.Register = Register;
@@ -6398,6 +6839,7 @@ exports.UserPaymentMethodFirestoreRepository = UserPaymentMethodFirestoreReposit
6398
6839
  exports.Variant = Variant;
6399
6840
  exports.VariantHasuraGraphQL = VariantHasuraGraphQL;
6400
6841
  exports.VariantHasuraGraphQLRepository = VariantHasuraGraphQLRepository;
6842
+ exports.VertexAxiosAdapter = VertexAxiosAdapter;
6401
6843
  exports.WeakPasswordError = WeakPasswordError;
6402
6844
  exports.Wishlist = Wishlist;
6403
6845
  exports.WishlistHasuraGraphQLRepository = WishlistHasuraGraphQLRepository;