@infrab4a/connect 4.0.0-beta.25 → 4.0.0-beta.26

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 (38) hide show
  1. package/domain/catalog/helpers/RoundProdutcPriceHelper.d.ts +4 -0
  2. package/domain/catalog/helpers/index.d.ts +1 -0
  3. package/domain/catalog/index.d.ts +1 -0
  4. package/domain/catalog/models/category-collection-children.d.ts +14 -0
  5. package/domain/catalog/models/category.d.ts +2 -1
  6. package/domain/catalog/models/index.d.ts +1 -0
  7. package/domain/catalog/models/types/category-product.d.ts +4 -0
  8. package/domain/catalog/models/types/index.d.ts +1 -0
  9. package/domain/catalog/repositories/category-collection-children.repository.d.ts +4 -0
  10. package/domain/catalog/repositories/category.repository.d.ts +1 -0
  11. package/domain/catalog/repositories/index.d.ts +1 -0
  12. package/domain/location/models/address.d.ts +1 -0
  13. package/esm2020/domain/catalog/helpers/RoundProdutcPriceHelper.mjs +15 -0
  14. package/esm2020/domain/catalog/helpers/index.mjs +2 -0
  15. package/esm2020/domain/catalog/index.mjs +2 -1
  16. package/esm2020/domain/catalog/models/category-collection-children.mjs +16 -0
  17. package/esm2020/domain/catalog/models/category.mjs +1 -1
  18. package/esm2020/domain/catalog/models/index.mjs +2 -1
  19. package/esm2020/domain/catalog/models/types/category-product.mjs +2 -0
  20. package/esm2020/domain/catalog/models/types/index.mjs +2 -1
  21. package/esm2020/domain/catalog/repositories/category-collection-children.repository.mjs +2 -0
  22. package/esm2020/domain/catalog/repositories/category.repository.mjs +1 -1
  23. package/esm2020/domain/catalog/repositories/index.mjs +2 -1
  24. package/esm2020/domain/location/models/address.mjs +1 -1
  25. package/esm2020/infra/firebase/firestore/repositories/catalog/category-firestore.repository.mjs +4 -1
  26. package/esm2020/infra/hasura-graphql/repositories/catalog/category-collection-children-hasura-graphql.repository.mjs +38 -0
  27. package/esm2020/infra/hasura-graphql/repositories/catalog/category-hasura-graphql.repository.mjs +26 -2
  28. package/esm2020/infra/hasura-graphql/repositories/catalog/index.mjs +2 -1
  29. package/esm2020/infra/hasura-graphql/repositories/catalog/product-hasura-graphql.repository.mjs +3 -2
  30. package/fesm2015/infrab4a-connect.mjs +94 -2
  31. package/fesm2015/infrab4a-connect.mjs.map +1 -1
  32. package/fesm2020/infrab4a-connect.mjs +92 -2
  33. package/fesm2020/infrab4a-connect.mjs.map +1 -1
  34. package/infra/firebase/firestore/repositories/catalog/category-firestore.repository.d.ts +1 -0
  35. package/infra/hasura-graphql/repositories/catalog/category-collection-children-hasura-graphql.repository.d.ts +10 -0
  36. package/infra/hasura-graphql/repositories/catalog/category-hasura-graphql.repository.d.ts +1 -0
  37. package/infra/hasura-graphql/repositories/catalog/index.d.ts +1 -0
  38. package/package.json +1 -1
@@ -785,6 +785,19 @@ __decorate([
785
785
  __metadata("design:type", Array)
786
786
  ], Category.prototype, "filters", void 0);
787
787
 
