@infrab4a/connect 3.14.4 → 3.15.0-beta.1

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 (77) hide show
  1. package/bundles/infrab4a-connect.umd.js +202 -650
  2. package/bundles/infrab4a-connect.umd.js.map +1 -1
  3. package/domain/catalog/models/category-filter.d.ts +0 -2
  4. package/domain/catalog/models/category.d.ts +27 -5
  5. package/domain/catalog/models/index.d.ts +0 -1
  6. package/domain/catalog/models/kit-product.d.ts +3 -3
  7. package/domain/catalog/models/product.d.ts +40 -5
  8. package/domain/catalog/repositories/category-filter.repository.d.ts +0 -1
  9. package/domain/catalog/repositories/index.d.ts +0 -1
  10. package/domain/shop-settings/enums/index.d.ts +1 -0
  11. package/domain/shop-settings/enums/shop-page-name.enum.d.ts +19 -0
  12. package/domain/shop-settings/models/campaign-banner.d.ts +11 -0
  13. package/domain/shop-settings/models/campaign.d.ts +10 -0
  14. package/domain/shop-settings/models/index.d.ts +2 -0
  15. package/domain/shop-settings/models/shop-settings.d.ts +2 -1
  16. package/domain/shop-settings/models/types/campaign-page.d.ts +17 -0
  17. package/domain/shop-settings/models/types/index.d.ts +4 -0
  18. package/domain/shop-settings/models/types/sections.type.d.ts +17 -0
  19. package/domain/shop-settings/models/types/shop-gift.type.d.ts +8 -0
  20. package/domain/shop-settings/models/types/shop-post.type.d.ts +7 -0
  21. package/domain/shop-settings/models/types/shop-section.type.d.ts +3 -0
  22. package/domain/shop-settings/repositories/campaign-banner.repository.d.ts +4 -0
  23. package/domain/shop-settings/repositories/campaign.repository.d.ts +4 -0
  24. package/domain/shop-settings/repositories/index.d.ts +2 -0
  25. package/esm2015/domain/catalog/models/category-filter.js +1 -6
  26. package/esm2015/domain/catalog/models/category.js +10 -6
  27. package/esm2015/domain/catalog/models/index.js +1 -2
  28. package/esm2015/domain/catalog/models/kit-product.js +6 -6
  29. package/esm2015/domain/catalog/models/product.js +24 -6
  30. package/esm2015/domain/catalog/repositories/category-filter.repository.js +1 -1
  31. package/esm2015/domain/catalog/repositories/index.js +1 -2
  32. package/esm2015/domain/shop-settings/enums/index.js +2 -1
  33. package/esm2015/domain/shop-settings/enums/shop-page-name.enum.js +21 -0
  34. package/esm2015/domain/shop-settings/models/campaign-banner.js +7 -0
  35. package/esm2015/domain/shop-settings/models/campaign.js +7 -0
  36. package/esm2015/domain/shop-settings/models/index.js +3 -1
  37. package/esm2015/domain/shop-settings/models/shop-settings.js +1 -1
  38. package/esm2015/domain/shop-settings/models/types/campaign-page.js +2 -0
  39. package/esm2015/domain/shop-settings/models/types/index.js +5 -1
  40. package/esm2015/domain/shop-settings/models/types/sections.type.js +2 -0
  41. package/esm2015/domain/shop-settings/models/types/shop-gift.type.js +2 -0
  42. package/esm2015/domain/shop-settings/models/types/shop-post.type.js +2 -0
  43. package/esm2015/domain/shop-settings/models/types/shop-section.type.js +1 -1
  44. package/esm2015/domain/shop-settings/repositories/campaign-banner.repository.js +2 -0
  45. package/esm2015/domain/shop-settings/repositories/campaign.repository.js +2 -0
  46. package/esm2015/domain/shop-settings/repositories/index.js +3 -1
  47. package/esm2015/infra/firebase/firestore/repositories/shop-settings/campaign-banner-firestore.repository.js +12 -0
  48. package/esm2015/infra/firebase/firestore/repositories/shop-settings/campaign-firestore.repository.js +12 -0
  49. package/esm2015/infra/firebase/firestore/repositories/shop-settings/index.js +3 -1
  50. package/esm2015/infra/hasura-graphql/mixins/helpers/bind-filter-query.helper.js +2 -2
  51. package/esm2015/infra/hasura-graphql/repositories/catalog/category-filter-hasura-graphql.repository.js +1 -52
  52. package/esm2015/infra/hasura-graphql/repositories/catalog/category-hasura-graphql.repository.js +50 -36
  53. package/esm2015/infra/hasura-graphql/repositories/catalog/index.js +1 -2
  54. package/fesm2015/infrab4a-connect.js +140 -424
  55. package/fesm2015/infrab4a-connect.js.map +1 -1
  56. package/infra/firebase/firestore/repositories/shop-settings/campaign-banner-firestore.repository.d.ts +8 -0
  57. package/infra/firebase/firestore/repositories/shop-settings/campaign-firestore.repository.d.ts +8 -0
  58. package/infra/firebase/firestore/repositories/shop-settings/index.d.ts +2 -0
  59. package/infra/hasura-graphql/repositories/catalog/category-filter-hasura-graphql.repository.d.ts +0 -1
  60. package/infra/hasura-graphql/repositories/catalog/index.d.ts +0 -1
  61. package/package.json +1 -1
  62. package/domain/catalog/models/category-base.d.ts +0 -30
  63. package/domain/catalog/models/category-for-product.d.ts +0 -5
  64. package/domain/catalog/models/product-base.d.ts +0 -40
  65. package/domain/catalog/models/product-for-category.d.ts +0 -7
  66. package/domain/catalog/models/product-for-kit.d.ts +0 -7
  67. package/domain/catalog/models/wishlist.d.ts +0 -6
  68. package/domain/catalog/repositories/wishlist.repository.d.ts +0 -6
  69. package/esm2015/domain/catalog/models/category-base.js +0 -18
  70. package/esm2015/domain/catalog/models/category-for-product.js +0 -7
  71. package/esm2015/domain/catalog/models/product-base.js +0 -25
  72. package/esm2015/domain/catalog/models/product-for-category.js +0 -14
  73. package/esm2015/domain/catalog/models/product-for-kit.js +0 -14
  74. package/esm2015/domain/catalog/models/wishlist.js +0 -7
  75. package/esm2015/domain/catalog/repositories/wishlist.repository.js +0 -2
  76. package/esm2015/infra/hasura-graphql/repositories/catalog/wishlist-hasura-graphql.repository.js +0 -252
  77. package/infra/hasura-graphql/repositories/catalog/wishlist-hasura-graphql.repository.d.ts +0 -27
