@infrab4a/connect 4.9.7-beta.2 → 4.9.7-beta.21

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 (35) hide show
  1. package/index.cjs.js +312 -83
  2. package/index.esm.js +311 -84
  3. package/package.json +1 -1
  4. package/src/domain/catalog/models/category-base.d.ts +17 -1
  5. package/src/domain/catalog/models/filter.d.ts +3 -1
  6. package/src/domain/catalog/models/types/category-images.type.d.ts +8 -0
  7. package/src/domain/catalog/models/types/category-metadata.type.d.ts +2 -0
  8. package/src/domain/catalog/models/types/category-most-relevant.type.d.ts +4 -0
  9. package/src/domain/catalog/models/types/index.d.ts +3 -0
  10. package/src/domain/catalog/models/types/report-stock-notification.type.d.ts +21 -0
  11. package/src/domain/catalog/models/wishlist.d.ts +3 -0
  12. package/src/domain/catalog/repositories/product-reviews.repository.d.ts +1 -0
  13. package/src/domain/catalog/repositories/product-stock-notification.repository.d.ts +9 -1
  14. package/src/domain/catalog/repositories/wishlist.repository.d.ts +3 -0
  15. package/src/domain/shopping/index.d.ts +1 -0
  16. package/src/domain/shopping/models/coupons/coupon.d.ts +1 -1
  17. package/src/domain/shopping/models/index.d.ts +1 -0
  18. package/src/domain/shopping/models/order-blocked.d.ts +26 -0
  19. package/src/domain/shopping/repositories/index.d.ts +1 -0
  20. package/src/domain/shopping/repositories/order-blocked.repository.d.ts +6 -0
  21. package/src/domain/shopping/types/index.d.ts +1 -0
  22. package/src/domain/shopping/types/payment-card-info.type.d.ts +4 -0
  23. package/src/domain/users/models/enums/index.d.ts +1 -0
  24. package/src/domain/users/models/enums/person-types.enum.d.ts +5 -0
  25. package/src/domain/users/models/index.d.ts +3 -2
  26. package/src/domain/users/models/types/index.d.ts +1 -0
  27. package/src/domain/users/models/types/person.type.d.ts +2 -0
  28. package/src/infra/elasticsearch/indexes/products-index.d.ts +1 -1
  29. package/src/infra/firebase/firestore/mixins/with-helpers.mixin.d.ts +1 -1
  30. package/src/infra/firebase/firestore/repositories/shopping/index.d.ts +1 -0
  31. package/src/infra/firebase/firestore/repositories/shopping/order-blocked-firestore.repository.ts.d.ts +9 -0
  32. package/src/infra/hasura-graphql/models/wishlist-hasura-graphql.d.ts +4 -0
  33. package/src/infra/hasura-graphql/repositories/catalog/product-review-hasura-graphql.repository.d.ts +1 -0
  34. package/src/infra/hasura-graphql/repositories/catalog/product-stock-notification-hasura-graphql.repository.d.ts +8 -1
  35. package/src/infra/hasura-graphql/repositories/catalog/wishlist-hasura-graphql.repository.d.ts +11 -9
package/index.cjs.js CHANGED
@@ -42,6 +42,21 @@ class BaseModel {
42
42
  }
43
43
  }
44
44
 