788
+ class CategoryCollectionChildren extends BaseModel {
789
+ identifierFields() {
790
+ return ['collectionId', 'categoryId'];
791
+ }
792
+ static get identifiersFields() {
793
+ return ['collectionId', 'categoryId'];
794
+ }
795
+ }
796
+ __decorate([
797
+ Type(() => CategoryCollectionChildren),
798
+ __metadata("design:type", CategoryCollectionChildren)
799
+ ], CategoryCollectionChildren.prototype, "parent", void 0);
800
+
788
801
  class CategoryFilter extends BaseModel {
789
802
  static get identifiersFields() {
790
803
  return ['id'];
@@ -979,6 +992,20 @@ __decorate([
979
992
  __metadata("design:type", Coupon)
980
993
  ], CheckoutSubscription.prototype, "coupon", void 0);
981
994
 
995
+ class RoundProductPricesHelper {
996
+ static roundProductPrices(product) {
997
+ product.price.price = Number(product.price.price.toFixed(2));
998
+ product.price.fullPrice = Number(product.price.fullPrice.toFixed(2));
999
+ if (product.price.subscriberPrice) {
1000
+ product.price.subscriberPrice = Number(product.price.subscriberPrice.toFixed(2));
1001
+ }
1002
+ if (product instanceof LineItem && product.pricePaid) {
1003
+ product.pricePaid = Number(product.pricePaid.toFixed(2));
1004
+ }
1005
+ return product;
1006
+ }
1007
+ }
1008
+
982
1009
  var FilterType;
983
1010
  (function (FilterType) {
984
1011
  FilterType["ACCESSORY_IMPORTANCE"] = "accessoryImportance";
@@ -1785,6 +1812,9 @@ class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFire
1785
1812
  }
1786
1813
  return is(products);
1787
1814
  }
1815
+ getCategoryByShop(shop) {
1816
+ return;
1817
+ }
1788
1818
  }
1789
1819
 
1790
1820
  class ProductFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
@@ -2753,6 +2783,41 @@ class VariantHasuraGraphQL extends Variant {
2753
2783
  }
2754
2784
  }
2755
2785
 
2786
+ class CategoryCollectionChildrenHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
2787
+ constructor(endpoint, authOptions) {
2788
+ super({
2789
+ tableName: 'category_collection_children',
2790
+ model: CategoryCollectionChildren,
2791
+ endpoint,
2792
+ authOptions,
2793
+ fields: [
2794
+ { collectionId: { columnName: 'collection_id' } },
2795
+ { categoryId: { columnName: 'category_id' } },
2796
+ 'name',
2797
+ 'slug',
2798
+ 'reference',
2799
+ { parentCollectionId: { columnName: 'parent_collection_id' } },
2800
+ { parentCategoryId: { columnName: 'parent_category_id' } },
2801
+ {
2802
+ parent: {
2803
+ columnName: 'parent',
2804
+ foreignKeyColumn: { collectionId: 'parentCollectionId', categoryId: 'parentCategoryId' },
2805
+ fields: [
2806
+ { collectionId: { columnName: 'collection_id' } },
2807
+ { categoryId: { columnName: 'category_id' } },
2808
+ 'name',
2809
+ 'slug',
2810
+ 'reference',
2811
+ { parentCollectionId: { columnName: 'parent_collection_id' } },
2812
+ { parentCategoryId: { columnName: 'parent_category_id' } },
2813
+ ],
2814
+ },
2815
+ },
2816
+ ],
2817
+ });
2818
+ }
2819
+ }
2820
+
2756
2821
  class CategoryFilterHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
2757
2822
  constructor({ endpoint, authOptions, interceptors, }) {
2758
2823
  super({
@@ -2822,6 +2887,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
2822
2887
  'image',
2823
2888
  'published',
2824
2889
  'shop',
2890
+ { shops: { columnName: 'shops', type: HasuraGraphQLColumnType.Jsonb } },
2825
2891
  'slug',
2826
2892
  { brandCategory: { columnName: 'brand_category' } },
2827
2893
  { brandCategoryBanner: { columnName: 'brand_banner' } },
@@ -2919,13 +2985,36 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
2919
2985
  async getCategoryBySlug(slug, shop) {
2920
2986
  if (!slug)
2921
2987
  return null;
2922
- const { data } = await this.find({ filters: { slug, shop, published: true }, options: { enableCount: false } });
2988
+ const { data } = await this.find({
2989
+ filters: {
2990
+ slug,
2991
+ shops: { operator: Where.IN, value: [shop] },
2992
+ published: { operator: Where.EQUALS, value: true },
2993
+ },
2994
+ options: {
2995
+ enableCount: false,
2996
+ },
2997
+ });
2923
2998
  if (!data.length)
2924
2999
  throw new NotFoundError(`Category with slug ${slug} not found`);
2925
3000
  if (data.length > 1)
2926
3001
  throw new DuplicatedResultsError('Query returned duplicated values');
2927
3002
  return data.shift();
2928
3003
  }
3004
+ async getCategoryByShop(shop) {
3005
+ if (!shop)
3006
+ return;
3007
+ const { data } = await this.find({
3008
+ filters: {
3009
+ shops: { operator: Where.IN, value: [shop] },
3010
+ published: { operator: Where.EQUALS, value: true },
3011
+ },
3012
+ options: {
3013
+ enableCount: false,
3014
+ },
3015
+ });
3016
+ return data;
3017
+ }
2929
3018
  async getCategoriesForHome(categoryIds, limit = 4, gender) {
2930
3019
  if (!categoryIds?.length)
2931
3020
  return [];
@@ -3504,6 +3593,7 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
3504
3593
  },
3505
3594
  });
3506
3595
  const product = result?.data?.shift();
3596
+ RoundProductPricesHelper.roundProductPrices(product);
3507
3597
  return product;
3508
3598
  }