@@ -1193,93 +1193,19 @@ class Filter extends BaseModel {
1193
1193
  }
1194
1194
  }
1195
1195
 
1196
- class CategoryBase extends BaseModel {
1196
+ class Category extends BaseModel {
1197
1197
  static get identifiersFields() {
1198
1198
  return ['id'];
1199
1199
  }
1200
1200
  }
1201
1201
  __decorate([
1202
- Type(() => CategoryBase),
1203
- __metadata("design:type", CategoryBase)
1204
- ], CategoryBase.prototype, "parent", void 0);
1202
+ Type(() => Category),
1203
+ __metadata("design:type", Category)
1204
+ ], Category.prototype, "parent", void 0);
1205
1205
  __decorate([
1206
1206
  Type(() => Filter),
1207
1207
  __metadata("design:type", Array)
1208
- ], CategoryBase.prototype, "filters", void 0);
1209
-
1210
- class CategoryForProduct extends CategoryBase {
1211
- static get identifiersFields() {
1212
- return ['id'];
1213
- }
1214
- }
1215
-
1216
- class ProductBase extends BaseModel {
1217
- get evaluation() {
1218
- return {
1219
- reviews: this.reviews,
1220
- count: this.reviewsTotal,
1221
- rating: this.rate,
1222
- };
1223
- }
1224
- set evaluation(evaluation) {
1225
- if (!evaluation) {
1226
- this.reviews = null;
1227
- this.reviewsTotal = null;
1228
- this.rate = null;
1229
- return;
1230
- }
1231
- this.reviews = evaluation.reviews || this.reviews;
1232
- this.reviewsTotal = evaluation.count || this.reviewsTotal;
1233
- this.rate = evaluation.rating || this.rate;
1234
- }
1235
- static get identifiersFields() {
1236
- return ['id'];
1237
- }
1238
- }
1239
-
1240
- class ProductForKit extends ProductBase {
1241
- static get identifiersFields() {
1242
- return ['id'];
1243
- }
1244
- }
1245
- __decorate([
1246
- Type(() => CategoryForProduct),
1247
- __metadata("design:type", CategoryForProduct)
1248
- ], ProductForKit.prototype, "category", void 0);
1249
-
1250
- class KitProduct extends BaseModel {
1251
- static get identifiersFields() {
1252
- return ['productId', 'kitProductId'];
1253
- }
1254
- }
1255
- __decorate([
1256
- Type(() => ProductForKit),
1257
- __metadata("design:type", ProductForKit)
1258
- ], KitProduct.prototype, "kit", void 0);
1259
- __decorate([
1260
- Type(() => ProductForKit),
1261
- __metadata("design:type", ProductForKit)
1262
- ], KitProduct.prototype, "product", void 0);
1263
-
1264
- class ProductForCategory extends ProductBase {
1265
- static get identifiersFields() {
1266
- return ['id'];
1267
- }
1268
- }
1269
- __decorate([
1270
- Type(() => KitProduct),
1271
- __metadata("design:type", Array)
1272
- ], ProductForCategory.prototype, "kitProducts", void 0);
1273
-
1274
- class Category extends CategoryBase {
1275
- static get identifiersFields() {
1276
- return ['id'];
1277
- }
1278
- }
1279
- __decorate([
1280
- Type(() => ProductForCategory),
1281
- __metadata("design:type", Array)
1282
- ], Category.prototype, "childrenProducts", void 0);
1208
+ ], Category.prototype, "filters", void 0);
1283
1209
 
