@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.esm.js CHANGED
@@ -36,6 +36,21 @@ class BaseModel {
36
36
  }
37
37
  }
38
38
 
39
+ var GenderDestination;
40
+ (function (GenderDestination) {
41
+ GenderDestination["FEMALE"] = "female";
42
+ GenderDestination["MALE"] = "male";
43
+ GenderDestination["UNISEX"] = "unisex";
44
+ })(GenderDestination || (GenderDestination = {}));
45
+
46
+ var Shops;
47
+ (function (Shops) {
48
+ Shops["MENSMARKET"] = "mensmarket";
49
+ Shops["GLAMSHOP"] = "Glamshop";
50
+ Shops["GLAMPOINTS"] = "Glampoints";
51
+ Shops["ALL"] = "ALL";
52
+ })(Shops || (Shops = {}));
53
+
39
54
  class Filter extends BaseModel {
40
55
  static get identifiersFields() {
41
56
  return ['id'];
@@ -50,6 +65,33 @@ class CategoryBase extends BaseModel {
50
65
  static get identifiersFields() {
51
66
  return ['id'];
52
67
  }
68
+ get glamImages() {
69
+ return this.images && this.images[Shops.GLAMSHOP]
70
+ ? this.images[Shops.GLAMSHOP]
71
+ : {
72
+ brandBanner: null,
73
+ brandBannerMobile: null,
74
+ image: null,
75
+ };
76
+ }
77
+ get mensImages() {
78
+ return this.images && this.images[Shops.MENSMARKET]
79
+ ? this.images[Shops.MENSMARKET]
80
+ : {
81
+ brandBanner: null,
82
+ brandBannerMobile: null,
83
+ image: null,
84
+ };
85
+ }
86
+ get glamMetadata() {
87
+ return this.metadatas.find((metadata) => metadata.shop === Shops.GLAMSHOP);
88
+ }
89
+ get mensMetadata() {
90
+ return this.metadatas.find((metadata) => metadata.shop === Shops.MENSMARKET);
91
+ }
92
+ getMostRelevantByShop(shop) {
93
+ return this.mostRelevants && this.mostRelevants[shop] ? this.mostRelevants[shop] : [];
94
+ }
53
95
  }
54
96
  __decorate([
55
97
  Type(() => CategoryBase),
@@ -158,21 +200,6 @@ __decorate([
158
200
  __metadata("design:type", Category)
159
201
  ], CategoryFilter.prototype, "category", void 0);
160
202
 
161
- var GenderDestination;
162
- (function (GenderDestination) {
163
- GenderDestination["FEMALE"] = "female";
164
- GenderDestination["MALE"] = "male";
165
- GenderDestination["UNISEX"] = "unisex";
166
- })(GenderDestination || (GenderDestination = {}));
167
-
168
- var Shops;
169
- (function (Shops) {
170
- Shops["MENSMARKET"] = "mensmarket";
171
- Shops["GLAMSHOP"] = "Glamshop";
172
- Shops["GLAMPOINTS"] = "Glampoints";
173
- Shops["ALL"] = "ALL";
174
- })(Shops || (Shops = {}));
175
-
176
203
  class FilterOption extends BaseModel {
177
204
  static get identifiersFields() {
178
205
  return ['id'];
@@ -265,6 +292,17 @@ class CampaignHashtag extends BaseModel {
265
292
  }
266
293
  }
267
294
 
295
+ class BeautyProfile extends BaseModel {
296
+ toPlain() {
297
+ const plain = super.toPlain();
298
+ delete plain.id;
299
+ return plain;
300
+ }
301
+ static get identifiersFields() {
302
+ return ['id', 'userId'];
303
+ }
304
+ }
305
+
268
306
  var AccessoryImportances;
269
307
  (function (AccessoryImportances) {
270
308
  AccessoryImportances["NOT_INTERESTED"] = "N\u00E3o tenho interesse";
@@ -441,6 +479,13 @@ var OfficePosition;
441
479
  OfficePosition["Director"] = "Diretor";
442
480
  })(OfficePosition || (OfficePosition = {}));
443
481
 
482
+ var PersonTypes;
483
+ (function (PersonTypes) {
484
+ PersonTypes["GLAMGIRL"] = "glamgirl";
485
+ PersonTypes["BFLU"] = "bflu";
486
+ PersonTypes["NONE"] = "none";
487
+ })(PersonTypes || (PersonTypes = {}));
488
+
444
489
  var ProductSpents;
445
490
  (function (ProductSpents) {
446
491
  ProductSpents["UNTIL_50"] = "At\u00E9 R$50";
@@ -461,6 +506,12 @@ var UserType;
461
506
  UserType["Influencer"] = "Influencer";
462
507
  })(UserType || (UserType = {}));
463
508
 
509
+ class Lead extends BaseModel {
510
+ static get identifiersFields() {
511
+ return ['id'];
512
+ }
513
+ }
514
+
464
515
  class Edition extends BaseModel {
465
516
  static get identifiersFields() {
466
517
  return ['id', 'subscriptionId'];
@@ -1859,17 +1910,6 @@ class SubscriptionPlan extends BaseModel {
1859
1910
  }
1860
1911
  }
1861
1912
 
1862
- class BeautyProfile extends BaseModel {
1863
- toPlain() {
1864
- const plain = super.toPlain();
1865
- delete plain.id;
1866
- return plain;
1867
- }
1868
- static get identifiersFields() {
1869
- return ['id', 'userId'];
1870
- }
1871
- }
1872
-
1873
1913
  class User extends BaseModel {
1874
1914
  static toInstance(data) {
1875
1915
  const instance = super.toInstance(data);
@@ -1983,12 +2023,6 @@ class UserPaymentMethod extends BaseModel {
1983
2023
  }
1984
2024
  }
1985
2025
 
1986
- class Lead extends BaseModel {
1987
- static get identifiersFields() {
1988
- return ['id'];
1989
- }
1990
- }
1991
-
1992
2026
  class UnauthorizedError extends CustomError {
1993
2027
  constructor(message) {
1994
2028
  super(message);
@@ -2161,6 +2195,12 @@ __decorate([
2161
2195
  __metadata("design:type", Payment)
2162
2196
  ], Order.prototype, "payment", void 0);
2163
2197
 
2198
+ class OrderBlocked extends BaseModel {
2199
+ static get identifiersFields() {
2200
+ return ['id'];
2201
+ }
2202
+ }
2203
+
2164
2204
  class CheckoutSubscription extends BaseModel {
2165
2205
  static get identifiersFields() {
2166
2206
  return ['id'];
@@ -2495,8 +2535,6 @@ class ProductsIndex {
2495
2535
  'rate',
2496
2536
  ];
2497
2537
  const filter = [{ term: { published: true } }];
2498
- if (shop && shop !== Shops.ALL)
2499
- filter.push({ term: { tags: shop == Shops.GLAMSHOP ? 'feminino' : 'masculino' } });
2500
2538
  if (size > 9)
2501
2539
  fields.push(...['pricePaid', 'isGift', 'stock', 'weight', 'tags']);
2502
2540
  const query = {
@@ -2986,6 +3024,8 @@ const withUpdateFirestore = (MixinBase) => {
2986
3024
  try {
2987
3025
  const identifiers = getValueFromParams(data, keyField);
2988
3026
  const docRef = this.collection(collectionName).getDoc(identifiers.toString());
3027
+ if (!(await docRef.get()).data())
3028
+ throw new NotFoundError(`Document '${collectionName}/${Object.values(identifiers.toString())}' not found`);
2989
3029
  const plainFromData = this.model.toInstance(this.paramsToPlain(data));
2990
3030
  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 }));
2991
3031
  const builded = (intercepted === null || intercepted === void 0 ? void 0 : intercepted.instance) || plainFromData;
@@ -3550,6 +3590,47 @@ class LegacyOrderFirestoreRepository extends OrderFirestoreRepository {
3550
3590
  }
3551
3591
  }
3552
3592
 
3593
+ class OrderBlockedFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3594
+ constructor({ firestore, interceptors, }) {
3595
+ super({
3596
+ firestore,
3597
+ collectionName: 'paymentBlockedAttempts',
3598
+ model: OrderBlocked,
3599
+ interceptors,
3600
+ });
3601
+ }
3602
+ async createBlockedOrderOrPayment(checkout, blockType, type, limiteRange, card = null) {
3603
+ var _a, _b, _c, _d, _e, _f, _g, _h;
3604
+ return this.create(OrderBlocked.toInstance({
3605
+ customer: {
3606
+ name: ((_a = checkout.user) === null || _a === void 0 ? void 0 : _a.displayName) || '',
3607
+ cpf: ((_b = checkout.user) === null || _b === void 0 ? void 0 : _b.cpf) || '',
3608
+ id: (_c = checkout.user) === null || _c === void 0 ? void 0 : _c.id,
3609
+ email: ((_d = checkout.user) === null || _d === void 0 ? void 0 : _d.email) || '',
3610
+ phoneNumber: '+55' + ((_e = checkout.user) === null || _e === void 0 ? void 0 : _e.phone),
3611
+ isSubscriber: (_f = checkout.user) === null || _f === void 0 ? void 0 : _f.isSubscriber,
3612
+ subscriptionPlan: ((_g = checkout.user) === null || _g === void 0 ? void 0 : _g.subscriptionPlan) || '',
3613
+ shippingAddress: Object.assign(Object.assign({}, checkout.shippingAddress), { zip: this.formatZip((_h = checkout.shippingAddress) === null || _h === void 0 ? void 0 : _h.zip) }),
3614
+ },
3615
+ blockType,
3616
+ limiteRange,
3617
+ type,
3618
+ card,
3619
+ checkout: {
3620
+ id: checkout.id,
3621
+ shop: checkout.shop,
3622
+ total: checkout.totalPrice,
3623
+ },
3624
+ date: new Date(),
3625
+ }));
3626
+ }
3627
+ formatZip(zip) {
3628
+ if (zip.length === 8)
3629
+ return zip.substring(0, 5) + '-' + zip.substring(5, 8);
3630
+ return zip;
3631
+ }
3632
+ }
3633
+
3553
3634
  class PaymentFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3554
3635
  constructor({ firestore, interceptors }) {
3555
3636
  super({
@@ -4205,7 +4286,7 @@ const withHasuraGraphQL = (MixinBase) => {
4205
4286
  const response = await axios(request);
4206
4287
  if (!isNil(response.data.errors)) {
4207
4288
  this.logger.error({ req: request, res: response.data.errors });
4208
- throw new Error(response.data.errors);
4289
+ throw new Error(JSON.stringify(response.data.errors));
4209
4290
  }
4210
4291
  this.logger.log({ req: request, res: response.data });
4211
4292
  return response.data.data;
@@ -4572,6 +4653,7 @@ class CategoryFilterHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHa
4572
4653
  fields: [
4573
4654
  'id',
4574
4655
  'description',
4656
+ 'title',
4575
4657
  'slug',
4576
4658
  'enabled',
4577
4659
  { createdAt: { columnName: 'created_at' } },
@@ -4683,6 +4765,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
4683
4765
  'name',
4684
4766
  'description',
4685
4767
  'image',
4768
+ { images: { columnName: 'images', type: HasuraGraphQLColumnType.Jsonb } },
4686
4769
  'published',
4687
4770
  'shop',
4688
4771
  { shops: { columnName: 'shops', type: HasuraGraphQLColumnType.Jsonb } },
@@ -4715,7 +4798,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
4715
4798
  filters: {
4716
4799
  columnName: 'filters',
4717
4800
  foreignKeyColumn: { filter_id: 'id' },
4718
- fields: [{ filter: ['id', 'description', 'slug', 'enabled'] }],
4801
+ fields: [{ filter: ['id', 'title', 'description', 'slug', 'enabled'] }],
4719
4802
  bindPersistData: (value) => ({
4720
4803
  filters: { data: value.map((filter) => ({ filter_id: filter.id })) },
4721
4804
  }),
@@ -4738,12 +4821,21 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
4738
4821
  {
4739
4822
  metadata: {
4740
4823
  columnName: 'metadata',
4741
- fields: ['title', 'description'],
4824
+ fields: ['shop', 'title', 'description'],
4742
4825
  bindPersistData: (value) => ({
4743
4826
  metadata: { data: value },
4744
4827
  }),
4745
4828
  },
4746
4829
  },
4830
+ {
4831
+ metadatas: {
4832
+ columnName: 'metadatas',
4833
+ fields: ['shop', 'title', 'description'],
4834
+ bindPersistData: (value) => ({
4835
+ metadatas: { data: value },
4836
+ }),
4837
+ },
4838
+ },
4747
4839
  { isCollection: { columnName: 'is_collection' } },
4748
4840
  { isWishlist: { columnName: 'is_wishlist' } },
4749
4841
  'reference',
@@ -4758,14 +4850,29 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
4758
4850
  'theme',
4759
4851
  { bannerUrl: { columnName: 'banner_url' } },
4760
4852
  { mostRelevant: { columnName: 'most_relevant', type: HasuraGraphQLColumnType.Jsonb } },
4853
+ { mostRelevants: { columnName: 'most_relevants', type: HasuraGraphQLColumnType.Jsonb } },
4761
4854
  ],
4762
4855
  });
4763
4856
  this.productRepository = productRepository;
4764
4857
  this.categoryFilterRepository = categoryFilterRepository;
4765
4858
  }
4766
4859
  async create(params) {
4767
- const { metadata } = params, data = __rest(params, ["metadata"]);
4768
- return super.create(Object.assign(Object.assign({}, data), { isWishlist: false, metadata: metadata || { description: null, title: null } }));
4860
+ const { images, mostRelevants, metadatas } = params, data = __rest(params, ["images", "mostRelevants", "metadatas"]);
4861
+ return super.create(Object.assign(Object.assign({}, data), { isWishlist: false, metadatas: metadatas || [{ shop: null, description: null, title: null }], mostRelevants: mostRelevants || {
4862
+ [Shops.GLAMSHOP]: null,
4863
+ [Shops.MENSMARKET]: null,
4864
+ }, images: images || {
4865
+ [Shops.GLAMSHOP]: {
4866
+ brandBanner: null,
4867
+ brandBannerMobile: null,
4868
+ image: null,
4869
+ },
4870
+ [Shops.MENSMARKET]: {
4871
+ brandBanner: null,
4872
+ brandBannerMobile: null,
4873
+ image: null,
4874
+ },
4875
+ } }));
4769
4876
  }
4770
4877
  async get(identifiers) {
4771
4878
  var _a;
@@ -4774,12 +4881,12 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
4774
4881
  : super.get(identifiers);
4775
4882
  }
4776
4883
  async update(params) {
4777
- const { products, id: checkId, metadata, filters } = params, data = __rest(params, ["products", "id", "metadata", "filters"]);
4884
+ const { products, id: checkId, metadatas, filters } = params, data = __rest(params, ["products", "id", "metadatas", "filters"]);
4778
4885
  const plainData = this.paramsToPlain({ id: checkId });
4779
4886
  const id = await this.getId(plainData.id);
4780
4887
  const category = await super.update(Object.assign(Object.assign({ id }, data), { isWishlist: false }));
4781
4888
  category.products = products && (await this.updateProducts(+id, { products }));
4782
- category.metadata = metadata && (await this.updateMetadata(+id, { metadata }));
4889
+ category.metadatas = metadatas && (await this.updateMetadata(+id, { metadatas }));
4783
4890
  category.filters = filters && (await this.updateFilters(+id, { filters }));
4784
4891
  return category;
4785
4892
  }
@@ -4875,7 +4982,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
4875
4982
  return products;
4876
4983
  }
4877
4984
  async getChildren(parentId) {
4878
- const { category_tree } = await this.query('category_tree', ['id', 'name', 'parent_id', 'slug', 'reference'], {
4985
+ const { category_tree } = await this.query('category_tree', ['id', 'name', 'parent_id', 'slug', 'reference', 'published', 'shops'], {
4879
4986
  args: {
4880
4987
  type: 'category_tree_args',
4881
4988
  value: { parentid: parentId },
@@ -4955,23 +5062,36 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
4955
5062
  });
4956
5063
  return plainData.products;
4957
5064
  }
4958
- async updateMetadata(categoryId, { metadata }) {
4959
- const plainData = this.paramsToPlain({ metadata });
4960
- if (!plainData.metadata)
4961
- return null;
4962
- await this.mutation('update_category_metadata_by_pk', ['category_id'], {
4963
- pk_columns: {
4964
- value: { category_id: categoryId },
4965
- type: 'category_metadata_pk_columns_input',
4966
- required: true,
4967
- },
4968
- _set: {
4969
- value: omit(metadata, ['category_id']),
4970
- type: 'category_metadata_set_input',
4971
- required: true,
4972
- },
4973
- });
4974
- return plainData.metadata;
5065
+ async updateMetadata(categoryId, { metadatas }) {
5066
+ if (Array.isArray(metadatas) && !metadatas.length)
5067
+ return [];
5068
+ if (Array.isArray(metadatas) && metadatas.length) {
5069
+ await this.mutation('delete_category_metadata', ['affected_rows'], {
5070
+ where: {
5071
+ type: 'category_metadata_bool_exp',
5072
+ required: true,
5073
+ value: { category_id: { _eq: categoryId } },
5074
+ },
5075
+ });
5076
+ await this.mutation('insert_category_metadata', ['affected_rows'], {
5077
+ objects: {
5078
+ type: '[category_metadata_insert_input!]',
5079
+ required: true,
5080
+ value: metadatas.map((m) => (Object.assign({ category_id: categoryId }, m))),
5081
+ },
5082
+ });
5083
+ return metadatas;
5084
+ }
5085
+ if ('action' in metadatas && metadatas.action === 'remove' && metadatas.value.length) {
5086
+ await this.mutation('delete_category_metadata', ['affected_rows'], {
5087
+ where: {
5088
+ type: 'category_metadata_bool_exp',
5089
+ required: true,
5090
+ value: { category_id: { _eq: categoryId } },
5091
+ },
5092
+ });
5093
+ return [];
5094
+ }
4975
5095
  }
4976
5096
  async updateFilters(categoryId, { filters }) {
4977
5097
  if ('action' in filters && filters.action === 'remove' && filters.value.length) {
@@ -5065,6 +5185,7 @@ class FilterHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGrap
5065
5185
  interceptors,
5066
5186
  fields: [
5067
5187
  'id',
5188
+ 'title',
5068
5189
  'description',
5069
5190
  'slug',
5070
5191
  'enabled',
@@ -5452,6 +5573,8 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
5452
5573
  enableCount: false,
5453
5574
  },
5454
5575
  });
5576
+ if (!result.data.length)
5577
+ return null;
5455
5578
  const product = (_a = result === null || result === void 0 ? void 0 : result.data) === null || _a === void 0 ? void 0 : _a.shift();
5456
5579
  RoundProductPricesHelper.roundProductPrices(product);
5457
5580
  return product;
@@ -5751,6 +5874,24 @@ class ProductReviewsHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHa
5751
5874
  ],
5752
5875
  });
5753
5876
  }
5877
+ async updateManyStatus(reviews) {
5878
+ return await this.mutation('update_product_review_many', ['affected_rows'], {
5879
+ updates: {
5880
+ type: '[product_review_updates!]',
5881
+ required: true,
5882
+ value: [
5883
+ {
5884
+ _set: { status: true },
5885
+ where: { id: { _in: reviews.filter((review) => review.status).map((review) => review.id) } },
5886
+ },
5887
+ {
5888
+ _set: { status: false },
5889
+ where: { id: { _in: reviews.filter((review) => !review.status).map((review) => review.id) } },
5890
+ },
5891
+ ],
5892
+ },
5893
+ });
5894
+ }
5754
5895
  aproveReview(id) {
5755
5896
  return this.update({ id, status: true });
5756
5897
  }
@@ -5805,6 +5946,31 @@ class ProductStockNotificationHasuraGraphQLRepository extends withCrudHasuraGrap
5805
5946
  email,
5806
5947
  });
5807
5948
  }
5949
+ async getNotificationsReport(params, orderBy, pagination) {
5950
+ 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 } }));
5951
+ const orderByField = {
5952
+ [orderBy.field]: orderBy.direction,
5953
+ };
5954
+ const { report_stock_notification } = await this.query('report_stock_notification', ['product_id', 'ean', 'sku', 'name', 'stock', 'category_id', 'category', 'reference', 'emails_registered'], {
5955
+ where: {
5956
+ type: 'report_stock_notification_bool_exp',
5957
+ value: query,
5958
+ required: true,
5959
+ },
5960
+ order_by: {
5961
+ type: '[report_stock_notification_order_by]',
5962
+ value: orderByField,
5963
+ required: true,
5964
+ },
5965
+ });
5966
+ const data = (pagination === null || pagination === void 0 ? void 0 : pagination.limit)
5967
+ ? 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))
5968
+ : report_stock_notification;
5969
+ return {
5970
+ data,
5971
+ count: report_stock_notification.length,
5972
+ };
5973
+ }
5808
5974
  }