45
+ exports.GenderDestination = void 0;
46
+ (function (GenderDestination) {
47
+ GenderDestination["FEMALE"] = "female";
48
+ GenderDestination["MALE"] = "male";
49
+ GenderDestination["UNISEX"] = "unisex";
50
+ })(exports.GenderDestination || (exports.GenderDestination = {}));
51
+
52
+ exports.Shops = void 0;
53
+ (function (Shops) {
54
+ Shops["MENSMARKET"] = "mensmarket";
55
+ Shops["GLAMSHOP"] = "Glamshop";
56
+ Shops["GLAMPOINTS"] = "Glampoints";
57
+ Shops["ALL"] = "ALL";
58
+ })(exports.Shops || (exports.Shops = {}));
59
+
45
60
  class Filter extends BaseModel {
46
61
  static get identifiersFields() {
47
62
  return ['id'];
@@ -56,6 +71,33 @@ class CategoryBase extends BaseModel {
56
71
  static get identifiersFields() {
57
72
  return ['id'];
58
73
  }
74
+ get glamImages() {
75
+ return this.images && this.images[exports.Shops.GLAMSHOP]
76
+ ? this.images[exports.Shops.GLAMSHOP]
77
+ : {
78
+ brandBanner: null,
79
+ brandBannerMobile: null,
80
+ image: null,
81
+ };
82
+ }
83
+ get mensImages() {
84
+ return this.images && this.images[exports.Shops.MENSMARKET]
85
+ ? this.images[exports.Shops.MENSMARKET]
86
+ : {
87
+ brandBanner: null,
88
+ brandBannerMobile: null,
89
+ image: null,
90
+ };
91
+ }
92
+ get glamMetadata() {
93
+ return this.metadatas.find((metadata) => metadata.shop === exports.Shops.GLAMSHOP);
94
+ }
95
+ get mensMetadata() {
96
+ return this.metadatas.find((metadata) => metadata.shop === exports.Shops.MENSMARKET);
97
+ }
98
+ getMostRelevantByShop(shop) {
99
+ return this.mostRelevants && this.mostRelevants[shop] ? this.mostRelevants[shop] : [];
100
+ }
59
101
  }
60
102
  tslib.__decorate([
61
103
  classTransformer.Type(() => CategoryBase),
@@ -164,21 +206,6 @@ tslib.__decorate([
164
206
  tslib.__metadata("design:type", Category)
165
207
  ], CategoryFilter.prototype, "category", void 0);
166
208
 
167
- exports.GenderDestination = void 0;
168
- (function (GenderDestination) {
169
- GenderDestination["FEMALE"] = "female";
170
- GenderDestination["MALE"] = "male";
171
- GenderDestination["UNISEX"] = "unisex";
172
- })(exports.GenderDestination || (exports.GenderDestination = {}));
173
-
174
- exports.Shops = void 0;
175
- (function (Shops) {
176
- Shops["MENSMARKET"] = "mensmarket";
177
- Shops["GLAMSHOP"] = "Glamshop";
178
- Shops["GLAMPOINTS"] = "Glampoints";
179
- Shops["ALL"] = "ALL";
180
- })(exports.Shops || (exports.Shops = {}));
181
-
182
209
  class FilterOption extends BaseModel {
183
210
  static get identifiersFields() {
184
211
  return ['id'];
@@ -271,6 +298,17 @@ class CampaignHashtag extends BaseModel {
271
298
  }
272
299
  }
273
300
 
301
+ class BeautyProfile extends BaseModel {
302
+ toPlain() {
303
+ const plain = super.toPlain();
304
+ delete plain.id;
305
+ return plain;
306
+ }
307
+ static get identifiersFields() {
308
+ return ['id', 'userId'];
309
+ }
310
+ }
311
+
274
312
  exports.AccessoryImportances = void 0;
275
313
  (function (AccessoryImportances) {
276
314
  AccessoryImportances["NOT_INTERESTED"] = "N\u00E3o tenho interesse";
@@ -447,6 +485,13 @@ exports.OfficePosition = void 0;
447
485
  OfficePosition["Director"] = "Diretor";
448
486
  })(exports.OfficePosition || (exports.OfficePosition = {}));
449
487
 
488
+ exports.PersonTypes = void 0;
489
+ (function (PersonTypes) {
490
+ PersonTypes["GLAMGIRL"] = "glamgirl";
491
+ PersonTypes["BFLU"] = "bflu";
492
+ PersonTypes["NONE"] = "none";
493
+ })(exports.PersonTypes || (exports.PersonTypes = {}));
494
+
450
495
  exports.ProductSpents = void 0;
451
496
  (function (ProductSpents) {
452
497
  ProductSpents["UNTIL_50"] = "At\u00E9 R$50";
@@ -467,6 +512,12 @@ exports.UserType = void 0;
467
512
  UserType["Influencer"] = "Influencer";
468
513
  })(exports.UserType || (exports.UserType = {}));
469
514
 
515
+ class Lead extends BaseModel {
516
+ static get identifiersFields() {
517
+ return ['id'];
518
+ }
519
+ }
520
+
470
521
  class Edition extends BaseModel {
471
522
  static get identifiersFields() {
472
523
  return ['id', 'subscriptionId'];
@@ -1865,17 +1916,6 @@ class SubscriptionPlan extends BaseModel {
1865
1916
  }
1866
1917
  }
1867
1918
 
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
1919
  class User extends BaseModel {
1880
1920
  static toInstance(data) {
1881
1921
  const instance = super.toInstance(data);
@@ -1989,12 +2029,6 @@ class UserPaymentMethod extends BaseModel {
1989
2029
  }
1990
2030
  }
1991
2031
 
1992
- class Lead extends BaseModel {
1993
- static get identifiersFields() {
1994
- return ['id'];
1995
- }
1996
- }
1997
-
1998
2032
  class UnauthorizedError extends tsCustomError.CustomError {
1999
2033
  constructor(message) {
2000
2034
  super(message);
@@ -2167,6 +2201,12 @@ tslib.__decorate([
2167
2201
  tslib.__metadata("design:type", Payment)
2168
2202
  ], Order.prototype, "payment", void 0);
2169
2203
 
2204
+ class OrderBlocked extends BaseModel {
2205
+ static get identifiersFields() {
2206
+ return ['id'];
2207
+ }
2208
+ }
2209
+
2170
2210
  class CheckoutSubscription extends BaseModel {
2171
2211
  static get identifiersFields() {
2172
2212
  return ['id'];
@@ -2501,8 +2541,6 @@ class ProductsIndex {
2501
2541
  'rate',
2502
2542
  ];
2503
2543
  const filter = [{ term: { published: true } }];
2504
- if (shop && shop !== exports.Shops.ALL)
2505
- filter.push({ term: { tags: shop == exports.Shops.GLAMSHOP ? 'feminino' : 'masculino' } });
2506
2544
  if (size > 9)
2507
2545
  fields.push(...['pricePaid', 'isGift', 'stock', 'weight', 'tags']);
2508
2546
  const query = {
@@ -2992,6 +3030,8 @@ const withUpdateFirestore = (MixinBase) => {
2992
3030
  try {
2993
3031
  const identifiers = getValueFromParams(data, keyField);
2994
3032
  const docRef = this.collection(collectionName).getDoc(identifiers.toString());
3033
+ if (!(await docRef.get()).data())
3034
+ throw new NotFoundError(`Document '${collectionName}/${Object.values(identifiers.toString())}' not found`);
2995
3035
  const plainFromData = this.model.toInstance(this.paramsToPlain(data));
2996
3036
  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
3037
  const builded = (intercepted === null || intercepted === void 0 ? void 0 : intercepted.instance) || plainFromData;
@@ -3556,6 +3596,47 @@ class LegacyOrderFirestoreRepository extends OrderFirestoreRepository {
3556
3596
  }
3557
3597
  }
3558
3598
 
3599
+ class OrderBlockedFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3600
+ constructor({ firestore, interceptors, }) {
3601
+ super({
3602
+ firestore,
3603
+ collectionName: 'paymentBlockedAttempts',
3604
+ model: OrderBlocked,
3605
+ interceptors,
3606
+ });
3607
+ }
3608
+ async createBlockedOrderOrPayment(checkout, blockType, type, limiteRange, card = null) {
3609
+ var _a, _b, _c, _d, _e, _f, _g, _h;
3610
+ return this.create(OrderBlocked.toInstance({
3611
+ customer: {
3612
+ name: ((_a = checkout.user) === null || _a === void 0 ? void 0 : _a.displayName) || '',
3613
+ cpf: ((_b = checkout.user) === null || _b === void 0 ? void 0 : _b.cpf) || '',
3614
+ id: (_c = checkout.user) === null || _c === void 0 ? void 0 : _c.id,
3615
+ email: ((_d = checkout.user) === null || _d === void 0 ? void 0 : _d.email) || '',
3616
+ phoneNumber: '+55' + ((_e = checkout.user) === null || _e === void 0 ? void 0 : _e.phone),
3617
+ isSubscriber: (_f = checkout.user) === null || _f === void 0 ? void 0 : _f.isSubscriber,
3618
+ subscriptionPlan: ((_g = checkout.user) === null || _g === void 0 ? void 0 : _g.subscriptionPlan) || '',
3619
+ shippingAddress: Object.assign(Object.assign({}, checkout.shippingAddress), { zip: this.formatZip((_h = checkout.shippingAddress) === null || _h === void 0 ? void 0 : _h.zip) }),
3620
+ },
3621
+ blockType,
3622
+ limiteRange,
3623
+ type,
3624
+ card,
3625
+ checkout: {
3626
+ id: checkout.id,
3627
+ shop: checkout.shop,
3628
+ total: checkout.totalPrice,
3629
+ },
3630
+ date: new Date(),
3631
+ }));
3632
+ }
3633
+ formatZip(zip) {
3634
+ if (zip.length === 8)
3635
+ return zip.substring(0, 5) + '-' + zip.substring(5, 8);
3636
+ return zip;
3637
+ }
3638
+ }
3639
+
3559
3640
  class PaymentFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3560
3641
  constructor({ firestore, interceptors }) {
3561
3642
  super({
@@ -4211,7 +4292,7 @@ const withHasuraGraphQL = (MixinBase) => {
4211
4292
  const response = await axios__default["default"](request);
4212
4293
  if (!lodash.isNil(response.data.errors)) {
4213
4294
  this.logger.error({ req: request, res: response.data.errors });
4214
- throw new Error(response.data.errors);
4295
+ throw new Error(JSON.stringify(response.data.errors));
4215
4296
  }
4216
4297
  this.logger.log({ req: request, res: response.data });
4217
4298
  return response.data.data;
@@ -4578,6 +4659,7 @@ class CategoryFilterHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHa
4578
4659
  fields: [
4579
4660
  'id',
4580
4661
  'description',
4662
+ 'title',
4581
4663
  'slug',
4582
4664
  'enabled',
4583
4665
  { createdAt: { columnName: 'created_at' } },
@@ -4689,6 +4771,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
4689
4771
  'name',
4690
4772
  'description',
4691
4773
  'image',
4774
+ { images: { columnName: 'images', type: HasuraGraphQLColumnType.Jsonb } },
4692
4775
  'published',
4693
4776
  'shop',
4694
4777
  { shops: { columnName: 'shops', type: HasuraGraphQLColumnType.Jsonb } },
@@ -4721,7 +4804,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
4721
4804
  filters: {
4722
4805
  columnName: 'filters',
4723
4806
  foreignKeyColumn: { filter_id: 'id' },
4724
- fields: [{ filter: ['id', 'description', 'slug', 'enabled'] }],
4807
+ fields: [{ filter: ['id', 'title', 'description', 'slug', 'enabled'] }],
4725
4808
  bindPersistData: (value) => ({
4726
4809
  filters: { data: value.map((filter) => ({ filter_id: filter.id })) },
4727
4810
  }),
@@ -4744,12 +4827,21 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
4744
4827
  {
4745
4828
  metadata: {
4746
4829
  columnName: 'metadata',
4747
- fields: ['title', 'description'],
4830
+ fields: ['shop', 'title', 'description'],
4748
4831
  bindPersistData: (value) => ({
4749
4832
  metadata: { data: value },
4750
4833
  }),
4751
4834
  },
4752
4835
  },
4836
+ {
4837
+ metadatas: {
4838
+ columnName: 'metadatas',
4839
+ fields: ['shop', 'title', 'description'],
4840
+ bindPersistData: (value) => ({
4841
+ metadatas: { data: value },
4842
+ }),
4843
+ },
4844
+ },
4753
4845
  { isCollection: { columnName: 'is_collection' } },
4754
4846
  { isWishlist: { columnName: 'is_wishlist' } },
4755
4847
  'reference',
@@ -4764,14 +4856,29 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
4764
4856
  'theme',
4765
4857
  { bannerUrl: { columnName: 'banner_url' } },
4766
4858
  { mostRelevant: { columnName: 'most_relevant', type: HasuraGraphQLColumnType.Jsonb } },
4859
+ { mostRelevants: { columnName: 'most_relevants', type: HasuraGraphQLColumnType.Jsonb } },
4767
4860
  ],
4768
4861
  });
4769
4862
  this.productRepository = productRepository;
4770
4863
  this.categoryFilterRepository = categoryFilterRepository;
4771
4864
  }
4772
4865
  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 } }));
4866
+ const { images, mostRelevants, metadatas } = params, data = tslib.__rest(params, ["images", "mostRelevants", "metadatas"]);
4867
+ return super.create(Object.assign(Object.assign({}, data), { isWishlist: false, metadatas: metadatas || [{ shop: null, description: null, title: null }], mostRelevants: mostRelevants || {
4868
+ [exports.Shops.GLAMSHOP]: null,
4869
+ [exports.Shops.MENSMARKET]: null,
4870
+ }, images: images || {
4871
+ [exports.Shops.GLAMSHOP]: {
4872
+ brandBanner: null,
4873
+ brandBannerMobile: null,
4874
+ image: null,
4875
+ },
4876
+ [exports.Shops.MENSMARKET]: {
4877
+ brandBanner: null,
4878
+ brandBannerMobile: null,
4879
+ image: null,
4880
+ },
4881
+ } }));
4775
4882
  }
4776
4883
  async get(identifiers) {
4777
4884
  var _a;
@@ -4780,12 +4887,12 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
4780
4887
  : super.get(identifiers);
4781
4888
  }
4782
4889
  async update(params) {
4783
- const { products, id: checkId, metadata, filters } = params, data = tslib.__rest(params, ["products", "id", "metadata", "filters"]);
4890
+ const { products, id: checkId, metadatas, filters } = params, data = tslib.__rest(params, ["products", "id", "metadatas", "filters"]);
4784
4891
  const plainData = this.paramsToPlain({ id: checkId });
4785
4892
  const id = await this.getId(plainData.id);
4786
4893
  const category = await super.update(Object.assign(Object.assign({ id }, data), { isWishlist: false }));
4787
4894
  category.products = products && (await this.updateProducts(+id, { products }));
4788
- category.metadata = metadata && (await this.updateMetadata(+id, { metadata }));
4895
+ category.metadatas = metadatas && (await this.updateMetadata(+id, { metadatas }));
4789
4896
  category.filters = filters && (await this.updateFilters(+id, { filters }));
4790
4897
  return category;
4791
4898
  }
@@ -4881,7 +4988,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
4881
4988
  return products;
4882
4989
  }
4883
4990
  async getChildren(parentId) {
4884
- const { category_tree } = await this.query('category_tree', ['id', 'name', 'parent_id', 'slug', 'reference'], {
4991
+ const { category_tree } = await this.query('category_tree', ['id', 'name', 'parent_id', 'slug', 'reference', 'published', 'shops'], {
4885
4992
  args: {
4886
4993
  type: 'category_tree_args',
4887
4994
  value: { parentid: parentId },
@@ -4961,23 +5068,36 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
4961
5068
  });
4962
5069
  return plainData.products;
4963
5070
  }
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;
5071
+ async updateMetadata(categoryId, { metadatas }) {
5072
+ if (Array.isArray(metadatas) && !metadatas.length)
5073
+ return [];
5074
+ if (Array.isArray(metadatas) && metadatas.length) {
5075
+ await this.mutation('delete_category_metadata', ['affected_rows'], {
5076
+ where: {
5077
+ type: 'category_metadata_bool_exp',
5078
+ required: true,
5079
+ value: { category_id: { _eq: categoryId } },
5080
+ },
5081
+ });
5082
+ await this.mutation('insert_category_metadata', ['affected_rows'], {
5083
+ objects: {
5084
+ type: '[category_metadata_insert_input!]',
5085
+ required: true,
5086
+ value: metadatas.map((m) => (Object.assign({ category_id: categoryId }, m))),
5087
+ },
5088
+ });
5089
+ return metadatas;
5090
+ }
5091
+ if ('action' in metadatas && metadatas.action === 'remove' && metadatas.value.length) {
5092
+ await this.mutation('delete_category_metadata', ['affected_rows'], {
5093
+ where: {
5094
+ type: 'category_metadata_bool_exp',
5095
+ required: true,
5096
+ value: { category_id: { _eq: categoryId } },
5097
+ },
5098
+ });
5099
+ return [];
5100
+ }
4981
5101
  }
4982
5102
  async updateFilters(categoryId, { filters }) {
4983
5103
  if ('action' in filters && filters.action === 'remove' && filters.value.length) {
@@ -5071,6 +5191,7 @@ class FilterHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGrap
5071
5191
  interceptors,
5072
5192
  fields: [
5073
5193
  'id',
5194
+ 'title',
5074
5195
  'description',
5075
5196
  'slug',
5076
5197
  'enabled',
@@ -5458,6 +5579,8 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
5458
5579
  enableCount: false,
5459
5580
  },
5460
5581
  });
5582
+ if (!result.data.length)
5583
+ return null;
5461
5584
  const product = (_a = result === null || result === void 0 ? void 0 : result.data) === null || _a === void 0 ? void 0 : _a.shift();
5462
5585
  RoundProductPricesHelper.roundProductPrices(product);
5463
5586
  return product;
@@ -5757,6 +5880,24 @@ class ProductReviewsHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHa
5757
5880
  ],
5758
5881
  });
5759
5882
  }
5883
+ async updateManyStatus(reviews) {
5884
+ return await this.mutation('update_product_review_many', ['affected_rows'], {
5885
+ updates: {
5886
+ type: '[product_review_updates!]',
5887
+ required: true,
5888
+ value: [
5889
+ {
5890
+ _set: { status: true },
5891
+ where: { id: { _in: reviews.filter((review) => review.status).map((review) => review.id) } },
5892
+ },
5893
+ {
5894
+ _set: { status: false },
5895
+ where: { id: { _in: reviews.filter((review) => !review.status).map((review) => review.id) } },
5896
+ },
5897
+ ],
5898
+ },
5899
+ });
5900
+ }
5760
5901
  aproveReview(id) {
5761
5902
  return this.update({ id, status: true });
5762
5903
  }
@@ -5811,6 +5952,31 @@ class ProductStockNotificationHasuraGraphQLRepository extends withCrudHasuraGrap
5811
5952
  email,
5812
5953
  });
5813
5954
  }
5955
+ async getNotificationsReport(params, orderBy, pagination) {
5956
+ 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 } }));
5957
+ const orderByField = {
5958
+ [orderBy.field]: orderBy.direction,
5959
+ };
5960
+ const { report_stock_notification } = await this.query('report_stock_notification', ['product_id', 'ean', 'sku', 'name', 'stock', 'category_id', 'category', 'reference', 'emails_registered'], {
5961
+ where: {
5962
+ type: 'report_stock_notification_bool_exp',
5963
+ value: query,
5964
+ required: true,
5965
+ },
5966
+ order_by: {
5967
+ type: '[report_stock_notification_order_by]',
5968
+ value: orderByField,
5969
+ required: true,
5970
+ },
5971
+ });
5972
+ const data = (pagination === null || pagination === void 0 ? void 0 : pagination.limit)
5973
+ ? 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))
5974
+ : report_stock_notification;
5975
+ return {
5976
+ data,
5977
+ count: report_stock_notification.length,
5978
+ };
5979
+ }
5814
5980
  }