1284
1210
  class CategoryCollectionChildren extends BaseModel {
1285
1211
  static get identifiersFields() {
@@ -1300,10 +1226,6 @@ __decorate([
1300
1226
  Type(() => Filter),
1301
1227
  __metadata("design:type", Filter)
1302
1228
  ], CategoryFilter.prototype, "filter", void 0);
1303
- __decorate([
1304
- Type(() => Category),
1305
- __metadata("design:type", Category)
1306
- ], CategoryFilter.prototype, "category", void 0);
1307
1229
 
1308
1230
  var GenderDestination;
1309
1231
  (function (GenderDestination) {
@@ -1326,29 +1248,55 @@ class FilterOption extends BaseModel {
1326
1248
  }
1327
1249
  }
1328
1250
 
1329
- class Product extends ProductBase {
1251
+ class Product extends BaseModel {
1252
+ get evaluation() {
1253
+ return {
1254
+ reviews: this.reviews,
1255
+ count: this.reviewsTotal,
1256
+ rating: this.rate,
1257
+ };
1258
+ }
1259
+ set evaluation(evaluation) {
1260
+ if (!evaluation) {
1261
+ this.reviews = null;
1262
+ this.reviewsTotal = null;
1263
+ this.rate = null;
1264
+ return;
1265
+ }
1266
+ this.reviews = evaluation.reviews || this.reviews;
1267
+ this.reviewsTotal = evaluation.count || this.reviewsTotal;
1268
+ this.rate = evaluation.rating || this.rate;
1269
+ }
1330
1270
  static get identifiersFields() {
1331
1271
  return ['id'];
1332
1272
  }
1333
1273
  }
1334
1274
  __decorate([
1335
- Type(() => CategoryForProduct),
1336
- __metadata("design:type", CategoryForProduct)
1275
+ Type(() => Category),
1276
+ __metadata("design:type", Category)
1337
1277
  ], Product.prototype, "category", void 0);
1338
1278
  __decorate([
1339
1279
  Type(() => KitProduct),
1340
1280
  __metadata("design:type", Array)
1341
1281
  ], Product.prototype, "kitProducts", void 0);
1342
1282
 
1343
- class Variant extends BaseModel {
1283
+ class KitProduct extends BaseModel {
1344
1284
  static get identifiersFields() {
1345
- return ['id', 'productId'];
1285
+ return ['productId', 'kitProductId'];
1346
1286
  }
1347
1287
  }
1288
+ __decorate([
1289
+ Type(() => Product),
1290
+ __metadata("design:type", Product)
1291
+ ], KitProduct.prototype, "kit", void 0);
1292
+ __decorate([
1293
+ Type(() => Product),
1294
+ __metadata("design:type", Product)
1295
+ ], KitProduct.prototype, "product", void 0);
1348
1296
 
1349
- class Wishlist extends Category {
1297
+ class Variant extends BaseModel {
1350
1298
  static get identifiersFields() {
1351
- return ['id'];
1299
+ return ['id', 'productId'];
1352
1300
  }
1353
1301
  }
1354
1302
 
@@ -1510,6 +1458,27 @@ var QuestionsFilters;
1510
1458
  QuestionsFilters["PRODUCT_SPENT"] = "Qual \u00E9 o seu nivel de gasto mensal em produtos de beleza e cuidados pessoais?";
1511
1459
  })(QuestionsFilters || (QuestionsFilters = {}));
1512
1460
 
1461
+ var ShopPageName;
1462
+ (function (ShopPageName) {
1463
+ ShopPageName["LP_CLUB"] = "LP_CLUBE";
1464
+ ShopPageName["SUBSCRIBER_PANEL"] = "SUBSCRIBER_PANEL";
1465
+ ShopPageName["INVITE_FRIENDS"] = "INVITE_FRIENDS";
1466
+ ShopPageName["INVITE_AND_WIN"] = "INVITE_AND_WIN";
1467
+ ShopPageName["WIN_GLAMPOINTS"] = "WIN_GLAMPOINTS";
1468
+ ShopPageName["POSTS"] = "POSTS";
1469
+ ShopPageName["GLAMPOINTS_SHOWCASE"] = "GLAMPOINTS_SHOWCASE";
1470
+ ShopPageName["LP_EDITIONS"] = "LP_EDITIONS";
1471
+ ShopPageName["LP_GLAMBOX_EDITION"] = "LP_GLAMBOX_EDITION";
1472
+ ShopPageName["LP_GLAMBOX_PROMOTION"] = "LP_GLAMBOX_PROMOTION";
1473
+ ShopPageName["LP_GLAMBAG_PROMOTION"] = "LP_GLAMBAG_PROMOTION";
1474
+ ShopPageName["LP_GLAMPASS_PROMOTION"] = "LP_GLAMPASS_PROMOTION";
1475
+ ShopPageName["LP_SUBSCRIPTION_PROMOTION"] = "LP_SUBSCRIPTION_PROMOTION";
1476
+ ShopPageName["LP_GLAMPARTNER_PROMOTION"] = "LP_GLAMPARTNER_PROMOTION";
1477
+ ShopPageName["LP_GLAMQUEENS"] = "LP_GLAMQUEENS";
1478
+ ShopPageName["LP_INVITE"] = "LP_INVITE";
1479
+ ShopPageName["LP_LIVELO"] = "LP_LIVELO";
1480
+ })(ShopPageName || (ShopPageName = {}));
1481
+
1513
1482
  class BeautyQuestionsHelper {
1514
1483
  static getAnswers(filter) {
1515
1484
  switch (filter) {
@@ -1554,6 +1523,18 @@ class BeautyQuestionsHelper {
1554
1523
  }
1555
1524
  }
1556
1525
 
1526
+ class Campaign extends BaseModel {
1527
+ static get identifiersFields() {
1528
+ return ['id'];
1529
+ }
1530
+ }
1531
+
1532
+ class CampaignBanner extends BaseModel {
1533
+ static get identifiersFields() {
1534
+ return ['id'];
1535
+ }
1536
+ }
1537
+
1557
1538
  class Home extends BaseModel {
1558
1539
  static get identifiersFields() {
1559
1540
  return ['id'];
@@ -2515,6 +2496,24 @@ class SubscriptionPlanFirestoreRepository extends withCrudFirestore(withHelpers(
2515
2496
  }
2516
2497
  }
2517
2498
 
2499
+ class CampaignBannerFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
2500
+ constructor(firestore) {
2501
+ super();
2502
+ this.firestore = firestore;
2503
+ this.collectionName = 'banners';
2504
+ this.model = CampaignBanner;
2505
+ }
2506
+ }
2507
+
2508
+ class CampaignFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
2509
+ constructor(firestore) {
2510
+ super();
2511
+ this.firestore = firestore;
2512
+ this.collectionName = 'campaigns';
2513
+ this.model = Campaign;
2514
+ }
2515
+ }
2516
+
2518
2517
  class HomeFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
2519
2518
  constructor(firestore) {
2520
2519
  super();
@@ -2760,7 +2759,7 @@ BindFilterQueryHelper.BuildWhereSentence = (field, options, fields) => {
2760
2759
  const fieldOptions = AttributeOptionHelper.FindByAttribute(key, (fieldSentenceOptions === null || fieldSentenceOptions === void 0 ? void 0 : fieldSentenceOptions.fields) || fields);
2761
2760
  const columnName = fieldOptions.columnName;
2762
2761
  const columnFields = fieldOptions.fields;
2763
- return Object.assign(Object.assign({}, variables), { [columnName]: BindFilterQueryHelper.BuildWhereSentence(key, options[key], (fieldSentenceOptions === null || fieldSentenceOptions === void 0 ? void 0 : fieldSentenceOptions.fields) || columnFields || fields) });
2762
+ return Object.assign(Object.assign({}, variables), { [columnName]: BindFilterQueryHelper.BuildWhereSentence(key, options[key], columnFields || []) });
2764
2763
  }, {});
2765
2764
  if (!Array.isArray(options) && !isNil(fieldSentenceOptions.fields))
2766
2765
  return {
@@ -3359,60 +3358,9 @@ class CategoryFilterHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHa
3359
3358
  ],
3360
3359
  },
3361
3360
  },
3362
- {
3363
- category: {
3364
- columnName: 'category',
3365
- foreignKeyColumn: { id: 'categoryId' },
3366
- fields: [
3367
- 'id',
3368
- 'description',
3369
- {
3370
- products: {
3371
- columnName: 'products',
3372
- fields: ['product_id'],
3373
- from: (value) => value.map((product) => product.product_id.toString()),
3374
- to: (productIds) => productIds.map((productId) => ({
3375
- product_id: +productId,
3376
- })),
3377
- },
3378
- },
3379
- {
3380
- childrenProducts: {
3381
- columnName: 'children_products',
3382
- foreignKeyColumn: { category_id: 'id' },
3383
- fields: [
3384
- 'id',
3385
- 'name',
3386
- 'slug',
3387
- {
3388
- categories: {
3389
- columnName: 'categories',
3390
- fields: ['category_id'],
3391
- bindPersistData: (value) => ({
3392
- categories: { data: value.map((category) => ({ category_id: +category })) },
3393
- }),
3394
- to: (categories) => categories.map((categoryId) => +categoryId),
3395
- from: (categories) => (categories === null || categories === void 0 ? void 0 : categories.map((category) => { var _a; return (_a = category === null || category === void 0 ? void 0 : category.category_id) === null || _a === void 0 ? void 0 : _a.toString(); })) || [],
3396
- },
3397
- },
3398
- ],
3399
- },
3400
- },
3401
- ],
3402
- },
3403
- },
3404
3361
  ],
3405
3362
  });
3406
3363
  }