5809
5975
 
5810
5976
  class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
@@ -5913,11 +6079,14 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
5913
6079
  }
5914
6080
  }
5915
6081
 
6082
+ class WishlistHasuraGraphQL extends Wishlist {
6083
+ }
6084
+
5916
6085
  class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
5917
6086
  constructor({ endpoint, authOptions, interceptors, }, categoryFilterRepository) {
5918
6087
  super({
5919
6088
  tableName: 'category',
5920
- model: Wishlist,
6089
+ model: WishlistHasuraGraphQL,
5921
6090
  endpoint,
5922
6091
  authOptions,
5923
6092
  interceptors,
@@ -5978,12 +6147,21 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
5978
6147
  {
5979
6148
  metadata: {
5980
6149
  columnName: 'metadata',
5981
- fields: ['title', 'description'],
6150
+ fields: ['shop', 'title', 'description'],
5982
6151
  bindPersistData: (value) => ({
5983
6152
  metadata: { data: value },
5984
6153
  }),
5985
6154
  },
5986
6155
  },
6156
+ {
6157
+ metadatas: {
6158
+ columnName: 'metadatas',
6159
+ fields: ['shop', 'title', 'description'],
6160
+ bindPersistData: (value) => ({
6161
+ metadatas: { data: value },
6162
+ }),
6163
+ },
6164
+ },
5987
6165
  { isCollection: { columnName: 'is_collection' } },
5988
6166
  { isWishlist: { columnName: 'is_wishlist' } },
5989
6167
  'reference',
@@ -5998,15 +6176,34 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
5998
6176
  { personId: { columnName: 'person_id' } },
5999
6177
  { personName: { columnName: 'person_name' } },
6000
6178
  { personPhoto: { columnName: 'person_photo' } },
6179
+ { personType: { columnName: 'person_type' } },
6180
+ { personIsSubscriber: { columnName: 'person_is_subscriber' } },
6001
6181
  'theme',
6002
6182
  { bannerUrl: { columnName: 'banner_url' } },
6183
+ { personHasPhoto: { columnName: 'person_has_photo' } },
6184
+ { mostRelevants: { columnName: 'most_relevants', type: HasuraGraphQLColumnType.Jsonb } },
6003
6185
  ],
6004
6186
  });