5815
5981
 
5816
5982
  class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
@@ -5919,11 +6085,14 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
5919
6085
  }
5920
6086
  }
5921
6087
 
6088
+ class WishlistHasuraGraphQL extends Wishlist {
6089
+ }
6090
+
5922
6091
  class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
5923
6092
  constructor({ endpoint, authOptions, interceptors, }, categoryFilterRepository) {
5924
6093
  super({
5925
6094
  tableName: 'category',
5926
- model: Wishlist,
6095
+ model: WishlistHasuraGraphQL,
5927
6096
  endpoint,
5928
6097
  authOptions,
5929
6098
  interceptors,
@@ -5984,12 +6153,21 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
5984
6153
  {
5985
6154
  metadata: {
5986
6155
  columnName: 'metadata',
5987
- fields: ['title', 'description'],
6156
+ fields: ['shop', 'title', 'description'],
5988
6157
  bindPersistData: (value) => ({
5989
6158
  metadata: { data: value },
5990
6159
  }),
5991
6160
  },
5992
6161
  },
6162
+ {
6163
+ metadatas: {
6164
+ columnName: 'metadatas',
6165
+ fields: ['shop', 'title', 'description'],
6166
+ bindPersistData: (value) => ({
6167
+ metadatas: { data: value },
6168
+ }),
6169
+ },
6170
+ },
5993
6171
  { isCollection: { columnName: 'is_collection' } },
5994
6172
  { isWishlist: { columnName: 'is_wishlist' } },
5995
6173
  'reference',
@@ -6004,15 +6182,34 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
6004
6182
  { personId: { columnName: 'person_id' } },
6005
6183
  { personName: { columnName: 'person_name' } },
6006
6184
  { personPhoto: { columnName: 'person_photo' } },
6185
+ { personType: { columnName: 'person_type' } },
6186
+ { personIsSubscriber: { columnName: 'person_is_subscriber' } },
6007
6187
  'theme',
6008
6188
  { bannerUrl: { columnName: 'banner_url' } },
6189
+ { personHasPhoto: { columnName: 'person_has_photo' } },
6190
+ { mostRelevants: { columnName: 'most_relevants', type: HasuraGraphQLColumnType.Jsonb } },
6009
6191
  ],
6010
6192
  });
