@infrab4a/connect 4.0.0-beta.9 → 4.0.0
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.
- package/domain/catalog/helpers/index.d.ts +1 -0
- package/domain/catalog/helpers/round-product-price.helper.d.ts +4 -0
- package/domain/catalog/index.d.ts +1 -0
- package/domain/catalog/models/category-base.d.ts +30 -0
- package/domain/catalog/models/category-collection-children.d.ts +13 -0
- package/domain/catalog/models/category-filter.d.ts +13 -0
- package/domain/catalog/models/category-for-product.d.ts +5 -0
- package/domain/catalog/models/category.d.ts +5 -22
- package/domain/catalog/models/filter-option.d.ts +9 -0
- package/domain/catalog/models/filter.d.ts +12 -0
- package/domain/catalog/models/index.d.ts +5 -0
- package/domain/catalog/models/kit-product.d.ts +4 -4
- package/domain/catalog/models/product-base.d.ts +40 -0
- package/domain/catalog/models/product-for-category.d.ts +7 -0
- package/domain/catalog/models/product-for-kit.d.ts +7 -0
- package/domain/catalog/models/product.d.ts +5 -35
- package/domain/catalog/models/types/category-product.d.ts +4 -0
- package/domain/catalog/models/types/index.d.ts +2 -1
- package/domain/catalog/models/types/product-evaluation.type.d.ts +6 -0
- package/domain/catalog/models/types/shop-description.type.d.ts +1 -0
- package/domain/catalog/models/variant.d.ts +1 -2
- package/domain/catalog/models/wishlist.d.ts +6 -0
- package/domain/catalog/repositories/category-collection-children.repository.d.ts +4 -0
- package/domain/catalog/repositories/category-filter.repository.d.ts +6 -0
- package/domain/catalog/repositories/category.repository.d.ts +6 -3
- package/domain/catalog/repositories/filter-option.repository.d.ts +4 -0
- package/domain/catalog/repositories/filter.repository.d.ts +4 -0
- package/domain/catalog/repositories/index.d.ts +5 -0
- package/domain/catalog/repositories/product.repository.d.ts +4 -1
- package/domain/catalog/repositories/wishlist.repository.d.ts +6 -0
- package/domain/generic/model/base.model.d.ts +9 -5
- package/domain/generic/model/types/base-model-builder.type.d.ts +4 -2
- package/domain/generic/model/types/identifier-model.type.d.ts +6 -5
- package/domain/generic/model/types/model-base-structure.type.d.ts +9 -3
- package/domain/generic/model/types/non-function-property-name.type.d.ts +12 -3
- package/domain/generic/repository/find.repository.d.ts +7 -1
- package/domain/generic/repository/get.repository.d.ts +2 -2
- package/domain/generic/repository/types/repository-find-filters.type.d.ts +3 -3
- package/domain/generic/repository/types/repository-find-result.type.d.ts +11 -1
- package/domain/generic/repository/types/repository-order-by-list.type.d.ts +2 -2
- package/domain/generic/repository/types/repository-update-params.type.d.ts +2 -2
- package/domain/location/models/address.d.ts +5 -3
- package/domain/shop-settings/models/index.d.ts +1 -0
- package/domain/shop-settings/models/shop-settings.d.ts +9 -0
- package/domain/shop-settings/models/types/index.d.ts +6 -1
- package/domain/shop-settings/models/types/shop-banner.type.d.ts +12 -0
- package/domain/shop-settings/models/types/shop-brands.type.d.ts +10 -0
- package/domain/shop-settings/models/types/shop-carousel.type.d.ts +5 -0
- package/domain/shop-settings/models/types/shop-collection.type.d.ts +9 -0
- package/domain/shop-settings/models/types/shop-section.type.d.ts +9 -0
- package/domain/shop-settings/repositories/index.d.ts +1 -0
- package/domain/shop-settings/repositories/shop-settings.repository.d.ts +4 -0
- package/domain/shopping/models/buy-2-win.d.ts +3 -1
- package/domain/shopping/models/campaign-dashboard.d.ts +15 -0
- package/domain/shopping/models/campaign-hashtag.d.ts +18 -0
- package/domain/shopping/models/checkout.d.ts +5 -6
- package/domain/shopping/models/coupons/coupon.d.ts +34 -6
- package/domain/shopping/models/index.d.ts +5 -4
- package/domain/shopping/models/order.d.ts +1 -0
- package/domain/shopping/models/shipping-method.d.ts +1 -0
- package/domain/shopping/models/subscription/checkout.d.ts +3 -4
- package/domain/shopping/repositories/campaign-dashboard.repository.d.ts +4 -0
- package/domain/shopping/repositories/campaign-hashtag.repository.d.ts +4 -0
- package/domain/shopping/repositories/index.d.ts +4 -2
- package/domain/users/models/lead.d.ts +1 -0
- package/domain/users/models/subscription/subscription.d.ts +3 -3
- package/domain/users/models/user-address.d.ts +1 -2
- package/domain/users/models/user.d.ts +2 -3
- package/esm2020/domain/catalog/helpers/index.mjs +2 -0
- package/esm2020/domain/catalog/helpers/round-product-price.helper.mjs +15 -0
- package/esm2020/domain/catalog/index.mjs +2 -1
- package/esm2020/domain/catalog/models/category-base.mjs +18 -0
- package/esm2020/domain/catalog/models/category-collection-children.mjs +13 -0
- package/esm2020/domain/catalog/models/category-filter.mjs +19 -0
- package/esm2020/domain/catalog/models/category-for-product.mjs +7 -0
- package/esm2020/domain/catalog/models/category.mjs +10 -6
- package/esm2020/domain/catalog/models/filter-option.mjs +7 -0
- package/esm2020/domain/catalog/models/filter.mjs +7 -0
- package/esm2020/domain/catalog/models/index.mjs +6 -1
- package/esm2020/domain/catalog/models/kit-product.mjs +7 -7
- package/esm2020/domain/catalog/models/product-base.mjs +25 -0
- package/esm2020/domain/catalog/models/product-for-category.mjs +14 -0
- package/esm2020/domain/catalog/models/product-for-kit.mjs +14 -0
- package/esm2020/domain/catalog/models/product.mjs +8 -6
- package/esm2020/domain/catalog/models/types/category-product.mjs +2 -0
- package/esm2020/domain/catalog/models/types/index.mjs +3 -2
- package/esm2020/domain/catalog/models/types/product-evaluation.type.mjs +2 -0
- package/esm2020/domain/catalog/models/types/shop-description.type.mjs +1 -1
- package/esm2020/domain/catalog/models/variant.mjs +1 -4
- package/esm2020/domain/catalog/models/wishlist.mjs +7 -0
- package/esm2020/domain/catalog/repositories/category-collection-children.repository.mjs +2 -0
- package/esm2020/domain/catalog/repositories/category-filter.repository.mjs +2 -0
- package/esm2020/domain/catalog/repositories/category.repository.mjs +1 -1
- package/esm2020/domain/catalog/repositories/filter-option.repository.mjs +2 -0
- package/esm2020/domain/catalog/repositories/filter.repository.mjs +2 -0
- package/esm2020/domain/catalog/repositories/index.mjs +6 -1
- package/esm2020/domain/catalog/repositories/product.repository.mjs +1 -1
- package/esm2020/domain/catalog/repositories/wishlist.repository.mjs +2 -0
- package/esm2020/domain/generic/model/base.model.mjs +3 -2
- package/esm2020/domain/generic/model/types/base-model-builder.type.mjs +1 -1
- package/esm2020/domain/generic/model/types/identifier-model.type.mjs +1 -1
- package/esm2020/domain/generic/model/types/model-base-structure.type.mjs +1 -1
- package/esm2020/domain/generic/model/types/non-function-property-name.type.mjs +1 -1
- package/esm2020/domain/generic/repository/find.repository.mjs +1 -1
- package/esm2020/domain/generic/repository/get.repository.mjs +1 -1
- package/esm2020/domain/generic/repository/types/repository-find-filters.type.mjs +1 -1
- package/esm2020/domain/generic/repository/types/repository-find-result.type.mjs +1 -1
- package/esm2020/domain/generic/repository/types/repository-order-by-list.type.mjs +1 -1
- package/esm2020/domain/generic/repository/types/repository-update-params.type.mjs +1 -1
- package/esm2020/domain/location/models/address.mjs +2 -2
- package/esm2020/domain/shop-settings/models/index.mjs +2 -1
- package/esm2020/domain/shop-settings/models/shop-settings.mjs +7 -0
- package/esm2020/domain/shop-settings/models/types/index.mjs +7 -2
- package/esm2020/domain/shop-settings/models/types/shop-banner.type.mjs +2 -0
- package/esm2020/domain/shop-settings/models/types/shop-brands.type.mjs +2 -0
- package/esm2020/domain/shop-settings/models/types/shop-carousel.type.mjs +2 -0
- package/esm2020/domain/shop-settings/models/types/shop-collection.type.mjs +2 -0
- package/esm2020/domain/shop-settings/models/types/shop-section.type.mjs +2 -0
- package/esm2020/domain/shop-settings/repositories/index.mjs +2 -1
- package/esm2020/domain/shop-settings/repositories/shop-settings.repository.mjs +2 -0
- package/esm2020/domain/shopping/models/buy-2-win.mjs +2 -2
- package/esm2020/domain/shopping/models/campaign-dashboard.mjs +7 -0
- package/esm2020/domain/shopping/models/campaign-hashtag.mjs +7 -0
- package/esm2020/domain/shopping/models/checkout.mjs +6 -7
- package/esm2020/domain/shopping/models/coupons/coupon.mjs +16 -16
- package/esm2020/domain/shopping/models/index.mjs +6 -5
- package/esm2020/domain/shopping/models/order.mjs +1 -1
- package/esm2020/domain/shopping/models/shipping-method.mjs +1 -1
- package/esm2020/domain/shopping/models/subscription/checkout.mjs +6 -6
- package/esm2020/domain/shopping/repositories/campaign-dashboard.repository.mjs +2 -0
- package/esm2020/domain/shopping/repositories/campaign-hashtag.repository.mjs +2 -0
- package/esm2020/domain/shopping/repositories/index.mjs +5 -3
- package/esm2020/domain/users/models/lead.mjs +1 -1
- package/esm2020/domain/users/models/subscription/subscription.mjs +6 -6
- package/esm2020/domain/users/models/user-address.mjs +1 -1
- package/esm2020/domain/users/models/user.mjs +2 -2
- package/esm2020/domain/users/use-cases/authentication.mjs +2 -2
- package/esm2020/infra/elasticsearch/adapters/axios.adapter.mjs +28 -11
- package/esm2020/infra/elasticsearch/adapters/elastic-search.adapter.mjs +1 -1
- package/esm2020/infra/elasticsearch/indexes/products-index.mjs +63 -51
- package/esm2020/infra/elasticsearch/types/elastic-search-result.mjs +1 -1
- package/esm2020/infra/firebase/firestore/mixins/with-create-firestore.mixin.mjs +8 -4
- package/esm2020/infra/firebase/firestore/mixins/with-crud-firestore.mixin.mjs +1 -1
- package/esm2020/infra/firebase/firestore/mixins/with-delete-firestore.mixin.mjs +6 -2
- package/esm2020/infra/firebase/firestore/mixins/with-find-firestore.mixin.mjs +11 -8
- package/esm2020/infra/firebase/firestore/mixins/with-firestore.mixin.mjs +27 -4
- package/esm2020/infra/firebase/firestore/mixins/with-get-firestore.mixin.mjs +6 -3
- package/esm2020/infra/firebase/firestore/mixins/with-helpers.mixin.mjs +1 -1
- package/esm2020/infra/firebase/firestore/mixins/with-sub-collection.mixin.mjs +5 -3
- package/esm2020/infra/firebase/firestore/mixins/with-update-firestore.mixin.mjs +7 -4
- package/esm2020/infra/firebase/firestore/repositories/catalog/category-firestore.repository.mjs +21 -8
- package/esm2020/infra/firebase/firestore/repositories/catalog/product-firestore.repository.mjs +15 -7
- package/esm2020/infra/firebase/firestore/repositories/catalog/product-variant-firestore.repository.mjs +10 -8
- package/esm2020/infra/firebase/firestore/repositories/catalog/subscription-product-firestore.repository.mjs +8 -6
- package/esm2020/infra/firebase/firestore/repositories/shop-settings/home-firestore.repository.mjs +36 -30
- package/esm2020/infra/firebase/firestore/repositories/shop-settings/index.mjs +2 -1
- package/esm2020/infra/firebase/firestore/repositories/shop-settings/shop-menu-firestore.repository.mjs +8 -6
- package/esm2020/infra/firebase/firestore/repositories/shop-settings/shop-settings-firestore.repository.mjs +14 -0
- package/esm2020/infra/firebase/firestore/repositories/shopping/buy-2-win-firestore.repository.mjs +8 -6
- package/esm2020/infra/firebase/firestore/repositories/shopping/campaign-dashboard-firestore.repository.mjs +14 -0
- package/esm2020/infra/firebase/firestore/repositories/shopping/campaign-hashtag-firestore.repository.mjs +14 -0
- package/esm2020/infra/firebase/firestore/repositories/shopping/checkout-firestore.repository.mjs +8 -6
- package/esm2020/infra/firebase/firestore/repositories/shopping/checkout-subscription-firestore.repository.mjs +8 -6
- package/esm2020/infra/firebase/firestore/repositories/shopping/coupon-firestore.repository.mjs +8 -6
- package/esm2020/infra/firebase/firestore/repositories/shopping/index.mjs +6 -4
- package/esm2020/infra/firebase/firestore/repositories/shopping/legacy-order-firestore.repository.mjs +6 -4
- package/esm2020/infra/firebase/firestore/repositories/shopping/order-firestore.repository.mjs +11 -9
- package/esm2020/infra/firebase/firestore/repositories/shopping/payment-firestore.repository.mjs +8 -6
- package/esm2020/infra/firebase/firestore/repositories/shopping/subscription-plan-firestore.repository.mjs +8 -6
- package/esm2020/infra/firebase/firestore/repositories/users/lead-firestore.repository.mjs +8 -6
- package/esm2020/infra/firebase/firestore/repositories/users/subscription-edition-firestore.repository.mjs +10 -8
- package/esm2020/infra/firebase/firestore/repositories/users/subscription-firestore.repository.mjs +8 -6
- package/esm2020/infra/firebase/firestore/repositories/users/subscription-payment-firestore.repository.mjs +10 -8
- package/esm2020/infra/firebase/firestore/repositories/users/user-address-firestore.repository.mjs +10 -8
- package/esm2020/infra/firebase/firestore/repositories/users/user-beauty-profile-firestore.repository.mjs +10 -8
- package/esm2020/infra/firebase/firestore/repositories/users/user-firestore.repository.mjs +8 -6
- package/esm2020/infra/firebase/firestore/repositories/users/user-payment-method-firestore.repository.mjs +10 -8
- package/esm2020/infra/firebase/firestore/types/firestore-interceptors.type.mjs +2 -0
- package/esm2020/infra/firebase/firestore/types/firestore-sub.repository.type.mjs +1 -1
- package/esm2020/infra/firebase/firestore/types/firestore.helpers.type.mjs +1 -1
- package/esm2020/infra/firebase/firestore/types/firestore.repository.type.mjs +1 -1
- package/esm2020/infra/firebase/firestore/types/index.mjs +4 -3
- package/esm2020/infra/hasura-graphql/mixins/helpers/attribute-option.helper.mjs +3 -3
- package/esm2020/infra/hasura-graphql/mixins/helpers/bind-filter-query.helper.mjs +6 -5
- package/esm2020/infra/hasura-graphql/mixins/helpers/filter-option.helper.mjs +1 -1
- package/esm2020/infra/hasura-graphql/mixins/helpers/graphql-field.helper.mjs +36 -25
- package/esm2020/infra/hasura-graphql/mixins/with-create-hasura-graphql.mixin.mjs +6 -4
- package/esm2020/infra/hasura-graphql/mixins/with-crud-hasura-graphql.mixin.mjs +1 -1
- package/esm2020/infra/hasura-graphql/mixins/with-delete-hasura-graphql.mixin.mjs +5 -3
- package/esm2020/infra/hasura-graphql/mixins/with-find-hasura-graphql.mixin.mjs +126 -20
- package/esm2020/infra/hasura-graphql/mixins/with-get-hasura-graphql.mixin.mjs +5 -3
- package/esm2020/infra/hasura-graphql/mixins/with-hasura-graphql.mixin.mjs +40 -22
- package/esm2020/infra/hasura-graphql/mixins/with-update-hasura-graphql.mixin.mjs +7 -5
- package/esm2020/infra/hasura-graphql/models/product-hasura-graphql.mjs +1 -1
- package/esm2020/infra/hasura-graphql/models/variant-hasura-graphql.mjs +1 -1
- package/esm2020/infra/hasura-graphql/repositories/catalog/category-collection-children-hasura-graphql.repository.mjs +39 -0
- package/esm2020/infra/hasura-graphql/repositories/catalog/category-filter-hasura-graphql.repository.mjs +107 -0
- package/esm2020/infra/hasura-graphql/repositories/catalog/category-hasura-graphql.repository.mjs +130 -14
- package/esm2020/infra/hasura-graphql/repositories/catalog/filter-hasura-graphql.repository.mjs +105 -0
- package/esm2020/infra/hasura-graphql/repositories/catalog/filter-option-hasura-graphql.repository.mjs +22 -0
- package/esm2020/infra/hasura-graphql/repositories/catalog/index.mjs +6 -1
- package/esm2020/infra/hasura-graphql/repositories/catalog/product-hasura-graphql.repository.mjs +68 -19
- package/esm2020/infra/hasura-graphql/repositories/catalog/variant-hasura-graphql.repository.mjs +4 -3
- package/esm2020/infra/hasura-graphql/repositories/catalog/wishlist-hasura-graphql.repository.mjs +236 -0
- package/esm2020/infra/hasura-graphql/types/graphql.repository.type.mjs +1 -1
- package/esm2020/infra/hasura-graphql/types/hasura-graphql-fields.type.mjs +1 -1
- package/esm2020/utils/decorators/debug.class.decorator.mjs +7 -0
- package/esm2020/utils/decorators/index.mjs +3 -0
- package/esm2020/utils/decorators/trace.method.decorator.mjs +81 -0
- package/esm2020/utils/helpers/class-name.helper.mjs +15 -0
- package/esm2020/utils/helpers/debug-decorator.helper.mjs +18 -0
- package/esm2020/utils/helpers/debug.helper.mjs +150 -0
- package/esm2020/utils/helpers/index.mjs +5 -0
- package/esm2020/utils/helpers/reflect.helper.mjs +165 -0
- package/esm2020/utils/index.mjs +6 -3
- package/esm2020/utils/log.utils.mjs +9 -0
- package/fesm2015/infrab4a-connect.mjs +2022 -444
- package/fesm2015/infrab4a-connect.mjs.map +1 -1
- package/fesm2020/infrab4a-connect.mjs +2004 -461
- package/fesm2020/infrab4a-connect.mjs.map +1 -1
- package/infra/elasticsearch/adapters/axios.adapter.d.ts +7 -5
- package/infra/elasticsearch/adapters/elastic-search.adapter.d.ts +3 -2
- package/infra/elasticsearch/indexes/products-index.d.ts +8 -10
- package/infra/elasticsearch/types/elastic-search-result.d.ts +2 -0
- package/infra/firebase/firestore/mixins/with-create-firestore.mixin.d.ts +2 -2
- package/infra/firebase/firestore/mixins/with-crud-firestore.mixin.d.ts +2 -1
- package/infra/firebase/firestore/mixins/with-delete-firestore.mixin.d.ts +2 -2
- package/infra/firebase/firestore/mixins/with-find-firestore.mixin.d.ts +2 -2
- package/infra/firebase/firestore/mixins/with-firestore.mixin.d.ts +13 -4
- package/infra/firebase/firestore/mixins/with-get-firestore.mixin.d.ts +2 -2
- package/infra/firebase/firestore/mixins/with-helpers.mixin.d.ts +2 -2
- package/infra/firebase/firestore/mixins/with-sub-collection.mixin.d.ts +8 -4
- package/infra/firebase/firestore/mixins/with-update-firestore.mixin.d.ts +3 -3
- package/infra/firebase/firestore/repositories/catalog/category-firestore.repository.d.ts +8 -5
- package/infra/firebase/firestore/repositories/catalog/product-firestore.repository.d.ts +6 -5
- package/infra/firebase/firestore/repositories/catalog/product-variant-firestore.repository.d.ts +3 -4
- package/infra/firebase/firestore/repositories/catalog/subscription-product-firestore.repository.d.ts +3 -4
- package/infra/firebase/firestore/repositories/shop-settings/home-firestore.repository.d.ts +4 -4
- package/infra/firebase/firestore/repositories/shop-settings/index.d.ts +1 -0
- package/infra/firebase/firestore/repositories/shop-settings/shop-menu-firestore.repository.d.ts +3 -4
- package/infra/firebase/firestore/repositories/shop-settings/shop-settings-firestore.repository.d.ts +7 -0
- package/infra/firebase/firestore/repositories/shopping/buy-2-win-firestore.repository.d.ts +3 -4
- package/infra/firebase/firestore/repositories/shopping/campaign-dashboard-firestore.repository.d.ts +8 -0
- package/infra/firebase/firestore/repositories/shopping/campaign-hashtag-firestore.repository.d.ts +8 -0
- package/infra/firebase/firestore/repositories/shopping/checkout-firestore.repository.d.ts +3 -4
- package/infra/firebase/firestore/repositories/shopping/checkout-subscription-firestore.repository.d.ts +3 -4
- package/infra/firebase/firestore/repositories/shopping/coupon-firestore.repository.d.ts +4 -4
- package/infra/firebase/firestore/repositories/shopping/index.d.ts +5 -3
- package/infra/firebase/firestore/repositories/shopping/legacy-order-firestore.repository.d.ts +3 -4
- package/infra/firebase/firestore/repositories/shopping/order-firestore.repository.d.ts +4 -4
- package/infra/firebase/firestore/repositories/shopping/payment-firestore.repository.d.ts +3 -4
- package/infra/firebase/firestore/repositories/shopping/subscription-plan-firestore.repository.d.ts +3 -4
- package/infra/firebase/firestore/repositories/users/lead-firestore.repository.d.ts +3 -4
- package/infra/firebase/firestore/repositories/users/subscription-edition-firestore.repository.d.ts +3 -4
- package/infra/firebase/firestore/repositories/users/subscription-firestore.repository.d.ts +3 -4
- package/infra/firebase/firestore/repositories/users/subscription-payment-firestore.repository.d.ts +3 -4
- package/infra/firebase/firestore/repositories/users/user-address-firestore.repository.d.ts +3 -4
- package/infra/firebase/firestore/repositories/users/user-beauty-profile-firestore.repository.d.ts +3 -4
- package/infra/firebase/firestore/repositories/users/user-firestore.repository.d.ts +4 -4
- package/infra/firebase/firestore/repositories/users/user-payment-method-firestore.repository.d.ts +3 -4
- package/infra/firebase/firestore/types/firestore-interceptors.type.d.ts +14 -0
- package/infra/firebase/firestore/types/firestore-sub.repository.type.d.ts +3 -3
- package/infra/firebase/firestore/types/firestore.helpers.type.d.ts +5 -5
- package/infra/firebase/firestore/types/firestore.repository.type.d.ts +3 -1
- package/infra/firebase/firestore/types/index.d.ts +3 -2
- package/infra/hasura-graphql/mixins/helpers/attribute-option.helper.d.ts +9 -3
- package/infra/hasura-graphql/mixins/helpers/bind-filter-query.helper.d.ts +5 -5
- package/infra/hasura-graphql/mixins/helpers/filter-option.helper.d.ts +4 -2
- package/infra/hasura-graphql/mixins/helpers/graphql-field.helper.d.ts +9 -5
- package/infra/hasura-graphql/mixins/with-create-hasura-graphql.mixin.d.ts +2 -1
- package/infra/hasura-graphql/mixins/with-crud-hasura-graphql.mixin.d.ts +3 -3
- package/infra/hasura-graphql/mixins/with-delete-hasura-graphql.mixin.d.ts +1 -1
- package/infra/hasura-graphql/mixins/with-find-hasura-graphql.mixin.d.ts +24 -15
- package/infra/hasura-graphql/mixins/with-get-hasura-graphql.mixin.d.ts +7 -6
- package/infra/hasura-graphql/mixins/with-hasura-graphql.mixin.d.ts +15 -7
- package/infra/hasura-graphql/mixins/with-update-hasura-graphql.mixin.d.ts +2 -2
- package/infra/hasura-graphql/models/product-hasura-graphql.d.ts +4 -0
- package/infra/hasura-graphql/models/variant-hasura-graphql.d.ts +1 -0
- package/infra/hasura-graphql/repositories/catalog/category-collection-children-hasura-graphql.repository.d.ts +10 -0
- package/infra/hasura-graphql/repositories/catalog/category-filter-hasura-graphql.repository.d.ts +12 -0
- package/infra/hasura-graphql/repositories/catalog/category-hasura-graphql.repository.d.ts +11 -4
- package/infra/hasura-graphql/repositories/catalog/filter-hasura-graphql.repository.d.ts +18 -0
- package/infra/hasura-graphql/repositories/catalog/filter-option-hasura-graphql.repository.d.ts +10 -0
- package/infra/hasura-graphql/repositories/catalog/index.d.ts +5 -0
- package/infra/hasura-graphql/repositories/catalog/product-hasura-graphql.repository.d.ts +6 -4
- package/infra/hasura-graphql/repositories/catalog/variant-hasura-graphql.repository.d.ts +3 -3
- package/infra/hasura-graphql/repositories/catalog/wishlist-hasura-graphql.repository.d.ts +27 -0
- package/infra/hasura-graphql/types/graphql.repository.type.d.ts +9 -6
- package/infra/hasura-graphql/types/hasura-graphql-fields.type.d.ts +7 -3
- package/package.json +2 -1
- package/utils/decorators/debug.class.decorator.d.ts +2 -0
- package/utils/decorators/index.d.ts +2 -0
- package/utils/decorators/trace.method.decorator.d.ts +14 -0
- package/utils/helpers/class-name.helper.d.ts +3 -0
- package/utils/helpers/debug-decorator.helper.d.ts +9 -0
- package/utils/helpers/debug.helper.d.ts +60 -0
- package/utils/helpers/index.d.ts +4 -0
- package/utils/helpers/reflect.helper.d.ts +50 -0
- package/utils/index.d.ts +5 -2
- package/utils/log.utils.d.ts +7 -0
- package/domain/catalog/models/types/category-filter.type.d.ts +0 -4
- package/esm2020/domain/catalog/models/types/category-filter.type.mjs +0 -2
|
@@ -3,8 +3,10 @@ import { plainToInstance, instanceToPlain, Expose, Type } from 'class-transforme
|
|
|
3
3
|
import { __decorate, __metadata, __awaiter, __rest } from 'tslib';
|
|
4
4
|
import { parseISO } from 'date-fns';
|
|
5
5
|
export { add, addBusinessDays, addDays, addMonths, addYears, endOfDay, format, formatISO9075, parseISO, startOfDay, sub } from 'date-fns';
|
|
6
|
-
import { get as get$1, isString,
|
|
7
|
-
export { chunk, isBoolean, isDate, isEmpty, isInteger, isNaN, isNil, isNumber, isObject, isString, now, omit, pick, set } from 'lodash';
|
|
6
|
+
import { isNil, isArray, first, last, flatten, compact, get as get$1, isString, each, unset, isObject, isNumber, isDate, set, isEmpty, chunk, isBoolean, isInteger, isNaN as isNaN$1, omit } from 'lodash';
|
|
7
|
+
export { chunk, each, get, isBoolean, isDate, isEmpty, isInteger, isNaN, isNil, isNumber, isObject, isString, now, omit, pick, set, unset } from 'lodash';
|
|
8
|
+
import { Subject } from 'rxjs';
|
|
9
|
+
import { debug } from 'debug';
|
|
8
10
|
import { CustomError } from 'ts-custom-error';
|
|
9
11
|
import axios from 'axios';
|
|
10
12
|
import { collection, getDoc, doc, where, orderBy, getDocs, query, startAfter, startAt, limit, addDoc, setDoc, deleteField, arrayUnion, arrayRemove, deleteDoc, Timestamp } from 'firebase/firestore';
|
|
@@ -14,7 +16,8 @@ import { mutation, query as query$1 } from 'gql-query-builder';
|
|
|
14
16
|
class BaseModel {
|
|
15
17
|
get identifier() {
|
|
16
18
|
const fields = this.constructor.identifiersFields.filter((field) => field !== 'identifier');
|
|
17
|
-
|
|
19
|
+
const data = this;
|
|
20
|
+
return fields.reduce((object, field) => (Object.assign(Object.assign({}, object), { [field]: data[field] })), {});
|
|
18
21
|
}
|
|
19
22
|
get identifiersFields() {
|
|
20
23
|
return this.constructor.identifiersFields;
|
|
@@ -460,11 +463,437 @@ __decorate([
|
|
|
460
463
|
__metadata("design:type", Payment)
|
|
461
464
|
], SubscriptionPayment.prototype, "payment", void 0);
|
|
462
465
|
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
+
var DebugNamespaces;
|
|
467
|
+
(function (DebugNamespaces) {
|
|
468
|
+
DebugNamespaces["ROOT"] = "connect";
|
|
469
|
+
DebugNamespaces["TRACE"] = "trace";
|
|
470
|
+
DebugNamespaces["ERROR"] = "error";
|
|
471
|
+
})(DebugNamespaces || (DebugNamespaces = {}));
|
|
472
|
+
const Logger = debug(DebugNamespaces.ROOT);
|
|
473
|
+
|
|
474
|
+
class ReflectHelper {
|
|
475
|
+
static get items() {
|
|
476
|
+
return this._items;
|
|
477
|
+
}
|
|
478
|
+
static get keys() {
|
|
479
|
+
return Object.keys(ReflectHelper.items);
|
|
480
|
+
}
|
|
481
|
+
static has(key, target, property) {
|
|
482
|
+
return (!isNil(key) &&
|
|
483
|
+
!isNil(ReflectHelper.items[key]) &&
|
|
484
|
+
(isNil(target) ||
|
|
485
|
+
(!isNil(ReflectHelper.items[key][target]) &&
|
|
486
|
+
(isNil(property) || !isNil(ReflectHelper.items[key][target][String(property)])))));
|
|
487
|
+
}
|
|
488
|
+
static get({ key, target, property, own = true }) {
|
|
489
|
+
try {
|
|
490
|
+
if (own) {
|
|
491
|
+
return Reflect.getOwnMetadata(key, target, property) || null;
|
|
492
|
+
}
|
|
493
|
+
else {
|
|
494
|
+
return Reflect.getMetadata(key, target, property) || null;
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
catch (_err) {
|
|
498
|
+
return null;
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
static first({ key, target, property, own = true }) {
|
|
502
|
+
const values = ReflectHelper.get({ key, target, property, own });
|
|
503
|
+
return isArray(values) ? first(values) : values;
|
|
504
|
+
}
|
|
505
|
+
static last({ key, target, property, own = true }) {
|
|
506
|
+
const values = ReflectHelper.get({ key, target, property, own });
|
|
507
|
+
return isArray(values) ? last(values) : values;
|
|
508
|
+
}
|
|
509
|
+
static set({ key, target, property, value, propertyDescriptor }) {
|
|
510
|
+
Reflect.defineMetadata(key, value, target, property);
|
|
511
|
+
ReflectHelper.put({ key, target, property, value, propertyDescriptor });
|
|
512
|
+
}
|
|
513
|
+
static add({ key, target, property, value, propertyDescriptor }) {
|
|
514
|
+
let values = ReflectHelper.get({ key, target, property }) || new Array();
|
|
515
|
+
if (!Array.isArray(values))
|
|
516
|
+
values = [values];
|
|
517
|
+
values.push(value);
|
|
518
|
+
ReflectHelper.set({ key, target, property, value: values, propertyDescriptor });
|
|
519
|
+
}
|
|
520
|
+
static all({ key }) {
|
|
521
|
+
const items = ReflectHelper.items[key] || {};
|
|
522
|
+
return flatten(Object.keys(items).map((item) => flatten(this.allFrom(key, items[item]))));
|
|
523
|
+
}
|
|
524
|
+
static allFrom(key, target) {
|
|
525
|
+
return Object.keys(target)
|
|
526
|
+
.filter((property) => property !== 'object')
|
|
527
|
+
.map((property) => this.allValuesFrom(key, target, property));
|
|
528
|
+
}
|
|
529
|
+
static allValuesFrom(key, target, property) {
|
|
530
|
+
const values = target[property];
|
|
531
|
+
let value = values.value;
|
|
532
|
+
const propertyDescriptor = values.propertyDescriptor;
|
|
533
|
+
if (!isArray(value))
|
|
534
|
+
value = [value];
|
|
535
|
+
return flatten(value.map((val) => {
|
|
536
|
+
return {
|
|
537
|
+
key,
|
|
538
|
+
target: target.object,
|
|
539
|
+
property,
|
|
540
|
+
value: val,
|
|
541
|
+
propertyDescriptor,
|
|
542
|
+
};
|
|
543
|
+
}));
|
|
544
|
+
}
|
|
545
|
+
static delete({ key, target, property }) {
|
|
546
|
+
Reflect.deleteMetadata(key, target, property);
|
|
547
|
+
return ReflectHelper.remove(key, target, property);
|
|
548
|
+
}
|
|
549
|
+
static clear(key) {
|
|
550
|
+
if (!key) {
|
|
551
|
+
ReflectHelper.keys.forEach((storedKey) => {
|
|
552
|
+
ReflectHelper.clear(storedKey);
|
|
553
|
+
});
|
|
554
|
+
}
|
|
555
|
+
else {
|
|
556
|
+
if (ReflectHelper.keys.includes(key)) {
|
|
557
|
+
Object.values(ReflectHelper.items[key]).forEach((target) => {
|
|
558
|
+
if (ReflectHelper.has(key, target)) {
|
|
559
|
+
Object.values(ReflectHelper.items[key][target.toString()]).forEach((property) => {
|
|
560
|
+
ReflectHelper.delete({
|
|
561
|
+
key,
|
|
562
|
+
target: target.object,
|
|
563
|
+
property: String(property),
|
|
564
|
+
});
|
|
565
|
+
ReflectHelper.remove(key, target, String(property));
|
|
566
|
+
});
|
|
567
|
+
}
|
|
568
|
+
ReflectHelper.delete({ key, target: target.object });
|
|
569
|
+
ReflectHelper.remove(key, target);
|
|
570
|
+
});
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
static getType({ target, propertyKey }) {
|
|
575
|
+
return Reflect.getMetadata('design:type', target, propertyKey);
|
|
576
|
+
}
|
|
577
|
+
static getReturntype({ target, propertyKey }) {
|
|
578
|
+
return Reflect.getMetadata('design:returntype', target, propertyKey);
|
|
579
|
+
}
|
|
580
|
+
static getAllMethods(target) {
|
|
581
|
+
const props = [];
|
|
582
|
+
let obj = target;
|
|
583
|
+
do {
|
|
584
|
+
props.push(...Object.getOwnPropertyNames(obj));
|
|
585
|
+
} while ((obj = Object.getPrototypeOf(obj)));
|
|
586
|
+
return props.sort().filter((e, i, arr) => {
|
|
587
|
+
if ([
|
|
588
|
+
'__defineGetter__',
|
|
589
|
+
'__defineSetter__',
|
|
590
|
+
'__lookupGetter__',
|
|
591
|
+
'__lookupSetter__',
|
|
592
|
+
'constructor',
|
|
593
|
+
'hasOwnProperty',
|
|
594
|
+
'isPrototypeOf',
|
|
595
|
+
'propertyIsEnumerable',
|
|
596
|
+
'toLocaleString',
|
|
597
|
+
'toString',
|
|
598
|
+
'valueOf',
|
|
599
|
+
].includes(e))
|
|
600
|
+
return false;
|
|
601
|
+
if (e != arr[i + 1] && typeof target[e] === 'function')
|
|
602
|
+
return true;
|
|
603
|
+
});
|
|
604
|
+
}
|
|
605
|
+
static put({ key, target, property, value, propertyDescriptor }) {
|
|
606
|
+
const index = target.constructor.name;
|
|
607
|
+
ReflectHelper.items[key] = ReflectHelper.items[key] || {};
|
|
608
|
+
ReflectHelper.items[key][index] = ReflectHelper.items[key][index] || {};
|
|
609
|
+
ReflectHelper.items[key][index].object = target;
|
|
610
|
+
if (isNil(property)) {
|
|
611
|
+
ReflectHelper.items[key][index].value = {
|
|
612
|
+
value,
|
|
613
|
+
propertyDescriptor,
|
|
614
|
+
};
|
|
615
|
+
}
|
|
616
|
+
else {
|
|
617
|
+
ReflectHelper.items[key][index][String(property)] = ReflectHelper.items[key][index][String(property)] || {};
|
|
618
|
+
ReflectHelper.items[key][index][String(property)] = {
|
|
619
|
+
value,
|
|
620
|
+
propertyDescriptor,
|
|
621
|
+
};
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
static remove(key, target, property) {
|
|
625
|
+
if (ReflectHelper.has(key, target, property))
|
|
626
|
+
return delete ReflectHelper.items[key][target][String(property)];
|
|
627
|
+
else if (ReflectHelper.has(key, target))
|
|
628
|
+
return delete ReflectHelper.items[key][target];
|
|
629
|
+
else if (ReflectHelper.has(key))
|
|
630
|
+
return delete ReflectHelper.items[key];
|
|
631
|
+
else
|
|
632
|
+
return false;
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
ReflectHelper._items = {};
|
|
636
|
+
|
|
637
|
+
class DebugDecoratorHelper {
|
|
638
|
+
static set(target, options) {
|
|
639
|
+
ReflectHelper.add({
|
|
640
|
+
key: DebugDecoratorHelper.DebugNamingMetadataKey,
|
|
641
|
+
target,
|
|
642
|
+
value: options,
|
|
643
|
+
});
|
|
644
|
+
}
|
|
645
|
+
static get(target) {
|
|
646
|
+
return ReflectHelper.first({
|
|
647
|
+
key: DebugDecoratorHelper.DebugNamingMetadataKey,
|
|
648
|
+
target,
|
|
649
|
+
});
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
DebugDecoratorHelper.DebugNamingMetadataKey = 'model:naming:decorator';
|
|
653
|
+
|
|
654
|
+
class ClassNameHelper {
|
|
655
|
+
static get(clazz) {
|
|
656
|
+
if (!clazz)
|
|
657
|
+
return null;
|
|
658
|
+
const prototype = Object.getPrototypeOf(clazz);
|
|
659
|
+
const names = compact([
|
|
660
|
+
get$1(clazz, 'constructor.name'),
|
|
661
|
+
get$1(prototype, 'constructor.name'),
|
|
662
|
+
get$1(prototype, '__proto__.constructor.name'),
|
|
663
|
+
]);
|
|
664
|
+
return names.find((name) => name !== 'class_1');
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
const isDebuggable = (object) => {
|
|
669
|
+
return 'debug' in object;
|
|
670
|
+
};
|
|
671
|
+
class DebugHelper {
|
|
672
|
+
constructor(...namespace) {
|
|
673
|
+
this.namespaces = new Set();
|
|
674
|
+
this.push(...namespace);
|
|
675
|
+
}
|
|
676
|
+
static namespacesFor(target) {
|
|
677
|
+
if (isNil(target))
|
|
678
|
+
return [];
|
|
679
|
+
const decorator = DebugDecoratorHelper.get(Object.getPrototypeOf(target));
|
|
680
|
+
const namespaces = get$1(decorator, 'namespaces', []);
|
|
681
|
+
const name = get$1(decorator, 'name', ClassNameHelper.get(target));
|
|
682
|
+
return [...namespaces, name];
|
|
683
|
+
}
|
|
684
|
+
static as(...namespaces) {
|
|
685
|
+
return new DebugHelper(...namespaces);
|
|
686
|
+
}
|
|
687
|
+
static for(target, ...namespaces) {
|
|
688
|
+
const targetNamespaces = this.namespacesFor(target);
|
|
689
|
+
return new DebugHelper(...targetNamespaces, ...namespaces);
|
|
690
|
+
}
|
|
691
|
+
static from(target, ...namespaces) {
|
|
692
|
+
if (this.isDebuggable(target)) {
|
|
693
|
+
const debug = target.debug;
|
|
694
|
+
if (namespaces)
|
|
695
|
+
debug.push(...namespaces);
|
|
696
|
+
return debug;
|
|
697
|
+
}
|
|
698
|
+
return DebugHelper.for(target, ...namespaces);
|
|
699
|
+
}
|
|
700
|
+
static clonedFrom(target, ...namespaces) {
|
|
701
|
+
if (this.isDebuggable(target)) {
|
|
702
|
+
namespaces.push(...target.debug.entries);
|
|
703
|
+
}
|
|
704
|
+
else if (!isNil(target)) {
|
|
705
|
+
namespaces.push(...this.namespacesFor(target));
|
|
706
|
+
}
|
|
707
|
+
return DebugHelper.for(target, ...namespaces);
|
|
708
|
+
}
|
|
709
|
+
static clone(target, ...namespaces) {
|
|
710
|
+
let original;
|
|
711
|
+
if (this.isDebuggable(target)) {
|
|
712
|
+
original = target.debug;
|
|
713
|
+
namespaces.push(...original.entries);
|
|
714
|
+
}
|
|
715
|
+
return {
|
|
716
|
+
original,
|
|
717
|
+
debug: DebugHelper.for(target, ...namespaces),
|
|
718
|
+
};
|
|
719
|
+
}
|
|
720
|
+
static replace(target, attrs) {
|
|
721
|
+
if (this.isDebuggable(target))
|
|
722
|
+
target.debug = attrs.with;
|
|
723
|
+
}
|
|
724
|
+
static mock(target, ...namespaces) {
|
|
725
|
+
const { original, debug } = DebugHelper.clone(target, ...namespaces);
|
|
726
|
+
DebugHelper.replace(target, { with: debug });
|
|
727
|
+
return { original, debug };
|
|
728
|
+
}
|
|
729
|
+
get entries() {
|
|
730
|
+
return Array.from(get$1(this, 'namespaces', []));
|
|
731
|
+
}
|
|
732
|
+
get namespace() {
|
|
733
|
+
return compact(flatten(this.entries)).join(':');
|
|
734
|
+
}
|
|
735
|
+
log(message, ...args) {
|
|
736
|
+
this.logger(JSON.stringify(message), ...args.map((element) => JSON.stringify(element)));
|
|
737
|
+
DebugHelper.logs$.next({ namespace: this.namespace, message, args });
|
|
738
|
+
return this;
|
|
739
|
+
}
|
|
740
|
+
trace(message, ...args) {
|
|
741
|
+
this.logger.extend(DebugNamespaces.TRACE)(message, ...args);
|
|
742
|
+
DebugHelper.traces$.next({ namespace: this.namespace, message, args });
|
|
743
|
+
return this;
|
|
744
|
+
}
|
|
745
|
+
error(error, ...args) {
|
|
746
|
+
this.logger.extend(DebugNamespaces.ERROR)(JSON.stringify(error), ...args.map((element) => JSON.stringify(element)));
|
|
747
|
+
DebugHelper.errors$.next({ namespace: this.namespace, error, args });
|
|
748
|
+
return this;
|
|
749
|
+
}
|
|
750
|
+
build() {
|
|
751
|
+
this.logger = Logger;
|
|
752
|
+
this.tracer = Logger;
|
|
753
|
+
this.err = Logger;
|
|
754
|
+
this.entries.forEach((namespace) => {
|
|
755
|
+
this.logger = this.logger.extend(namespace);
|
|
756
|
+
this.tracer = this.tracer.extend(namespace);
|
|
757
|
+
this.err = this.err.extend(namespace);
|
|
758
|
+
});
|
|
759
|
+
return this;
|
|
760
|
+
}
|
|
761
|
+
with(...namespace) {
|
|
762
|
+
return new DebugHelper(...this.entries, ...namespace);
|
|
763
|
+
}
|
|
764
|
+
push(...namespace) {
|
|
765
|
+
if (namespace) {
|
|
766
|
+
namespace.filter((item) => Boolean(item)).forEach((item) => this.namespaces.add(item));
|
|
767
|
+
}
|
|
768
|
+
return this.build();
|
|
769
|
+
}
|
|
770
|
+
unshift(...namespace) {
|
|
771
|
+
if (namespace) {
|
|
772
|
+
return this.reset(...namespace, ...this.entries);
|
|
773
|
+
}
|
|
774
|
+
return this;
|
|
775
|
+
}
|
|
776
|
+
reset(...namespace) {
|
|
777
|
+
this.namespaces = new Set(flatten(compact(namespace)));
|
|
778
|
+
return this.build();
|
|
779
|
+
}
|
|
780
|
+
startWith(...namespace) {
|
|
781
|
+
const current = this.namespaces;
|
|
782
|
+
this.namespaces = new Set(flatten([compact(namespace), ...current]));
|
|
783
|
+
return this.build();
|
|
784
|
+
}
|
|
785
|
+
shift() {
|
|
786
|
+
const list = this.entries;
|
|
787
|
+
list.shift();
|
|
788
|
+
return this.reset(...list);
|
|
789
|
+
}
|
|
790
|
+
pop() {
|
|
791
|
+
const list = this.entries;
|
|
792
|
+
list.pop();
|
|
793
|
+
return this.reset(...list);
|
|
794
|
+
}
|
|
795
|
+
clear() {
|
|
796
|
+
return this.reset();
|
|
797
|
+
}
|
|
798
|
+
remove(...namespace) {
|
|
799
|
+
if (namespace) {
|
|
800
|
+
namespace.filter((item) => Boolean(item)).forEach((item) => this.namespaces.delete(item));
|
|
801
|
+
}
|
|
802
|
+
return this.build();
|
|
466
803
|
}
|
|
804
|
+
puts(...args) {
|
|
805
|
+
return [`[${this.namespace}]`, ...args].join(' ');
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
DebugHelper.logs$ = new Subject();
|
|
809
|
+
DebugHelper.traces$ = new Subject();
|
|
810
|
+
DebugHelper.errors$ = new Subject();
|
|
811
|
+
DebugHelper.isDebuggable = isDebuggable;
|
|
812
|
+
|
|
813
|
+
function Debug(opts) {
|
|
814
|
+
return function (target) {
|
|
815
|
+
DebugDecoratorHelper.set(target.prototype, opts);
|
|
816
|
+
};
|
|
817
|
+
}
|
|
818
|
+
|
|
819
|
+
const ASYNC_IDENTIFIER = 'async';
|
|
820
|
+
function Log(options = {}) {
|
|
821
|
+
return Trace(Object.assign({ level: 'log' }, options));
|
|
822
|
+
}
|
|
823
|
+
function Trace(options = {}) {
|
|
824
|
+
return function (target, propertyKey, propertyDescriptor) {
|
|
825
|
+
const method = propertyDescriptor.value;
|
|
826
|
+
const isPromise = method.toString().includes(ASYNC_IDENTIFIER);
|
|
827
|
+
const args = {
|
|
828
|
+
options,
|
|
829
|
+
method,
|
|
830
|
+
target,
|
|
831
|
+
propertyKey,
|
|
832
|
+
propertyDescriptor,
|
|
833
|
+
};
|
|
834
|
+
propertyDescriptor.value = isPromise ? promiseTracer(args) : functionTracer(args);
|
|
835
|
+
return propertyDescriptor;
|
|
836
|
+
};
|
|
467
837
|
}
|
|
838
|
+
const traceCall = function ({ target, propertyKey, propertyDescriptor, args }) {
|
|
839
|
+
if (!target.debug)
|
|
840
|
+
target.debug = DebugHelper.for(target, propertyKey);
|
|
841
|
+
return target.debug.push(propertyKey).trace('called', { target, propertyKey, propertyDescriptor, args });
|
|
842
|
+
};
|
|
843
|
+
const promiseTracer = function ({ options, method, propertyKey, propertyDescriptor }) {
|
|
844
|
+
return function (...args) {
|
|
845
|
+
return new Promise((resolve, reject) => {
|
|
846
|
+
const debug = traceCall({ target: this, propertyDescriptor, propertyKey, args });
|
|
847
|
+
if (get$1(options, 'level', '') === 'log') {
|
|
848
|
+
debug.with('params').log(args);
|
|
849
|
+
}
|
|
850
|
+
return method
|
|
851
|
+
.apply(this, args)
|
|
852
|
+
.then((result) => {
|
|
853
|
+
if (options.callbackFn) {
|
|
854
|
+
options.callbackFn({ target: this, result, args, namespace: [propertyKey] });
|
|
855
|
+
}
|
|
856
|
+
if (get$1(options, 'level', '') === 'log') {
|
|
857
|
+
debug.with('returns').log(result === undefined ? 'void' : result);
|
|
858
|
+
}
|
|
859
|
+
return resolve(result);
|
|
860
|
+
})
|
|
861
|
+
.catch((error) => {
|
|
862
|
+
debug.error(error, ...args);
|
|
863
|
+
debug.with('stack').error(error.stack).pop();
|
|
864
|
+
return reject(error);
|
|
865
|
+
})
|
|
866
|
+
.finally(() => {
|
|
867
|
+
return debug.trace('finally', { args }).pop();
|
|
868
|
+
});
|
|
869
|
+
});
|
|
870
|
+
};
|
|
871
|
+
};
|
|
872
|
+
const functionTracer = function ({ options, target, method, propertyKey, propertyDescriptor, }) {
|
|
873
|
+
return function (...args) {
|
|
874
|
+
const debug = traceCall({ target: this || target, propertyDescriptor, propertyKey, args });
|
|
875
|
+
if (get$1(options, 'level', '') === 'log') {
|
|
876
|
+
debug.with('params').log(args);
|
|
877
|
+
}
|
|
878
|
+
let result;
|
|
879
|
+
try {
|
|
880
|
+
result = method.apply(this, args);
|
|
881
|
+
if (options.callbackFn)
|
|
882
|
+
options.callbackFn({ target: this, result, args, namespace: [propertyKey] });
|
|
883
|
+
if (get$1(options, 'level', '') === 'log') {
|
|
884
|
+
debug.with('returns').log(result === undefined ? 'void' : result);
|
|
885
|
+
}
|
|
886
|
+
return result;
|
|
887
|
+
}
|
|
888
|
+
catch (error) {
|
|
889
|
+
debug.error(error, ...args).pop();
|
|
890
|
+
throw error;
|
|
891
|
+
}
|
|
892
|
+
finally {
|
|
893
|
+
debug.trace('finally', { args }).pop();
|
|
894
|
+
}
|
|
895
|
+
};
|
|
896
|
+
};
|
|
468
897
|
|
|
469
898
|
const get = (object, path, defaultValue) => get$1(object, path, defaultValue);
|
|
470
899
|
|
|
@@ -536,26 +965,28 @@ class Coupon extends BaseModel {
|
|
|
536
965
|
static createCoupon(userId) {
|
|
537
966
|
return this.toInstance({
|
|
538
967
|
nickname: `${Date.now()}`,
|
|
539
|
-
type: CouponTypes.ABSOLUTE,
|
|
540
968
|
checkoutType: CheckoutTypes.ECOMMERCE,
|
|
541
|
-
discount:
|
|
969
|
+
discount: {
|
|
970
|
+
subscriber: {
|
|
971
|
+
type: CouponTypes.ABSOLUTE,
|
|
972
|
+
value: 10,
|
|
973
|
+
},
|
|
974
|
+
non_subscriber: {
|
|
975
|
+
type: CouponTypes.ABSOLUTE,
|
|
976
|
+
value: 10,
|
|
977
|
+
},
|
|
978
|
+
subscription: {
|
|
979
|
+
type: CouponTypes.ABSOLUTE,
|
|
980
|
+
value: 10,
|
|
981
|
+
},
|
|
982
|
+
},
|
|
542
983
|
user: userId,
|
|
543
|
-
useLimit: 1,
|
|
544
|
-
useLimitPerUser: true,
|
|
545
984
|
createdAt: new Date(Date.now()),
|
|
546
985
|
beginAt: new Date(Date.now()),
|
|
547
986
|
expiresIn: new Date(Date.now() + COUPON_EXPIRATION),
|
|
548
987
|
});
|
|
549
988
|
}
|
|
550
989
|
}
|
|
551
|
-
__decorate([
|
|
552
|
-
Expose({ name: 'checkout_type' }),
|
|
553
|
-
__metadata("design:type", Number)
|
|
554
|
-
], Coupon.prototype, "checkoutType", void 0);
|
|
555
|
-
__decorate([
|
|
556
|
-
Expose({ name: 'exclusivity_type' }),
|
|
557
|
-
__metadata("design:type", Number)
|
|
558
|
-
], Coupon.prototype, "exclusivityType", void 0);
|
|
559
990
|
|
|
560
991
|
class SubscriptionPlan extends BaseModel {
|
|
561
992
|
static get identifiersFields() {
|
|
@@ -595,6 +1026,18 @@ __decorate([
|
|
|
595
1026
|
__metadata("design:type", BeautyProfile)
|
|
596
1027
|
], User.prototype, "beautyProfile", void 0);
|
|
597
1028
|
|
|
1029
|
+
class Address extends BaseModel {
|
|
1030
|
+
static get identifiersFields() {
|
|
1031
|
+
return ['id'];
|
|
1032
|
+
}
|
|
1033
|
+
}
|
|
1034
|
+
|
|
1035
|
+
class UserAddress extends Address {
|
|
1036
|
+
static get identifiersFields() {
|
|
1037
|
+
return ['id', 'userId'];
|
|
1038
|
+
}
|
|
1039
|
+
}
|
|
1040
|
+
|
|
598
1041
|
class Subscription extends BaseModel {
|
|
599
1042
|
static get identifiersFields() {
|
|
600
1043
|
return ['id'];
|
|
@@ -609,12 +1052,12 @@ __decorate([
|
|
|
609
1052
|
__metadata("design:type", SubscriptionPlan)
|
|
610
1053
|
], Subscription.prototype, "subscriptionPlan", void 0);
|
|
611
1054
|
__decorate([
|
|
612
|
-
Type(() =>
|
|
613
|
-
__metadata("design:type",
|
|
1055
|
+
Type(() => UserAddress),
|
|
1056
|
+
__metadata("design:type", UserAddress)
|
|
614
1057
|
], Subscription.prototype, "shippingAddress", void 0);
|
|
615
1058
|
__decorate([
|
|
616
|
-
Type(() =>
|
|
617
|
-
__metadata("design:type",
|
|
1059
|
+
Type(() => UserAddress),
|
|
1060
|
+
__metadata("design:type", UserAddress)
|
|
618
1061
|
], Subscription.prototype, "billingAddress", void 0);
|
|
619
1062
|
__decorate([
|
|
620
1063
|
Type(() => Coupon),
|
|
@@ -629,12 +1072,6 @@ __decorate([
|
|
|
629
1072
|
__metadata("design:type", Array)
|
|
630
1073
|
], Subscription.prototype, "payment", void 0);
|
|
631
1074
|
|
|
632
|
-
class UserAddress extends Address {
|
|
633
|
-
static get identifiersFields() {
|
|
634
|
-
return ['id', 'userId'];
|
|
635
|
-
}
|
|
636
|
-
}
|
|
637
|
-
|
|
638
1075
|
class UserPaymentMethod extends BaseModel {
|
|
639
1076
|
static get identifiersFields() {
|
|
640
1077
|
return ['id', 'userId'];
|
|
@@ -667,7 +1104,7 @@ class Authentication {
|
|
|
667
1104
|
return __awaiter(this, void 0, void 0, function* () {
|
|
668
1105
|
const method = this.getServiceByMethod(signInMethod);
|
|
669
1106
|
const userAuth = yield this.authService[method]({ email, password });
|
|
670
|
-
const user = this.userRepository.get(userAuth);
|
|
1107
|
+
const user = this.userRepository.get({ id: userAuth.id });
|
|
671
1108
|
if (!isNil(user))
|
|
672
1109
|
return user;
|
|
673
1110
|
if (/^.+@b4a.com.br$/.test(userAuth.email))
|
|
@@ -754,14 +1191,123 @@ class RecoveryPassword {
|
|
|
754
1191
|
}
|
|
755
1192
|
}
|
|
756
1193
|
|
|
757
|
-
class
|
|
758
|
-
|
|
1194
|
+
class Filter extends BaseModel {
|
|
1195
|
+
static get identifiersFields() {
|
|
1196
|
+
return ['id'];
|
|
1197
|
+
}
|
|
1198
|
+
}
|
|
1199
|
+
|
|
1200
|
+
class CategoryBase extends BaseModel {
|
|
1201
|
+
static get identifiersFields() {
|
|
1202
|
+
return ['id'];
|
|
1203
|
+
}
|
|
1204
|
+
}
|
|
1205
|
+
__decorate([
|
|
1206
|
+
Type(() => CategoryBase),
|
|
1207
|
+
__metadata("design:type", CategoryBase)
|
|
1208
|
+
], CategoryBase.prototype, "parent", void 0);
|
|
1209
|
+
__decorate([
|
|
1210
|
+
Type(() => Filter),
|
|
1211
|
+
__metadata("design:type", Array)
|
|
1212
|
+
], CategoryBase.prototype, "filters", void 0);
|
|
1213
|
+
|
|
1214
|
+
class CategoryForProduct extends CategoryBase {
|
|
1215
|
+
static get identifiersFields() {
|
|
1216
|
+
return ['id'];
|
|
1217
|
+
}
|
|
1218
|
+
}
|
|
1219
|
+
|
|
1220
|
+
class ProductBase extends BaseModel {
|
|
1221
|
+
get evaluation() {
|
|
1222
|
+
return {
|
|
1223
|
+
reviews: this.reviews,
|
|
1224
|
+
count: this.reviewsTotal,
|
|
1225
|
+
rating: this.rate,
|
|
1226
|
+
};
|
|
1227
|
+
}
|
|
1228
|
+
set evaluation(evaluation) {
|
|
1229
|
+
if (!evaluation) {
|
|
1230
|
+
this.reviews = null;
|
|
1231
|
+
this.reviewsTotal = null;
|
|
1232
|
+
this.rate = null;
|
|
1233
|
+
return;
|
|
1234
|
+
}
|
|
1235
|
+
this.reviews = evaluation.reviews || this.reviews;
|
|
1236
|
+
this.reviewsTotal = evaluation.count || this.reviewsTotal;
|
|
1237
|
+
this.rate = evaluation.rating || this.rate;
|
|
1238
|
+
}
|
|
1239
|
+
static get identifiersFields() {
|
|
1240
|
+
return ['id'];
|
|
1241
|
+
}
|
|
1242
|
+
}
|
|
1243
|
+
|
|
1244
|
+
class ProductForKit extends ProductBase {
|
|
1245
|
+
static get identifiersFields() {
|
|
1246
|
+
return ['id'];
|
|
1247
|
+
}
|
|
1248
|
+
}
|
|
1249
|
+
__decorate([
|
|
1250
|
+
Type(() => CategoryForProduct),
|
|
1251
|
+
__metadata("design:type", CategoryForProduct)
|
|
1252
|
+
], ProductForKit.prototype, "category", void 0);
|
|
1253
|
+
|
|
1254
|
+
class KitProduct extends BaseModel {
|
|
1255
|
+
static get identifiersFields() {
|
|
1256
|
+
return ['productId', 'kitProductId'];
|
|
1257
|
+
}
|
|
1258
|
+
}
|
|
1259
|
+
__decorate([
|
|
1260
|
+
Type(() => ProductForKit),
|
|
1261
|
+
__metadata("design:type", ProductForKit)
|
|
1262
|
+
], KitProduct.prototype, "kit", void 0);
|
|
1263
|
+
__decorate([
|
|
1264
|
+
Type(() => ProductForKit),
|
|
1265
|
+
__metadata("design:type", ProductForKit)
|
|
1266
|
+
], KitProduct.prototype, "product", void 0);
|
|
1267
|
+
|
|
1268
|
+
class ProductForCategory extends ProductBase {
|
|
1269
|
+
static get identifiersFields() {
|
|
1270
|
+
return ['id'];
|
|
1271
|
+
}
|
|
1272
|
+
}
|
|
1273
|
+
__decorate([
|
|
1274
|
+
Type(() => KitProduct),
|
|
1275
|
+
__metadata("design:type", Array)
|
|
1276
|
+
], ProductForCategory.prototype, "kitProducts", void 0);
|
|
1277
|
+
|
|
1278
|
+
class Category extends CategoryBase {
|
|
1279
|
+
static get identifiersFields() {
|
|
759
1280
|
return ['id'];
|
|
760
1281
|
}
|
|
1282
|
+
}
|
|
1283
|
+
__decorate([
|
|
1284
|
+
Type(() => ProductForCategory),
|
|
1285
|
+
__metadata("design:type", Array)
|
|
1286
|
+
], Category.prototype, "childrenProducts", void 0);
|
|
1287
|
+
|
|
1288
|
+
class CategoryCollectionChildren extends BaseModel {
|
|
1289
|
+
static get identifiersFields() {
|
|
1290
|
+
return ['collectionId', 'categoryId'];
|
|
1291
|
+
}
|
|
1292
|
+
}
|
|
1293
|
+
__decorate([
|
|
1294
|
+
Type(() => CategoryCollectionChildren),
|
|
1295
|
+
__metadata("design:type", CategoryCollectionChildren)
|
|
1296
|
+
], CategoryCollectionChildren.prototype, "parent", void 0);
|
|
1297
|
+
|
|
1298
|
+
class CategoryFilter extends BaseModel {
|
|
761
1299
|
static get identifiersFields() {
|
|
762
1300
|
return ['id'];
|
|
763
1301
|
}
|
|
764
1302
|
}
|
|
1303
|
+
__decorate([
|
|
1304
|
+
Type(() => Filter),
|
|
1305
|
+
__metadata("design:type", Filter)
|
|
1306
|
+
], CategoryFilter.prototype, "filter", void 0);
|
|
1307
|
+
__decorate([
|
|
1308
|
+
Type(() => Category),
|
|
1309
|
+
__metadata("design:type", Category)
|
|
1310
|
+
], CategoryFilter.prototype, "category", void 0);
|
|
765
1311
|
|
|
766
1312
|
var GenderDestination;
|
|
767
1313
|
(function (GenderDestination) {
|
|
@@ -778,53 +1324,59 @@ var Shops;
|
|
|
778
1324
|
Shops["ALL"] = "ALL";
|
|
779
1325
|
})(Shops || (Shops = {}));
|
|
780
1326
|
|
|
781
|
-
class
|
|
782
|
-
|
|
1327
|
+
class FilterOption extends BaseModel {
|
|
1328
|
+
static get identifiersFields() {
|
|
783
1329
|
return ['id'];
|
|
784
1330
|
}
|
|
1331
|
+
}
|
|
1332
|
+
|
|
1333
|
+
class Product extends ProductBase {
|
|
785
1334
|
static get identifiersFields() {
|
|
786
1335
|
return ['id'];
|
|
787
1336
|
}
|
|
788
1337
|
}
|
|
1338
|
+
__decorate([
|
|
1339
|
+
Type(() => CategoryForProduct),
|
|
1340
|
+
__metadata("design:type", CategoryForProduct)
|
|
1341
|
+
], Product.prototype, "category", void 0);
|
|
789
1342
|
__decorate([
|
|
790
1343
|
Type(() => KitProduct),
|
|
791
1344
|
__metadata("design:type", Array)
|
|
792
1345
|
], Product.prototype, "kitProducts", void 0);
|
|
793
1346
|
|
|
794
|
-
class
|
|
1347
|
+
class Variant extends BaseModel {
|
|
795
1348
|
static get identifiersFields() {
|
|
796
|
-
return ['
|
|
1349
|
+
return ['id', 'productId'];
|
|
797
1350
|
}
|
|
798
1351
|
}
|
|
799
|
-
__decorate([
|
|
800
|
-
Type(() => Product),
|
|
801
|
-
__metadata("design:type", Product)
|
|
802
|
-
], KitProduct.prototype, "kit", void 0);
|
|
803
|
-
__decorate([
|
|
804
|
-
Type(() => Product),
|
|
805
|
-
__metadata("design:type", Product)
|
|
806
|
-
], KitProduct.prototype, "product", void 0);
|
|
807
1352
|
|
|
808
|
-
class
|
|
809
|
-
|
|
1353
|
+
class Wishlist extends Category {
|
|
1354
|
+
static get identifiersFields() {
|
|
1355
|
+
return ['id'];
|
|
1356
|
+
}
|
|
1357
|
+
}
|
|
1358
|
+
|
|
1359
|
+
class Buy2Win extends BaseModel {
|
|
1360
|
+
static get identifiersFields() {
|
|
810
1361
|
return ['id'];
|
|
811
1362
|
}
|
|
1363
|
+
}
|
|
1364
|
+
__decorate([
|
|
1365
|
+
Type(() => Category),
|
|
1366
|
+
__metadata("design:type", Array)
|
|
1367
|
+
], Buy2Win.prototype, "categories", void 0);
|
|
1368
|
+
|
|
1369
|
+
class CampaignDashboard extends BaseModel {
|
|
812
1370
|
static get identifiersFields() {
|
|
813
|
-
return ['id'
|
|
1371
|
+
return ['id'];
|
|
814
1372
|
}
|
|
815
1373
|
}
|
|
816
1374
|
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
OrderStatus["AGUARDANDO_ENVIO"] = "Aguardando Transaportadora";
|
|
823
|
-
OrderStatus["ENVIADO"] = "Enviado";
|
|
824
|
-
OrderStatus["ENTREGUE"] = "Entregue";
|
|
825
|
-
OrderStatus["CANCELADO"] = "Cancelado";
|
|
826
|
-
OrderStatus["CREDIT_CARD"] = "credit_card";
|
|
827
|
-
})(OrderStatus || (OrderStatus = {}));
|
|
1375
|
+
class CampaignHashtag extends BaseModel {
|
|
1376
|
+
static get identifiersFields() {
|
|
1377
|
+
return ['id'];
|
|
1378
|
+
}
|
|
1379
|
+
}
|
|
828
1380
|
|
|
829
1381
|
class LineItem extends Product {
|
|
830
1382
|
}
|
|
@@ -849,12 +1401,12 @@ __decorate([
|
|
|
849
1401
|
__metadata("design:type", User)
|
|
850
1402
|
], Checkout.prototype, "user", void 0);
|
|
851
1403
|
__decorate([
|
|
852
|
-
Type(() =>
|
|
853
|
-
__metadata("design:type",
|
|
1404
|
+
Type(() => UserAddress),
|
|
1405
|
+
__metadata("design:type", UserAddress)
|
|
854
1406
|
], Checkout.prototype, "shippingAddress", void 0);
|
|
855
1407
|
__decorate([
|
|
856
|
-
Type(() =>
|
|
857
|
-
__metadata("design:type",
|
|
1408
|
+
Type(() => UserAddress),
|
|
1409
|
+
__metadata("design:type", UserAddress)
|
|
858
1410
|
], Checkout.prototype, "billingAddress", void 0);
|
|
859
1411
|
__decorate([
|
|
860
1412
|
Type(() => ShippingMethod),
|
|
@@ -865,6 +1417,18 @@ __decorate([
|
|
|
865
1417
|
__metadata("design:type", Coupon)
|
|
866
1418
|
], Checkout.prototype, "coupon", void 0);
|
|
867
1419
|
|
|
1420
|
+
var OrderStatus;
|
|
1421
|
+
(function (OrderStatus) {
|
|
1422
|
+
OrderStatus["AGUARDANDO_PAGAMENTO"] = "Aguardando pagamento";
|
|
1423
|
+
OrderStatus["EM_PREPARO"] = "Preparando pedido";
|
|
1424
|
+
OrderStatus["NF_EMITIDA"] = "Nota Fiscal Emitida";
|
|
1425
|
+
OrderStatus["AGUARDANDO_ENVIO"] = "Aguardando Transaportadora";
|
|
1426
|
+
OrderStatus["ENVIADO"] = "Enviado";
|
|
1427
|
+
OrderStatus["ENTREGUE"] = "Entregue";
|
|
1428
|
+
OrderStatus["CANCELADO"] = "Cancelado";
|
|
1429
|
+
OrderStatus["CREDIT_CARD"] = "credit_card";
|
|
1430
|
+
})(OrderStatus || (OrderStatus = {}));
|
|
1431
|
+
|
|
868
1432
|
class Order extends Checkout {
|
|
869
1433
|
}
|
|
870
1434
|
__decorate([
|
|
@@ -878,12 +1442,12 @@ class CheckoutSubscription extends BaseModel {
|
|
|
878
1442
|
}
|
|
879
1443
|
}
|
|
880
1444
|
__decorate([
|
|
881
|
-
Type(() =>
|
|
882
|
-
__metadata("design:type",
|
|
1445
|
+
Type(() => UserAddress),
|
|
1446
|
+
__metadata("design:type", UserAddress)
|
|
883
1447
|
], CheckoutSubscription.prototype, "shippingAddress", void 0);
|
|
884
1448
|
__decorate([
|
|
885
|
-
Type(() =>
|
|
886
|
-
__metadata("design:type",
|
|
1449
|
+
Type(() => UserAddress),
|
|
1450
|
+
__metadata("design:type", UserAddress)
|
|
887
1451
|
], CheckoutSubscription.prototype, "billingAddress", void 0);
|
|
888
1452
|
__decorate([
|
|
889
1453
|
Type(() => SubscriptionPlan),
|
|
@@ -894,15 +1458,19 @@ __decorate([
|
|
|
894
1458
|
__metadata("design:type", Coupon)
|
|
895
1459
|
], CheckoutSubscription.prototype, "coupon", void 0);
|
|
896
1460
|
|
|
897
|
-
class
|
|
898
|
-
static
|
|
899
|
-
|
|
1461
|
+
class RoundProductPricesHelper {
|
|
1462
|
+
static roundProductPrices(product) {
|
|
1463
|
+
product.price.price = Number(product.price.price.toFixed(2));
|
|
1464
|
+
product.price.fullPrice = Number(product.price.fullPrice.toFixed(2));
|
|
1465
|
+
if (product.price.subscriberPrice) {
|
|
1466
|
+
product.price.subscriberPrice = Number(product.price.subscriberPrice.toFixed(2));
|
|
1467
|
+
}
|
|
1468
|
+
if (product instanceof LineItem && product.pricePaid) {
|
|
1469
|
+
product.pricePaid = Number(product.pricePaid.toFixed(2));
|
|
1470
|
+
}
|
|
1471
|
+
return product;
|
|
900
1472
|
}
|
|
901
1473
|
}
|
|
902
|
-
__decorate([
|
|
903
|
-
Type(() => Category),
|
|
904
|
-
__metadata("design:type", Array)
|
|
905
|
-
], Buy2Win.prototype, "categories", void 0);
|
|
906
1474
|
|
|
907
1475
|
var FilterType;
|
|
908
1476
|
(function (FilterType) {
|
|
@@ -1003,6 +1571,12 @@ class ShopMenu extends BaseModel {
|
|
|
1003
1571
|
}
|
|
1004
1572
|
}
|
|
1005
1573
|
|
|
1574
|
+
class ShopSettings extends BaseModel {
|
|
1575
|
+
static get identifiersFields() {
|
|
1576
|
+
return ['id'];
|
|
1577
|
+
}
|
|
1578
|
+
}
|
|
1579
|
+
|
|
1006
1580
|
class InvalidArgumentError extends CustomError {
|
|
1007
1581
|
constructor(message) {
|
|
1008
1582
|
super(message);
|
|
@@ -1033,13 +1607,17 @@ class AxiosAdapter {
|
|
|
1033
1607
|
constructor(config) {
|
|
1034
1608
|
this.config = config;
|
|
1035
1609
|
}
|
|
1036
|
-
get(index) {
|
|
1610
|
+
get(index, id) {
|
|
1037
1611
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1038
1612
|
try {
|
|
1039
1613
|
const { data } = yield axios({
|
|
1040
|
-
url: `${this.config.url}/${index}`,
|
|
1614
|
+
url: `${this.config.url}/${index}/_doc/${id}`,
|
|
1041
1615
|
method: 'GET',
|
|
1042
|
-
|
|
1616
|
+
responseType: 'json',
|
|
1617
|
+
headers: {
|
|
1618
|
+
'Content-Type': 'application/json',
|
|
1619
|
+
Authorization: `ApiKey ${this.config.credential}`,
|
|
1620
|
+
},
|
|
1043
1621
|
});
|
|
1044
1622
|
return data._source;
|
|
1045
1623
|
}
|
|
@@ -1053,9 +1631,14 @@ class AxiosAdapter {
|
|
|
1053
1631
|
query(index, query) {
|
|
1054
1632
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1055
1633
|
const { data } = yield axios({
|
|
1056
|
-
url: `${this.config.url}/${index}`,
|
|
1634
|
+
url: `${this.config.url}/${index}/_search`,
|
|
1057
1635
|
method: 'POST',
|
|
1058
|
-
|
|
1636
|
+
responseType: 'json',
|
|
1637
|
+
headers: {
|
|
1638
|
+
Accept: 'application/vnd.elasticsearch+json;compatible-with=7',
|
|
1639
|
+
'Content-Type': 'application/vnd.elasticsearch+json;compatible-with=7',
|
|
1640
|
+
Authorization: `ApiKey ${this.config.credential}`,
|
|
1641
|
+
},
|
|
1059
1642
|
data: query,
|
|
1060
1643
|
});
|
|
1061
1644
|
return {
|
|
@@ -1067,19 +1650,29 @@ class AxiosAdapter {
|
|
|
1067
1650
|
save(index, data) {
|
|
1068
1651
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1069
1652
|
yield axios({
|
|
1070
|
-
url: `${this.config.url}/${index}`,
|
|
1653
|
+
url: `${this.config.url}/${index}/_doc`,
|
|
1654
|
+
method: 'POST',
|
|
1655
|
+
headers: { Authorization: `ApiKey ${this.config.credential}` },
|
|
1656
|
+
data,
|
|
1657
|
+
});
|
|
1658
|
+
});
|
|
1659
|
+
}
|
|
1660
|
+
update(index, id, data) {
|
|
1661
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1662
|
+
yield axios({
|
|
1663
|
+
url: `${this.config.url}/${index}/_update/${id}`,
|
|
1071
1664
|
method: 'PUT',
|
|
1072
|
-
headers: { Authorization: `
|
|
1665
|
+
headers: { Authorization: `ApiKey ${this.config.credential}` },
|
|
1073
1666
|
data,
|
|
1074
1667
|
});
|
|
1075
1668
|
});
|
|
1076
1669
|
}
|
|
1077
|
-
delete(index) {
|
|
1670
|
+
delete(index, id) {
|
|
1078
1671
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1079
1672
|
yield axios({
|
|
1080
|
-
url: `${this.config.url}/${index}`,
|
|
1673
|
+
url: `${this.config.url}/${index}/_doc/${id}`,
|
|
1081
1674
|
method: 'DELETE',
|
|
1082
|
-
headers: { Authorization: `
|
|
1675
|
+
headers: { Authorization: `ApiKey ${this.config.credential}` },
|
|
1083
1676
|
});
|
|
1084
1677
|
});
|
|
1085
1678
|
}
|
|
@@ -1088,16 +1681,19 @@ class AxiosAdapter {
|
|
|
1088
1681
|
class ProductsIndex {
|
|
1089
1682
|
constructor(adapter) {
|
|
1090
1683
|
this.adapter = adapter;
|
|
1684
|
+
this.index = `products`;
|
|
1091
1685
|
}
|
|
1092
|
-
|
|
1686
|
+
getById(id) {
|
|
1093
1687
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1094
|
-
const data = yield this.adapter.get(
|
|
1688
|
+
const data = yield this.adapter.get(this.index, id);
|
|
1095
1689
|
return Product.toInstance(data);
|
|
1096
1690
|
});
|
|
1097
1691
|
}
|
|
1098
|
-
|
|
1692
|
+
search(searchTerm, total, shop) {
|
|
1099
1693
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1694
|
+
const size = total || 9;
|
|
1100
1695
|
const fields = [
|
|
1696
|
+
'EAN',
|
|
1101
1697
|
'brand',
|
|
1102
1698
|
'id',
|
|
1103
1699
|
'images',
|
|
@@ -1108,73 +1704,88 @@ class ProductsIndex {
|
|
|
1108
1704
|
'stock',
|
|
1109
1705
|
'slug',
|
|
1110
1706
|
'reviews',
|
|
1111
|
-
'pricePaid',
|
|
1112
|
-
'isGift',
|
|
1113
|
-
'stock',
|
|
1114
|
-
'weight',
|
|
1115
|
-
'tags',
|
|
1116
1707
|
'hasVariants',
|
|
1117
|
-
'
|
|
1708
|
+
'rate',
|
|
1118
1709
|
];
|
|
1119
|
-
const
|
|
1710
|
+
const filter = [{ term: { published: true } }];
|
|
1711
|
+
if (size > 9) {
|
|
1712
|
+
fields.push(...['pricePaid', 'isGift', 'stock', 'weight', 'tags']);
|
|
1713
|
+
}
|
|
1714
|
+
else {
|
|
1715
|
+
filter.push({ term: { tags: shop == Shops.GLAMSHOP ? 'feminino' : 'masculino' } });
|
|
1716
|
+
}
|
|
1717
|
+
const search = yield this.adapter.query(this.index, {
|
|
1718
|
+
size,
|
|
1719
|
+
_source: fields,
|
|
1720
|
+
query: {
|
|
1120
1721
|
bool: {
|
|
1121
|
-
|
|
1122
|
-
{
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1722
|
+
must: {
|
|
1723
|
+
multi_match: {
|
|
1724
|
+
query: `${searchTerm}`,
|
|
1725
|
+
type: 'bool_prefix',
|
|
1726
|
+
fields: [
|
|
1727
|
+
'name',
|
|
1728
|
+
'name.folded',
|
|
1729
|
+
'name.search',
|
|
1730
|
+
'description',
|
|
1731
|
+
'description.search',
|
|
1732
|
+
'description.folded',
|
|
1733
|
+
'brand',
|
|
1734
|
+
'brand.search',
|
|
1735
|
+
'brand.folded',
|
|
1736
|
+
],
|
|
1737
|
+
fuzziness: 2,
|
|
1126
1738
|
},
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1739
|
+
},
|
|
1740
|
+
should: {
|
|
1741
|
+
match_phrase_prefix: {
|
|
1742
|
+
'name.search': {
|
|
1743
|
+
query: `${searchTerm}`,
|
|
1744
|
+
slop: 10,
|
|
1130
1745
|
},
|
|
1131
1746
|
},
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
{
|
|
1135
|
-
range: {
|
|
1136
|
-
'stock.quantity': {
|
|
1137
|
-
gt: 0,
|
|
1138
|
-
},
|
|
1139
|
-
},
|
|
1140
|
-
},
|
|
1141
|
-
]
|
|
1142
|
-
: []),
|
|
1143
|
-
],
|
|
1747
|
+
},
|
|
1748
|
+
filter,
|
|
1144
1749
|
},
|
|
1145
|
-
}
|
|
1146
|
-
|
|
1750
|
+
},
|
|
1751
|
+
});
|
|
1752
|
+
search.hits = search.hits
|
|
1753
|
+
.filter((e) => e._source.name !== '')
|
|
1754
|
+
.map((hit) => {
|
|
1755
|
+
RoundProductPricesHelper.roundProductPrices(hit._source);
|
|
1756
|
+
return hit;
|
|
1757
|
+
});
|
|
1758
|
+
return search;
|
|
1147
1759
|
});
|
|
1148
1760
|
}
|
|
1149
1761
|
save(product) {
|
|
1150
1762
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1151
|
-
delete product.createdAt;
|
|
1152
|
-
delete product.updatedAt;
|
|
1153
|
-
delete product.kitProducts;
|
|
1154
1763
|
try {
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
yield this.get(product.firestoreId);
|
|
1158
|
-
yield this.adapter.save(`products/_doc/${product.firestoreId}`, product.toPlain());
|
|
1764
|
+
const { createdAt, updatedAt, kitProducts } = product, data = __rest(product, ["createdAt", "updatedAt", "kitProducts"]);
|
|
1765
|
+
this.adapter.save(this.index, data);
|
|
1159
1766
|
}
|
|
1160
1767
|
catch (error) {
|
|
1161
|
-
|
|
1162
|
-
throw error;
|
|
1163
|
-
console.error(error.message);
|
|
1164
|
-
yield this.adapter.save(`products/_doc/${product.id}`, product.toPlain());
|
|
1768
|
+
console.error(error);
|
|
1165
1769
|
}
|
|
1166
1770
|
});
|
|
1167
1771
|
}
|
|
1168
|
-
|
|
1772
|
+
update(product) {
|
|
1773
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1774
|
+
try {
|
|
1775
|
+
yield this.adapter.update(this.index, product.id, product);
|
|
1776
|
+
}
|
|
1777
|
+
catch (error) {
|
|
1778
|
+
console.error(error);
|
|
1779
|
+
}
|
|
1780
|
+
});
|
|
1781
|
+
}
|
|
1782
|
+
delete(id) {
|
|
1169
1783
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1170
|
-
if (!product.firestoreId)
|
|
1171
|
-
return;
|
|
1172
1784
|
try {
|
|
1173
|
-
yield this.
|
|
1174
|
-
yield this.adapter.delete(`products/_doc/${product.firestoreId}`);
|
|
1785
|
+
yield this.adapter.delete(this.index, id);
|
|
1175
1786
|
}
|
|
1176
1787
|
catch (error) {
|
|
1177
|
-
|
|
1788
|
+
console.error(error);
|
|
1178
1789
|
}
|
|
1179
1790
|
});
|
|
1180
1791
|
}
|
|
@@ -1202,17 +1813,39 @@ const withFirestore = (MixinBase) => {
|
|
|
1202
1813
|
? data[key].map((element) => (isObjectsAndNoDate(element) ? bindAllDateFromObject(element) : element))
|
|
1203
1814
|
: bindDate(data[key], key) })), {});
|
|
1204
1815
|
};
|
|
1816
|
+
const omitByRecursivelyInPlace = (value, iteratee) => {
|
|
1817
|
+
each(value, (v, k) => {
|
|
1818
|
+
if (iteratee(v, k)) {
|
|
1819
|
+
unset(value, k);
|
|
1820
|
+
}
|
|
1821
|
+
else if (isObject(v)) {
|
|
1822
|
+
omitByRecursivelyInPlace(v, iteratee);
|
|
1823
|
+
}
|
|
1824
|
+
});
|
|
1825
|
+
return value;
|
|
1826
|
+
};
|
|
1205
1827
|
return class extends MixinBase {
|
|
1206
|
-
constructor() {
|
|
1207
|
-
super(...
|
|
1828
|
+
constructor(...params) {
|
|
1829
|
+
super(...params);
|
|
1830
|
+
this.fields = {};
|
|
1831
|
+
this.interceptors = {};
|
|
1208
1832
|
this.collectionName = '';
|
|
1833
|
+
const options = params[0];
|
|
1834
|
+
this.firestore = options.firestore;
|
|
1835
|
+
this.collectionName = options.collectionName;
|
|
1836
|
+
this.model = options.model;
|
|
1837
|
+
this.fields = options.fields;
|
|
1838
|
+
this.interceptors = options.interceptors;
|
|
1209
1839
|
}
|
|
1210
1840
|
collection(path) {
|
|
1211
1841
|
return collection(this.firestore, path || this.collectionName).withConverter(this.buildModelInstance());
|
|
1212
1842
|
}
|
|
1213
1843
|
buildModelInstance() {
|
|
1214
1844
|
return {
|
|
1215
|
-
toFirestore: (data) =>
|
|
1845
|
+
toFirestore: (data) => {
|
|
1846
|
+
const plain = (data === null || data === void 0 ? void 0 : data.toPlain) ? data.toPlain() : data;
|
|
1847
|
+
return omitByRecursivelyInPlace(plain, (value) => value === undefined);
|
|
1848
|
+
},
|
|
1216
1849
|
fromFirestore: (snap) => {
|
|
1217
1850
|
const data = snap.data();
|
|
1218
1851
|
let bindedData = null;
|
|
@@ -1252,12 +1885,16 @@ const withHelpers = (MixinBase) => {
|
|
|
1252
1885
|
const withGetFirestore = (MixinBase) => {
|
|
1253
1886
|
return class GetFirestore extends MixinBase {
|
|
1254
1887
|
get(identifiers) {
|
|
1888
|
+
var _a, _b, _c, _d;
|
|
1255
1889
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1256
|
-
const
|
|
1890
|
+
const instance = this.model.toInstance(this.model.identifiersFields.reduce((acc, field) => (Object.assign(Object.assign({}, acc), { [field]: identifiers[field] })), {}));
|
|
1891
|
+
const intercepted = yield ((_b = (_a = this.interceptors) === null || _a === void 0 ? void 0 : _a.request) === null || _b === void 0 ? void 0 : _b.call(_a, { instance }));
|
|
1892
|
+
const builded = (intercepted === null || intercepted === void 0 ? void 0 : intercepted.instance) || instance;
|
|
1893
|
+
const docRef = yield getDoc(doc(yield this.collection(this.buildCollectionPathForGet(identifiers)), Object.values(builded.identifier).shift().toString()));
|
|
1257
1894
|
const data = docRef.data();
|
|
1258
1895
|
if (isNil(data))
|
|
1259
1896
|
throw new NotFoundError(`Document ${JSON.stringify(identifiers)} not found`);
|
|
1260
|
-
return data;
|
|
1897
|
+
return ((_d = (_c = this.interceptors) === null || _c === void 0 ? void 0 : _c.response) === null || _d === void 0 ? void 0 : _d.call(_c, data, intercepted)) || data;
|
|
1261
1898
|
});
|
|
1262
1899
|
}
|
|
1263
1900
|
buildCollectionPathForGet(identifiers) {
|
|
@@ -1295,7 +1932,7 @@ const withFindFirestore = (MixinBase) => {
|
|
|
1295
1932
|
], []);
|
|
1296
1933
|
this.buildWhereSentence = (fieldName, options) => {
|
|
1297
1934
|
if (this.isSubCollection(this) && fieldName === this.parentIdField)
|
|
1298
|
-
[];
|
|
1935
|
+
return [];
|
|
1299
1936
|
const value = (options === null || options === void 0 ? void 0 : options.value) || options;
|
|
1300
1937
|
const object = {};
|
|
1301
1938
|
set(object, fieldName, value);
|
|
@@ -1336,9 +1973,13 @@ const withFindFirestore = (MixinBase) => {
|
|
|
1336
1973
|
return Object.keys(fieldsToOrderBy).map((fieldName) => orderBy(fieldName, fieldsToOrderBy[fieldName]));
|
|
1337
1974
|
};
|
|
1338
1975
|
}
|
|
1339
|
-
find(
|
|
1976
|
+
find(find = {}) {
|
|
1977
|
+
var _a, _b, _c, _d, _e, _f;
|
|
1340
1978
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1341
|
-
const collection = this.collection(this.buildCollectionPathForFind(filters));
|
|
1979
|
+
const collection = this.collection(this.buildCollectionPathForFind(find.filters));
|
|
1980
|
+
const enableCount = (_b = (_a = find === null || find === void 0 ? void 0 : find.options) === null || _a === void 0 ? void 0 : _a.enableCount) !== null && _b !== void 0 ? _b : true;
|
|
1981
|
+
const intercepted = yield ((_d = (_c = this.interceptors) === null || _c === void 0 ? void 0 : _c.request) === null || _d === void 0 ? void 0 : _d.call(_c, { find }));
|
|
1982
|
+
const { filters, limits, orderBy } = intercepted.find || find;
|
|
1342
1983
|
const queries = this.makeFirestoreWhere(filters || {});
|
|
1343
1984
|
const ordination = this.makeFirestoreOrderBy(filters, orderBy);
|
|
1344
1985
|
const offsets = yield this.defineLimits(filters, limits);
|
|
@@ -1346,8 +1987,8 @@ const withFindFirestore = (MixinBase) => {
|
|
|
1346
1987
|
const docs = yield getDocs(query(collection, ...queryArgumments));
|
|
1347
1988
|
const data = docs.docs.map((doc) => doc.data());
|
|
1348
1989
|
return {
|
|
1349
|
-
data,
|
|
1350
|
-
count: this.calculateCount(data, limits),
|
|
1990
|
+
data: (yield ((_f = (_e = this.interceptors) === null || _e === void 0 ? void 0 : _e.response) === null || _f === void 0 ? void 0 : _f.call(_e, data, intercepted))) || data,
|
|
1991
|
+
count: enableCount ? this.calculateCount(data, limits) : Infinity,
|
|
1351
1992
|
};
|
|
1352
1993
|
});
|
|
1353
1994
|
}
|
|
@@ -1364,7 +2005,7 @@ const withFindFirestore = (MixinBase) => {
|
|
|
1364
2005
|
const queries = [];
|
|
1365
2006
|
if (limits === null || limits === void 0 ? void 0 : limits.offset) {
|
|
1366
2007
|
if (this.model.isModel(limits.offset))
|
|
1367
|
-
queries.push(startAfter(yield getDoc(doc(this.collection(this.buildCollectionPathForFind(filters)),
|
|
2008
|
+
queries.push(startAfter(yield getDoc(doc(this.collection(this.buildCollectionPathForFind(filters)), (_a = Object.values(limits.offset.identifier).shift()) === null || _a === void 0 ? void 0 : _a.toString()))));
|
|
1368
2009
|
else if (isNumber(limits.offset) || isString(limits.offset))
|
|
1369
2010
|
queries.push(startAt(limits.offset));
|
|
1370
2011
|
}
|
|
@@ -1386,16 +2027,21 @@ const withFindFirestore = (MixinBase) => {
|
|
|
1386
2027
|
const withCreateFirestore = (MixinBase) => {
|
|
1387
2028
|
return class CreateFirestore extends MixinBase {
|
|
1388
2029
|
create(data) {
|
|
2030
|
+
var _a, _b, _c, _d;
|
|
1389
2031
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1390
|
-
const
|
|
2032
|
+
const instance = this.model.toInstance(data);
|
|
2033
|
+
const intercepted = yield ((_b = (_a = this.interceptors) === null || _a === void 0 ? void 0 : _a.request) === null || _b === void 0 ? void 0 : _b.call(_a, { instance }));
|
|
2034
|
+
const builded = (intercepted === null || intercepted === void 0 ? void 0 : intercepted.instance) || instance;
|
|
2035
|
+
const docRef = yield this.save(builded);
|
|
1391
2036
|
const doc = yield getDoc(docRef);
|
|
1392
|
-
|
|
2037
|
+
const docBuilded = (yield ((_d = (_c = this.interceptors) === null || _c === void 0 ? void 0 : _c.response) === null || _d === void 0 ? void 0 : _d.call(_c, doc.data(), intercepted))) || doc.data();
|
|
2038
|
+
return docBuilded;
|
|
1393
2039
|
});
|
|
1394
2040
|
}
|
|
1395
2041
|
save(data) {
|
|
1396
2042
|
var _a, _b;
|
|
1397
2043
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1398
|
-
const id = (_b =
|
|
2044
|
+
const id = (_b = (_a = Object.values(data.identifier)) === null || _a === void 0 ? void 0 : _a.shift()) === null || _b === void 0 ? void 0 : _b.toString();
|
|
1399
2045
|
const collectionPath = this.buildCollectionPathForAdd(data);
|
|
1400
2046
|
const collection = this.collection(collectionPath);
|
|
1401
2047
|
if (isEmpty(id))
|
|
@@ -1437,13 +2083,17 @@ const withUpdateFirestore = (MixinBase) => {
|
|
|
1437
2083
|
};
|
|
1438
2084
|
return class UpdateFirestore extends MixinBase {
|
|
1439
2085
|
update(data) {
|
|
2086
|
+
var _a, _b, _c, _d;
|
|
1440
2087
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1441
2088
|
const model = new this.model();
|
|
1442
2089
|
const keyField = model.identifiersFields.shift();
|
|
1443
2090
|
const docRef = doc(this.collection(this.buildCollectionPathForUpdate(data)), getValueFromParams(data, keyField).toString());
|
|
1444
|
-
|
|
1445
|
-
const
|
|
1446
|
-
|
|
2091
|
+
const plainFromData = this.model.toInstance(this.paramsToPlain(data));
|
|
2092
|
+
const intercepted = yield ((_b = (_a = this.interceptors) === null || _a === void 0 ? void 0 : _a.request) === null || _b === void 0 ? void 0 : _b.call(_a, { instance: plainFromData }));
|
|
2093
|
+
const builded = (intercepted === null || intercepted === void 0 ? void 0 : intercepted.instance) || plainFromData;
|
|
2094
|
+
yield setDoc(docRef, builded.toPlain(), { merge: true });
|
|
2095
|
+
const docData = yield getDoc(docRef).then((doc) => doc.data());
|
|
2096
|
+
return ((_d = (_c = this.interceptors) === null || _c === void 0 ? void 0 : _c.response) === null || _d === void 0 ? void 0 : _d.call(_c, docData, intercepted)) || docData;
|
|
1447
2097
|
});
|
|
1448
2098
|
}
|
|
1449
2099
|
buildCollectionPathForUpdate(identifiers) {
|
|
@@ -1463,8 +2113,13 @@ const withUpdateFirestore = (MixinBase) => {
|
|
|
1463
2113
|
const withDeleteFirestore = (MixinBase) => {
|
|
1464
2114
|
return class DeleteFirestore extends MixinBase {
|
|
1465
2115
|
delete(identifiers) {
|
|
2116
|
+
var _a, _b, _c, _d;
|
|
1466
2117
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1467
|
-
|
|
2118
|
+
const instance = this.model.toInstance(this.model.identifiersFields.reduce((acc, field) => (Object.assign(Object.assign({}, acc), { [field]: identifiers[field] })), {}));
|
|
2119
|
+
const intercepted = yield ((_b = (_a = this.interceptors) === null || _a === void 0 ? void 0 : _a.request) === null || _b === void 0 ? void 0 : _b.call(_a, { instance }));
|
|
2120
|
+
const builded = (intercepted === null || intercepted === void 0 ? void 0 : intercepted.instance) || instance;
|
|
2121
|
+
yield deleteDoc(doc(this.collection(this.buildCollectionPathForRemove(identifiers)), Object.values(builded.identifier).shift().toString()));
|
|
2122
|
+
yield ((_d = (_c = this.interceptors) === null || _c === void 0 ? void 0 : _c.response) === null || _d === void 0 ? void 0 : _d.call(_c, instance, intercepted));
|
|
1468
2123
|
});
|
|
1469
2124
|
}
|
|
1470
2125
|
buildCollectionPathForRemove(identifiers) {
|
|
@@ -1477,8 +2132,10 @@ const withDeleteFirestore = (MixinBase) => {
|
|
|
1477
2132
|
|
|
1478
2133
|
const withSubCollection = (MixinBase, ParentModel) => {
|
|
1479
2134
|
return class SubCollectionMix extends MixinBase {
|
|
1480
|
-
constructor(...
|
|
1481
|
-
|
|
2135
|
+
constructor(...params) {
|
|
2136
|
+
const options = params[0];
|
|
2137
|
+
super(...params);
|
|
2138
|
+
this.parentIdField = options.parentIdField;
|
|
1482
2139
|
}
|
|
1483
2140
|
collection(path) {
|
|
1484
2141
|
return super.collection(path);
|
|
@@ -1492,73 +2149,87 @@ const withCrudFirestore = (MixinBase) => {
|
|
|
1492
2149
|
};
|
|
1493
2150
|
|
|
1494
2151
|
class LeadFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1495
|
-
constructor(firestore) {
|
|
1496
|
-
super(
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
2152
|
+
constructor({ firestore, interceptors }) {
|
|
2153
|
+
super({
|
|
2154
|
+
firestore,
|
|
2155
|
+
collectionName: 'leads',
|
|
2156
|
+
model: Lead,
|
|
2157
|
+
interceptors,
|
|
2158
|
+
});
|
|
1500
2159
|
}
|
|
1501
2160
|
}
|
|
1502
2161
|
|
|
1503
2162
|
class SubscriptionEditionFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), Subscription) {
|
|
1504
|
-
constructor(firestore, parentRepository) {
|
|
1505
|
-
super(
|
|
1506
|
-
|
|
2163
|
+
constructor({ firestore, interceptors }, parentRepository) {
|
|
2164
|
+
super({
|
|
2165
|
+
firestore,
|
|
2166
|
+
collectionName: 'editions',
|
|
2167
|
+
parentIdField: 'subscriptionId',
|
|
2168
|
+
model: Edition,
|
|
2169
|
+
interceptors,
|
|
2170
|
+
});
|
|
1507
2171
|
this.parentRepository = parentRepository;
|
|
1508
|
-
this.collectionName = 'editions';
|
|
1509
|
-
this.parentIdField = 'subscriptionId';
|
|
1510
|
-
this.model = Edition;
|
|
1511
2172
|
}
|
|
1512
2173
|
}
|
|
1513
2174
|
|
|
1514
2175
|
class SubscriptionFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1515
|
-
constructor(firestore) {
|
|
1516
|
-
super(
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
2176
|
+
constructor({ firestore, interceptors, }) {
|
|
2177
|
+
super({
|
|
2178
|
+
firestore,
|
|
2179
|
+
collectionName: 'subscription',
|
|
2180
|
+
model: Subscription,
|
|
2181
|
+
interceptors,
|
|
2182
|
+
});
|
|
1520
2183
|
}
|
|
1521
2184
|
}
|
|
1522
2185
|
|
|
1523
2186
|
class SubscriptionPaymentFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), Subscription) {
|
|
1524
|
-
constructor(firestore, parentRepository) {
|
|
1525
|
-
super(
|
|
1526
|
-
|
|
2187
|
+
constructor({ firestore, interceptors }, parentRepository) {
|
|
2188
|
+
super({
|
|
2189
|
+
firestore,
|
|
2190
|
+
collectionName: 'payments',
|
|
2191
|
+
parentIdField: 'subscriptionId',
|
|
2192
|
+
model: SubscriptionPayment,
|
|
2193
|
+
interceptors,
|
|
2194
|
+
});
|
|
1527
2195
|
this.parentRepository = parentRepository;
|
|
1528
|
-
this.collectionName = 'payments';
|
|
1529
|
-
this.parentIdField = 'subscriptionId';
|
|
1530
|
-
this.model = SubscriptionPayment;
|
|
1531
2196
|
}
|
|
1532
2197
|
}
|
|
1533
2198
|
|
|
1534
2199
|
class UserAddressFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), User) {
|
|
1535
|
-
constructor(firestore, parentRepository) {
|
|
1536
|
-
super(
|
|
1537
|
-
|
|
2200
|
+
constructor({ firestore, interceptors }, parentRepository) {
|
|
2201
|
+
super({
|
|
2202
|
+
firestore,
|
|
2203
|
+
collectionName: 'address',
|
|
2204
|
+
parentIdField: 'userId',
|
|
2205
|
+
model: UserAddress,
|
|
2206
|
+
interceptors,
|
|
2207
|
+
});
|
|
1538
2208
|
this.parentRepository = parentRepository;
|
|
1539
|
-
this.collectionName = 'address';
|
|
1540
|
-
this.parentIdField = 'userId';
|
|
1541
|
-
this.model = UserAddress;
|
|
1542
2209
|
}
|
|
1543
2210
|
}
|
|
1544
2211
|
|
|
1545
2212
|
class UserBeautyProfileFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), User) {
|
|
1546
|
-
constructor(firestore, parentRepository) {
|
|
1547
|
-
super(
|
|
1548
|
-
|
|
2213
|
+
constructor({ firestore, interceptors }, parentRepository) {
|
|
2214
|
+
super({
|
|
2215
|
+
firestore,
|
|
2216
|
+
collectionName: 'CX',
|
|
2217
|
+
parentIdField: 'userId',
|
|
2218
|
+
model: BeautyProfile,
|
|
2219
|
+
interceptors,
|
|
2220
|
+
});
|
|
1549
2221
|
this.parentRepository = parentRepository;
|
|
1550
|
-
this.collectionName = 'CX';
|
|
1551
|
-
this.parentIdField = 'userId';
|
|
1552
|
-
this.model = BeautyProfile;
|
|
1553
2222
|
}
|
|
1554
2223
|
}
|
|
1555
2224
|
|
|
1556
2225
|
class UserFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1557
|
-
constructor(firestore) {
|
|
1558
|
-
super(
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
2226
|
+
constructor({ firestore, interceptors }) {
|
|
2227
|
+
super({
|
|
2228
|
+
firestore,
|
|
2229
|
+
collectionName: 'users',
|
|
2230
|
+
model: User,
|
|
2231
|
+
interceptors,
|
|
2232
|
+
});
|
|
1562
2233
|
}
|
|
1563
2234
|
get(identifiers) {
|
|
1564
2235
|
const _super = Object.create(null, {
|
|
@@ -1609,22 +2280,26 @@ class UserFirestoreRepository extends withCrudFirestore(withHelpers(withFirestor
|
|
|
1609
2280
|
}
|
|
1610
2281
|
|
|
1611
2282
|
class UserPaymentMethodFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), User) {
|
|
1612
|
-
constructor(firestore, parentRepository) {
|
|
1613
|
-
super(
|
|
1614
|
-
|
|
2283
|
+
constructor({ firestore, interceptors }, parentRepository) {
|
|
2284
|
+
super({
|
|
2285
|
+
firestore,
|
|
2286
|
+
collectionName: 'payment_method',
|
|
2287
|
+
parentIdField: 'userId',
|
|
2288
|
+
model: UserPaymentMethod,
|
|
2289
|
+
interceptors,
|
|
2290
|
+
});
|
|
1615
2291
|
this.parentRepository = parentRepository;
|
|
1616
|
-
this.collectionName = 'payment_method';
|
|
1617
|
-
this.parentIdField = 'userId';
|
|
1618
|
-
this.model = UserPaymentMethod;
|
|
1619
2292
|
}
|
|
1620
2293
|
}
|
|
1621
2294
|
|
|
1622
2295
|
class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1623
|
-
constructor(firestore) {
|
|
1624
|
-
super(
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
2296
|
+
constructor({ firestore, interceptors }) {
|
|
2297
|
+
super({
|
|
2298
|
+
firestore,
|
|
2299
|
+
collectionName: 'categories',
|
|
2300
|
+
model: Category,
|
|
2301
|
+
interceptors,
|
|
2302
|
+
});
|
|
1628
2303
|
}
|
|
1629
2304
|
getCategoryBySlug(slug, shop) {
|
|
1630
2305
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -1636,7 +2311,7 @@ class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFire
|
|
|
1636
2311
|
return categoryDocs.docs[0].data();
|
|
1637
2312
|
});
|
|
1638
2313
|
}
|
|
1639
|
-
getCategoriesForHome(categoryIds, limit = 4) {
|
|
2314
|
+
getCategoriesForHome(categoryIds, limit = 4, gender) {
|
|
1640
2315
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1641
2316
|
const categorySnap = yield getDocs(query(this.collection(this.collectionName), where('id', 'in', categoryIds.filter(Boolean)), where('published', '==', true)));
|
|
1642
2317
|
if (categorySnap.empty)
|
|
@@ -1645,7 +2320,7 @@ class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFire
|
|
|
1645
2320
|
const homeSections = yield Promise.all(categories.map((category) => __awaiter(this, void 0, void 0, function* () {
|
|
1646
2321
|
return ({
|
|
1647
2322
|
category,
|
|
1648
|
-
products: yield this.mountCategory(category, { limit, hasStock: true }),
|
|
2323
|
+
products: yield this.mountCategory(category, { limit, hasStock: true, gender }),
|
|
1649
2324
|
});
|
|
1650
2325
|
})));
|
|
1651
2326
|
return homeSections;
|
|
@@ -1664,6 +2339,8 @@ class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFire
|
|
|
1664
2339
|
wheres.push(where('published', '==', true), where('id', 'in', productIds));
|
|
1665
2340
|
if (options === null || options === void 0 ? void 0 : options.hasStock)
|
|
1666
2341
|
wheres.push(where('stock.quantity', '>', 0));
|
|
2342
|
+
if (options === null || options === void 0 ? void 0 : options.gender)
|
|
2343
|
+
wheres.push(where('tags', 'array-contains', options === null || options === void 0 ? void 0 : options.gender));
|
|
1667
2344
|
if (options === null || options === void 0 ? void 0 : options.limit)
|
|
1668
2345
|
wheres.push(limit(options === null || options === void 0 ? void 0 : options.limit));
|
|
1669
2346
|
const productSnap = yield getDocs(query(this.collection('productsErpVitrine'), ...wheres));
|
|
@@ -1674,15 +2351,26 @@ class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFire
|
|
|
1674
2351
|
return is(products);
|
|
1675
2352
|
});
|
|
1676
2353
|
}
|
|
2354
|
+
getCategoryByShop(shop) {
|
|
2355
|
+
return;
|
|
2356
|
+
}
|
|
2357
|
+
getChildren(parentId) {
|
|
2358
|
+
return;
|
|
2359
|
+
}
|
|
2360
|
+
isChild(id, parentId) {
|
|
2361
|
+
return;
|
|
2362
|
+
}
|
|
1677
2363
|
}
|
|
1678
2364
|
|
|
1679
2365
|
class ProductFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1680
|
-
constructor(firestore) {
|
|
1681
|
-
super(
|
|
1682
|
-
|
|
2366
|
+
constructor({ firestore, interceptors }) {
|
|
2367
|
+
super({
|
|
2368
|
+
firestore,
|
|
2369
|
+
collectionName: 'productsErpVitrine',
|
|
2370
|
+
model: Product,
|
|
2371
|
+
interceptors,
|
|
2372
|
+
});
|
|
1683
2373
|
this.reviews = {};
|
|
1684
|
-
this.collectionName = 'productsErpVitrine';
|
|
1685
|
-
this.model = Product;
|
|
1686
2374
|
}
|
|
1687
2375
|
getBySlug(slug) {
|
|
1688
2376
|
var _a;
|
|
@@ -1723,43 +2411,101 @@ class ProductFirestoreRepository extends withCrudFirestore(withHelpers(withFires
|
|
|
1723
2411
|
return this.reviews[status];
|
|
1724
2412
|
});
|
|
1725
2413
|
}
|
|
2414
|
+
cleanShoppingCountFromIds() {
|
|
2415
|
+
return;
|
|
2416
|
+
}
|
|
2417
|
+
findCatalog(params) {
|
|
2418
|
+
return this.find(params);
|
|
2419
|
+
}
|
|
1726
2420
|
}
|
|
1727
2421
|
|
|
1728
2422
|
class ProductVariantFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), Product) {
|
|
1729
|
-
constructor(firestore, parentRepository) {
|
|
1730
|
-
super(
|
|
1731
|
-
|
|
2423
|
+
constructor({ firestore, interceptors }, parentRepository) {
|
|
2424
|
+
super({
|
|
2425
|
+
firestore,
|
|
2426
|
+
collectionName: 'variants',
|
|
2427
|
+
parentIdField: 'productId',
|
|
2428
|
+
model: Variant,
|
|
2429
|
+
interceptors,
|
|
2430
|
+
});
|
|
1732
2431
|
this.parentRepository = parentRepository;
|
|
1733
|
-
this.collectionName = 'variants';
|
|
1734
|
-
this.parentIdField = 'productId';
|
|
1735
|
-
this.model = Variant;
|
|
1736
2432
|
}
|
|
1737
2433
|
}
|
|
1738
2434
|
|
|
1739
2435
|
class SubscriptionProductFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1740
|
-
constructor(firestore) {
|
|
1741
|
-
super(
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
2436
|
+
constructor({ firestore, interceptors }) {
|
|
2437
|
+
super({
|
|
2438
|
+
firestore,
|
|
2439
|
+
collectionName: 'subscriptionProducts',
|
|
2440
|
+
model: Product,
|
|
2441
|
+
interceptors,
|
|
2442
|
+
});
|
|
2443
|
+
}
|
|
2444
|
+
}
|
|
2445
|
+
|
|
2446
|
+
class Buy2WinFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
2447
|
+
constructor({ firestore, interceptors }) {
|
|
2448
|
+
super({
|
|
2449
|
+
firestore,
|
|
2450
|
+
collectionName: 'buy2win',
|
|
2451
|
+
model: Buy2Win,
|
|
2452
|
+
interceptors,
|
|
2453
|
+
});
|
|
2454
|
+
}
|
|
2455
|
+
}
|
|
2456
|
+
|
|
2457
|
+
class CampaignDashboardFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
2458
|
+
constructor({ firestore, interceptors, }) {
|
|
2459
|
+
super({
|
|
2460
|
+
firestore,
|
|
2461
|
+
collectionName: 'dashboardCampaignsAuto',
|
|
2462
|
+
model: CampaignDashboard,
|
|
2463
|
+
interceptors,
|
|
2464
|
+
});
|
|
2465
|
+
}
|
|
2466
|
+
}
|
|
2467
|
+
|
|
2468
|
+
class CampaignHashtagFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
2469
|
+
constructor({ firestore, interceptors, }) {
|
|
2470
|
+
super({
|
|
2471
|
+
firestore,
|
|
2472
|
+
collectionName: 'hashtagCampaignsAuto',
|
|
2473
|
+
model: CampaignHashtag,
|
|
2474
|
+
interceptors,
|
|
2475
|
+
});
|
|
1745
2476
|
}
|
|
1746
2477
|
}
|
|
1747
2478
|
|
|
1748
2479
|
class CheckoutFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1749
|
-
constructor(firestore) {
|
|
1750
|
-
super(
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
2480
|
+
constructor({ firestore, interceptors }) {
|
|
2481
|
+
super({
|
|
2482
|
+
firestore,
|
|
2483
|
+
collectionName: 'checkouts',
|
|
2484
|
+
model: Checkout,
|
|
2485
|
+
interceptors,
|
|
2486
|
+
});
|
|
2487
|
+
}
|
|
2488
|
+
}
|
|
2489
|
+
|
|
2490
|
+
class CheckoutSubscriptionFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
2491
|
+
constructor({ firestore, interceptors, }) {
|
|
2492
|
+
super({
|
|
2493
|
+
firestore,
|
|
2494
|
+
collectionName: 'checkoutsSubscription',
|
|
2495
|
+
model: CheckoutSubscription,
|
|
2496
|
+
interceptors,
|
|
2497
|
+
});
|
|
1754
2498
|
}
|
|
1755
2499
|
}
|
|
1756
2500
|
|
|
1757
2501
|
class CouponFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1758
|
-
constructor(firestore) {
|
|
1759
|
-
super(
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
2502
|
+
constructor({ firestore, interceptors }) {
|
|
2503
|
+
super({
|
|
2504
|
+
firestore,
|
|
2505
|
+
collectionName: 'coupons',
|
|
2506
|
+
model: Coupon,
|
|
2507
|
+
interceptors,
|
|
2508
|
+
});
|
|
1763
2509
|
}
|
|
1764
2510
|
buildModelInstance() {
|
|
1765
2511
|
const { fromFirestore, toFirestore } = super.buildModelInstance();
|
|
@@ -1781,9 +2527,16 @@ class CouponFirestoreRepository extends withCrudFirestore(withHelpers(withFirest
|
|
|
1781
2527
|
}
|
|
1782
2528
|
|
|
1783
2529
|
class OrderFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1784
|
-
constructor(firestore) {
|
|
1785
|
-
super(
|
|
1786
|
-
|
|
2530
|
+
constructor({ firestore, interceptors }) {
|
|
2531
|
+
super({
|
|
2532
|
+
firestore,
|
|
2533
|
+
collectionName: 'orders',
|
|
2534
|
+
model: Order,
|
|
2535
|
+
interceptors,
|
|
2536
|
+
fields: {
|
|
2537
|
+
status: FirestoreFieldType.String,
|
|
2538
|
+
},
|
|
2539
|
+
});
|
|
1787
2540
|
this.orderFromFirestore = (order) => {
|
|
1788
2541
|
var _a;
|
|
1789
2542
|
if (!!((_a = order === null || order === void 0 ? void 0 : order.lineItems) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
@@ -1797,11 +2550,6 @@ class OrderFirestoreRepository extends withCrudFirestore(withHelpers(withFiresto
|
|
|
1797
2550
|
}
|
|
1798
2551
|
return order;
|
|
1799
2552
|
};
|
|
1800
|
-
this.collectionName = 'orders';
|
|
1801
|
-
this.model = Order;
|
|
1802
|
-
this.fields = {
|
|
1803
|
-
status: FirestoreFieldType.String,
|
|
1804
|
-
};
|
|
1805
2553
|
}
|
|
1806
2554
|
buildModelInstance() {
|
|
1807
2555
|
const { fromFirestore, toFirestore } = super.buildModelInstance();
|
|
@@ -1815,86 +2563,62 @@ class OrderFirestoreRepository extends withCrudFirestore(withHelpers(withFiresto
|
|
|
1815
2563
|
}
|
|
1816
2564
|
}
|
|
1817
2565
|
|
|
1818
|
-
class
|
|
1819
|
-
constructor(firestore) {
|
|
1820
|
-
super(
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
2566
|
+
class LegacyOrderFirestoreRepository extends OrderFirestoreRepository {
|
|
2567
|
+
constructor({ firestore, interceptors }) {
|
|
2568
|
+
super({
|
|
2569
|
+
firestore,
|
|
2570
|
+
interceptors,
|
|
2571
|
+
});
|
|
2572
|
+
this.collectionName = 'legacyOrders';
|
|
1824
2573
|
}
|
|
1825
2574
|
}
|
|
1826
2575
|
|
|
1827
|
-
class
|
|
1828
|
-
constructor(firestore) {
|
|
1829
|
-
super(
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
2576
|
+
class PaymentFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
2577
|
+
constructor({ firestore, interceptors }) {
|
|
2578
|
+
super({
|
|
2579
|
+
firestore,
|
|
2580
|
+
collectionName: 'payments',
|
|
2581
|
+
model: Payment,
|
|
2582
|
+
interceptors,
|
|
2583
|
+
});
|
|
1833
2584
|
}
|
|
1834
2585
|
}
|
|
1835
2586
|
|
|
1836
2587
|
class SubscriptionPlanFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1837
|
-
constructor(firestore) {
|
|
1838
|
-
super(
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
}
|
|
1844
|
-
|
|
1845
|
-
class Buy2WinFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1846
|
-
constructor(firestore) {
|
|
1847
|
-
super();
|
|
1848
|
-
this.firestore = firestore;
|
|
1849
|
-
this.collectionName = 'buy2win';
|
|
1850
|
-
this.model = Buy2Win;
|
|
1851
|
-
}
|
|
1852
|
-
}
|
|
1853
|
-
|
|
1854
|
-
class LegacyOrderFirestoreRepository extends OrderFirestoreRepository {
|
|
1855
|
-
constructor(firestore) {
|
|
1856
|
-
super(firestore);
|
|
1857
|
-
this.firestore = firestore;
|
|
1858
|
-
this.collectionName = 'legacyOrders';
|
|
2588
|
+
constructor({ firestore, interceptors, }) {
|
|
2589
|
+
super({
|
|
2590
|
+
firestore,
|
|
2591
|
+
collectionName: 'subscriptionPlans',
|
|
2592
|
+
model: SubscriptionPlan,
|
|
2593
|
+
interceptors,
|
|
2594
|
+
});
|
|
1859
2595
|
}
|
|
1860
2596
|
}
|
|
1861
2597
|
|
|
1862
2598
|
class HomeFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1863
|
-
constructor(firestore) {
|
|
1864
|
-
super(
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
home.data.data.discoverProducts = home.data.data.discoverProducts.map(this.homeCategoryGroupToPlain);
|
|
1870
|
-
home.data.data.featuredProducts = home.data.data.featuredProducts.map(this.homeCategoryGroupToPlain);
|
|
1871
|
-
home.data.data.verticalProducts = home.data.data.verticalProducts.map(this.homeCategoryGroupToPlain);
|
|
1872
|
-
}
|
|
1873
|
-
return home;
|
|
1874
|
-
};
|
|
1875
|
-
this.homeCategoryGroupToPlain = (homeCategoryGroup) => ({
|
|
1876
|
-
category: homeCategoryGroup.category.toPlain(),
|
|
1877
|
-
products: homeCategoryGroup.products.map((product) => product.toPlain()),
|
|
2599
|
+
constructor({ firestore, interceptors }) {
|
|
2600
|
+
super({
|
|
2601
|
+
firestore,
|
|
2602
|
+
collectionName: 'dms',
|
|
2603
|
+
model: Home,
|
|
2604
|
+
interceptors,
|
|
1878
2605
|
});
|
|
1879
|
-
this.
|
|
2606
|
+
this.homeCategoryGroupToPlain = (homeCategoryGroup) => {
|
|
2607
|
+
var _a, _b, _c;
|
|
2608
|
+
return ({
|
|
2609
|
+
category: ((_a = homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category) === null || _a === void 0 ? void 0 : _a.toPlain)
|
|
2610
|
+
? (_b = homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category) === null || _b === void 0 ? void 0 : _b.toPlain()
|
|
2611
|
+
: homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category,
|
|
2612
|
+
products: ((_c = homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.products) === null || _c === void 0 ? void 0 : _c.map((product) => ((product === null || product === void 0 ? void 0 : product.toPlain) ? product === null || product === void 0 ? void 0 : product.toPlain() : product)).filter(Boolean)) || [],
|
|
2613
|
+
});
|
|
2614
|
+
};
|
|
2615
|
+
this.plainToHomeCategoryGroup = (homeCategoryGroup) => {
|
|
1880
2616
|
var _a;
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
home.data.createdAt =
|
|
1886
|
-
home.data.createdAt instanceof Timestamp ? home.data.createdAt.toDate() : home.data.createdAt;
|
|
1887
|
-
home.data.expiresAt =
|
|
1888
|
-
home.data.expiresAt instanceof Timestamp ? home.data.expiresAt.toDate() : home.data.expiresAt;
|
|
1889
|
-
}
|
|
1890
|
-
return home;
|
|
2617
|
+
return ({
|
|
2618
|
+
category: Category.toInstance(homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category),
|
|
2619
|
+
products: (_a = homeCategoryGroup.products) === null || _a === void 0 ? void 0 : _a.map((product) => Product.toInstance(product)),
|
|
2620
|
+
});
|
|
1891
2621
|
};
|
|
1892
|
-
this.plainToHomeCategoryGroup = (homeCategoryGroup) => ({
|
|
1893
|
-
category: Category.toInstance(homeCategoryGroup.category),
|
|
1894
|
-
products: homeCategoryGroup.products.map((product) => Product.toInstance(product)),
|
|
1895
|
-
});
|
|
1896
|
-
this.collectionName = 'dms';
|
|
1897
|
-
this.model = Home;
|
|
1898
2622
|
}
|
|
1899
2623
|
buildModelInstance() {
|
|
1900
2624
|
const { fromFirestore, toFirestore } = super.buildModelInstance();
|
|
@@ -1909,14 +2633,49 @@ class HomeFirestoreRepository extends withCrudFirestore(withHelpers(withFirestor
|
|
|
1909
2633
|
},
|
|
1910
2634
|
};
|
|
1911
2635
|
}
|
|
2636
|
+
homeToFirestore(home) {
|
|
2637
|
+
var _a, _b, _c, _d;
|
|
2638
|
+
if ((_a = home.data) === null || _a === void 0 ? void 0 : _a.data) {
|
|
2639
|
+
home.data.data.discoverProducts = ((_b = home.data.data.discoverProducts) === null || _b === void 0 ? void 0 : _b.map(this.homeCategoryGroupToPlain)) || [];
|
|
2640
|
+
home.data.data.featuredProducts = ((_c = home.data.data.featuredProducts) === null || _c === void 0 ? void 0 : _c.map(this.homeCategoryGroupToPlain)) || [];
|
|
2641
|
+
home.data.data.verticalProducts = ((_d = home.data.data.verticalProducts) === null || _d === void 0 ? void 0 : _d.map(this.homeCategoryGroupToPlain)) || [];
|
|
2642
|
+
}
|
|
2643
|
+
return home;
|
|
2644
|
+
}
|
|
2645
|
+
homeFromFirestore(home) {
|
|
2646
|
+
var _a;
|
|
2647
|
+
if ((_a = home.data) === null || _a === void 0 ? void 0 : _a.data) {
|
|
2648
|
+
home.data.data.discoverProducts = home.data.data.discoverProducts.map(this.plainToHomeCategoryGroup);
|
|
2649
|
+
home.data.data.featuredProducts = home.data.data.featuredProducts.map(this.plainToHomeCategoryGroup);
|
|
2650
|
+
home.data.data.verticalProducts = home.data.data.verticalProducts.map(this.plainToHomeCategoryGroup);
|
|
2651
|
+
home.data.createdAt =
|
|
2652
|
+
home.data.createdAt instanceof Timestamp ? home.data.createdAt.toDate() : home.data.createdAt;
|
|
2653
|
+
home.data.expiresAt =
|
|
2654
|
+
home.data.expiresAt instanceof Timestamp ? home.data.expiresAt.toDate() : home.data.expiresAt;
|
|
2655
|
+
}
|
|
2656
|
+
return home;
|
|
2657
|
+
}
|
|
1912
2658
|
}
|
|
1913
2659
|
|
|
1914
2660
|
class ShopMenuFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1915
|
-
constructor(firestore) {
|
|
1916
|
-
super(
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
2661
|
+
constructor({ firestore, interceptors }) {
|
|
2662
|
+
super({
|
|
2663
|
+
firestore,
|
|
2664
|
+
collectionName: 'shopMenus',
|
|
2665
|
+
model: ShopMenu,
|
|
2666
|
+
interceptors,
|
|
2667
|
+
});
|
|
2668
|
+
}
|
|
2669
|
+
}
|
|
2670
|
+
|
|
2671
|
+
class ShopSettingsFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
2672
|
+
constructor({ firestore, interceptors, }) {
|
|
2673
|
+
super({
|
|
2674
|
+
firestore,
|
|
2675
|
+
collectionName: 'shopSettings',
|
|
2676
|
+
model: ShopSettings,
|
|
2677
|
+
interceptors,
|
|
2678
|
+
});
|
|
1920
2679
|
}
|
|
1921
2680
|
}
|
|
1922
2681
|
|
|
@@ -2006,7 +2765,7 @@ class AttributeOptionHelper {
|
|
|
2006
2765
|
AttributeOptionHelper.FindByAttribute = (attributeName, fields) => {
|
|
2007
2766
|
var _a;
|
|
2008
2767
|
if (fields.includes(attributeName))
|
|
2009
|
-
return { columnName: attributeName.toString(), attributeName };
|
|
2768
|
+
return { columnName: attributeName.toString(), attributeName, to: (value) => value, from: (value) => value };
|
|
2010
2769
|
const field = fields.find((columnOption) => isObject(columnOption) && Object.keys(columnOption).includes(attributeName.toString()));
|
|
2011
2770
|
const fieldOption = (_a = is(field)) === null || _a === void 0 ? void 0 : _a[attributeName];
|
|
2012
2771
|
if (isNil(fieldOption))
|
|
@@ -2015,7 +2774,7 @@ AttributeOptionHelper.FindByAttribute = (attributeName, fields) => {
|
|
|
2015
2774
|
return { columnName: attributeName.toString(), attributeName, fields: fieldOption };
|
|
2016
2775
|
return Object.assign({ attributeName, columnName: attributeName.toString() }, fieldOption);
|
|
2017
2776
|
};
|
|
2018
|
-
AttributeOptionHelper.CheckIsColumnOption = (fieldValue) => !!fieldValue.columnName;
|
|
2777
|
+
AttributeOptionHelper.CheckIsColumnOption = (fieldValue) => !!(fieldValue === null || fieldValue === void 0 ? void 0 : fieldValue.columnName);
|
|
2019
2778
|
AttributeOptionHelper.FindColumnOptionFromList = (columnName, fields) => {
|
|
2020
2779
|
if (fields.includes(columnName))
|
|
2021
2780
|
return { columnName, attributeName: columnName };
|
|
@@ -2095,22 +2854,23 @@ BindFilterQueryHelper.MakeGraphQLWhere = (filter, fields) => Object.keys(filter)
|
|
|
2095
2854
|
}, {});
|
|
2096
2855
|
BindFilterQueryHelper.BuildWhereSentence = (field, options, fields) => {
|
|
2097
2856
|
const fieldSentenceOptions = AttributeOptionHelper.FindByAttribute(field, fields);
|
|
2098
|
-
|
|
2857
|
+
const isNestedField = !Array.isArray(options) &&
|
|
2099
2858
|
isObject(options) &&
|
|
2100
2859
|
isNil(options === null || options === void 0 ? void 0 : options.operator) &&
|
|
2101
2860
|
isNil(options === null || options === void 0 ? void 0 : options.value) &&
|
|
2102
|
-
isNil(fieldSentenceOptions === null || fieldSentenceOptions === void 0 ? void 0 : fieldSentenceOptions.to)
|
|
2861
|
+
isNil(fieldSentenceOptions === null || fieldSentenceOptions === void 0 ? void 0 : fieldSentenceOptions.to);
|
|
2862
|
+
if (isNestedField)
|
|
2103
2863
|
return Object.keys(options).reduce((variables, key) => {
|
|
2104
2864
|
const fieldOptions = AttributeOptionHelper.FindByAttribute(key, (fieldSentenceOptions === null || fieldSentenceOptions === void 0 ? void 0 : fieldSentenceOptions.fields) || fields);
|
|
2105
2865
|
const columnName = fieldOptions.columnName;
|
|
2106
2866
|
const columnFields = fieldOptions.fields;
|
|
2107
|
-
return Object.assign(Object.assign({}, variables), { [columnName]: BindFilterQueryHelper.BuildWhereSentence(key, is(is(options)[key]), columnFields ||
|
|
2867
|
+
return Object.assign(Object.assign({}, variables), { [columnName]: BindFilterQueryHelper.BuildWhereSentence(key, is(is(options)[key]), (fieldSentenceOptions === null || fieldSentenceOptions === void 0 ? void 0 : fieldSentenceOptions.fields) || columnFields || fields) });
|
|
2108
2868
|
}, {});
|
|
2109
2869
|
if (!Array.isArray(options) && !isNil(fieldSentenceOptions.fields))
|
|
2110
2870
|
return {
|
|
2111
2871
|
[fieldSentenceOptions.fields[0]]: BindFilterQueryHelper.BuildOperatorSentence(options, fieldSentenceOptions),
|
|
2112
2872
|
};
|
|
2113
|
-
if (isObject(options) && !FilterOptionHelper.CheckIfIsFilterOption(options))
|
|
2873
|
+
if (!Array.isArray(options) && isObject(options) && !FilterOptionHelper.CheckIfIsFilterOption(options))
|
|
2114
2874
|
options = Object.values(options)[0];
|
|
2115
2875
|
return Array.isArray(options)
|
|
2116
2876
|
? options.reduce((whereSentence, option) => (Object.assign(Object.assign({}, whereSentence), BindFilterQueryHelper.BuildOperatorSentence(option, fieldSentenceOptions))), {})
|
|
@@ -2142,33 +2902,18 @@ GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields = (fields) => {
|
|
|
2142
2902
|
if (field === 'affected_rows')
|
|
2143
2903
|
return field;
|
|
2144
2904
|
const fieldName = Object.keys(field).shift();
|
|
2145
|
-
const fieldValue = field[fieldName];
|
|
2905
|
+
const fieldValue = is(field[fieldName]);
|
|
2146
2906
|
if (Array.isArray(fieldValue))
|
|
2147
2907
|
return { [fieldName]: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(fieldValue) };
|
|
2148
2908
|
if (!AttributeOptionHelper.CheckIsColumnOption(fieldValue))
|
|
2149
|
-
return
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
[fieldValue.columnName || fieldName]: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(fieldValue.fields),
|
|
2154
|
-
}
|
|
2155
|
-
: {
|
|
2156
|
-
operation: fieldValue.columnName || fieldName,
|
|
2157
|
-
fields: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(fieldValue.fields),
|
|
2158
|
-
variables: {
|
|
2159
|
-
[`${fieldValue.columnName}_where`]: {
|
|
2160
|
-
name: 'where',
|
|
2161
|
-
type: fieldValue.filters.filterType,
|
|
2162
|
-
value: BindFilterQueryHelper.MakeGraphQLWhere(fieldValue.filters.filters, fieldValue.fields),
|
|
2163
|
-
required: true,
|
|
2164
|
-
},
|
|
2165
|
-
},
|
|
2166
|
-
};
|
|
2909
|
+
return;
|
|
2910
|
+
const isNestedField = !!fieldValue.fields;
|
|
2911
|
+
if (isNestedField)
|
|
2912
|
+
return GraphQLFieldHelper.ConvertNestedFieldsToGraphQLFields(fieldName, fieldValue);
|
|
2167
2913
|
return fieldValue.columnName;
|
|
2168
2914
|
}).filter((field) => !!field);
|
|
2169
2915
|
};
|
|
2170
2916
|
GraphQLFieldHelper.ConvertFieldValueFrom = (data, fields) => Object.keys(data).reduce((result, columnName) => {
|
|
2171
|
-
var _a;
|
|
2172
2917
|
const { attributeName, fields: attributeFields, from, } = AttributeOptionHelper.FindColumnOptionFromList(columnName, fields);
|
|
2173
2918
|
if (!!attributeFields && Array.isArray(attributeFields)) {
|
|
2174
2919
|
if (Array.isArray(data[columnName]))
|
|
@@ -2182,7 +2927,7 @@ GraphQLFieldHelper.ConvertFieldValueFrom = (data, fields) => Object.keys(data).r
|
|
|
2182
2927
|
}
|
|
2183
2928
|
if (!!from)
|
|
2184
2929
|
return Object.assign(Object.assign({}, result), { [attributeName]: from(data[columnName], data) });
|
|
2185
|
-
return Object.assign(Object.assign({}, result), { [attributeName]:
|
|
2930
|
+
return Object.assign(Object.assign({}, result), { [attributeName]: isString(data[columnName]) ? parseDateTime(data[columnName].toString()) : data[columnName] });
|
|
2186
2931
|
}, {});
|
|
2187
2932
|
GraphQLFieldHelper.ConvertFieldValueTo = (instance, fields, update = false) => {
|
|
2188
2933
|
var _a;
|
|
@@ -2198,7 +2943,8 @@ GraphQLFieldHelper.ConvertFieldValueTo = (instance, fields, update = false) => {
|
|
|
2198
2943
|
!Object.keys(foreignKeyColumn).filter((key) => { var _a; return !((_a = is(data[attributeName])) === null || _a === void 0 ? void 0 : _a[key]); }).length)
|
|
2199
2944
|
return Object.keys(foreignKeyColumn).reduce((object, current) => {
|
|
2200
2945
|
var _a;
|
|
2201
|
-
|
|
2946
|
+
const { columnName: foreignColumnName } = AttributeOptionHelper.FindByAttribute(foreignKeyColumn[current], fields);
|
|
2947
|
+
return Object.assign(Object.assign({}, object), { [foreignColumnName]: (_a = data[attributeName]) === null || _a === void 0 ? void 0 : _a[current] });
|
|
2202
2948
|
}, Object.assign({}, result));
|
|
2203
2949
|
if (update &&
|
|
2204
2950
|
isObject(data[attributeName]) &&
|
|
@@ -2226,6 +2972,25 @@ GraphQLFieldHelper.ConvertFieldValueTo = (instance, fields, update = false) => {
|
|
|
2226
2972
|
return Object.assign(Object.assign({}, result), { [columnName]: data[attributeName] });
|
|
2227
2973
|
}, {});
|
|
2228
2974
|
};
|
|
2975
|
+
GraphQLFieldHelper.ConvertNestedFieldsToGraphQLFields = (fieldName, fieldValue) => {
|
|
2976
|
+
const hasCustomFilters = !!fieldValue.filters;
|
|
2977
|
+
if (hasCustomFilters)
|
|
2978
|
+
return {
|
|
2979
|
+
operation: fieldValue.columnName || fieldName,
|
|
2980
|
+
fields: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(fieldValue.fields),
|
|
2981
|
+
variables: {
|
|
2982
|
+
[`${fieldValue.columnName}_where`]: {
|
|
2983
|
+
name: 'where',
|
|
2984
|
+
type: fieldValue.filters.filterType,
|
|
2985
|
+
value: BindFilterQueryHelper.MakeGraphQLWhere(fieldValue.filters.filters, fieldValue.fields),
|
|
2986
|
+
required: true,
|
|
2987
|
+
},
|
|
2988
|
+
},
|
|
2989
|
+
};
|
|
2990
|
+
return {
|
|
2991
|
+
[fieldValue.columnName || fieldName]: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(fieldValue.fields),
|
|
2992
|
+
};
|
|
2993
|
+
};
|
|
2229
2994
|
|
|
2230
2995
|
const withCreateHasuraGraphQL = (MixinBase) => {
|
|
2231
2996
|
return class CreateHasuraGraphQLMixin extends MixinBase {
|
|
@@ -2237,6 +3002,7 @@ const withCreateHasuraGraphQL = (MixinBase) => {
|
|
|
2237
3002
|
}
|
|
2238
3003
|
create(data) {
|
|
2239
3004
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3005
|
+
this.logger = DebugHelper.from(this, 'create');
|
|
2240
3006
|
const newData = yield this.save(this.model.toInstance(data));
|
|
2241
3007
|
return this.model.toInstance(newData);
|
|
2242
3008
|
});
|
|
@@ -2249,12 +3015,11 @@ const withCreateHasuraGraphQL = (MixinBase) => {
|
|
|
2249
3015
|
const columnOptions = Object.values(field).shift();
|
|
2250
3016
|
return (AttributeOptionHelper.CheckIsColumnOption(columnOptions) &&
|
|
2251
3017
|
columnOptions.foreignKeyColumn && [
|
|
2252
|
-
...Object.values(columnOptions.foreignKeyColumn),
|
|
3018
|
+
...Object.values(columnOptions.foreignKeyColumn).map((foreignKeyName) => { var _a; return (_a = AttributeOptionHelper.FindByAttribute(foreignKeyName, this.fields)) === null || _a === void 0 ? void 0 : _a.columnName; }),
|
|
2253
3019
|
{
|
|
2254
3020
|
[columnOptions.columnName]: Object.keys(columnOptions.foreignKeyColumn).map((foreignKeyField) => {
|
|
2255
3021
|
var _a;
|
|
2256
|
-
return ((_a = AttributeOptionHelper.FindByAttribute(foreignKeyField, columnOptions === null || columnOptions === void 0 ? void 0 : columnOptions.fields)) === null || _a === void 0 ? void 0 : _a.columnName) ||
|
|
2257
|
-
foreignKeyField;
|
|
3022
|
+
return ((_a = AttributeOptionHelper.FindByAttribute(foreignKeyField, columnOptions === null || columnOptions === void 0 ? void 0 : columnOptions.fields)) === null || _a === void 0 ? void 0 : _a.columnName) || foreignKeyField;
|
|
2258
3023
|
}),
|
|
2259
3024
|
},
|
|
2260
3025
|
]);
|
|
@@ -2279,9 +3044,11 @@ const withDeleteHasuraGraphQL = (MixinBase) => {
|
|
|
2279
3044
|
}
|
|
2280
3045
|
delete(identifiers) {
|
|
2281
3046
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3047
|
+
this.logger = DebugHelper.from(this, 'delete');
|
|
2282
3048
|
const instance = this.model.toInstance(identifiers);
|
|
2283
3049
|
yield this.mutation(this.deleteGraphQLOperation, this.model.identifiersFields.map((field) => AttributeOptionHelper.FindByAttribute(field, this.fields).columnName), this.model.identifiersFields.reduce((ids, identifier) => {
|
|
2284
|
-
|
|
3050
|
+
const identifierBinded = identifier;
|
|
3051
|
+
if (isNil(instance.identifier[identifierBinded]))
|
|
2285
3052
|
return ids;
|
|
2286
3053
|
const columnOption = AttributeOptionHelper.FindByAttribute(identifier, this.fields);
|
|
2287
3054
|
const value = columnOption.to(identifiers[identifier], instance);
|
|
@@ -2306,11 +3073,16 @@ const withHasuraGraphQL = (MixinBase) => {
|
|
|
2306
3073
|
this.authOptions = options.authOptions;
|
|
2307
3074
|
this.model = options.model;
|
|
2308
3075
|
this.fields = options.fields || this.model.identifiersFields;
|
|
3076
|
+
this.logger = DebugHelper.from(this);
|
|
2309
3077
|
}
|
|
2310
3078
|
get headers() {
|
|
2311
|
-
|
|
3079
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
3080
|
+
return Object.assign(Object.assign(Object.assign({ 'Content-Type': 'application/json' }, (isNil((_a = this.authOptions) === null || _a === void 0 ? void 0 : _a.authToken) ? {} : { Authorization: (_b = this.authOptions) === null || _b === void 0 ? void 0 : _b.authToken })), (isNil((_c = this.authOptions) === null || _c === void 0 ? void 0 : _c.adminSecret) ? {} : { 'X-Hasura-Admin-Secret': (_d = this.authOptions) === null || _d === void 0 ? void 0 : _d.adminSecret })), (isNil((_e = this.authOptions) === null || _e === void 0 ? void 0 : _e.authRole)
|
|
2312
3081
|
? {}
|
|
2313
|
-
: {
|
|
3082
|
+
: {
|
|
3083
|
+
'X-Hasura-Role': this.authOptions.authRole.role,
|
|
3084
|
+
'X-Hasura-User-Id': (_g = (_f = this.authOptions) === null || _f === void 0 ? void 0 : _f.authRole) === null || _g === void 0 ? void 0 : _g.userId,
|
|
3085
|
+
}));
|
|
2314
3086
|
}
|
|
2315
3087
|
mutation(operation, fields, variables) {
|
|
2316
3088
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -2323,30 +3095,32 @@ const withHasuraGraphQL = (MixinBase) => {
|
|
|
2323
3095
|
});
|
|
2324
3096
|
}
|
|
2325
3097
|
query(operation, fields, variables) {
|
|
3098
|
+
var _a, _b, _c, _d;
|
|
2326
3099
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2327
|
-
const
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
fields: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(fields),
|
|
2337
|
-
});
|
|
2338
|
-
return this.fetch(resultQuery);
|
|
3100
|
+
const builded = this.buildHasuraQueryFields({
|
|
3101
|
+
operation,
|
|
3102
|
+
fields: fields,
|
|
3103
|
+
variables,
|
|
3104
|
+
});
|
|
3105
|
+
const interpected = (yield ((_b = (_a = this.interceptors) === null || _a === void 0 ? void 0 : _a.request) === null || _b === void 0 ? void 0 : _b.call(_a, builded))) || builded;
|
|
3106
|
+
const resultQuery = query$1(interpected);
|
|
3107
|
+
const result = yield this.fetch(resultQuery);
|
|
3108
|
+
return (yield ((_d = (_c = this.interceptors) === null || _c === void 0 ? void 0 : _c.response) === null || _d === void 0 ? void 0 : _d.call(_c, result, interpected))) || result;
|
|
2339
3109
|
});
|
|
2340
3110
|
}
|
|
2341
3111
|
fetch(params) {
|
|
2342
3112
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3113
|
+
this.logger.with('params').log(params);
|
|
2343
3114
|
const headers = this.headers;
|
|
2344
|
-
const
|
|
3115
|
+
const { data: result } = yield axios({
|
|
3116
|
+
url: `${this.endpoint}`,
|
|
3117
|
+
method: 'POST',
|
|
3118
|
+
data: params,
|
|
2345
3119
|
headers,
|
|
2346
3120
|
});
|
|
2347
|
-
const result = yield response.data;
|
|
2348
3121
|
if (!isNil(result.errors))
|
|
2349
3122
|
throw new Error(JSON.stringify(result.errors));
|
|
3123
|
+
this.logger.with('returns').log(result);
|
|
2350
3124
|
return result.data;
|
|
2351
3125
|
});
|
|
2352
3126
|
}
|
|
@@ -2373,13 +3147,26 @@ const withHasuraGraphQL = (MixinBase) => {
|
|
|
2373
3147
|
return value;
|
|
2374
3148
|
return date;
|
|
2375
3149
|
}
|
|
2376
|
-
convertDataFromHasura(data) {
|
|
2377
|
-
const plain = GraphQLFieldHelper.ConvertFieldValueFrom(data, this.fields);
|
|
3150
|
+
convertDataFromHasura(data, fields) {
|
|
3151
|
+
const plain = GraphQLFieldHelper.ConvertFieldValueFrom(data, fields || this.fields);
|
|
2378
3152
|
return this.model.toInstance(plain);
|
|
2379
3153
|
}
|
|
2380
3154
|
convertDataToHasura(instance, update = false) {
|
|
2381
3155
|
return GraphQLFieldHelper.ConvertFieldValueTo(instance, this.fields, update);
|
|
2382
3156
|
}
|
|
3157
|
+
buildHasuraQueryFields({ operation, fields, variables, }) {
|
|
3158
|
+
return GraphQLFieldHelper.CheckIsGraphQLParams(operation)
|
|
3159
|
+
? operation.map((option) => ({
|
|
3160
|
+
operation: option.operation,
|
|
3161
|
+
variables: option.variables,
|
|
3162
|
+
fields: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(option.fields),
|
|
3163
|
+
}))
|
|
3164
|
+
: {
|
|
3165
|
+
operation,
|
|
3166
|
+
variables,
|
|
3167
|
+
fields: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(fields),
|
|
3168
|
+
};
|
|
3169
|
+
}
|
|
2383
3170
|
};
|
|
2384
3171
|
};
|
|
2385
3172
|
|
|
@@ -2403,6 +3190,7 @@ const withUpdateHasuraGraphQL = (MixinBase) => {
|
|
|
2403
3190
|
}
|
|
2404
3191
|
update(data) {
|
|
2405
3192
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3193
|
+
this.logger = DebugHelper.from(this, 'update');
|
|
2406
3194
|
const plainData = this.paramsToPlain(data);
|
|
2407
3195
|
yield this.mutation(this.updateGraphQLOperation, this.model.identifiersFields.map((field) => AttributeOptionHelper.FindByAttribute(field, this.fields).columnName), {
|
|
2408
3196
|
_set: {
|
|
@@ -2427,10 +3215,11 @@ const withUpdateHasuraGraphQL = (MixinBase) => {
|
|
|
2427
3215
|
const instance = this.model.toInstance(data);
|
|
2428
3216
|
return this.model.identifiersFields.reduce((ids, identifier) => {
|
|
2429
3217
|
var _a;
|
|
2430
|
-
|
|
3218
|
+
const identifierBinded = identifier;
|
|
3219
|
+
if (isNil(instance.identifier[identifierBinded]))
|
|
2431
3220
|
return ids;
|
|
2432
|
-
const columnOption = AttributeOptionHelper.FindByAttribute(
|
|
2433
|
-
const value = ((_a = columnOption === null || columnOption === void 0 ? void 0 : columnOption.to) === null || _a === void 0 ? void 0 : _a.call(columnOption, data[
|
|
3221
|
+
const columnOption = AttributeOptionHelper.FindByAttribute(identifierBinded, this.fields);
|
|
3222
|
+
const value = ((_a = columnOption === null || columnOption === void 0 ? void 0 : columnOption.to) === null || _a === void 0 ? void 0 : _a.call(columnOption, data[identifierBinded], instance)) || data[columnOption.attributeName];
|
|
2434
3223
|
return Object.assign(Object.assign({}, ids), { [columnOption.columnName]: value });
|
|
2435
3224
|
}, {});
|
|
2436
3225
|
}
|
|
@@ -2446,10 +3235,12 @@ const withGetHasuraGraphQL = (MixinBase) => {
|
|
|
2446
3235
|
}
|
|
2447
3236
|
get(identifiers) {
|
|
2448
3237
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3238
|
+
this.logger = DebugHelper.from(this, 'get');
|
|
2449
3239
|
const instance = this.model.toInstance(identifiers);
|
|
2450
3240
|
const result = yield this.query(this.getGraphQLOperation, this.fields, this.model.identifiersFields.reduce((ids, identifier) => {
|
|
2451
3241
|
var _a;
|
|
2452
|
-
|
|
3242
|
+
const identifierBinded = identifier;
|
|
3243
|
+
if (isNil(instance[identifierBinded]))
|
|
2453
3244
|
return ids;
|
|
2454
3245
|
const columnOption = AttributeOptionHelper.FindByAttribute(identifier, this.fields);
|
|
2455
3246
|
const value = ((_a = columnOption === null || columnOption === void 0 ? void 0 : columnOption.to) === null || _a === void 0 ? void 0 : _a.call(columnOption, identifiers[identifier], instance)) ||
|
|
@@ -2471,10 +3262,46 @@ const withGetHasuraGraphQL = (MixinBase) => {
|
|
|
2471
3262
|
|
|
2472
3263
|
const withFindHasuraGraphQL = (MixinBase) => {
|
|
2473
3264
|
return class FindHasuraGraphQLMixin extends MixinBase {
|
|
2474
|
-
|
|
3265
|
+
constructor() {
|
|
3266
|
+
super(...arguments);
|
|
3267
|
+
this.bindOrderByAttributes = (orderBy, fields) => Object.keys(orderBy).reduce((acc, current) => [
|
|
3268
|
+
...acc,
|
|
3269
|
+
{
|
|
3270
|
+
[AttributeOptionHelper.FindByAttribute(current, fields)
|
|
3271
|
+
.columnName]: orderBy[current] === 'asc'
|
|
3272
|
+
? 'asc_nulls_last'
|
|
3273
|
+
: 'desc_nulls_last',
|
|
3274
|
+
},
|
|
3275
|
+
], []);
|
|
3276
|
+
this.bindAggretageAttributes = (aggregates, fields) => {
|
|
3277
|
+
var _a, _b;
|
|
3278
|
+
return [
|
|
3279
|
+
...(((_a = aggregates === null || aggregates === void 0 ? void 0 : aggregates.minimal) === null || _a === void 0 ? void 0 : _a.length)
|
|
3280
|
+
? [
|
|
3281
|
+
{
|
|
3282
|
+
min: this.bindAttributesToColumns(aggregates === null || aggregates === void 0 ? void 0 : aggregates.minimal, fields),
|
|
3283
|
+
},
|
|
3284
|
+
]
|
|
3285
|
+
: []),
|
|
3286
|
+
...(((_b = aggregates === null || aggregates === void 0 ? void 0 : aggregates.maximum) === null || _b === void 0 ? void 0 : _b.length)
|
|
3287
|
+
? [
|
|
3288
|
+
{
|
|
3289
|
+
max: this.bindAttributesToColumns(aggregates === null || aggregates === void 0 ? void 0 : aggregates.maximum, fields),
|
|
3290
|
+
},
|
|
3291
|
+
]
|
|
3292
|
+
: []),
|
|
3293
|
+
];
|
|
3294
|
+
};
|
|
3295
|
+
this.bindDistinctAttributes = (distinct, fields) => this.bindAttributesToColumns(distinct, fields);
|
|
3296
|
+
this.bindAttributesToColumns = (attributes, fields) => attributes.map((attr) => { var _a; return ((_a = AttributeOptionHelper.FindByAttribute(attr.toString().split('.').pop(), fields)) === null || _a === void 0 ? void 0 : _a.columnName) || attr; });
|
|
3297
|
+
}
|
|
3298
|
+
find(params) {
|
|
3299
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
2475
3300
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2476
|
-
|
|
2477
|
-
const
|
|
3301
|
+
this.logger = DebugHelper.from(this, 'find');
|
|
3302
|
+
const { filters, limits, orderBy, options } = params || {};
|
|
3303
|
+
const enableCount = (_a = options === null || options === void 0 ? void 0 : options.enableCount) !== null && _a !== void 0 ? _a : true;
|
|
3304
|
+
const variablesFilters = isNil(filters)
|
|
2478
3305
|
? {}
|
|
2479
3306
|
: {
|
|
2480
3307
|
where: {
|
|
@@ -2482,13 +3309,26 @@ const withFindHasuraGraphQL = (MixinBase) => {
|
|
|
2482
3309
|
type: `${this.tableName}_bool_exp`,
|
|
2483
3310
|
required: true,
|
|
2484
3311
|
},
|
|
2485
|
-
}
|
|
3312
|
+
};
|
|
3313
|
+
const variablesCount = Object.assign(Object.assign({}, (isNil(orderBy)
|
|
3314
|
+
? {}
|
|
3315
|
+
: {
|
|
3316
|
+
order_by: {
|
|
3317
|
+
type: `${this.tableName}_order_by!`,
|
|
3318
|
+
list: true,
|
|
3319
|
+
value: this.bindOrderByAttributes(orderBy, this.fields),
|
|
3320
|
+
},
|
|
3321
|
+
})), variablesFilters);
|
|
2486
3322
|
const variables = Object.assign(Object.assign({}, (isNil(limits) ? {} : limits)), variablesCount);
|
|
3323
|
+
const aggregateFields = [
|
|
3324
|
+
...(enableCount ? ['count'] : []),
|
|
3325
|
+
...this.bindAggretageAttributes(params.options, this.fields),
|
|
3326
|
+
];
|
|
2487
3327
|
const result = yield this.query([
|
|
2488
3328
|
{
|
|
2489
3329
|
operation: this.tableName,
|
|
2490
|
-
fields:
|
|
2491
|
-
?
|
|
3330
|
+
fields: params.fields
|
|
3331
|
+
? params.fields
|
|
2492
3332
|
.map((fieldName) => {
|
|
2493
3333
|
var _a;
|
|
2494
3334
|
return (_a = this.fields.find((fieldOption) => fieldOption === fieldName)) !== null && _a !== void 0 ? _a : this.fields.find((fieldOption) => Object.keys(fieldOption).shift() === fieldName);
|
|
@@ -2497,15 +3337,64 @@ const withFindHasuraGraphQL = (MixinBase) => {
|
|
|
2497
3337
|
: this.fields,
|
|
2498
3338
|
variables,
|
|
2499
3339
|
},
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
|
|
3340
|
+
...(aggregateFields.length > 0
|
|
3341
|
+
? [
|
|
3342
|
+
{
|
|
3343
|
+
operation: `${this.tableName}_aggregate`,
|
|
3344
|
+
fields: [
|
|
3345
|
+
{
|
|
3346
|
+
aggregate: aggregateFields,
|
|
3347
|
+
},
|
|
3348
|
+
],
|
|
3349
|
+
variables: variablesCount,
|
|
3350
|
+
},
|
|
3351
|
+
]
|
|
3352
|
+
: []),
|
|
3353
|
+
...((!((_b = params.limits) === null || _b === void 0 ? void 0 : _b.offset) &&
|
|
3354
|
+
((_d = (_c = params.options) === null || _c === void 0 ? void 0 : _c.distinct) === null || _d === void 0 ? void 0 : _d.map((distinct) => {
|
|
3355
|
+
var _a, _b;
|
|
3356
|
+
const distinctOption = (_a = this.fields.find((fieldOption) => fieldOption === distinct)) !== null && _a !== void 0 ? _a : this.fields.find((fieldOption) => Object.keys(fieldOption).shift() === distinct);
|
|
3357
|
+
const fieldName = ((_b = Object.values(distinctOption).shift()) === null || _b === void 0 ? void 0 : _b.columnName) || distinct;
|
|
3358
|
+
return {
|
|
3359
|
+
operation: {
|
|
3360
|
+
name: `${this.tableName}`,
|
|
3361
|
+
alias: `${this.tableName}_${distinct.toString()}_distinct`,
|
|
3362
|
+
},
|
|
3363
|
+
fields: [distinctOption],
|
|
3364
|
+
variables: Object.assign(Object.assign({}, variablesFilters), { [`${this.tableName}_${fieldName}_distinct`]: {
|
|
3365
|
+
type: `${this.tableName}_select_column!`,
|
|
3366
|
+
list: true,
|
|
3367
|
+
value: fieldName,
|
|
3368
|
+
name: 'distinct_on',
|
|
3369
|
+
} }),
|
|
3370
|
+
};
|
|
3371
|
+
}))) ||
|
|
3372
|
+
[]),
|
|
2505
3373
|
]);
|
|
2506
3374
|
const data = result[this.tableName].map((row) => this.convertDataFromHasura(row));
|
|
2507
|
-
|
|
2508
|
-
|
|
3375
|
+
return Object.assign(Object.assign(Object.assign({ data, count: enableCount ? result[`${this.tableName}_aggregate`].aggregate.count : Infinity }, (((_e = options === null || options === void 0 ? void 0 : options.minimal) === null || _e === void 0 ? void 0 : _e.length)
|
|
3376
|
+
? {
|
|
3377
|
+
minimal: options.minimal.reduce((minimals, current) => {
|
|
3378
|
+
var _a;
|
|
3379
|
+
return (Object.assign(Object.assign({}, minimals), set(minimals, current, result[`${this.tableName}_aggregate`].aggregate.min[((_a = AttributeOptionHelper.FindByAttribute(current.toString().split('.').pop(), this.fields)) === null || _a === void 0 ? void 0 : _a.columnName) || current])));
|
|
3380
|
+
}, {}),
|
|
3381
|
+
}
|
|
3382
|
+
: {})), (((_f = options === null || options === void 0 ? void 0 : options.maximum) === null || _f === void 0 ? void 0 : _f.length)
|
|
3383
|
+
? {
|
|
3384
|
+
maximum: options.maximum.reduce((maximums, current) => {
|
|
3385
|
+
var _a;
|
|
3386
|
+
return (Object.assign(Object.assign({}, maximums), set(maximums, current, result[`${this.tableName}_aggregate`].aggregate.max[((_a = AttributeOptionHelper.FindByAttribute(current.toString().split('.').pop(), this.fields)) === null || _a === void 0 ? void 0 : _a.columnName) || current])));
|
|
3387
|
+
}, {}),
|
|
3388
|
+
}
|
|
3389
|
+
: {})), (!((_g = params.limits) === null || _g === void 0 ? void 0 : _g.offset) &&
|
|
3390
|
+
((_h = options === null || options === void 0 ? void 0 : options.distinct) === null || _h === void 0 ? void 0 : _h.length) && {
|
|
3391
|
+
distinct: options === null || options === void 0 ? void 0 : options.distinct.reduce((distinct, current) => {
|
|
3392
|
+
var _a, _b;
|
|
3393
|
+
const distinctOption = (_a = this.fields.find((fieldOption) => fieldOption === current)) !== null && _a !== void 0 ? _a : this.fields.find((fieldOption) => Object.keys(fieldOption).shift() === current);
|
|
3394
|
+
const fieldName = ((_b = Object.values(distinctOption).shift()) === null || _b === void 0 ? void 0 : _b.columnName) || current;
|
|
3395
|
+
return Object.assign(Object.assign({}, distinct), { [current.toString()]: result[`${this.tableName}_${current.toString()}_distinct`].map((obj) => obj[fieldName]) });
|
|
3396
|
+
}, {}),
|
|
3397
|
+
}));
|
|
2509
3398
|
});
|
|
2510
3399
|
}
|
|
2511
3400
|
};
|
|
@@ -2545,48 +3434,199 @@ class VariantHasuraGraphQL extends Variant {
|
|
|
2545
3434
|
}
|
|
2546
3435
|
}
|
|
2547
3436
|
|
|
2548
|
-
class
|
|
2549
|
-
constructor({ endpoint, authOptions, interceptors, }
|
|
3437
|
+
class CategoryCollectionChildrenHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
3438
|
+
constructor({ endpoint, authOptions, interceptors, }) {
|
|
2550
3439
|
super({
|
|
2551
|
-
tableName: '
|
|
2552
|
-
model:
|
|
3440
|
+
tableName: 'category_collection_children',
|
|
3441
|
+
model: CategoryCollectionChildren,
|
|
2553
3442
|
endpoint,
|
|
2554
3443
|
authOptions,
|
|
2555
3444
|
interceptors,
|
|
2556
3445
|
fields: [
|
|
2557
|
-
{
|
|
2558
|
-
{
|
|
3446
|
+
{ collectionId: { columnName: 'collection_id' } },
|
|
3447
|
+
{ categoryId: { columnName: 'category_id' } },
|
|
2559
3448
|
'name',
|
|
2560
|
-
'description',
|
|
2561
|
-
'image',
|
|
2562
|
-
'published',
|
|
2563
|
-
'shop',
|
|
2564
3449
|
'slug',
|
|
2565
|
-
|
|
2566
|
-
{
|
|
2567
|
-
{
|
|
2568
|
-
{ brandLogo: { columnName: 'brand_logo' } },
|
|
2569
|
-
{ brandCondition: { columnName: 'brand_condition' } },
|
|
3450
|
+
'reference',
|
|
3451
|
+
{ parentCollectionId: { columnName: 'parent_collection_id' } },
|
|
3452
|
+
{ parentCategoryId: { columnName: 'parent_category_id' } },
|
|
2570
3453
|
{
|
|
2571
|
-
|
|
2572
|
-
columnName: '
|
|
2573
|
-
|
|
2574
|
-
|
|
2575
|
-
|
|
2576
|
-
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
|
|
3454
|
+
parent: {
|
|
3455
|
+
columnName: 'parent',
|
|
3456
|
+
foreignKeyColumn: { collectionId: 'parentCollectionId', categoryId: 'parentCategoryId' },
|
|
3457
|
+
fields: [
|
|
3458
|
+
{ collectionId: { columnName: 'collection_id' } },
|
|
3459
|
+
{ categoryId: { columnName: 'category_id' } },
|
|
3460
|
+
'name',
|
|
3461
|
+
'slug',
|
|
3462
|
+
'reference',
|
|
3463
|
+
{ parentCollectionId: { columnName: 'parent_collection_id' } },
|
|
3464
|
+
{ parentCategoryId: { columnName: 'parent_category_id' } },
|
|
3465
|
+
],
|
|
3466
|
+
},
|
|
3467
|
+
},
|
|
3468
|
+
],
|
|
3469
|
+
});
|
|
3470
|
+
}
|
|
3471
|
+
}
|
|
3472
|
+
|
|
3473
|
+
class CategoryFilterHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
3474
|
+
constructor({ endpoint, authOptions, interceptors, }) {
|
|
3475
|
+
super({
|
|
3476
|
+
tableName: 'category_filter',
|
|
3477
|
+
model: CategoryFilter,
|
|
3478
|
+
endpoint,
|
|
3479
|
+
authOptions,
|
|
3480
|
+
interceptors,
|
|
3481
|
+
fields: [
|
|
3482
|
+
'id',
|
|
3483
|
+
{ filterId: { columnName: 'filter_id' } },
|
|
3484
|
+
{ categoryId: { columnName: 'category_id' } },
|
|
3485
|
+
{
|
|
3486
|
+
filter: {
|
|
3487
|
+
columnName: 'filter',
|
|
3488
|
+
foreignKeyColumn: { id: 'filterId' },
|
|
3489
|
+
fields: [
|
|
3490
|
+
'id',
|
|
3491
|
+
'description',
|
|
3492
|
+
'slug',
|
|
3493
|
+
'enabled',
|
|
3494
|
+
{ createdAt: { columnName: 'created_at' } },
|
|
3495
|
+
{ updatedAt: { columnName: 'updated_at' } },
|
|
3496
|
+
{
|
|
3497
|
+
options: {
|
|
3498
|
+
columnName: 'options',
|
|
3499
|
+
foreignKeyColumn: { filterId: 'id' },
|
|
3500
|
+
fields: [
|
|
3501
|
+
'id',
|
|
3502
|
+
{ filterId: { columnName: 'filter_id' } },
|
|
3503
|
+
'description',
|
|
3504
|
+
{ createdAt: { columnName: 'created_at' } },
|
|
3505
|
+
{ updatedAt: { columnName: 'updated_at' } },
|
|
3506
|
+
],
|
|
3507
|
+
},
|
|
3508
|
+
},
|
|
3509
|
+
],
|
|
3510
|
+
},
|
|
3511
|
+
},
|
|
3512
|
+
{
|
|
3513
|
+
category: {
|
|
3514
|
+
columnName: 'category',
|
|
3515
|
+
foreignKeyColumn: { id: 'categoryId' },
|
|
3516
|
+
fields: [
|
|
3517
|
+
'id',
|
|
3518
|
+
'description',
|
|
3519
|
+
{
|
|
3520
|
+
products: {
|
|
3521
|
+
columnName: 'products',
|
|
3522
|
+
fields: ['product_id'],
|
|
3523
|
+
from: (value) => value.map((product) => product.product_id.toString()),
|
|
3524
|
+
to: (productIds) => productIds.map((productId) => ({
|
|
3525
|
+
product_id: +productId,
|
|
3526
|
+
})),
|
|
3527
|
+
},
|
|
3528
|
+
},
|
|
3529
|
+
{
|
|
3530
|
+
childrenProducts: {
|
|
3531
|
+
columnName: 'children_products',
|
|
3532
|
+
foreignKeyColumn: { category_id: 'id' },
|
|
3533
|
+
fields: [
|
|
3534
|
+
'id',
|
|
3535
|
+
'name',
|
|
3536
|
+
'slug',
|
|
3537
|
+
{
|
|
3538
|
+
categories: {
|
|
3539
|
+
columnName: 'categories',
|
|
3540
|
+
fields: ['category_id'],
|
|
3541
|
+
bindPersistData: (value) => ({
|
|
3542
|
+
categories: { data: value.map((category) => ({ category_id: +category })) },
|
|
3543
|
+
}),
|
|
3544
|
+
to: (categories) => categories.map((categoryId) => +categoryId),
|
|
3545
|
+
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(); })) || [],
|
|
3546
|
+
},
|
|
3547
|
+
},
|
|
3548
|
+
],
|
|
3549
|
+
},
|
|
3550
|
+
},
|
|
3551
|
+
],
|
|
3552
|
+
},
|
|
3553
|
+
},
|
|
3554
|
+
],
|
|
3555
|
+
});
|
|
3556
|
+
}
|
|
3557
|
+
deleteByCategory(categoryId) {
|
|
3558
|
+
return this.mutation('delete_category_filter', ['affected_rows'], {
|
|
3559
|
+
where: {
|
|
3560
|
+
type: 'category_filter_bool_exp',
|
|
3561
|
+
required: true,
|
|
3562
|
+
value: { category_id: { _eq: categoryId } },
|
|
3563
|
+
},
|
|
3564
|
+
});
|
|
3565
|
+
}
|
|
3566
|
+
deleteByCategoryAndFilter(categoryId, filterId) {
|
|
3567
|
+
return this.mutation('delete_category_filter', ['affected_rows'], {
|
|
3568
|
+
where: {
|
|
3569
|
+
type: 'category_filter_bool_exp',
|
|
3570
|
+
required: true,
|
|
3571
|
+
value: { category_id: { _eq: categoryId }, filter_id: { _eq: filterId } },
|
|
3572
|
+
},
|
|
3573
|
+
});
|
|
3574
|
+
}
|
|
3575
|
+
}
|
|
3576
|
+
|
|
3577
|
+
class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
3578
|
+
constructor({ endpoint, authOptions, interceptors, }, productRepository, categoryFilterRepository) {
|
|
3579
|
+
super({
|
|
3580
|
+
tableName: 'category',
|
|
3581
|
+
model: Category,
|
|
3582
|
+
endpoint,
|
|
3583
|
+
authOptions,
|
|
3584
|
+
interceptors,
|
|
3585
|
+
fields: [
|
|
3586
|
+
{ id: { columnName: 'id', to: (value) => +value, from: (value) => value.toString() } },
|
|
3587
|
+
{ firestoreId: { columnName: 'firestore_id' } },
|
|
3588
|
+
'name',
|
|
3589
|
+
'description',
|
|
3590
|
+
'image',
|
|
3591
|
+
'published',
|
|
3592
|
+
'shop',
|
|
3593
|
+
{ shops: { columnName: 'shops', type: HasuraGraphQLColumnType.Jsonb } },
|
|
3594
|
+
'slug',
|
|
3595
|
+
{ brandCategory: { columnName: 'brand_category' } },
|
|
3596
|
+
{ brandCategoryBanner: { columnName: 'brand_banner' } },
|
|
3597
|
+
{ brandCategoryBannerMobile: { columnName: 'brand_banner_mobile' } },
|
|
3598
|
+
{ brandLogo: { columnName: 'brand_logo' } },
|
|
3599
|
+
{ brandCondition: { columnName: 'brand_condition' } },
|
|
3600
|
+
{
|
|
3601
|
+
conditions: {
|
|
3602
|
+
columnName: 'tag_condition',
|
|
3603
|
+
type: HasuraGraphQLColumnType.Jsonb,
|
|
3604
|
+
from: (tags, row) => ({
|
|
3605
|
+
brand: row.brand_condition,
|
|
3606
|
+
tags: Array.isArray(tags) ? tags : [],
|
|
3607
|
+
}),
|
|
3608
|
+
bindPersistData: (value) => {
|
|
3609
|
+
return {
|
|
3610
|
+
brand_condition: value.brand,
|
|
3611
|
+
tag_condition: (value === null || value === void 0 ? void 0 : value.tags) || [],
|
|
3612
|
+
};
|
|
3613
|
+
},
|
|
3614
|
+
bindFindFilter: (sentence) => {
|
|
3615
|
+
return Object.assign(Object.assign({}, (sentence.brand ? { brand_condition: sentence.brand } : {})), (sentence.tags ? { tag_condition: sentence.tags } : {}));
|
|
3616
|
+
},
|
|
3617
|
+
},
|
|
3618
|
+
},
|
|
3619
|
+
{
|
|
3620
|
+
filters: {
|
|
3621
|
+
columnName: 'filters',
|
|
3622
|
+
foreignKeyColumn: { filter_id: 'id' },
|
|
3623
|
+
fields: [{ filter: ['id', 'description', 'slug', 'enabled'] }],
|
|
3624
|
+
bindPersistData: (value) => ({
|
|
3625
|
+
filters: { data: value.map((filter) => ({ filter_id: filter.id })) },
|
|
3626
|
+
}),
|
|
3627
|
+
from: (filters) => (filters === null || filters === void 0 ? void 0 : filters.map((filter) => filter === null || filter === void 0 ? void 0 : filter.filter)) || [],
|
|
2587
3628
|
},
|
|
2588
3629
|
},
|
|
2589
|
-
'filters',
|
|
2590
3630
|
{ createdAt: { columnName: 'created_at' } },
|
|
2591
3631
|
{ updatedAt: { columnName: 'updated_at' } },
|
|
2592
3632
|
{
|
|
@@ -2608,9 +3648,21 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
2608
3648
|
}),
|
|
2609
3649
|
},
|
|
2610
3650
|
},
|
|
3651
|
+
{ isCollection: { columnName: 'is_collection' } },
|
|
3652
|
+
{ isWishlist: { columnName: 'is_wishlist' } },
|
|
3653
|
+
'reference',
|
|
3654
|
+
{ parentId: { columnName: 'parent_id' } },
|
|
3655
|
+
{
|
|
3656
|
+
parent: {
|
|
3657
|
+
columnName: 'parent',
|
|
3658
|
+
foreignKeyColumn: { id: 'parentId' },
|
|
3659
|
+
fields: ['id', 'name', 'reference', 'slug'],
|
|
3660
|
+
},
|
|
3661
|
+
},
|
|
2611
3662
|
],
|
|
2612
3663
|
});
|
|
2613
3664
|
this.productRepository = productRepository;
|
|
3665
|
+
this.categoryFilterRepository = categoryFilterRepository;
|
|
2614
3666
|
}
|
|
2615
3667
|
create(params) {
|
|
2616
3668
|
const _super = Object.create(null, {
|
|
@@ -2618,7 +3670,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
2618
3670
|
});
|
|
2619
3671
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2620
3672
|
const { metadata } = params, data = __rest(params, ["metadata"]);
|
|
2621
|
-
return _super.create.call(this, Object.assign(Object.assign({}, data), { metadata: metadata || { description: null, title: null } }));
|
|
3673
|
+
return _super.create.call(this, Object.assign(Object.assign({}, data), { isWishlist: false, metadata: metadata || { description: null, title: null } }));
|
|
2622
3674
|
});
|
|
2623
3675
|
}
|
|
2624
3676
|
get(identifiers) {
|
|
@@ -2628,7 +3680,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
2628
3680
|
var _a;
|
|
2629
3681
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2630
3682
|
return Number.isNaN(+identifiers.id)
|
|
2631
|
-
? (_a = (yield this.find({ filters: { firestoreId: identifiers.id } })).data) === null || _a === void 0 ? void 0 : _a[0]
|
|
3683
|
+
? (_a = (yield this.find({ filters: { firestoreId: identifiers.id }, options: { enableCount: false } })).data) === null || _a === void 0 ? void 0 : _a[0]
|
|
2632
3684
|
: _super.get.call(this, identifiers);
|
|
2633
3685
|
});
|
|
2634
3686
|
}
|
|
@@ -2637,12 +3689,13 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
2637
3689
|
update: { get: () => super.update }
|
|
2638
3690
|
});
|
|
2639
3691
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2640
|
-
const { products, id: checkId, metadata } = params, data = __rest(params, ["products", "id", "metadata"]);
|
|
3692
|
+
const { products, id: checkId, metadata, filters } = params, data = __rest(params, ["products", "id", "metadata", "filters"]);
|
|
2641
3693
|
const plainData = this.paramsToPlain({ id: checkId });
|
|
2642
3694
|
const id = yield this.getId(plainData.id);
|
|
2643
|
-
const category = yield _super.update.call(this, Object.assign({ id }, data));
|
|
3695
|
+
const category = yield _super.update.call(this, Object.assign(Object.assign({ id }, data), { isWishlist: false }));
|
|
2644
3696
|
category.products = products && (yield this.updateProducts(+id, { products }));
|
|
2645
3697
|
category.metadata = metadata && (yield this.updateMetadata(+id, { metadata }));
|
|
3698
|
+
category.filters = filters && (yield this.updateFilters(+id, { filters }));
|
|
2646
3699
|
return category;
|
|
2647
3700
|
});
|
|
2648
3701
|
}
|
|
@@ -2650,15 +3703,42 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
2650
3703
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2651
3704
|
if (!slug)
|
|
2652
3705
|
return null;
|
|
2653
|
-
const { data
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
|
|
3706
|
+
const { data } = yield this.find({
|
|
3707
|
+
filters: {
|
|
3708
|
+
slug,
|
|
3709
|
+
shops: { operator: Where.IN, value: [shop] },
|
|
3710
|
+
published: { operator: Where.EQUALS, value: true },
|
|
3711
|
+
isWishlist: { operator: Where.EQUALS, value: false },
|
|
3712
|
+
},
|
|
3713
|
+
options: {
|
|
3714
|
+
enableCount: false,
|
|
3715
|
+
},
|
|
3716
|
+
});
|
|
3717
|
+
if (!data.length)
|
|
2657
3718
|
throw new NotFoundError(`Category with slug ${slug} not found`);
|
|
3719
|
+
if (data.length > 1)
|
|
3720
|
+
throw new DuplicatedResultsError('Query returned duplicated values');
|
|
2658
3721
|
return data.shift();
|
|
2659
3722
|
});
|
|
2660
3723
|
}
|
|
2661
|
-
|
|
3724
|
+
getCategoryByShop(shop) {
|
|
3725
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
3726
|
+
if (!shop)
|
|
3727
|
+
return;
|
|
3728
|
+
const { data } = yield this.find({
|
|
3729
|
+
filters: {
|
|
3730
|
+
shops: { operator: Where.IN, value: [shop] },
|
|
3731
|
+
published: { operator: Where.EQUALS, value: true },
|
|
3732
|
+
isWishlist: { operator: Where.EQUALS, value: false },
|
|
3733
|
+
},
|
|
3734
|
+
options: {
|
|
3735
|
+
enableCount: false,
|
|
3736
|
+
},
|
|
3737
|
+
});
|
|
3738
|
+
return data;
|
|
3739
|
+
});
|
|
3740
|
+
}
|
|
3741
|
+
getCategoriesForHome(categoryIds, limit = 4, gender) {
|
|
2662
3742
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2663
3743
|
if (!(categoryIds === null || categoryIds === void 0 ? void 0 : categoryIds.length))
|
|
2664
3744
|
return [];
|
|
@@ -2678,7 +3758,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
2678
3758
|
const homeSections = yield Promise.all(categories.map((category) => __awaiter(this, void 0, void 0, function* () {
|
|
2679
3759
|
return ({
|
|
2680
3760
|
category,
|
|
2681
|
-
products: yield this.mountCategory(category, { limit, hasStock: true }),
|
|
3761
|
+
products: yield this.mountCategory(category, { limit, hasStock: true, gender }),
|
|
2682
3762
|
});
|
|
2683
3763
|
})));
|
|
2684
3764
|
return homeSections;
|
|
@@ -2690,7 +3770,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
2690
3770
|
if (!((_a = category === null || category === void 0 ? void 0 : category.products) === null || _a === void 0 ? void 0 : _a.length))
|
|
2691
3771
|
return [];
|
|
2692
3772
|
const products = [];
|
|
2693
|
-
const { data: productsData } = yield this.productRepository.find(Object.assign({ filters: Object.assign({ id: { operator: Where.IN, value: category.products }, published: true }, ((options === null || options === void 0 ? void 0 : options.hasStock) ? { stock: { quantity: { operator: Where.GT, value: 0 } } } : {})), fields: [
|
|
3773
|
+
const { data: productsData } = yield this.productRepository.find(Object.assign(Object.assign({ filters: Object.assign(Object.assign({ id: { operator: Where.IN, value: category.products }, published: true }, ((options === null || options === void 0 ? void 0 : options.hasStock) ? { stock: { quantity: { operator: Where.GT, value: 0 } } } : {})), ((options === null || options === void 0 ? void 0 : options.gender) ? { tags: { operator: Where.IN, value: [options === null || options === void 0 ? void 0 : options.gender] } } : {})), fields: [
|
|
2694
3774
|
'id',
|
|
2695
3775
|
'name',
|
|
2696
3776
|
'slug',
|
|
@@ -2714,7 +3794,9 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
2714
3794
|
'tags',
|
|
2715
3795
|
'type',
|
|
2716
3796
|
'shoppingCount',
|
|
2717
|
-
|
|
3797
|
+
'gender',
|
|
3798
|
+
'createdAt',
|
|
3799
|
+
] }, ((options === null || options === void 0 ? void 0 : options.limit) ? { limits: { limit: options === null || options === void 0 ? void 0 : options.limit } } : {})), { options: { enableCount: false } }));
|
|
2718
3800
|
products.push(...productsData);
|
|
2719
3801
|
return products;
|
|
2720
3802
|
});
|
|
@@ -2724,7 +3806,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
2724
3806
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2725
3807
|
if (!Number.isNaN(+id))
|
|
2726
3808
|
return id;
|
|
2727
|
-
const { data } = yield this.find({ filters: { firestoreId: id } });
|
|
3809
|
+
const { data } = yield this.find({ filters: { firestoreId: id }, options: { enableCount: false } });
|
|
2728
3810
|
if ((_a = data === null || data === void 0 ? void 0 : data[0]) === null || _a === void 0 ? void 0 : _a.id)
|
|
2729
3811
|
return (_b = data === null || data === void 0 ? void 0 : data[0]) === null || _b === void 0 ? void 0 : _b.id;
|
|
2730
3812
|
throw new NotFoundError(`Category with id ${id} not found`);
|
|
@@ -2782,6 +3864,210 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
2782
3864
|
return plainData.metadata;
|
|
2783
3865
|
});
|
|
2784
3866
|
}
|
|
3867
|
+
updateFilters(categoryId, { filters }) {
|
|
3868
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
3869
|
+
if ('action' in filters && filters.action === 'remove' && filters.value.length) {
|
|
3870
|
+
for (let i = 0; i < filters.value.length; i++) {
|
|
3871
|
+
yield this.categoryFilterRepository.deleteByCategoryAndFilter(categoryId, filters.value[i].id);
|
|
3872
|
+
}
|
|
3873
|
+
return [];
|
|
3874
|
+
}
|
|
3875
|
+
if ('action' in filters && filters.action === 'merge' && filters.value.length) {
|
|
3876
|
+
let filtersList = [];
|
|
3877
|
+
const currentFilters = yield this.categoryFilterRepository
|
|
3878
|
+
.find({
|
|
3879
|
+
filters: {
|
|
3880
|
+
categoryId,
|
|
3881
|
+
},
|
|
3882
|
+
})
|
|
3883
|
+
.then((res) => res.data);
|
|
3884
|
+
const currentFiltersId = currentFilters.map((f) => f.id);
|
|
3885
|
+
const filtersUpdatedId = filters.value.map((f) => f.id);
|
|
3886
|
+
const filterToBeDeleted = currentFiltersId.filter((c) => !filtersUpdatedId.includes(c));
|
|
3887
|
+
const filterToBeInserted = filtersUpdatedId.filter((c) => !currentFiltersId.includes(c));
|
|
3888
|
+
for (const filter of filterToBeDeleted) {
|
|
3889
|
+
const index = currentFilters.findIndex((f) => f.id == filter);
|
|
3890
|
+
if (index != -1) {
|
|
3891
|
+
currentFilters.splice(index, 1);
|
|
3892
|
+
}
|
|
3893
|
+
yield this.categoryFilterRepository.deleteByCategoryAndFilter(categoryId, filter);
|
|
3894
|
+
}
|
|
3895
|
+
for (const filter of filterToBeInserted) {
|
|
3896
|
+
const newCategoryFilter = yield this.categoryFilterRepository.create({
|
|
3897
|
+
filterId: filter,
|
|
3898
|
+
categoryId,
|
|
3899
|
+
});
|
|
3900
|
+
filtersList.push(filter);
|
|
3901
|
+
}
|
|
3902
|
+
return filters.value;
|
|
3903
|
+
}
|
|
3904
|
+
if (Array.isArray(filters) && filters.length) {
|
|
3905
|
+
yield this.categoryFilterRepository.deleteByCategory(categoryId);
|
|
3906
|
+
let filtersList = [];
|
|
3907
|
+
for (let i = 0; i < filters.length; i++) {
|
|
3908
|
+
const newCategoryFilter = yield this.categoryFilterRepository.create({
|
|
3909
|
+
filterId: filters[i].id,
|
|
3910
|
+
categoryId,
|
|
3911
|
+
});
|
|
3912
|
+
filtersList.push(newCategoryFilter);
|
|
3913
|
+
}
|
|
3914
|
+
return filters;
|
|
3915
|
+
}
|
|
3916
|
+
});
|
|
3917
|
+
}
|
|
3918
|
+
getChildren(parentId) {
|
|
3919
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
3920
|
+
const { category_tree } = yield this.query('category_tree', ['id', 'name', 'parent_id'], {
|
|
3921
|
+
args: {
|
|
3922
|
+
type: 'category_tree_args',
|
|
3923
|
+
value: { parentid: parentId },
|
|
3924
|
+
required: true,
|
|
3925
|
+
},
|
|
3926
|
+
});
|
|
3927
|
+
return category_tree.map((category) => Category.toInstance(category));
|
|
3928
|
+
});
|
|
3929
|
+
}
|
|
3930
|
+
isChild(id, parentId) {
|
|
3931
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
3932
|
+
const categoryTree = yield this.getChildren(parentId);
|
|
3933
|
+
return categoryTree.some((c) => c.id == id.toString());
|
|
3934
|
+
});
|
|
3935
|
+
}
|
|
3936
|
+
}
|
|
3937
|
+
|
|
3938
|
+
class FilterHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
3939
|
+
constructor({ endpoint, authOptions, interceptors, }, filterOptionRepository, categoryFilterRepository) {
|
|
3940
|
+
super({
|
|
3941
|
+
tableName: 'filter',
|
|
3942
|
+
model: Filter,
|
|
3943
|
+
endpoint,
|
|
3944
|
+
authOptions,
|
|
3945
|
+
interceptors,
|
|
3946
|
+
fields: [
|
|
3947
|
+
'id',
|
|
3948
|
+
'description',
|
|
3949
|
+
'slug',
|
|
3950
|
+
'enabled',
|
|
3951
|
+
{ createdAt: { columnName: 'created_at' } },
|
|
3952
|
+
{ updatedAt: { columnName: 'updated_at' } },
|
|
3953
|
+
{
|
|
3954
|
+
options: {
|
|
3955
|
+
columnName: 'options',
|
|
3956
|
+
foreignKeyColumn: { filterId: 'id' },
|
|
3957
|
+
fields: [
|
|
3958
|
+
'id',
|
|
3959
|
+
{ filterId: { columnName: 'filter_id' } },
|
|
3960
|
+
'description',
|
|
3961
|
+
{ createdAt: { columnName: 'created_at' } },
|
|
3962
|
+
{ updatedAt: { columnName: 'updated_at' } },
|
|
3963
|
+
],
|
|
3964
|
+
},
|
|
3965
|
+
},
|
|
3966
|
+
],
|
|
3967
|
+
});
|
|
3968
|
+
this.filterOptionRepository = filterOptionRepository;
|
|
3969
|
+
this.categoryFilterRepository = categoryFilterRepository;
|
|
3970
|
+
}
|
|
3971
|
+
update(params) {
|
|
3972
|
+
const _super = Object.create(null, {
|
|
3973
|
+
update: { get: () => super.update }
|
|
3974
|
+
});
|
|
3975
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
3976
|
+
const { options } = params, data = __rest(params, ["options"]);
|
|
3977
|
+
const filter = yield _super.update.call(this, data);
|
|
3978
|
+
filter.options = yield this.updateOptions(+data.id, { options });
|
|
3979
|
+
return filter;
|
|
3980
|
+
});
|
|
3981
|
+
}
|
|
3982
|
+
updateOptions(filterId, { options }) {
|
|
3983
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
3984
|
+
if (!options)
|
|
3985
|
+
return [];
|
|
3986
|
+
if ('action' in options && options.action === 'remove' && options.value.length) {
|
|
3987
|
+
for (let i = 0; i < options.value.length; i++) {
|
|
3988
|
+
yield this.filterOptionRepository.delete({ id: options.value[i].id });
|
|
3989
|
+
}
|
|
3990
|
+
return [];
|
|
3991
|
+
}
|
|
3992
|
+
if ('action' in options && options.action === 'merge' && options.value.length) {
|
|
3993
|
+
let filterOptions = [];
|
|
3994
|
+
for (let i = 0; i < options.value.length; i++) {
|
|
3995
|
+
try {
|
|
3996
|
+
const hasFilter = yield this.filterOptionRepository.get({ id: options.value[i].id });
|
|
3997
|
+
if (hasFilter)
|
|
3998
|
+
filterOptions.push(hasFilter);
|
|
3999
|
+
}
|
|
4000
|
+
catch (error) {
|
|
4001
|
+
const newOption = yield this.filterOptionRepository.create(Object.assign(Object.assign({}, options.value[i]), { filterId }));
|
|
4002
|
+
filterOptions.push(newOption);
|
|
4003
|
+
}
|
|
4004
|
+
}
|
|
4005
|
+
return filterOptions;
|
|
4006
|
+
}
|
|
4007
|
+
if (Array.isArray(options) && options.length) {
|
|
4008
|
+
let filterOptions = [];
|
|
4009
|
+
for (let i = 0; i < options.length; i++) {
|
|
4010
|
+
try {
|
|
4011
|
+
const hasFilter = yield this.filterOptionRepository.get({ id: options[i].id });
|
|
4012
|
+
if (hasFilter)
|
|
4013
|
+
filterOptions.push(hasFilter);
|
|
4014
|
+
}
|
|
4015
|
+
catch (error) {
|
|
4016
|
+
const newOption = yield this.filterOptionRepository.create(Object.assign(Object.assign({}, options[i]), { filterId }));
|
|
4017
|
+
filterOptions.push(newOption);
|
|
4018
|
+
}
|
|
4019
|
+
}
|
|
4020
|
+
}
|
|
4021
|
+
return [];
|
|
4022
|
+
});
|
|
4023
|
+
}
|
|
4024
|
+
delete(params) {
|
|
4025
|
+
const _super = Object.create(null, {
|
|
4026
|
+
delete: { get: () => super.delete }
|
|
4027
|
+
});
|
|
4028
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
4029
|
+
const { data: categoryFilters } = yield this.categoryFilterRepository.find({
|
|
4030
|
+
filters: {
|
|
4031
|
+
filterId: params.id,
|
|
4032
|
+
},
|
|
4033
|
+
});
|
|
4034
|
+
if (categoryFilters.length)
|
|
4035
|
+
throw new Error('Erro: o filtro está associado a uma ou mais categoria(s)');
|
|
4036
|
+
yield this.deleteOptions(+params.id);
|
|
4037
|
+
yield _super.delete.call(this, { id: +params.id });
|
|
4038
|
+
return;
|
|
4039
|
+
});
|
|
4040
|
+
}
|
|
4041
|
+
deleteOptions(filterId) {
|
|
4042
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
4043
|
+
yield this.mutation('delete_filter_option', ['affected_rows'], {
|
|
4044
|
+
where: {
|
|
4045
|
+
type: 'filter_option_bool_exp',
|
|
4046
|
+
required: true,
|
|
4047
|
+
value: { filter_id: { _eq: filterId } },
|
|
4048
|
+
},
|
|
4049
|
+
});
|
|
4050
|
+
});
|
|
4051
|
+
}
|
|
4052
|
+
}
|
|
4053
|
+
|
|
4054
|
+
class FilterOptionHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
4055
|
+
constructor({ endpoint, authOptions, interceptors, }) {
|
|
4056
|
+
super({
|
|
4057
|
+
tableName: 'filter_option',
|
|
4058
|
+
model: FilterOption,
|
|
4059
|
+
endpoint,
|
|
4060
|
+
authOptions,
|
|
4061
|
+
interceptors,
|
|
4062
|
+
fields: [
|
|
4063
|
+
'id',
|
|
4064
|
+
'description',
|
|
4065
|
+
{ filterId: { columnName: 'filter_id' } },
|
|
4066
|
+
{ createdAt: { columnName: 'created_at' } },
|
|
4067
|
+
{ updatedAt: { columnName: 'updated_at' } },
|
|
4068
|
+
],
|
|
4069
|
+
});
|
|
4070
|
+
}
|
|
2785
4071
|
}
|
|
2786
4072
|
|
|
2787
4073
|
class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
@@ -2814,26 +4100,29 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
2814
4100
|
whoMustUse: data.who_must_use,
|
|
2815
4101
|
howToUse: data.how_to_use,
|
|
2816
4102
|
brand: data.brand_description,
|
|
4103
|
+
ingredients: data.ingredients,
|
|
2817
4104
|
}),
|
|
2818
|
-
bindFindFilter: (
|
|
2819
|
-
|
|
2820
|
-
return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, ((filters === null || filters === void 0 ? void 0 : filters.description) && { description: filters.description })), (filters.differentials && { differentials: filters.differentials })), (filters.whoMustUse && {
|
|
4105
|
+
bindFindFilter: (filters) => {
|
|
4106
|
+
return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, ((filters === null || filters === void 0 ? void 0 : filters.description) && { description: filters.description })), (filters.differentials && { differentials: filters.differentials })), (filters.whoMustUse && {
|
|
2821
4107
|
who_must_use: filters.whoMustUse,
|
|
2822
4108
|
})), (filters.howToUse && {
|
|
2823
4109
|
how_to_use: filters.howToUse,
|
|
2824
4110
|
})), (filters.brand && {
|
|
2825
4111
|
brand_description: filters.brand,
|
|
4112
|
+
})), (filters.ingredients && {
|
|
4113
|
+
ingredients: filters.ingredients,
|
|
2826
4114
|
}));
|
|
2827
4115
|
},
|
|
2828
|
-
bindPersistData: (descriptionData) => (Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, ((descriptionData === null || descriptionData === void 0 ? void 0 : descriptionData.description) && { description: descriptionData.description })), (descriptionData.differentials && { differentials: descriptionData.differentials })), (descriptionData.whoMustUse && {
|
|
4116
|
+
bindPersistData: (descriptionData) => (Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, ((descriptionData === null || descriptionData === void 0 ? void 0 : descriptionData.description) && { description: descriptionData.description })), (descriptionData.differentials && { differentials: descriptionData.differentials })), (descriptionData.whoMustUse && {
|
|
2829
4117
|
who_must_use: descriptionData.whoMustUse,
|
|
2830
|
-
})), (descriptionData.howToUse && { how_to_use: descriptionData.howToUse })), (descriptionData.brand && { brand_description: descriptionData.brand }))),
|
|
4118
|
+
})), (descriptionData.howToUse && { how_to_use: descriptionData.howToUse })), (descriptionData.brand && { brand_description: descriptionData.brand })), (descriptionData.ingredients && { ingredients: descriptionData.ingredients }))),
|
|
2831
4119
|
},
|
|
2832
4120
|
},
|
|
2833
4121
|
{ differentials: { columnName: 'differentials' } },
|
|
2834
4122
|
{ whoMustUse: { columnName: 'who_must_use' } },
|
|
2835
4123
|
{ howToUse: { columnName: 'how_to_use' } },
|
|
2836
4124
|
{ brandDescription: { columnName: 'brand_description' } },
|
|
4125
|
+
{ ingredients: { columnName: 'ingredients' } },
|
|
2837
4126
|
{ hasVariants: { columnName: 'has_variants' } },
|
|
2838
4127
|
{
|
|
2839
4128
|
images: {
|
|
@@ -2857,8 +4146,7 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
2857
4146
|
subscriberDiscountPercentage: data.subscriber_discount_percentage,
|
|
2858
4147
|
subscriberPrice: data.subscriber_price,
|
|
2859
4148
|
}),
|
|
2860
|
-
bindFindFilter: (
|
|
2861
|
-
const filters = Object.values(sentence).shift();
|
|
4149
|
+
bindFindFilter: (filters) => {
|
|
2862
4150
|
return Object.assign(Object.assign(Object.assign(Object.assign({}, (((filters === null || filters === void 0 ? void 0 : filters.price) || (filters === null || filters === void 0 ? void 0 : filters.price) === 0) && { price: filters.price })), ((filters.fullPrice || filters.fullPrice === 0) && { full_price: filters.fullPrice })), ((filters.subscriberDiscountPercentage || filters.subscriberDiscountPercentage === 0) && {
|
|
2863
4151
|
subscriber_discount_percentage: filters.subscriberDiscountPercentage,
|
|
2864
4152
|
})), ((filters.subscriberPrice || filters.subscriberPrice === 0) && {
|
|
@@ -2882,27 +4170,29 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
2882
4170
|
to: (value) => (isNil(value === null || value === void 0 ? void 0 : value.quantity) ? value : value === null || value === void 0 ? void 0 : value.quantity),
|
|
2883
4171
|
},
|
|
2884
4172
|
},
|
|
4173
|
+
{ hasStock: { columnName: 'has_stock' } },
|
|
2885
4174
|
'slug',
|
|
2886
4175
|
'type',
|
|
2887
4176
|
'video',
|
|
2888
4177
|
'weight',
|
|
2889
4178
|
'gender',
|
|
4179
|
+
{ intGender: { columnName: 'int_gender' } },
|
|
2890
4180
|
{ tags: { columnName: 'tags', type: HasuraGraphQLColumnType.Jsonb } },
|
|
4181
|
+
{ filters: { columnName: 'filters', type: HasuraGraphQLColumnType.Jsonb } },
|
|
2891
4182
|
{ isKit: { columnName: 'is_kit' } },
|
|
2892
4183
|
{ createdAt: { columnName: 'created_at' } },
|
|
2893
4184
|
{ updatedAt: { columnName: 'updated_at' } },
|
|
4185
|
+
{ rate: { columnName: 'rating' } },
|
|
4186
|
+
{ reviewsTotal: { columnName: 'reviews_total' } },
|
|
4187
|
+
{ shoppingCount: { columnName: 'shopping_count' } },
|
|
4188
|
+
{ categoryId: { columnName: 'category_id' } },
|
|
2894
4189
|
{
|
|
2895
|
-
|
|
2896
|
-
columnName: '
|
|
2897
|
-
|
|
2898
|
-
|
|
2899
|
-
filterType: 'product_review_bool_exp',
|
|
2900
|
-
},
|
|
2901
|
-
fields: [{ aggregate: [{ avg: ['rate'] }] }],
|
|
2902
|
-
from: (value) => value.aggregate.avg.rate,
|
|
4190
|
+
category: {
|
|
4191
|
+
columnName: 'category',
|
|
4192
|
+
foreignKeyColumn: { id: 'categoryId' },
|
|
4193
|
+
fields: ['id', 'name', 'reference', 'slug'],
|
|
2903
4194
|
},
|
|
2904
4195
|
},
|
|
2905
|
-
{ shoppingCount: { columnName: 'shopping_count' } },
|
|
2906
4196
|
];
|
|
2907
4197
|
this.fields = [
|
|
2908
4198
|
...commonFields,
|
|
@@ -2989,7 +4279,7 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
2989
4279
|
var _a;
|
|
2990
4280
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2991
4281
|
const product = Number.isNaN(+identifiers.id)
|
|
2992
|
-
? (_a = (yield this.find({ filters: { firestoreId: identifiers.id } })).data) === null || _a === void 0 ? void 0 : _a[0]
|
|
4282
|
+
? (_a = (yield this.find({ filters: { firestoreId: identifiers.id }, options: { enableCount: false } })).data) === null || _a === void 0 ? void 0 : _a[0]
|
|
2993
4283
|
: yield _super.get.call(this, identifiers);
|
|
2994
4284
|
if (product.productId)
|
|
2995
4285
|
throw new NotFoundError('Product not found, it is a variant');
|
|
@@ -3001,13 +4291,29 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
3001
4291
|
const _super = Object.create(null, {
|
|
3002
4292
|
find: { get: () => super.find }
|
|
3003
4293
|
});
|
|
4294
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
3004
4295
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3005
|
-
const
|
|
4296
|
+
const _o = params || {}, { filters, fields } = _o, options = __rest(_o, ["filters", "fields"]);
|
|
3006
4297
|
const bindFields = fields ||
|
|
3007
4298
|
this.fields
|
|
3008
4299
|
.map((field) => (typeof field === 'string' ? field : Object.keys(field).shift()))
|
|
3009
4300
|
.filter((field) => field !== 'reviews');
|
|
3010
|
-
|
|
4301
|
+
if ((_b = (_a = options.options) === null || _a === void 0 ? void 0 : _a.minimal) === null || _b === void 0 ? void 0 : _b.includes('price'))
|
|
4302
|
+
(_c = options.options) === null || _c === void 0 ? void 0 : _c.minimal.push('price.price', 'price.fullPrice', 'price.subscriberPrice');
|
|
4303
|
+
if ((_e = (_d = options.options) === null || _d === void 0 ? void 0 : _d.maximum) === null || _e === void 0 ? void 0 : _e.includes('price'))
|
|
4304
|
+
(_f = options.options) === null || _f === void 0 ? void 0 : _f.maximum.push('price.price', 'price.fullPrice', 'price.subscriberPrice');
|
|
4305
|
+
(_h = (_g = options.options) === null || _g === void 0 ? void 0 : _g.minimal) === null || _h === void 0 ? void 0 : _h.splice((_j = options.options) === null || _j === void 0 ? void 0 : _j.minimal.indexOf('price'), 1);
|
|
4306
|
+
(_l = (_k = options.options) === null || _k === void 0 ? void 0 : _k.maximum) === null || _l === void 0 ? void 0 : _l.splice((_m = options.options) === null || _m === void 0 ? void 0 : _m.maximum.indexOf('price'), 1);
|
|
4307
|
+
return _super.find.call(this, Object.assign(Object.assign({}, options), { filters: Object.assign(Object.assign({}, filters), { productId: { operator: Where.ISNULL } }), fields: [
|
|
4308
|
+
...bindFields,
|
|
4309
|
+
...(bindFields.includes('price')
|
|
4310
|
+
? [
|
|
4311
|
+
'subscriberPrice',
|
|
4312
|
+
'subscriberDiscountPercentage',
|
|
4313
|
+
'fullPrice',
|
|
4314
|
+
]
|
|
4315
|
+
: []),
|
|
4316
|
+
] }));
|
|
3011
4317
|
});
|
|
3012
4318
|
}
|
|
3013
4319
|
getBySlug(slug) {
|
|
@@ -3017,9 +4323,13 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
3017
4323
|
filters: {
|
|
3018
4324
|
slug,
|
|
3019
4325
|
},
|
|
4326
|
+
fields: this.fields.map((field) => typeof field === 'string' ? field : Object.keys(field).shift()),
|
|
4327
|
+
options: {
|
|
4328
|
+
enableCount: false,
|
|
4329
|
+
},
|
|
3020
4330
|
});
|
|
3021
4331
|
const product = (_a = result === null || result === void 0 ? void 0 : result.data) === null || _a === void 0 ? void 0 : _a.shift();
|
|
3022
|
-
|
|
4332
|
+
RoundProductPricesHelper.roundProductPrices(product);
|
|
3023
4333
|
return product;
|
|
3024
4334
|
});
|
|
3025
4335
|
}
|
|
@@ -3059,6 +4369,11 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
3059
4369
|
], []);
|
|
3060
4370
|
});
|
|
3061
4371
|
}
|
|
4372
|
+
findCatalog(params, mainGender) {
|
|
4373
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
4374
|
+
return this.find(Object.assign(Object.assign({}, params), { filters: Object.assign(Object.assign({}, params.filters), { published: true }), orderBy: Object.assign(Object.assign({ hasStock: 'desc' }, (!mainGender ? {} : { intGender: mainGender === 'female' ? 'desc' : 'asc' })), omit(params.orderBy, ['hasStock', 'intGender'])) }));
|
|
4375
|
+
});
|
|
4376
|
+
}
|
|
3062
4377
|
updateCategories(productId, { categories }) {
|
|
3063
4378
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3064
4379
|
if ('action' in categories && categories.action === 'remove') {
|
|
@@ -3182,7 +4497,7 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
3182
4497
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3183
4498
|
if (!Number.isNaN(+id))
|
|
3184
4499
|
return id;
|
|
3185
|
-
const { data } = yield this.find({ filters: { firestoreId: id } });
|
|
4500
|
+
const { data } = yield this.find({ filters: { firestoreId: id }, options: { enableCount: false } });
|
|
3186
4501
|
if ((_a = data === null || data === void 0 ? void 0 : data[0]) === null || _a === void 0 ? void 0 : _a.id)
|
|
3187
4502
|
return (_b = data === null || data === void 0 ? void 0 : data[0]) === null || _b === void 0 ? void 0 : _b.id;
|
|
3188
4503
|
throw new NotFoundError(`Product with id ${id} not found`);
|
|
@@ -3238,6 +4553,21 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
3238
4553
|
return data && data[0] && this.bindReviewToModel(data[0]);
|
|
3239
4554
|
});
|
|
3240
4555
|
}
|
|
4556
|
+
cleanShoppingCountFromIds(ids) {
|
|
4557
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
4558
|
+
return yield this.mutation('update_product', ['affected_rows'], {
|
|
4559
|
+
where: {
|
|
4560
|
+
value: { id: { _nin: ids } },
|
|
4561
|
+
type: 'product_bool_exp',
|
|
4562
|
+
required: true,
|
|
4563
|
+
},
|
|
4564
|
+
_set: {
|
|
4565
|
+
value: { shopping_count: 0 },
|
|
4566
|
+
type: 'product_set_input',
|
|
4567
|
+
},
|
|
4568
|
+
});
|
|
4569
|
+
});
|
|
4570
|
+
}
|
|
3241
4571
|
}
|
|
3242
4572
|
|
|
3243
4573
|
class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
@@ -3270,7 +4600,7 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
3270
4600
|
subscriberPrice: data.subscriber_price,
|
|
3271
4601
|
}),
|
|
3272
4602
|
bindFindFilter: (sentence) => {
|
|
3273
|
-
const filters = Object.values(sentence
|
|
4603
|
+
const filters = Object.values(sentence).shift();
|
|
3274
4604
|
return Object.assign(Object.assign(Object.assign(Object.assign({}, (((filters === null || filters === void 0 ? void 0 : filters.price) || (filters === null || filters === void 0 ? void 0 : filters.price) === 0) && { price: filters.price })), ((filters.fullPrice || filters.fullPrice === 0) && { full_price: filters.fullPrice })), ((filters.subscriberDiscountPercentage || filters.subscriberDiscountPercentage === 0) && {
|
|
3275
4605
|
subscriber_discount_percentage: filters.subscriberDiscountPercentage,
|
|
3276
4606
|
})), ((filters.subscriberPrice || filters.subscriberPrice === 0) && {
|
|
@@ -3293,6 +4623,7 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
3293
4623
|
to: (value) => (isNil(value === null || value === void 0 ? void 0 : value.quantity) ? value : value === null || value === void 0 ? void 0 : value.quantity),
|
|
3294
4624
|
},
|
|
3295
4625
|
},
|
|
4626
|
+
{ hasStock: { columnName: 'has_stock' } },
|
|
3296
4627
|
'weight',
|
|
3297
4628
|
{ name: { to: () => '', from: () => undefined } },
|
|
3298
4629
|
{ hasVariants: { columnName: 'has_variants', to: () => false, from: () => undefined } },
|
|
@@ -3348,7 +4679,7 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
3348
4679
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3349
4680
|
if (!Number.isNaN(+id))
|
|
3350
4681
|
return id;
|
|
3351
|
-
const { data } = yield this.find({ filters: { firestoreId: id } });
|
|
4682
|
+
const { data } = yield this.find({ filters: { firestoreId: id }, options: { enableCount: false } });
|
|
3352
4683
|
if ((_a = data === null || data === void 0 ? void 0 : data[0]) === null || _a === void 0 ? void 0 : _a.id)
|
|
3353
4684
|
return (_b = data === null || data === void 0 ? void 0 : data[0]) === null || _b === void 0 ? void 0 : _b.id;
|
|
3354
4685
|
throw new NotFoundError(`Product with id ${id} not found`);
|
|
@@ -3356,9 +4687,256 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
3356
4687
|
}
|
|
3357
4688
|
}
|
|
3358
4689
|
|
|
4690
|
+
class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
4691
|
+
constructor({ endpoint, authOptions, interceptors, }, categoryFilterRepository) {
|
|
4692
|
+
super({
|
|
4693
|
+
tableName: 'category',
|
|
4694
|
+
model: Wishlist,
|
|
4695
|
+
endpoint,
|
|
4696
|
+
authOptions,
|
|
4697
|
+
interceptors,
|
|
4698
|
+
fields: [
|
|
4699
|
+
{ id: { columnName: 'id', to: (value) => +value, from: (value) => value.toString() } },
|
|
4700
|
+
{ firestoreId: { columnName: 'firestore_id' } },
|
|
4701
|
+
'name',
|
|
4702
|
+
'description',
|
|
4703
|
+
'image',
|
|
4704
|
+
'published',
|
|
4705
|
+
'shop',
|
|
4706
|
+
{ shops: { columnName: 'shops', type: HasuraGraphQLColumnType.Jsonb } },
|
|
4707
|
+
'slug',
|
|
4708
|
+
{ brandCategory: { columnName: 'brand_category' } },
|
|
4709
|
+
{ brandCategoryBanner: { columnName: 'brand_banner' } },
|
|
4710
|
+
{ brandCategoryBannerMobile: { columnName: 'brand_banner_mobile' } },
|
|
4711
|
+
{ brandLogo: { columnName: 'brand_logo' } },
|
|
4712
|
+
{ brandCondition: { columnName: 'brand_condition' } },
|
|
4713
|
+
{
|
|
4714
|
+
conditions: {
|
|
4715
|
+
columnName: 'tag_condition',
|
|
4716
|
+
type: HasuraGraphQLColumnType.Jsonb,
|
|
4717
|
+
from: (tags, row) => ({ brand: row.brand_condition, tags: Array.isArray(tags) ? tags : [] }),
|
|
4718
|
+
bindPersistData: (value) => {
|
|
4719
|
+
return {
|
|
4720
|
+
brand_condition: value.brand,
|
|
4721
|
+
tag_condition: (value === null || value === void 0 ? void 0 : value.tags) || [],
|
|
4722
|
+
};
|
|
4723
|
+
},
|
|
4724
|
+
bindFindFilter: (sentence) => {
|
|
4725
|
+
return Object.assign(Object.assign({}, (sentence.brand ? { brand_condition: sentence.brand } : {})), (sentence.tags ? { tag_condition: sentence.tags } : {}));
|
|
4726
|
+
},
|
|
4727
|
+
},
|
|
4728
|
+
},
|
|
4729
|
+
{
|
|
4730
|
+
filters: {
|
|
4731
|
+
columnName: 'filters',
|
|
4732
|
+
foreignKeyColumn: { filter_id: 'id' },
|
|
4733
|
+
fields: [{ filter: ['id', 'description', 'slug', 'enabled'] }],
|
|
4734
|
+
bindPersistData: (value) => ({
|
|
4735
|
+
filters: { data: value.map((filter) => ({ filter_id: filter.id })) },
|
|
4736
|
+
}),
|
|
4737
|
+
from: (filters) => (filters === null || filters === void 0 ? void 0 : filters.map((filter) => filter === null || filter === void 0 ? void 0 : filter.filter)) || [],
|
|
4738
|
+
},
|
|
4739
|
+
},
|
|
4740
|
+
{ createdAt: { columnName: 'created_at' } },
|
|
4741
|
+
{ updatedAt: { columnName: 'updated_at' } },
|
|
4742
|
+
{
|
|
4743
|
+
products: {
|
|
4744
|
+
columnName: 'products',
|
|
4745
|
+
fields: ['product_id'],
|
|
4746
|
+
from: (value) => value.map((product) => product.product_id.toString()),
|
|
4747
|
+
to: (productIds) => productIds.map((productId) => ({
|
|
4748
|
+
product_id: +productId,
|
|
4749
|
+
})),
|
|
4750
|
+
},
|
|
4751
|
+
},
|
|
4752
|
+
{
|
|
4753
|
+
metadata: {
|
|
4754
|
+
columnName: 'metadata',
|
|
4755
|
+
fields: ['title', 'description'],
|
|
4756
|
+
bindPersistData: (value) => ({
|
|
4757
|
+
metadata: { data: value },
|
|
4758
|
+
}),
|
|
4759
|
+
},
|
|
4760
|
+
},
|
|
4761
|
+
{ isCollection: { columnName: 'is_collection' } },
|
|
4762
|
+
{ isWishlist: { columnName: 'is_wishlist' } },
|
|
4763
|
+
'reference',
|
|
4764
|
+
{ parentId: { columnName: 'parent_id' } },
|
|
4765
|
+
{
|
|
4766
|
+
parent: {
|
|
4767
|
+
columnName: 'parent',
|
|
4768
|
+
foreignKeyColumn: { id: 'parentId' },
|
|
4769
|
+
fields: ['id', 'name', 'reference', 'slug'],
|
|
4770
|
+
},
|
|
4771
|
+
},
|
|
4772
|
+
{ personId: { columnName: 'person_id' } },
|
|
4773
|
+
],
|
|
4774
|
+
});
|
|
4775
|
+
this.categoryFilterRepository = categoryFilterRepository;
|
|
4776
|
+
}
|
|
4777
|
+
create(params) {
|
|
4778
|
+
const _super = Object.create(null, {
|
|
4779
|
+
create: { get: () => super.create }
|
|
4780
|
+
});
|
|
4781
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
4782
|
+
const { metadata } = params, data = __rest(params, ["metadata"]);
|
|
4783
|
+
return _super.create.call(this, Object.assign(Object.assign({}, data), { isWishlist: true, isCollection: true, brandCategory: false, metadata: metadata || { description: data.description, title: data.name } }));
|
|
4784
|
+
});
|
|
4785
|
+
}
|
|
4786
|
+
get(identifiers) {
|
|
4787
|
+
const _super = Object.create(null, {
|
|
4788
|
+
get: { get: () => super.get }
|
|
4789
|
+
});
|
|
4790
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
4791
|
+
const data = yield _super.get.call(this, identifiers);
|
|
4792
|
+
if (!data.isWishlist)
|
|
4793
|
+
throw new NotFoundError(`Category with id ${identifiers.id} is not a wishlist`);
|
|
4794
|
+
return data;
|
|
4795
|
+
});
|
|
4796
|
+
}
|
|
4797
|
+
update(params) {
|
|
4798
|
+
const _super = Object.create(null, {
|
|
4799
|
+
update: { get: () => super.update }
|
|
4800
|
+
});
|
|
4801
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
4802
|
+
const { products, id: checkId, metadata, filters } = params, data = __rest(params, ["products", "id", "metadata", "filters"]);
|
|
4803
|
+
const plainData = this.paramsToPlain({ id: checkId });
|
|
4804
|
+
const id = plainData.id;
|
|
4805
|
+
const category = yield _super.update.call(this, Object.assign(Object.assign({ id }, data), { isWishlist: true, isCollection: true, brandCategory: false }));
|
|
4806
|
+
category.products = products && (yield this.updateProducts(+id, { products }));
|
|
4807
|
+
category.metadata = metadata && (yield this.updateMetadata(+id, { metadata }));
|
|
4808
|
+
return category;
|
|
4809
|
+
});
|
|
4810
|
+
}
|
|
4811
|
+
getWishlistBySlug(slug) {
|
|
4812
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
4813
|
+
if (!slug)
|
|
4814
|
+
return;
|
|
4815
|
+
const { data } = yield this.find({
|
|
4816
|
+
filters: {
|
|
4817
|
+
slug,
|
|
4818
|
+
isWishlist: { operator: Where.EQUALS, value: true },
|
|
4819
|
+
},
|
|
4820
|
+
options: {
|
|
4821
|
+
enableCount: false,
|
|
4822
|
+
},
|
|
4823
|
+
});
|
|
4824
|
+
if (!data.length)
|
|
4825
|
+
throw new NotFoundError(`Wishlist with slug ${slug} not found`);
|
|
4826
|
+
if (data.length > 1)
|
|
4827
|
+
throw new DuplicatedResultsError('Query returned duplicated values');
|
|
4828
|
+
return data.shift();
|
|
4829
|
+
});
|
|
4830
|
+
}
|
|
4831
|
+
getWishlistByPerson(personId) {
|
|
4832
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
4833
|
+
if (!personId)
|
|
4834
|
+
return;
|
|
4835
|
+
const { data } = yield this.find({
|
|
4836
|
+
filters: {
|
|
4837
|
+
personId: { operator: Where.EQUALS, value: personId },
|
|
4838
|
+
isWishlist: { operator: Where.EQUALS, value: true },
|
|
4839
|
+
},
|
|
4840
|
+
options: {
|
|
4841
|
+
enableCount: false,
|
|
4842
|
+
},
|
|
4843
|
+
});
|
|
4844
|
+
if (!data.length)
|
|
4845
|
+
throw new NotFoundError(`Wishlists from person ${personId} not found`);
|
|
4846
|
+
return data;
|
|
4847
|
+
});
|
|
4848
|
+
}
|
|
4849
|
+
updateProducts(categoryId, { products }) {
|
|
4850
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
4851
|
+
if ('action' in products && products.action === 'remove') {
|
|
4852
|
+
yield this.mutation('delete_category_product', ['affected_rows'], {
|
|
4853
|
+
where: {
|
|
4854
|
+
type: 'category_product_bool_exp',
|
|
4855
|
+
required: true,
|
|
4856
|
+
value: { category_id: { _eq: categoryId } },
|
|
4857
|
+
},
|
|
4858
|
+
});
|
|
4859
|
+
yield this.categoryFilterRepository.deleteByCategory(categoryId);
|
|
4860
|
+
return [];
|
|
4861
|
+
}
|
|
4862
|
+
const plainData = this.paramsToPlain({ products });
|
|
4863
|
+
if (!plainData.products || plainData.products.length <= 0)
|
|
4864
|
+
return [];
|
|
4865
|
+
yield this.mutation('delete_category_product', ['affected_rows'], {
|
|
4866
|
+
where: {
|
|
4867
|
+
type: 'category_product_bool_exp',
|
|
4868
|
+
required: true,
|
|
4869
|
+
value: { category_id: { _eq: categoryId } },
|
|
4870
|
+
},
|
|
4871
|
+
});
|
|
4872
|
+
yield this.categoryFilterRepository.deleteByCategory(categoryId);
|
|
4873
|
+
yield this.mutation('insert_category_product', ['affected_rows'], {
|
|
4874
|
+
objects: {
|
|
4875
|
+
type: '[category_product_insert_input!]',
|
|
4876
|
+
required: true,
|
|
4877
|
+
value: plainData.products.map((productId) => ({ category_id: categoryId, product_id: productId })),
|
|
4878
|
+
},
|
|
4879
|
+
});
|
|
4880
|
+
return plainData.products;
|
|
4881
|
+
});
|
|
4882
|
+
}
|
|
4883
|
+
updateMetadata(categoryId, { metadata }) {
|
|
4884
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
4885
|
+
const plainData = this.paramsToPlain({ metadata });
|
|
4886
|
+
if (!plainData.metadata)
|
|
4887
|
+
return;
|
|
4888
|
+
yield this.mutation('update_category_metadata_by_pk', ['category_id'], {
|
|
4889
|
+
pk_columns: {
|
|
4890
|
+
value: { category_id: categoryId },
|
|
4891
|
+
type: 'category_metadata_pk_columns_input',
|
|
4892
|
+
required: true,
|
|
4893
|
+
},
|
|
4894
|
+
_set: {
|
|
4895
|
+
value: omit(metadata, ['category_id']),
|
|
4896
|
+
type: 'category_metadata_set_input',
|
|
4897
|
+
required: true,
|
|
4898
|
+
},
|
|
4899
|
+
});
|
|
4900
|
+
return plainData.metadata;
|
|
4901
|
+
});
|
|
4902
|
+
}
|
|
4903
|
+
getCategoryBySlug(slug, _shop) {
|
|
4904
|
+
return this.getWishlistBySlug(slug);
|
|
4905
|
+
}
|
|
4906
|
+
getCategoryByShop(shop) {
|
|
4907
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
4908
|
+
if (!shop)
|
|
4909
|
+
return;
|
|
4910
|
+
const { data } = yield this.find({
|
|
4911
|
+
filters: {
|
|
4912
|
+
shops: { operator: Where.IN, value: [shop] },
|
|
4913
|
+
published: { operator: Where.EQUALS, value: true },
|
|
4914
|
+
isWishlist: { operator: Where.EQUALS, value: true },
|
|
4915
|
+
},
|
|
4916
|
+
options: {
|
|
4917
|
+
enableCount: false,
|
|
4918
|
+
},
|
|
4919
|
+
});
|
|
4920
|
+
return data;
|
|
4921
|
+
});
|
|
4922
|
+
}
|
|
4923
|
+
getCategoriesForHome(categoryIds, limit, gender) {
|
|
4924
|
+
return;
|
|
4925
|
+
}
|
|
4926
|
+
mountCategory(category, options) {
|
|
4927
|
+
return;
|
|
4928
|
+
}
|
|
4929
|
+
getChildren(parentId) {
|
|
4930
|
+
return;
|
|
4931
|
+
}
|
|
4932
|
+
isChild(id, parentId) {
|
|
4933
|
+
return;
|
|
4934
|
+
}
|
|
4935
|
+
}
|
|
4936
|
+
|
|
3359
4937
|
/**
|
|
3360
4938
|
* Generated bundle index. Do not edit.
|
|
3361
4939
|
*/
|
|
3362
4940
|
|
|
3363
|
-
export { AccessoryImportances, Address, Area, Authentication, AuthenticationFirebaseAuthService, AxiosAdapter, Base, BaseModel, BeardProblems, BeardSizes, BeautyProductImportances, BeautyProfile, BeautyQuestionsHelper, BillingStatus, BodyProblems, BodyShapes, BodyTattoos, Buy2Win, Buy2WinFirestoreRepository, Category, CategoryFirestoreRepository, CategoryHasuraGraphQL, CategoryHasuraGraphQLRepository, Checkout, CheckoutFirestoreRepository, CheckoutSubscription, CheckoutSubscriptionFirestoreRepository, CheckoutTypes, Coupon, CouponFirestoreRepository, CouponSubtypes, CouponTypes, DuplicatedResultsError, Edition, EditionStatus, Exclusivities, FaceSkinOilinesses, FaceSkinProblems, FaceSkinTones, FamilyIncomes, 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, 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,
|
|
4941
|
+
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, is, isDebuggable, isUUID, parseDateTime, withCreateFirestore, withCreateHasuraGraphQL, withCrudFirestore, withCrudHasuraGraphQL, withDeleteFirestore, withDeleteHasuraGraphQL, withFindFirestore, withFindHasuraGraphQL, withFirestore, withGetFirestore, withGetHasuraGraphQL, withHasuraGraphQL, withHelpers, withSubCollection, withUpdateFirestore, withUpdateHasuraGraphQL };
|
|
3364
4942
|
//# sourceMappingURL=infrab4a-connect.mjs.map
|