6005
6187
  this.categoryFilterRepository = categoryFilterRepository;
6006
6188
  }
6007
6189
  async create(params) {
6008
- const { metadata } = params, data = __rest(params, ["metadata"]);
6009
- return super.create(Object.assign(Object.assign({}, data), { isWishlist: true, isCollection: true, brandCategory: false, metadata: metadata || { description: data.description, title: data.name } }));
6190
+ var _a;
6191
+ const { images, mostRelevants, metadatas } = params, data = __rest(params, ["images", "mostRelevants", "metadatas"]);
6192
+ 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 || {
6193
+ [Shops.GLAMSHOP]: null,
6194
+ [Shops.MENSMARKET]: null,
6195
+ }, images: images || {
6196
+ [Shops.GLAMSHOP]: {
6197
+ brandBanner: null,
6198
+ brandBannerMobile: null,
6199
+ image: null,
6200
+ },
6201
+ [Shops.MENSMARKET]: {
6202
+ brandBanner: null,
6203
+ brandBannerMobile: null,
6204
+ image: null,
6205
+ },
6206
+ } }));
6010
6207
  }
6011
6208
  async get(identifiers) {
6012
6209
  const data = await super.get(identifiers);
@@ -6019,12 +6216,12 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
6019
6216
  return await super.find(Object.assign(Object.assign({}, rest), { filters: Object.assign(Object.assign({}, filters), { isWishlist: { operator: Where.EQUALS, value: true } }) }));
6020
6217
  }