6011
6193
  this.categoryFilterRepository = categoryFilterRepository;
6012
6194
  }
6013
6195
  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 } }));
6196
+ var _a;
6197
+ const { images, mostRelevants, metadatas } = params, data = tslib.__rest(params, ["images", "mostRelevants", "metadatas"]);
6198
+ 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 || {
6199
+ [exports.Shops.GLAMSHOP]: null,
6200
+ [exports.Shops.MENSMARKET]: null,
6201
+ }, images: images || {
6202
+ [exports.Shops.GLAMSHOP]: {
6203
+ brandBanner: null,
6204
+ brandBannerMobile: null,
6205
+ image: null,
6206
+ },
6207
+ [exports.Shops.MENSMARKET]: {
6208
+ brandBanner: null,
6209
+ brandBannerMobile: null,
6210
+ image: null,
6211
+ },
6212
+ } }));
6016
6213
  }
6017
6214
  async get(identifiers) {
6018
6215
  const data = await super.get(identifiers);
@@ -6025,12 +6222,12 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
6025
6222
  return await super.find(Object.assign(Object.assign({}, rest), { filters: Object.assign(Object.assign({}, filters), { isWishlist: { operator: exports.Where.EQUALS, value: true } }) }));
6026
6223
  }
6027
6224
  async update(params) {
6028
- const { products, id: checkId, metadata, filters } = params, data = tslib.__rest(params, ["products", "id", "metadata", "filters"]);
6225
+ const { products, id: checkId, metadatas, filters } = params, data = tslib.__rest(params, ["products", "id", "metadatas", "filters"]);
6029
6226
  const plainData = this.paramsToPlain({ id: checkId });
6030
6227
  const id = plainData.id;
6031
6228
  const category = await super.update(Object.assign(Object.assign({ id }, data), { isWishlist: true, isCollection: true, brandCategory: false }));
6032
6229
  category.products = products && (await this.updateProducts(+id, { products }));
6033
- category.metadata = metadata && (await this.updateMetadata(+id, { metadata }));
6230
+ category.metadatas = metadatas && (await this.updateMetadata(+id, { metadatas }));
6034
6231
  return category;
6035
6232
  }