3509
3599
  async update(params) {
@@ -3835,5 +3925,5 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
3835
3925
  * Generated bundle index. Do not edit.
3836
3926
  */
3837
3927
 
3838
- 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, CategoryFilter, CategoryFilterHasuraGraphQLRepository, CategoryFirestoreRepository, CategoryHasuraGraphQL, CategoryHasuraGraphQLRepository, Checkout, CheckoutFirestoreRepository, CheckoutSubscription, CheckoutSubscriptionFirestoreRepository, CheckoutTypes, Coupon, CouponFirestoreRepository, CouponSubtypes, CouponTypes, 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, NotFoundError, OfficePosition, Order, OrderFirestoreRepository, OrderStatus, Payment, PaymentFirestoreRepository, PaymentType, Product, ProductFirestoreRepository, ProductHasuraGraphQL, ProductHasuraGraphQLRepository, ProductSpents, ProductVariantFirestoreRepository, ProductsIndex, QuestionsFilters, RecoveryPassword, Register, RegisterFirebaseAuthService, RequiredArgumentError, ShippingMethod, ShopMenu, ShopMenuFirestoreRepository, ShopSettings, ShopSettingsFirestoreRepository, Shops, SignInMethods, SignOut, Status, Subscription, SubscriptionEditionFirestoreRepository, SubscriptionFirestoreRepository, SubscriptionPayment, SubscriptionPaymentFirestoreRepository, SubscriptionPlan, SubscriptionPlanFirestoreRepository, SubscriptionProductFirestoreRepository, UnauthorizedError, UpdateOptionActions, User, UserAddress, UserAddressFirestoreRepository, UserAlreadyRegisteredError, UserBeautyProfileFirestoreRepository, UserFirestoreRepository, UserPaymentMethod, UserPaymentMethodFirestoreRepository, UserType, Variant, VariantHasuraGraphQL, VariantHasuraGraphQLRepository, WeakPasswordError, Where, get, is, isUUID, parseDateTime, withCreateFirestore, withCreateHasuraGraphQL, withCrudFirestore, withCrudHasuraGraphQL, withDeleteFirestore, withDeleteHasuraGraphQL, withFindFirestore, withFindHasuraGraphQL, withFirestore, withGetFirestore, withGetHasuraGraphQL, withHasuraGraphQL, withHelpers, withSubCollection, withUpdateFirestore, withUpdateHasuraGraphQL };
3928
+ 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, Coupon, CouponFirestoreRepository, CouponSubtypes, CouponTypes, 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, NotFoundError, OfficePosition, Order, OrderFirestoreRepository, OrderStatus, Payment, PaymentFirestoreRepository, PaymentType, Product, ProductFirestoreRepository, ProductHasuraGraphQL, ProductHasuraGraphQLRepository, ProductSpents, ProductVariantFirestoreRepository, ProductsIndex, QuestionsFilters, RecoveryPassword, Register, RegisterFirebaseAuthService, RequiredArgumentError, RoundProductPricesHelper, ShippingMethod, ShopMenu, ShopMenuFirestoreRepository, ShopSettings, ShopSettingsFirestoreRepository, Shops, SignInMethods, SignOut, Status, Subscription, SubscriptionEditionFirestoreRepository, SubscriptionFirestoreRepository, SubscriptionPayment, SubscriptionPaymentFirestoreRepository, SubscriptionPlan, SubscriptionPlanFirestoreRepository, SubscriptionProductFirestoreRepository, UnauthorizedError, UpdateOptionActions, User, UserAddress, UserAddressFirestoreRepository, UserAlreadyRegisteredError, UserBeautyProfileFirestoreRepository, UserFirestoreRepository, UserPaymentMethod, UserPaymentMethodFirestoreRepository, UserType, Variant, VariantHasuraGraphQL, VariantHasuraGraphQLRepository, WeakPasswordError, Where, get, is, isUUID, parseDateTime, withCreateFirestore, withCreateHasuraGraphQL, withCrudFirestore, withCrudHasuraGraphQL, withDeleteFirestore, withDeleteHasuraGraphQL, withFindFirestore, withFindHasuraGraphQL, withFirestore, withGetFirestore, withGetHasuraGraphQL, withHasuraGraphQL, withHelpers, withSubCollection, withUpdateFirestore, withUpdateHasuraGraphQL };
3839
3929
  //# sourceMappingURL=infrab4a-connect.mjs.map