6021
6218
  async update(params) {
6022
- const { products, id: checkId, metadata, filters } = params, data = __rest(params, ["products", "id", "metadata", "filters"]);
6219
+ const { products, id: checkId, metadatas, filters } = params, data = __rest(params, ["products", "id", "metadatas", "filters"]);
6023
6220
  const plainData = this.paramsToPlain({ id: checkId });
6024
6221
  const id = plainData.id;
6025
6222
  const category = await super.update(Object.assign(Object.assign({ id }, data), { isWishlist: true, isCollection: true, brandCategory: false }));
6026
6223
  category.products = products && (await this.updateProducts(+id, { products }));
6027
- category.metadata = metadata && (await this.updateMetadata(+id, { metadata }));
6224
+ category.metadatas = metadatas && (await this.updateMetadata(+id, { metadatas }));
6028
6225
  return category;
6029
6226
  }
6030
6227
  async getWishlistBySlug(slug) {
@@ -6061,7 +6258,7 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
6061
6258
  throw new NotFoundError(`Wishlists from person ${personId} not found`);
6062
6259
  return data;
6063
6260
  }
6064
- getCategoryBySlug(slug, _shop) {
6261
+ async getCategoryBySlug(slug, _shop) {
6065
6262
  return this.getWishlistBySlug(slug);
6066
6263
  }
6067
6264
  async getCategoryByShop(shop) {
@@ -6079,6 +6276,13 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
6079
6276
  });