6036
6233
  async getWishlistBySlug(slug) {
@@ -6067,7 +6264,7 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
6067
6264
  throw new NotFoundError(`Wishlists from person ${personId} not found`);
6068
6265
  return data;
6069
6266
  }
6070
- getCategoryBySlug(slug, _shop) {
6267
+ async getCategoryBySlug(slug, _shop) {
6071
6268
  return this.getWishlistBySlug(slug);
6072
6269
  }
6073
6270
  async getCategoryByShop(shop) {
@@ -6085,6 +6282,13 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
6085
6282
  });
6086
6283
  return data;
6087
6284
  }
6285
+ async findBfluOrGlamgirlWishlists(params, shops) {
6286
+ var _a, _b;
6287
+ 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 : {
6288
+ operator: exports.Where.IN,
6289
+ value: [exports.PersonTypes.BFLU, exports.PersonTypes.GLAMGIRL],
6290
+ } }), orderBy: Object.assign({ personHasPhoto: 'desc' }, lodash.omit(params.orderBy, ['personHasPhoto'])) }));
6291
+ }
6088
6292
  getCategoriesForHome(categoryIds, limit, gender) {
6089
6293
  return;
6090
6294
  }
@@ -6135,23 +6339,40 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
6135
6339
  });
6136
6340
  return plainData.products;