3407
- deleteByCategory(categoryId) {
3408
- return this.mutation('delete_category_filter', ['affected_rows'], {
3409
- where: {
3410
- type: 'category_filter_bool_exp',
3411
- required: true,
3412
- value: { category_id: { _eq: categoryId } },
3413
- },
3414
- });
3415
- }
3416
3364
  deleteByCategoryAndFilter(categoryId, filterId) {
3417
3365
  return this.mutation('delete_category_filter', ['affected_rows'], {
3418
3366
  where: {
@@ -3495,7 +3443,6 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
3495
3443
  },
3496
3444
  },
3497
3445
  { isCollection: { columnName: 'is_collection' } },
3498
- { isWishlist: { columnName: 'is_wishlist' } },
3499
3446
  'reference',
3500
3447
  { parentId: { columnName: 'parent_id' } },
3501
3448
  {
@@ -3516,7 +3463,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
3516
3463
  });
3517
3464
  return __awaiter(this, void 0, void 0, function* () {
3518
3465
  const { metadata } = params, data = __rest(params, ["metadata"]);
3519
- return _super.create.call(this, Object.assign(Object.assign({}, data), { isWishlist: false, metadata: metadata || { description: null, title: null } }));
3466
+ return _super.create.call(this, Object.assign(Object.assign({}, data), { metadata: metadata || { description: null, title: null } }));
3520
3467
  });
3521
3468
  }