6080
6277
  return data;
6081
6278
  }
6279
+ async findBfluOrGlamgirlWishlists(params, shops) {
6280
+ var _a, _b;
6281
+ return this.find(Object.assign(Object.assign({}, params), { filters: Object.assign(Object.assign({}, params.filters), { published: true, shops: { operator: Where.LIKE, value: shops }, personType: (_b = (_a = params.filters) === null || _a === void 0 ? void 0 : _a.personType) !== null && _b !== void 0 ? _b : {
6282
+ operator: Where.IN,
6283
+ value: [PersonTypes.BFLU, PersonTypes.GLAMGIRL],
6284
+ } }), orderBy: Object.assign({ personHasPhoto: 'desc' }, omit(params.orderBy, ['personHasPhoto'])) }));
6285
+ }
6082
6286
  getCategoriesForHome(categoryIds, limit, gender) {
6083
6287
  return;
6084
6288
  }
@@ -6129,23 +6333,40 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
6129
6333
  });
6130
6334
  return plainData.products;
6131
6335
  }
6132
- async updateMetadata(categoryId, { metadata }) {
6133
- const plainData = this.paramsToPlain({ metadata });
6134
- if (!plainData.metadata)
6135
- return;
6136
- await this.mutation('update_category_metadata_by_pk', ['category_id'], {
6137
- pk_columns: {
6138
- value: { category_id: categoryId },
6139
- type: 'category_metadata_pk_columns_input',
6140
- required: true,
6141
- },
6142
- _set: {
6143
- value: omit(metadata, ['category_id']),
6144
- type: 'category_metadata_set_input',
6145
- required: true,
6146
- },
6147
- });
6148
- return plainData.metadata;
6336
+ async updateMetadata(categoryId, { metadatas }) {
6337
+ if (Array.isArray(metadatas) && !metadatas.length)
6338
+ return [];
6339
+ if (Array.isArray(metadatas) && metadatas.length) {
6340
+ const metadataUpdated = [];
6341
+ for (const data of metadatas) {
6342
+ const update = await this.mutation('update_category_metadata_by_pk', ['category_id', 'shop'], {
6343
+ pk_columns: {
6344
+ value: { category_id: categoryId, shop: data.shop },
6345
+ type: 'category_metadata_pk_columns_input',
6346
+ required: true,
6347
+ },
6348
+ _set: {
6349
+ value: omit(data, ['category_id', 'shop']),
6350
+ type: 'category_metadata_set_input',
6351
+ required: true,
6352
+ },
6353
+ });
6354
+ metadataUpdated.push(update);
6355
+ }
6356
+ return metadataUpdated;
6357
+ }
6358
+ if ('action' in metadatas && metadatas.action === 'remove' && metadatas.value.length) {
6359
+ for (let i = 0; i < metadatas.value.length; i++) {
6360
+ await this.mutation('delete_category_metadata', ['affected_rows'], {
6361
+ where: {
6362
+ type: 'category_metadata_bool_exp',
6363
+ required: true,
6364
+ value: { category_id: { _eq: categoryId }, shop: metadatas.value[i].shop },
6365
+ },
6366
+ });
6367
+ }
6368
+ return [];
6369
+ }
6149
6370
  }
6150
6371
  }