6137
6341
  }
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;
6342
+ async updateMetadata(categoryId, { metadatas }) {
6343
+ if (Array.isArray(metadatas) && !metadatas.length)
6344
+ return [];
6345
+ if (Array.isArray(metadatas) && metadatas.length) {
6346
+ const metadataUpdated = [];
6347
+ for (const data of metadatas) {
6348
+ const update = await this.mutation('update_category_metadata_by_pk', ['category_id', 'shop'], {
6349
+ pk_columns: {
6350
+ value: { category_id: categoryId, shop: data.shop },
6351
+ type: 'category_metadata_pk_columns_input',
6352
+ required: true,
6353
+ },
6354
+ _set: {
6355
+ value: lodash.omit(data, ['category_id', 'shop']),
6356
+ type: 'category_metadata_set_input',
6357
+ required: true,
6358
+ },
6359
+ });
6360
+ metadataUpdated.push(update);
6361
+ }
6362
+ return metadataUpdated;
6363
+ }
6364
+ if ('action' in metadatas && metadatas.action === 'remove' && metadatas.value.length) {
6365
+ for (let i = 0; i < metadatas.value.length; i++) {
6366
+ await this.mutation('delete_category_metadata', ['affected_rows'], {
6367
+ where: {
6368
+ type: 'category_metadata_bool_exp',
6369
+ required: true,
6370
+ value: { category_id: { _eq: categoryId }, shop: metadatas.value[i].shop },
6371
+ },
6372
+ });
6373
+ }
6374
+ return [];
6375
+ }
6155
6376
  }