3522
3469
  get(identifiers) {
@@ -3538,7 +3485,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
3538
3485
  const { products, id: checkId, metadata, filters } = params, data = __rest(params, ["products", "id", "metadata", "filters"]);
3539
3486
  const plainData = this.paramsToPlain({ id: checkId });
3540
3487
  const id = yield this.getId(plainData.id);
3541
- const category = yield _super.update.call(this, Object.assign(Object.assign({ id }, data), { isWishlist: false }));
3488
+ const category = yield _super.update.call(this, Object.assign({ id }, data));
3542
3489
  category.products = products && (yield this.updateProducts(+id, { products }));
3543
3490
  category.metadata = metadata && (yield this.updateMetadata(+id, { metadata }));
3544
3491
  category.filters = filters && (yield this.updateFilters(+id, { filters }));
@@ -3554,7 +3501,6 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
3554
3501
  slug,
3555
3502
  shops: { operator: Where.IN, value: [shop] },
3556
3503
  published: { operator: Where.EQUALS, value: true },
3557
- isWishlist: { operator: Where.EQUALS, value: false },
3558
3504
  },
3559
3505
  options: {
3560
3506
  enableCount: false,
@@ -3575,7 +3521,6 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
3575
3521
  filters: {
3576
3522
  shops: { operator: Where.IN, value: [shop] },
3577
3523
  published: { operator: Where.EQUALS, value: true },
3578
- isWishlist: { operator: Where.EQUALS, value: false },
3579
3524
  },
3580
3525
  options: {
3581
3526
  enableCount: false,
@@ -3720,42 +3665,59 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
3720
3665
  }
3721
3666
  if ('action' in filters && filters.action === 'merge' && filters.value.length) {
3722
3667
  let filtersList = [];
3723
- const currentFilters = yield this.categoryFilterRepository
3724
- .find({
3725
- filters: {
3726
- categoryId,
3727
- },
3728
- })
3729
- .then((res) => res.data);
3730
- const currentFiltersId = currentFilters.map((f) => f.id);
3731
- const filtersUpdatedId = filters.value.map((f) => f.id);
3732
- const filterToBeDeleted = currentFiltersId.filter((c) => !filtersUpdatedId.includes(c));
3733
- const filterToBeInserted = filtersUpdatedId.filter((c) => !currentFiltersId.includes(c));
3734
- for (const filter of filterToBeDeleted) {
3735
- const index = currentFilters.findIndex((f) => f.id == filter);
3736
- if (index != -1) {
3737
- currentFilters.splice(index, 1);
3668
+ for (let i = 0; i < filters.value.length; i++) {
3669
+ try {
3670
+ const hasFilter = yield this.categoryFilterRepository
3671
+ .find({
3672
+ filters: {
3673
+ categoryId,
3674
+ filterId: filters.value[i].id,
3675
+ },
3676
+ })
3677
+ .then((data) => data.data.shift());
3678
+ if (hasFilter) {
3679
+ filtersList.push(hasFilter);
3680
+ }
3681
+ else {
3682
+ const newCategoryFilter = yield this.categoryFilterRepository.create({
3683
+ filterId: filters.value[i].id,
3684
+ categoryId,
3685
+ });
3686
+ filtersList.push(newCategoryFilter);
3687
+ }
3688
+ }
3689
+ catch (error) {
3690
+ console.log('catch error: ', error);
3738
3691
  }
3739
- yield this.categoryFilterRepository.deleteByCategoryAndFilter(categoryId, filter);
3740
- }
3741
- for (const filter of filterToBeInserted) {
3742
- const newCategoryFilter = yield this.categoryFilterRepository.create({
3743
- filterId: filter,
3744
- categoryId,
3745
- });
3746
- filtersList.push(newCategoryFilter);
3747
3692
  }
3748
- return [...currentFilters, ...filtersList];
3693
+ return filtersList;
3749
3694
  }
3750
3695
  if (Array.isArray(filters) && filters.length) {
3751
- yield this.categoryFilterRepository.deleteByCategory(categoryId);
3752
3696
  let filtersList = [];
3753
3697
  for (let i = 0; i < filters.length; i++) {
3754
- const newCategoryFilter = yield this.categoryFilterRepository.create({
3755
- filterId: filters[i].id,
3756
- categoryId,
3757
- });
3758
- filtersList.push(newCategoryFilter);
3698
+ try {
3699
+ const hasFilter = yield this.categoryFilterRepository
3700
+ .find({
3701
+ filters: {
3702
+ categoryId,
3703
+ filterId: filters[i].id,
3704
+ },
3705
+ })
3706
+ .then((data) => data.data.shift());
3707
+ if (hasFilter) {
3708
+ filtersList.push(hasFilter);
3709
+ }
3710
+ else {
3711
+ const newCategoryFilter = yield this.categoryFilterRepository.create({
3712
+ filterId: filters[i].id,
3713
+ categoryId,
3714
+ });
3715
+ filtersList.push(newCategoryFilter);
3716
+ }
3717
+ }
3718
+ catch (error) {
3719
+ console.log('catch error: ', error);
3720
+ }
3759
3721
  }
3760
3722
  return filtersList;
3761
3723
  }
@@ -4527,255 +4489,9 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
4527
4489
  }
4528
4490
  }
4529
4491
 
4530
- class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
4531
- constructor(endpoint, authOptions, categoryFilterRepository) {
4532
- super({
4533
- tableName: 'category',
4534
- model: Wishlist,
4535
- endpoint,
4536
- authOptions,
4537
- fields: [
4538
- { id: { columnName: 'id', to: (value) => +value, from: (value) => value.toString() } },
4539
- { firestoreId: { columnName: 'firestore_id' } },
4540
- 'name',
4541
- 'description',
4542
- 'image',
4543
- 'published',
4544
- 'shop',
4545
- { shops: { columnName: 'shops', type: HasuraGraphQLColumnType.Jsonb } },
4546
- 'slug',
4547
- { brandCategory: { columnName: 'brand_category' } },
4548
- { brandCategoryBanner: { columnName: 'brand_banner' } },
4549
- { brandCategoryBannerMobile: { columnName: 'brand_banner_mobile' } },
4550
- { brandLogo: { columnName: 'brand_logo' } },
4551
- { brandCondition: { columnName: 'brand_condition' } },
4552
- {
4553
- conditions: {
4554
- columnName: 'tag_condition',
4555
- type: HasuraGraphQLColumnType.Jsonb,
4556
- from: (tags, row) => ({ brand: row.brand_condition, tags: Array.isArray(tags) ? tags : [] }),
4557
- bindPersistData: (value) => {
4558
- return {
4559
- brand_condition: value.brand,
4560
- tag_condition: (value === null || value === void 0 ? void 0 : value.tags) || [],
4561
- };
4562
- },
4563
- bindFindFilter: (sentence) => {
4564
- return Object.assign(Object.assign({}, (sentence.brand ? { brand_condition: sentence.brand } : {})), (sentence.tags ? { tag_condition: sentence.tags } : {}));
4565
- },
4566
- },
4567
- },
4568
- {
4569
- filters: {
4570
- columnName: 'filters',
4571
- foreignKeyColumn: { filter_id: 'id' },
4572
- fields: [{ filter: ['id', 'description', 'slug', 'enabled'] }],
4573
- bindPersistData: (value) => ({
4574
- filters: { data: value.map((filter) => ({ filter_id: filter.id })) },
4575
- }),
4576
- from: (filters) => (filters === null || filters === void 0 ? void 0 : filters.map((filter) => filter === null || filter === void 0 ? void 0 : filter.filter)) || [],
4577
- },
4578
- },
4579
- { createdAt: { columnName: 'created_at' } },
4580
- { updatedAt: { columnName: 'updated_at' } },
4581
- {
4582
- products: {
4583
- columnName: 'products',
4584
- fields: ['product_id'],
4585
- from: (value) => value.map((product) => product.product_id.toString()),
4586
- to: (productIds) => productIds.map((productId) => ({
4587
- product_id: +productId,
4588
- })),
4589
- },
4590
- },
4591
- {
4592
- metadata: {
4593
- columnName: 'metadata',
4594
- fields: ['title', 'description'],
4595
- bindPersistData: (value) => ({
4596
- metadata: { data: value },
4597
- }),
4598
- },
4599
- },
4600
- { isCollection: { columnName: 'is_collection' } },
4601
- { isWishlist: { columnName: 'is_wishlist' } },
4602
- 'reference',
4603
- { parentId: { columnName: 'parent_id' } },
4604
- {
4605
- parent: {
4606
- columnName: 'parent',
4607
- foreignKeyColumn: { id: 'parentId' },
4608
- fields: ['id', 'name', 'reference', 'slug'],
4609
- },
4610
- },
4611
- { personId: { columnName: 'person_id' } },
4612
- ],
4613
- });
4614
- this.categoryFilterRepository = categoryFilterRepository;
4615
- }
4616
- create(params) {
4617
- const _super = Object.create(null, {
4618
- create: { get: () => super.create }
4619
- });
4620
- return __awaiter(this, void 0, void 0, function* () {
4621
- const { metadata } = params, data = __rest(params, ["metadata"]);
4622
- return _super.create.call(this, Object.assign(Object.assign({}, data), { isWishlist: true, isCollection: true, brandCategory: false, metadata: metadata || { description: data.description, title: data.name } }));
4623
- });
4624
- }
4625
- get(identifiers) {
4626
- const _super = Object.create(null, {
4627
- get: { get: () => super.get }
4628
- });
4629
- return __awaiter(this, void 0, void 0, function* () {
4630
- const data = yield _super.get.call(this, identifiers);
4631
- if (!data.isWishlist)
4632
- throw new NotFoundError(`Category with id ${identifiers.id} is not a wishlist`);
4633
- return data;
4634
- });
4635
- }
4636
- update(params) {
4637
- const _super = Object.create(null, {
4638
- update: { get: () => super.update }
4639
- });
4640
- return __awaiter(this, void 0, void 0, function* () {
4641
- const { products, id: checkId, metadata, filters } = params, data = __rest(params, ["products", "id", "metadata", "filters"]);
4642
- const plainData = this.paramsToPlain({ id: checkId });
4643
- const id = plainData.id;
4644
- const category = yield _super.update.call(this, Object.assign(Object.assign({ id }, data), { isWishlist: true, isCollection: true, brandCategory: false }));
4645
- category.products = products && (yield this.updateProducts(+id, { products }));
4646
- category.metadata = metadata && (yield this.updateMetadata(+id, { metadata }));
4647
- return category;
4648
- });
4649
- }
4650
- getWishlistBySlug(slug) {
4651
- return __awaiter(this, void 0, void 0, function* () {
4652
- if (!slug)
4653
- return;
4654
- const { data } = yield this.find({
4655
- filters: {
4656
- slug,
4657
- isWishlist: { operator: Where.EQUALS, value: true },
4658
- },
4659
- options: {
4660
- enableCount: false,
4661
- },
4662
- });
4663
- if (!data.length)
4664
- throw new NotFoundError(`Wishlist with slug ${slug} not found`);
4665
- if (data.length > 1)
4666
- throw new DuplicatedResultsError('Query returned duplicated values');
4667
- return data.shift();
4668
- });
4669
- }
4670
- getWishlistByPerson(personId) {
4671
- return __awaiter(this, void 0, void 0, function* () {
4672
- if (!personId)
4673
- return;
4674
- const { data } = yield this.find({
4675
- filters: {
4676
- personId: { operator: Where.EQUALS, value: personId },
4677
- isWishlist: { operator: Where.EQUALS, value: true },
4678
- },
4679
- options: {
4680
- enableCount: false,
4681
- },
4682
- });
4683
- if (!data.length)
4684
- throw new NotFoundError(`Wishlists from person ${personId} not found`);
4685
- return data;
4686
- });
4687
- }
4688
- updateProducts(categoryId, { products }) {
4689
- return __awaiter(this, void 0, void 0, function* () {
4690
- if ('action' in products && products.action === 'remove') {
4691
- yield this.mutation('delete_category_product', ['affected_rows'], {
4692
- where: {
4693
- type: 'category_product_bool_exp',
4694
- required: true,
4695
- value: { category_id: { _eq: categoryId } },
4696
- },
4697
- });
4698
- yield this.categoryFilterRepository.deleteByCategory(categoryId);
4699
- return [];
4700
- }
4701
- const plainData = this.paramsToPlain({ products });
4702
- if (!plainData.products || plainData.products.length <= 0)
4703
- return [];
4704
- yield this.mutation('delete_category_product', ['affected_rows'], {
4705
- where: {
4706
- type: 'category_product_bool_exp',
4707
- required: true,
4708
- value: { category_id: { _eq: categoryId } },
4709
- },
4710
- });
4711
- yield this.categoryFilterRepository.deleteByCategory(categoryId);
4712
- yield this.mutation('insert_category_product', ['affected_rows'], {
4713
- objects: {
4714
- type: '[category_product_insert_input!]',
4715
- required: true,
4716
- value: plainData.products.map((productId) => ({ category_id: categoryId, product_id: productId })),
4717
- },
4718
- });
4719
- return plainData.products;
4720
- });
4721
- }
4722
- updateMetadata(categoryId, { metadata }) {
4723
- return __awaiter(this, void 0, void 0, function* () {
4724
- const plainData = this.paramsToPlain({ metadata });
4725
- if (!plainData.metadata)
4726
- return;
4727
- yield this.mutation('update_category_metadata_by_pk', ['category_id'], {
4728
- pk_columns: {
4729
- value: { category_id: categoryId },
4730
- type: 'category_metadata_pk_columns_input',
4731
- required: true,
4732
- },
4733
- _set: {
4734
- value: omit(metadata, ['category_id']),
4735
- type: 'category_metadata_set_input',
4736
- required: true,
4737
- },
4738
- });
4739
- return plainData.metadata;
4740
- });
4741
- }
4742
- getCategoryBySlug(slug, _shop) {
4743
- return this.getWishlistBySlug(slug);
4744
- }
4745
- getCategoryByShop(shop) {
4746
- return __awaiter(this, void 0, void 0, function* () {
4747
- if (!shop)
4748
- return;
4749
- const { data } = yield this.find({
4750
- filters: {
4751
- shops: { operator: Where.IN, value: [shop] },
4752
- published: { operator: Where.EQUALS, value: true },
4753
- isWishlist: { operator: Where.EQUALS, value: true },
4754
- },
4755
- options: {
4756
- enableCount: false,
4757
- },
4758
- });
4759
- return data;
4760
- });
4761
- }
4762
- getCategoriesForHome(categoryIds, limit, gender) {
4763
- return;
4764
- }
4765
- mountCategory(category, options) {
4766
- return;
4767
- }
4768
- getChildren(parentId) {
4769
- return;
4770
- }
4771
- isChild(id, parentId) {
4772
- return;
4773
- }
4774
- }
4775
-
4776
4492
  /**
4777
4493
  * Generated bundle index. Do not edit.
4778
4494
  */