6151
6372
  __decorate([
@@ -6166,5 +6387,11 @@ __decorate([
6166
6387
  __metadata("design:paramtypes", [String]),
6167
6388
  __metadata("design:returntype", Promise)
6168
6389
  ], WishlistHasuraGraphQLRepository.prototype, "getCategoryByShop", null);
6390
+ __decorate([
6391
+ Log(),
6392
+ __metadata("design:type", Function),
6393
+ __metadata("design:paramtypes", [Object, Array]),
6394
+ __metadata("design:returntype", Promise)
6395
+ ], WishlistHasuraGraphQLRepository.prototype, "findBfluOrGlamgirlWishlists", null);
6169
6396
 
6170
- export { AccessoryImportances, Address, Area, Authentication, AuthenticationFirebaseAuthService, AxiosAdapter, Base, BaseModel, BeardProblems, BeardSizes, BeautyProductImportances, BeautyProfile, BeautyQuestionsHelper, BillingStatus, BodyProblems, BodyShapes, BodyTattoos, Buy2Win, Buy2WinFirestoreRepository, Campaign, CampaignBanner, CampaignDashboard, CampaignDashboardFirestoreRepository, CampaignHashtag, CampaignHashtagFirestoreRepository, Category, CategoryCollectionChildren, CategoryCollectionChildrenHasuraGraphQLRepository, CategoryFilter, CategoryFilterHasuraGraphQLRepository, CategoryFirestoreRepository, CategoryHasuraGraphQL, CategoryHasuraGraphQLRepository, Checkout, CheckoutFirestoreRepository, CheckoutSubscription, CheckoutSubscriptionFirestoreRepository, CheckoutTypes, ClassNameHelper, ConnectBaseDocumentSnapshot, ConnectCollectionService, ConnectDocumentService, ConnectFirestoreService, Coupon, CouponFirestoreRepository, CouponSubtypes, CouponTypes, Debug, DebugDecoratorHelper, DebugHelper, DebugNamespaces, DuplicatedResultsError, Edition, EditionStatus, Exclusivities, FaceSkinOilinesses, FaceSkinProblems, FaceSkinTones, FamilyIncomes, Filter, FilterHasuraGraphQLRepository, FilterOption, FilterOptionHasuraGraphQLRepository, FilterType, FirebaseFileUploaderService, FragranceImportances, GenderDestination, HairColors, HairProblems, HairStrands, HairTypes, Home, HomeFirestoreRepository, InvalidArgumentError, KitProduct, KitProductHasuraGraphQL, Lead, LeadFirestoreRepository, LegacyOrderFirestoreRepository, LineItem, Log, Logger, NotFoundError, OfficePosition, Order, OrderFirestoreRepository, OrderStatus, Payment, PaymentFirestoreRepository, PaymentType, Plans, Product, ProductFirestoreRepository, ProductHasuraGraphQL, ProductHasuraGraphQLRepository, ProductReviews, ProductReviewsHasuraGraphQLRepository, ProductSpents, ProductStockNotification, ProductStockNotificationHasuraGraphQLRepository, ProductVariantFirestoreRepository, ProductsIndex, QuestionsFilters, RecoveryPassword, ReflectHelper, Register, RegisterFirebaseAuthService, RequiredArgumentError, RoundProductPricesHelper, ShippingMethod, ShopMenu, ShopMenuFirestoreRepository, ShopPageName, ShopSettings, ShopSettingsFirestoreRepository, Shops, SignInMethods, SignOut, Status, Subscription, SubscriptionEditionFirestoreRepository, SubscriptionFirestoreRepository, SubscriptionMaterialization, SubscriptionMaterializationFirestoreRepository, SubscriptionPayment, SubscriptionPaymentFirestoreRepository, SubscriptionPlan, SubscriptionPlanFirestoreRepository, SubscriptionProductFirestoreRepository, SubscriptionSummary, SubscriptionSummaryFirestoreRepository, Trace, UnauthorizedError, UpdateOptionActions, UpdateUserImage, User, UserAddress, UserAddressFirestoreRepository, UserAlreadyRegisteredError, UserBeautyProfileFirestoreRepository, UserFirestoreRepository, UserPaymentMethod, UserPaymentMethodFirestoreRepository, UserType, Variant, VariantHasuraGraphQL, VariantHasuraGraphQLRepository, WeakPasswordError, Where, Wishlist, WishlistHasuraGraphQLRepository, is, isDebuggable, isUUID, parseDateTime, withCreateFirestore, withCreateHasuraGraphQL, withCrudFirestore, withCrudHasuraGraphQL, withDeleteFirestore, withDeleteHasuraGraphQL, withFindFirestore, withFindHasuraGraphQL, withFirestore, withGetFirestore, withGetHasuraGraphQL, withHasuraGraphQL, withHelpers, withSubCollection, withUpdateFirestore, withUpdateHasuraGraphQL };
6397
+ export { AccessoryImportances, Address, Area, Authentication, AuthenticationFirebaseAuthService, AxiosAdapter, Base, BaseModel, BeardProblems, BeardSizes, BeautyProductImportances, BeautyProfile, BeautyQuestionsHelper, BillingStatus, BodyProblems, BodyShapes, BodyTattoos, Buy2Win, Buy2WinFirestoreRepository, Campaign, CampaignBanner, CampaignDashboard, CampaignDashboardFirestoreRepository, CampaignHashtag, CampaignHashtagFirestoreRepository, Category, CategoryCollectionChildren, CategoryCollectionChildrenHasuraGraphQLRepository, CategoryFilter, CategoryFilterHasuraGraphQLRepository, CategoryFirestoreRepository, CategoryHasuraGraphQL, CategoryHasuraGraphQLRepository, Checkout, CheckoutFirestoreRepository, CheckoutSubscription, CheckoutSubscriptionFirestoreRepository, CheckoutTypes, ClassNameHelper, ConnectBaseDocumentSnapshot, ConnectCollectionService, ConnectDocumentService, ConnectFirestoreService, Coupon, CouponFirestoreRepository, CouponSubtypes, CouponTypes, Debug, DebugDecoratorHelper, DebugHelper, DebugNamespaces, DuplicatedResultsError, Edition, EditionStatus, Exclusivities, FaceSkinOilinesses, FaceSkinProblems, FaceSkinTones, FamilyIncomes, Filter, FilterHasuraGraphQLRepository, FilterOption, FilterOptionHasuraGraphQLRepository, FilterType, FirebaseFileUploaderService, FragranceImportances, GenderDestination, HairColors, HairProblems, HairStrands, HairTypes, Home, HomeFirestoreRepository, InvalidArgumentError, KitProduct, KitProductHasuraGraphQL, Lead, LeadFirestoreRepository, LegacyOrderFirestoreRepository, LineItem, Log, Logger, NotFoundError, OfficePosition, Order, OrderBlocked, OrderBlockedFirestoreRepository, OrderFirestoreRepository, OrderStatus, Payment, PaymentFirestoreRepository, PaymentType, PersonTypes, Plans, Product, ProductFirestoreRepository, ProductHasuraGraphQL, ProductHasuraGraphQLRepository, ProductReviews, ProductReviewsHasuraGraphQLRepository, ProductSpents, ProductStockNotification, ProductStockNotificationHasuraGraphQLRepository, ProductVariantFirestoreRepository, ProductsIndex, QuestionsFilters, RecoveryPassword, ReflectHelper, Register, RegisterFirebaseAuthService, RequiredArgumentError, RoundProductPricesHelper, ShippingMethod, ShopMenu, ShopMenuFirestoreRepository, ShopPageName, ShopSettings, ShopSettingsFirestoreRepository, Shops, SignInMethods, SignOut, Status, Subscription, SubscriptionEditionFirestoreRepository, SubscriptionFirestoreRepository, SubscriptionMaterialization, SubscriptionMaterializationFirestoreRepository, SubscriptionPayment, SubscriptionPaymentFirestoreRepository, SubscriptionPlan, SubscriptionPlanFirestoreRepository, SubscriptionProductFirestoreRepository, SubscriptionSummary, SubscriptionSummaryFirestoreRepository, Trace, UnauthorizedError, UpdateOptionActions, UpdateUserImage, User, UserAddress, UserAddressFirestoreRepository, UserAlreadyRegisteredError, UserBeautyProfileFirestoreRepository, UserFirestoreRepository, UserPaymentMethod, UserPaymentMethodFirestoreRepository, UserType, Variant, VariantHasuraGraphQL, VariantHasuraGraphQLRepository, WeakPasswordError, Where, Wishlist, WishlistHasuraGraphQLRepository, is, isDebuggable, isUUID, parseDateTime, withCreateFirestore, withCreateHasuraGraphQL, withCrudFirestore, withCrudHasuraGraphQL, withDeleteFirestore, withDeleteHasuraGraphQL, withFindFirestore, withFindHasuraGraphQL, withFirestore, withGetFirestore, withGetHasuraGraphQL, withHasuraGraphQL, withHelpers, withSubCollection, withUpdateFirestore, withUpdateHasuraGraphQL };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@infrab4a/connect",
3
- "version": "4.9.7-beta.2",
3
+ "version": "4.9.7-beta.21",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org"
6
6
  },