6156
6377
  }
6157
6378
  tslib.__decorate([
@@ -6172,6 +6393,12 @@ tslib.__decorate([
6172
6393
  tslib.__metadata("design:paramtypes", [String]),
6173
6394
  tslib.__metadata("design:returntype", Promise)
6174
6395
  ], WishlistHasuraGraphQLRepository.prototype, "getCategoryByShop", null);
6396
+ tslib.__decorate([
6397
+ Log(),
6398
+ tslib.__metadata("design:type", Function),
6399
+ tslib.__metadata("design:paramtypes", [Object, Array]),
6400
+ tslib.__metadata("design:returntype", Promise)
6401
+ ], WishlistHasuraGraphQLRepository.prototype, "findBfluOrGlamgirlWishlists", null);
6175
6402
 
6176
6403
  Object.defineProperty(exports, 'add', {
6177
6404
  enumerable: true,
@@ -6347,6 +6574,8 @@ exports.Log = Log;
6347
6574
  exports.Logger = Logger;
6348
6575
  exports.NotFoundError = NotFoundError;
6349
6576
  exports.Order = Order;
6577
+ exports.OrderBlocked = OrderBlocked;
6578
+ exports.OrderBlockedFirestoreRepository = OrderBlockedFirestoreRepository;
6350
6579
  exports.OrderFirestoreRepository = OrderFirestoreRepository;
6351
6580
  exports.Payment = Payment;
6352
6581
  exports.PaymentFirestoreRepository = PaymentFirestoreRepository;