4779
4495
 
4780
- export { AccessoryImportances, Address, Area, Authentication, AuthenticationFirebaseAuthService, AxiosAdapter, Base, BaseModel, BeardProblems, BeardSizes, BeautyProductImportances, BeautyProfile, BeautyQuestionsHelper, BillingStatus, BodyProblems, BodyShapes, BodyTattoos, Buy2Win, Buy2WinFirestoreRepository, CampaignDashboard, CampaignDashboardFirestoreRepository, CampaignHashtag, CampaignHashtagFirestoreRepository, Category, CategoryCollectionChildren, CategoryCollectionChildrenHasuraGraphQLRepository, CategoryFilter, CategoryFilterHasuraGraphQLRepository, CategoryFirestoreRepository, CategoryHasuraGraphQL, CategoryHasuraGraphQLRepository, Checkout, CheckoutFirestoreRepository, CheckoutSubscription, CheckoutSubscriptionFirestoreRepository, CheckoutTypes, ClassNameHelper, Coupon, CouponFirestoreRepository, CouponSubtypes, CouponTypes, Debug, DebugDecoratorHelper, DebugHelper, DebugNamespaces, DuplicatedResultsError, Edition, EditionStatus, Exclusivities, FaceSkinOilinesses, FaceSkinProblems, FaceSkinTones, FamilyIncomes, Filter, FilterHasuraGraphQLRepository, FilterOption, FilterOptionHasuraGraphQLRepository, FilterType, 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, Product, ProductFirestoreRepository, ProductHasuraGraphQL, ProductHasuraGraphQLRepository, ProductSpents, ProductVariantFirestoreRepository, ProductsIndex, QuestionsFilters, RecoveryPassword, ReflectHelper, Register, RegisterFirebaseAuthService, RequiredArgumentError, RoundProductPricesHelper, ShippingMethod, ShopMenu, ShopMenuFirestoreRepository, ShopSettings, ShopSettingsFirestoreRepository, Shops, SignInMethods, SignOut, Status, Subscription, SubscriptionEditionFirestoreRepository, SubscriptionFirestoreRepository, SubscriptionPayment, SubscriptionPaymentFirestoreRepository, SubscriptionPlan, SubscriptionPlanFirestoreRepository, SubscriptionProductFirestoreRepository, Trace, UnauthorizedError, UpdateOptionActions, User, UserAddress, UserAddressFirestoreRepository, UserAlreadyRegisteredError, UserBeautyProfileFirestoreRepository, UserFirestoreRepository, UserPaymentMethod, UserPaymentMethodFirestoreRepository, UserType, Variant, VariantHasuraGraphQL, VariantHasuraGraphQLRepository, WeakPasswordError, Where, Wishlist, WishlistHasuraGraphQLRepository, isDebuggable, isUUID, parseDateTime, withCreateFirestore, withCreateHasuraGraphQL, withCrudFirestore, withCrudHasuraGraphQL, withDeleteFirestore, withDeleteHasuraGraphQL, withFindFirestore, withFindHasuraGraphQL, withFirestore, withGetFirestore, withGetHasuraGraphQL, withHasuraGraphQL, withHelpers, withSubCollection, withUpdateFirestore, withUpdateHasuraGraphQL };
4496
+ export { AccessoryImportances, Address, Area, Authentication, AuthenticationFirebaseAuthService, AxiosAdapter, Base, BaseModel, BeardProblems, BeardSizes, BeautyProductImportances, BeautyProfile, BeautyQuestionsHelper, BillingStatus, BodyProblems, BodyShapes, BodyTattoos, Buy2Win, Buy2WinFirestoreRepository, Campaign, CampaignBanner, CampaignBannerFirestoreRepository, CampaignDashboard, CampaignDashboardFirestoreRepository, CampaignFirestoreRepository, CampaignHashtag, CampaignHashtagFirestoreRepository, Category, CategoryCollectionChildren, CategoryCollectionChildrenHasuraGraphQLRepository, CategoryFilter, CategoryFilterHasuraGraphQLRepository, CategoryFirestoreRepository, CategoryHasuraGraphQL, CategoryHasuraGraphQLRepository, Checkout, CheckoutFirestoreRepository, CheckoutSubscription, CheckoutSubscriptionFirestoreRepository, CheckoutTypes, ClassNameHelper, Coupon, CouponFirestoreRepository, CouponSubtypes, CouponTypes, Debug, DebugDecoratorHelper, DebugHelper, DebugNamespaces, DuplicatedResultsError, Edition, EditionStatus, Exclusivities, FaceSkinOilinesses, FaceSkinProblems, FaceSkinTones, FamilyIncomes, Filter, FilterHasuraGraphQLRepository, FilterOption, FilterOptionHasuraGraphQLRepository, FilterType, 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, Product, ProductFirestoreRepository, ProductHasuraGraphQL, ProductHasuraGraphQLRepository, ProductSpents, ProductVariantFirestoreRepository, ProductsIndex, QuestionsFilters, RecoveryPassword, ReflectHelper, Register, RegisterFirebaseAuthService, RequiredArgumentError, RoundProductPricesHelper, ShippingMethod, ShopMenu, ShopMenuFirestoreRepository, ShopPageName, ShopSettings, ShopSettingsFirestoreRepository, Shops, SignInMethods, SignOut, Status, Subscription, SubscriptionEditionFirestoreRepository, SubscriptionFirestoreRepository, SubscriptionPayment, SubscriptionPaymentFirestoreRepository, SubscriptionPlan, SubscriptionPlanFirestoreRepository, SubscriptionProductFirestoreRepository, Trace, UnauthorizedError, UpdateOptionActions, User, UserAddress, UserAddressFirestoreRepository, UserAlreadyRegisteredError, UserBeautyProfileFirestoreRepository, UserFirestoreRepository, UserPaymentMethod, UserPaymentMethodFirestoreRepository, UserType, Variant, VariantHasuraGraphQL, VariantHasuraGraphQLRepository, WeakPasswordError, Where, isDebuggable, isUUID, parseDateTime, withCreateFirestore, withCreateHasuraGraphQL, withCrudFirestore, withCrudHasuraGraphQL, withDeleteFirestore, withDeleteHasuraGraphQL, withFindFirestore, withFindHasuraGraphQL, withFirestore, withGetFirestore, withGetHasuraGraphQL, withHasuraGraphQL, withHelpers, withSubCollection, withUpdateFirestore, withUpdateHasuraGraphQL };
4781
4497
  //# sourceMappingURL=infrab4a-connect.js.map