@infrab4a/connect 4.0.0-beta.5 → 4.0.0-beta.50
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/auth/authentication-firebase-auth.service.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 -24
- 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 +131 -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 +70 -20
- package/esm2020/infra/hasura-graphql/repositories/catalog/variant-hasura-graphql.repository.mjs +9 -7
- 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 -4
- package/esm2020/utils/log.utils.mjs +9 -0
- package/fesm2015/infrab4a-connect.mjs +2000 -422
- package/fesm2015/infrab4a-connect.mjs.map +1 -1
- package/fesm2020/infrab4a-connect.mjs +1966 -425
- 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 -3
- 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 +12 -5
- 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 +4 -4
- 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 -22
- 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,19 +3,21 @@ 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
|
|
7
|
-
|
|
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';
|
|
11
13
|
import { signInWithEmailAndPassword, signInWithPopup, GoogleAuthProvider, signInAnonymously, sendPasswordResetEmail, createUserWithEmailAndPassword, sendEmailVerification } from 'firebase/auth';
|
|
12
14
|
import { mutation, query as query$1 } from 'gql-query-builder';
|
|
13
|
-
import fetch from 'node-fetch';
|
|
14
15
|
|
|
15
16
|
class BaseModel {
|
|
16
17
|
get identifier() {
|
|
17
18
|
const fields = this.constructor.identifiersFields.filter((field) => field !== 'identifier');
|
|
18
|
-
|
|
19
|
+
const data = this;
|
|
20
|
+
return fields.reduce((object, field) => (Object.assign(Object.assign({}, object), { [field]: data[field] })), {});
|
|
19
21
|
}
|
|
20
22
|
get identifiersFields() {
|
|
21
23
|
return this.constructor.identifiersFields;
|
|
@@ -461,11 +463,437 @@ __decorate([
|
|
|
461
463
|
__metadata("design:type", Payment)
|
|
462
464
|
], SubscriptionPayment.prototype, "payment", void 0);
|
|
463
465
|
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
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();
|
|
467
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
|
+
};
|
|
468
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
|
+
};
|
|
469
897
|
|
|
470
898
|
const get = (object, path, defaultValue) => get$1(object, path, defaultValue);
|
|
471
899
|
|
|
@@ -473,7 +901,7 @@ function is(value) {
|
|
|
473
901
|
return value;
|
|
474
902
|
}
|
|
475
903
|
|
|
476
|
-
const isUUID = (value) => isString
|
|
904
|
+
const isUUID = (value) => isString(value) && /[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}/.test(value);
|
|
477
905
|
|
|
478
906
|
class Base {
|
|
479
907
|
constructor(...args) {
|
|
@@ -482,7 +910,7 @@ class Base {
|
|
|
482
910
|
}
|
|
483
911
|
|
|
484
912
|
const parseDateTime = (value) => {
|
|
485
|
-
if (!isString
|
|
913
|
+
if (!isString(value))
|
|
486
914
|
return value;
|
|
487
915
|
if (!/^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])$/.test(value) &&
|
|
488
916
|
!/^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])T\d{2}:\d{2}:\d{2}/.test(value))
|
|
@@ -493,8 +921,6 @@ const parseDateTime = (value) => {
|
|
|
493
921
|
return date;
|
|
494
922
|
};
|
|
495
923
|
|
|
496
|
-
const { chunk, isBoolean, isDate, isEmpty, isInteger, isNaN: isNaN$1, isNil, isNumber, isObject, isString, now, omit, pick, set, } = lodash;
|
|
497
|
-
|
|
498
924
|
var CheckoutTypes;
|
|
499
925
|
(function (CheckoutTypes) {
|
|
500
926
|
CheckoutTypes[CheckoutTypes["ECOMMERCE"] = 1] = "ECOMMERCE";
|
|
@@ -539,26 +965,28 @@ class Coupon extends BaseModel {
|
|
|
539
965
|
static createCoupon(userId) {
|
|
540
966
|
return this.toInstance({
|
|
541
967
|
nickname: `${Date.now()}`,
|
|
542
|
-
type: CouponTypes.ABSOLUTE,
|
|
543
968
|
checkoutType: CheckoutTypes.ECOMMERCE,
|
|
544
|
-
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
|
+
},
|
|
545
983
|
user: userId,
|
|
546
|
-
useLimit: 1,
|
|
547
|
-
useLimitPerUser: true,
|
|
548
984
|
createdAt: new Date(Date.now()),
|
|
549
985
|
beginAt: new Date(Date.now()),
|
|
550
986
|
expiresIn: new Date(Date.now() + COUPON_EXPIRATION),
|
|
551
987
|
});
|
|
552
988
|
}
|
|
553
989
|
}
|
|
554
|
-
__decorate([
|
|
555
|
-
Expose({ name: 'checkout_type' }),
|
|
556
|
-
__metadata("design:type", Number)
|
|
557
|
-
], Coupon.prototype, "checkoutType", void 0);
|
|
558
|
-
__decorate([
|
|
559
|
-
Expose({ name: 'exclusivity_type' }),
|
|
560
|
-
__metadata("design:type", Number)
|
|
561
|
-
], Coupon.prototype, "exclusivityType", void 0);
|
|
562
990
|
|
|
563
991
|
class SubscriptionPlan extends BaseModel {
|
|
564
992
|
static get identifiersFields() {
|
|
@@ -598,6 +1026,18 @@ __decorate([
|
|
|
598
1026
|
__metadata("design:type", BeautyProfile)
|
|
599
1027
|
], User.prototype, "beautyProfile", void 0);
|
|
600
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
|
+
|
|
601
1041
|
class Subscription extends BaseModel {
|
|
602
1042
|
static get identifiersFields() {
|
|
603
1043
|
return ['id'];
|
|
@@ -612,12 +1052,12 @@ __decorate([
|
|
|
612
1052
|
__metadata("design:type", SubscriptionPlan)
|
|
613
1053
|
], Subscription.prototype, "subscriptionPlan", void 0);
|
|
614
1054
|
__decorate([
|
|
615
|
-
Type(() =>
|
|
616
|
-
__metadata("design:type",
|
|
1055
|
+
Type(() => UserAddress),
|
|
1056
|
+
__metadata("design:type", UserAddress)
|
|
617
1057
|
], Subscription.prototype, "shippingAddress", void 0);
|
|
618
1058
|
__decorate([
|
|
619
|
-
Type(() =>
|
|
620
|
-
__metadata("design:type",
|
|
1059
|
+
Type(() => UserAddress),
|
|
1060
|
+
__metadata("design:type", UserAddress)
|
|
621
1061
|
], Subscription.prototype, "billingAddress", void 0);
|
|
622
1062
|
__decorate([
|
|
623
1063
|
Type(() => Coupon),
|
|
@@ -632,12 +1072,6 @@ __decorate([
|
|
|
632
1072
|
__metadata("design:type", Array)
|
|
633
1073
|
], Subscription.prototype, "payment", void 0);
|
|
634
1074
|
|
|
635
|
-
class UserAddress extends Address {
|
|
636
|
-
static get identifiersFields() {
|
|
637
|
-
return ['id', 'userId'];
|
|
638
|
-
}
|
|
639
|
-
}
|
|
640
|
-
|
|
641
1075
|
class UserPaymentMethod extends BaseModel {
|
|
642
1076
|
static get identifiersFields() {
|
|
643
1077
|
return ['id', 'userId'];
|
|
@@ -670,7 +1104,7 @@ class Authentication {
|
|
|
670
1104
|
return __awaiter(this, void 0, void 0, function* () {
|
|
671
1105
|
const method = this.getServiceByMethod(signInMethod);
|
|
672
1106
|
const userAuth = yield this.authService[method]({ email, password });
|
|
673
|
-
const user = this.userRepository.get(userAuth);
|
|
1107
|
+
const user = this.userRepository.get({ id: userAuth.id });
|
|
674
1108
|
if (!isNil(user))
|
|
675
1109
|
return user;
|
|
676
1110
|
if (/^.+@b4a.com.br$/.test(userAuth.email))
|
|
@@ -757,14 +1191,123 @@ class RecoveryPassword {
|
|
|
757
1191
|
}
|
|
758
1192
|
}
|
|
759
1193
|
|
|
760
|
-
class
|
|
761
|
-
|
|
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() {
|
|
762
1280
|
return ['id'];
|
|
763
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 {
|
|
764
1299
|
static get identifiersFields() {
|
|
765
1300
|
return ['id'];
|
|
766
1301
|
}
|
|
767
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);
|
|
768
1311
|
|
|
769
1312
|
var GenderDestination;
|
|
770
1313
|
(function (GenderDestination) {
|
|
@@ -781,53 +1324,59 @@ var Shops;
|
|
|
781
1324
|
Shops["ALL"] = "ALL";
|
|
782
1325
|
})(Shops || (Shops = {}));
|
|
783
1326
|
|
|
784
|
-
class
|
|
785
|
-
|
|
1327
|
+
class FilterOption extends BaseModel {
|
|
1328
|
+
static get identifiersFields() {
|
|
786
1329
|
return ['id'];
|
|
787
1330
|
}
|
|
1331
|
+
}
|
|
1332
|
+
|
|
1333
|
+
class Product extends ProductBase {
|
|
788
1334
|
static get identifiersFields() {
|
|
789
1335
|
return ['id'];
|
|
790
1336
|
}
|
|
791
1337
|
}
|
|
1338
|
+
__decorate([
|
|
1339
|
+
Type(() => CategoryForProduct),
|
|
1340
|
+
__metadata("design:type", CategoryForProduct)
|
|
1341
|
+
], Product.prototype, "category", void 0);
|
|
792
1342
|
__decorate([
|
|
793
1343
|
Type(() => KitProduct),
|
|
794
1344
|
__metadata("design:type", Array)
|
|
795
1345
|
], Product.prototype, "kitProducts", void 0);
|
|
796
1346
|
|
|
797
|
-
class
|
|
1347
|
+
class Variant extends BaseModel {
|
|
798
1348
|
static get identifiersFields() {
|
|
799
|
-
return ['
|
|
1349
|
+
return ['id', 'productId'];
|
|
800
1350
|
}
|
|
801
1351
|
}
|
|
802
|
-
__decorate([
|
|
803
|
-
Type(() => Product),
|
|
804
|
-
__metadata("design:type", Product)
|
|
805
|
-
], KitProduct.prototype, "kit", void 0);
|
|
806
|
-
__decorate([
|
|
807
|
-
Type(() => Product),
|
|
808
|
-
__metadata("design:type", Product)
|
|
809
|
-
], KitProduct.prototype, "product", void 0);
|
|
810
1352
|
|
|
811
|
-
class
|
|
812
|
-
|
|
1353
|
+
class Wishlist extends Category {
|
|
1354
|
+
static get identifiersFields() {
|
|
813
1355
|
return ['id'];
|
|
814
1356
|
}
|
|
1357
|
+
}
|
|
1358
|
+
|
|
1359
|
+
class Buy2Win extends BaseModel {
|
|
815
1360
|
static get identifiersFields() {
|
|
816
|
-
return ['id'
|
|
1361
|
+
return ['id'];
|
|
817
1362
|
}
|
|
818
1363
|
}
|
|
1364
|
+
__decorate([
|
|
1365
|
+
Type(() => Category),
|
|
1366
|
+
__metadata("design:type", Array)
|
|
1367
|
+
], Buy2Win.prototype, "categories", void 0);
|
|
819
1368
|
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
}
|
|
1369
|
+
class CampaignDashboard extends BaseModel {
|
|
1370
|
+
static get identifiersFields() {
|
|
1371
|
+
return ['id'];
|
|
1372
|
+
}
|
|
1373
|
+
}
|
|
1374
|
+
|
|
1375
|
+
class CampaignHashtag extends BaseModel {
|
|
1376
|
+
static get identifiersFields() {
|
|
1377
|
+
return ['id'];
|
|
1378
|
+
}
|
|
1379
|
+
}
|
|
831
1380
|
|
|
832
1381
|
class LineItem extends Product {
|
|
833
1382
|
}
|
|
@@ -852,12 +1401,12 @@ __decorate([
|
|
|
852
1401
|
__metadata("design:type", User)
|
|
853
1402
|
], Checkout.prototype, "user", void 0);
|
|
854
1403
|
__decorate([
|
|
855
|
-
Type(() =>
|
|
856
|
-
__metadata("design:type",
|
|
1404
|
+
Type(() => UserAddress),
|
|
1405
|
+
__metadata("design:type", UserAddress)
|
|
857
1406
|
], Checkout.prototype, "shippingAddress", void 0);
|
|
858
1407
|
__decorate([
|
|
859
|
-
Type(() =>
|
|
860
|
-
__metadata("design:type",
|
|
1408
|
+
Type(() => UserAddress),
|
|
1409
|
+
__metadata("design:type", UserAddress)
|
|
861
1410
|
], Checkout.prototype, "billingAddress", void 0);
|
|
862
1411
|
__decorate([
|
|
863
1412
|
Type(() => ShippingMethod),
|
|
@@ -868,6 +1417,18 @@ __decorate([
|
|
|
868
1417
|
__metadata("design:type", Coupon)
|
|
869
1418
|
], Checkout.prototype, "coupon", void 0);
|
|
870
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
|
+
|
|
871
1432
|
class Order extends Checkout {
|
|
872
1433
|
}
|
|
873
1434
|
__decorate([
|
|
@@ -881,12 +1442,12 @@ class CheckoutSubscription extends BaseModel {
|
|
|
881
1442
|
}
|
|
882
1443
|
}
|
|
883
1444
|
__decorate([
|
|
884
|
-
Type(() =>
|
|
885
|
-
__metadata("design:type",
|
|
1445
|
+
Type(() => UserAddress),
|
|
1446
|
+
__metadata("design:type", UserAddress)
|
|
886
1447
|
], CheckoutSubscription.prototype, "shippingAddress", void 0);
|
|
887
1448
|
__decorate([
|
|
888
|
-
Type(() =>
|
|
889
|
-
__metadata("design:type",
|
|
1449
|
+
Type(() => UserAddress),
|
|
1450
|
+
__metadata("design:type", UserAddress)
|
|
890
1451
|
], CheckoutSubscription.prototype, "billingAddress", void 0);
|
|
891
1452
|
__decorate([
|
|
892
1453
|
Type(() => SubscriptionPlan),
|
|
@@ -897,15 +1458,19 @@ __decorate([
|
|
|
897
1458
|
__metadata("design:type", Coupon)
|
|
898
1459
|
], CheckoutSubscription.prototype, "coupon", void 0);
|
|
899
1460
|
|
|
900
|
-
class
|
|
901
|
-
static
|
|
902
|
-
|
|
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;
|
|
903
1472
|
}
|
|
904
1473
|
}
|
|
905
|
-
__decorate([
|
|
906
|
-
Type(() => Category),
|
|
907
|
-
__metadata("design:type", Array)
|
|
908
|
-
], Buy2Win.prototype, "categories", void 0);
|
|
909
1474
|
|
|
910
1475
|
var FilterType;
|
|
911
1476
|
(function (FilterType) {
|
|
@@ -1006,6 +1571,12 @@ class ShopMenu extends BaseModel {
|
|
|
1006
1571
|
}
|
|
1007
1572
|
}
|
|
1008
1573
|
|
|
1574
|
+
class ShopSettings extends BaseModel {
|
|
1575
|
+
static get identifiersFields() {
|
|
1576
|
+
return ['id'];
|
|
1577
|
+
}
|
|
1578
|
+
}
|
|
1579
|
+
|
|
1009
1580
|
class InvalidArgumentError extends CustomError {
|
|
1010
1581
|
constructor(message) {
|
|
1011
1582
|
super(message);
|
|
@@ -1036,13 +1607,17 @@ class AxiosAdapter {
|
|
|
1036
1607
|
constructor(config) {
|
|
1037
1608
|
this.config = config;
|
|
1038
1609
|
}
|
|
1039
|
-
get(index) {
|
|
1610
|
+
get(index, id) {
|
|
1040
1611
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1041
1612
|
try {
|
|
1042
1613
|
const { data } = yield axios({
|
|
1043
|
-
url: `${this.config.url}/${index}`,
|
|
1614
|
+
url: `${this.config.url}/${index}/_doc/${id}`,
|
|
1044
1615
|
method: 'GET',
|
|
1045
|
-
|
|
1616
|
+
responseType: 'json',
|
|
1617
|
+
headers: {
|
|
1618
|
+
'Content-Type': 'application/json',
|
|
1619
|
+
Authorization: `ApiKey ${this.config.credential}`,
|
|
1620
|
+
},
|
|
1046
1621
|
});
|
|
1047
1622
|
return data._source;
|
|
1048
1623
|
}
|
|
@@ -1056,9 +1631,14 @@ class AxiosAdapter {
|
|
|
1056
1631
|
query(index, query) {
|
|
1057
1632
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1058
1633
|
const { data } = yield axios({
|
|
1059
|
-
url: `${this.config.url}/${index}`,
|
|
1634
|
+
url: `${this.config.url}/${index}/_search`,
|
|
1060
1635
|
method: 'POST',
|
|
1061
|
-
|
|
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
|
+
},
|
|
1062
1642
|
data: query,
|
|
1063
1643
|
});
|
|
1064
1644
|
return {
|
|
@@ -1070,19 +1650,29 @@ class AxiosAdapter {
|
|
|
1070
1650
|
save(index, data) {
|
|
1071
1651
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1072
1652
|
yield axios({
|
|
1073
|
-
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}`,
|
|
1074
1664
|
method: 'PUT',
|
|
1075
|
-
headers: { Authorization: `
|
|
1665
|
+
headers: { Authorization: `ApiKey ${this.config.credential}` },
|
|
1076
1666
|
data,
|
|
1077
1667
|
});
|
|
1078
1668
|
});
|
|
1079
1669
|
}
|
|
1080
|
-
delete(index) {
|
|
1670
|
+
delete(index, id) {
|
|
1081
1671
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1082
1672
|
yield axios({
|
|
1083
|
-
url: `${this.config.url}/${index}`,
|
|
1673
|
+
url: `${this.config.url}/${index}/_doc/${id}`,
|
|
1084
1674
|
method: 'DELETE',
|
|
1085
|
-
headers: { Authorization: `
|
|
1675
|
+
headers: { Authorization: `ApiKey ${this.config.credential}` },
|
|
1086
1676
|
});
|
|
1087
1677
|
});
|
|
1088
1678
|
}
|
|
@@ -1091,16 +1681,19 @@ class AxiosAdapter {
|
|
|
1091
1681
|
class ProductsIndex {
|
|
1092
1682
|
constructor(adapter) {
|
|
1093
1683
|
this.adapter = adapter;
|
|
1684
|
+
this.index = `products`;
|
|
1094
1685
|
}
|
|
1095
|
-
|
|
1686
|
+
getById(id) {
|
|
1096
1687
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1097
|
-
const data = yield this.adapter.get(
|
|
1688
|
+
const data = yield this.adapter.get(this.index, id);
|
|
1098
1689
|
return Product.toInstance(data);
|
|
1099
1690
|
});
|
|
1100
1691
|
}
|
|
1101
|
-
|
|
1692
|
+
search(searchTerm, total, shop) {
|
|
1102
1693
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1694
|
+
const size = total || 9;
|
|
1103
1695
|
const fields = [
|
|
1696
|
+
'EAN',
|
|
1104
1697
|
'brand',
|
|
1105
1698
|
'id',
|
|
1106
1699
|
'images',
|
|
@@ -1111,73 +1704,88 @@ class ProductsIndex {
|
|
|
1111
1704
|
'stock',
|
|
1112
1705
|
'slug',
|
|
1113
1706
|
'reviews',
|
|
1114
|
-
'pricePaid',
|
|
1115
|
-
'isGift',
|
|
1116
|
-
'stock',
|
|
1117
|
-
'weight',
|
|
1118
|
-
'tags',
|
|
1119
1707
|
'hasVariants',
|
|
1120
|
-
'
|
|
1708
|
+
'rate',
|
|
1121
1709
|
];
|
|
1122
|
-
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: {
|
|
1123
1721
|
bool: {
|
|
1124
|
-
|
|
1125
|
-
{
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
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,
|
|
1129
1738
|
},
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1739
|
+
},
|
|
1740
|
+
should: {
|
|
1741
|
+
match_phrase_prefix: {
|
|
1742
|
+
'name.search': {
|
|
1743
|
+
query: `${searchTerm}`,
|
|
1744
|
+
slop: 10,
|
|
1133
1745
|
},
|
|
1134
1746
|
},
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
{
|
|
1138
|
-
range: {
|
|
1139
|
-
'stock.quantity': {
|
|
1140
|
-
gt: 0,
|
|
1141
|
-
},
|
|
1142
|
-
},
|
|
1143
|
-
},
|
|
1144
|
-
]
|
|
1145
|
-
: []),
|
|
1146
|
-
],
|
|
1747
|
+
},
|
|
1748
|
+
filter,
|
|
1147
1749
|
},
|
|
1148
|
-
}
|
|
1149
|
-
|
|
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;
|
|
1150
1759
|
});
|
|
1151
1760
|
}
|
|
1152
1761
|
save(product) {
|
|
1153
1762
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1154
|
-
delete product.createdAt;
|
|
1155
|
-
delete product.updatedAt;
|
|
1156
|
-
delete product.kitProducts;
|
|
1157
1763
|
try {
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
yield this.get(product.firestoreId);
|
|
1161
|
-
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);
|
|
1162
1766
|
}
|
|
1163
1767
|
catch (error) {
|
|
1164
|
-
|
|
1165
|
-
throw error;
|
|
1166
|
-
console.error(error.message);
|
|
1167
|
-
yield this.adapter.save(`products/_doc/${product.id}`, product.toPlain());
|
|
1768
|
+
console.error(error);
|
|
1168
1769
|
}
|
|
1169
1770
|
});
|
|
1170
1771
|
}
|
|
1171
|
-
|
|
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) {
|
|
1172
1783
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1173
|
-
if (!product.firestoreId)
|
|
1174
|
-
return;
|
|
1175
1784
|
try {
|
|
1176
|
-
yield this.
|
|
1177
|
-
yield this.adapter.delete(`products/_doc/${product.firestoreId}`);
|
|
1785
|
+
yield this.adapter.delete(this.index, id);
|
|
1178
1786
|
}
|
|
1179
1787
|
catch (error) {
|
|
1180
|
-
|
|
1788
|
+
console.error(error);
|
|
1181
1789
|
}
|
|
1182
1790
|
});
|
|
1183
1791
|
}
|
|
@@ -1205,17 +1813,39 @@ const withFirestore = (MixinBase) => {
|
|
|
1205
1813
|
? data[key].map((element) => (isObjectsAndNoDate(element) ? bindAllDateFromObject(element) : element))
|
|
1206
1814
|
: bindDate(data[key], key) })), {});
|
|
1207
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
|
+
};
|
|
1208
1827
|
return class extends MixinBase {
|
|
1209
|
-
constructor() {
|
|
1210
|
-
super(...
|
|
1828
|
+
constructor(...params) {
|
|
1829
|
+
super(...params);
|
|
1830
|
+
this.fields = {};
|
|
1831
|
+
this.interceptors = {};
|
|
1211
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;
|
|
1212
1839
|
}
|
|
1213
1840
|
collection(path) {
|
|
1214
1841
|
return collection(this.firestore, path || this.collectionName).withConverter(this.buildModelInstance());
|
|
1215
1842
|
}
|
|
1216
1843
|
buildModelInstance() {
|
|
1217
1844
|
return {
|
|
1218
|
-
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
|
+
},
|
|
1219
1849
|
fromFirestore: (snap) => {
|
|
1220
1850
|
const data = snap.data();
|
|
1221
1851
|
let bindedData = null;
|
|
@@ -1255,12 +1885,16 @@ const withHelpers = (MixinBase) => {
|
|
|
1255
1885
|
const withGetFirestore = (MixinBase) => {
|
|
1256
1886
|
return class GetFirestore extends MixinBase {
|
|
1257
1887
|
get(identifiers) {
|
|
1888
|
+
var _a, _b, _c, _d;
|
|
1258
1889
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1259
|
-
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()));
|
|
1260
1894
|
const data = docRef.data();
|
|
1261
1895
|
if (isNil(data))
|
|
1262
1896
|
throw new NotFoundError(`Document ${JSON.stringify(identifiers)} not found`);
|
|
1263
|
-
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;
|
|
1264
1898
|
});
|
|
1265
1899
|
}
|
|
1266
1900
|
buildCollectionPathForGet(identifiers) {
|
|
@@ -1298,7 +1932,7 @@ const withFindFirestore = (MixinBase) => {
|
|
|
1298
1932
|
], []);
|
|
1299
1933
|
this.buildWhereSentence = (fieldName, options) => {
|
|
1300
1934
|
if (this.isSubCollection(this) && fieldName === this.parentIdField)
|
|
1301
|
-
[];
|
|
1935
|
+
return [];
|
|
1302
1936
|
const value = (options === null || options === void 0 ? void 0 : options.value) || options;
|
|
1303
1937
|
const object = {};
|
|
1304
1938
|
set(object, fieldName, value);
|
|
@@ -1339,9 +1973,13 @@ const withFindFirestore = (MixinBase) => {
|
|
|
1339
1973
|
return Object.keys(fieldsToOrderBy).map((fieldName) => orderBy(fieldName, fieldsToOrderBy[fieldName]));
|
|
1340
1974
|
};
|
|
1341
1975
|
}
|
|
1342
|
-
find(
|
|
1976
|
+
find(find = {}) {
|
|
1977
|
+
var _a, _b, _c, _d, _e, _f;
|
|
1343
1978
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1344
|
-
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;
|
|
1345
1983
|
const queries = this.makeFirestoreWhere(filters || {});
|
|
1346
1984
|
const ordination = this.makeFirestoreOrderBy(filters, orderBy);
|
|
1347
1985
|
const offsets = yield this.defineLimits(filters, limits);
|
|
@@ -1349,8 +1987,8 @@ const withFindFirestore = (MixinBase) => {
|
|
|
1349
1987
|
const docs = yield getDocs(query(collection, ...queryArgumments));
|
|
1350
1988
|
const data = docs.docs.map((doc) => doc.data());
|
|
1351
1989
|
return {
|
|
1352
|
-
data,
|
|
1353
|
-
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,
|
|
1354
1992
|
};
|
|
1355
1993
|
});
|
|
1356
1994
|
}
|
|
@@ -1362,11 +2000,12 @@ const withFindFirestore = (MixinBase) => {
|
|
|
1362
2000
|
return `${this.parentRepository.collectionName}/${parentId}/${this.collectionName}`;
|
|
1363
2001
|
}
|
|
1364
2002
|
defineLimits(filters, limits) {
|
|
2003
|
+
var _a;
|
|
1365
2004
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1366
2005
|
const queries = [];
|
|
1367
2006
|
if (limits === null || limits === void 0 ? void 0 : limits.offset) {
|
|
1368
2007
|
if (this.model.isModel(limits.offset))
|
|
1369
|
-
queries.push(startAfter(yield getDoc(doc(this.collection(this.buildCollectionPathForFind(filters)), limits.offset.identifier.shift()))));
|
|
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()))));
|
|
1370
2009
|
else if (isNumber(limits.offset) || isString(limits.offset))
|
|
1371
2010
|
queries.push(startAt(limits.offset));
|
|
1372
2011
|
}
|
|
@@ -1388,16 +2027,21 @@ const withFindFirestore = (MixinBase) => {
|
|
|
1388
2027
|
const withCreateFirestore = (MixinBase) => {
|
|
1389
2028
|
return class CreateFirestore extends MixinBase {
|
|
1390
2029
|
create(data) {
|
|
2030
|
+
var _a, _b, _c, _d;
|
|
1391
2031
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1392
|
-
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);
|
|
1393
2036
|
const doc = yield getDoc(docRef);
|
|
1394
|
-
|
|
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;
|
|
1395
2039
|
});
|
|
1396
2040
|
}
|
|
1397
2041
|
save(data) {
|
|
1398
2042
|
var _a, _b;
|
|
1399
2043
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1400
|
-
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();
|
|
1401
2045
|
const collectionPath = this.buildCollectionPathForAdd(data);
|
|
1402
2046
|
const collection = this.collection(collectionPath);
|
|
1403
2047
|
if (isEmpty(id))
|
|
@@ -1439,13 +2083,17 @@ const withUpdateFirestore = (MixinBase) => {
|
|
|
1439
2083
|
};
|
|
1440
2084
|
return class UpdateFirestore extends MixinBase {
|
|
1441
2085
|
update(data) {
|
|
2086
|
+
var _a, _b, _c, _d;
|
|
1442
2087
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1443
2088
|
const model = new this.model();
|
|
1444
2089
|
const keyField = model.identifiersFields.shift();
|
|
1445
2090
|
const docRef = doc(this.collection(this.buildCollectionPathForUpdate(data)), getValueFromParams(data, keyField).toString());
|
|
1446
|
-
|
|
1447
|
-
const
|
|
1448
|
-
|
|
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;
|
|
1449
2097
|
});
|
|
1450
2098
|
}
|
|
1451
2099
|
buildCollectionPathForUpdate(identifiers) {
|
|
@@ -1465,8 +2113,13 @@ const withUpdateFirestore = (MixinBase) => {
|
|
|
1465
2113
|
const withDeleteFirestore = (MixinBase) => {
|
|
1466
2114
|
return class DeleteFirestore extends MixinBase {
|
|
1467
2115
|
delete(identifiers) {
|
|
2116
|
+
var _a, _b, _c, _d;
|
|
1468
2117
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1469
|
-
|
|
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));
|
|
1470
2123
|
});
|
|
1471
2124
|
}
|
|
1472
2125
|
buildCollectionPathForRemove(identifiers) {
|
|
@@ -1479,8 +2132,10 @@ const withDeleteFirestore = (MixinBase) => {
|
|
|
1479
2132
|
|
|
1480
2133
|
const withSubCollection = (MixinBase, ParentModel) => {
|
|
1481
2134
|
return class SubCollectionMix extends MixinBase {
|
|
1482
|
-
constructor(...
|
|
1483
|
-
|
|
2135
|
+
constructor(...params) {
|
|
2136
|
+
const options = params[0];
|
|
2137
|
+
super(...params);
|
|
2138
|
+
this.parentIdField = options.parentIdField;
|
|
1484
2139
|
}
|
|
1485
2140
|
collection(path) {
|
|
1486
2141
|
return super.collection(path);
|
|
@@ -1494,73 +2149,87 @@ const withCrudFirestore = (MixinBase) => {
|
|
|
1494
2149
|
};
|
|
1495
2150
|
|
|
1496
2151
|
class LeadFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1497
|
-
constructor(firestore) {
|
|
1498
|
-
super(
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
2152
|
+
constructor({ firestore, interceptors }) {
|
|
2153
|
+
super({
|
|
2154
|
+
firestore,
|
|
2155
|
+
collectionName: 'leads',
|
|
2156
|
+
model: Lead,
|
|
2157
|
+
interceptors,
|
|
2158
|
+
});
|
|
1502
2159
|
}
|
|
1503
2160
|
}
|
|
1504
2161
|
|
|
1505
2162
|
class SubscriptionEditionFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), Subscription) {
|
|
1506
|
-
constructor(firestore, parentRepository) {
|
|
1507
|
-
super(
|
|
1508
|
-
|
|
2163
|
+
constructor({ firestore, interceptors }, parentRepository) {
|
|
2164
|
+
super({
|
|
2165
|
+
firestore,
|
|
2166
|
+
collectionName: 'editions',
|
|
2167
|
+
parentIdField: 'subscriptionId',
|
|
2168
|
+
model: Edition,
|
|
2169
|
+
interceptors,
|
|
2170
|
+
});
|
|
1509
2171
|
this.parentRepository = parentRepository;
|
|
1510
|
-
this.collectionName = 'editions';
|
|
1511
|
-
this.parentIdField = 'subscriptionId';
|
|
1512
|
-
this.model = Edition;
|
|
1513
2172
|
}
|
|
1514
2173
|
}
|
|
1515
2174
|
|
|
1516
2175
|
class SubscriptionFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1517
|
-
constructor(firestore) {
|
|
1518
|
-
super(
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
2176
|
+
constructor({ firestore, interceptors, }) {
|
|
2177
|
+
super({
|
|
2178
|
+
firestore,
|
|
2179
|
+
collectionName: 'subscription',
|
|
2180
|
+
model: Subscription,
|
|
2181
|
+
interceptors,
|
|
2182
|
+
});
|
|
1522
2183
|
}
|
|
1523
2184
|
}
|
|
1524
2185
|
|
|
1525
2186
|
class SubscriptionPaymentFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), Subscription) {
|
|
1526
|
-
constructor(firestore, parentRepository) {
|
|
1527
|
-
super(
|
|
1528
|
-
|
|
2187
|
+
constructor({ firestore, interceptors }, parentRepository) {
|
|
2188
|
+
super({
|
|
2189
|
+
firestore,
|
|
2190
|
+
collectionName: 'payments',
|
|
2191
|
+
parentIdField: 'subscriptionId',
|
|
2192
|
+
model: SubscriptionPayment,
|
|
2193
|
+
interceptors,
|
|
2194
|
+
});
|
|
1529
2195
|
this.parentRepository = parentRepository;
|
|
1530
|
-
this.collectionName = 'payments';
|
|
1531
|
-
this.parentIdField = 'subscriptionId';
|
|
1532
|
-
this.model = SubscriptionPayment;
|
|
1533
2196
|
}
|
|
1534
2197
|
}
|
|
1535
2198
|
|
|
1536
2199
|
class UserAddressFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), User) {
|
|
1537
|
-
constructor(firestore, parentRepository) {
|
|
1538
|
-
super(
|
|
1539
|
-
|
|
2200
|
+
constructor({ firestore, interceptors }, parentRepository) {
|
|
2201
|
+
super({
|
|
2202
|
+
firestore,
|
|
2203
|
+
collectionName: 'address',
|
|
2204
|
+
parentIdField: 'userId',
|
|
2205
|
+
model: UserAddress,
|
|
2206
|
+
interceptors,
|
|
2207
|
+
});
|
|
1540
2208
|
this.parentRepository = parentRepository;
|
|
1541
|
-
this.collectionName = 'address';
|
|
1542
|
-
this.parentIdField = 'userId';
|
|
1543
|
-
this.model = UserAddress;
|
|
1544
2209
|
}
|
|
1545
2210
|
}
|
|
1546
2211
|
|
|
1547
2212
|
class UserBeautyProfileFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), User) {
|
|
1548
|
-
constructor(firestore, parentRepository) {
|
|
1549
|
-
super(
|
|
1550
|
-
|
|
2213
|
+
constructor({ firestore, interceptors }, parentRepository) {
|
|
2214
|
+
super({
|
|
2215
|
+
firestore,
|
|
2216
|
+
collectionName: 'CX',
|
|
2217
|
+
parentIdField: 'userId',
|
|
2218
|
+
model: BeautyProfile,
|
|
2219
|
+
interceptors,
|
|
2220
|
+
});
|
|
1551
2221
|
this.parentRepository = parentRepository;
|
|
1552
|
-
this.collectionName = 'CX';
|
|
1553
|
-
this.parentIdField = 'userId';
|
|
1554
|
-
this.model = BeautyProfile;
|
|
1555
2222
|
}
|
|
1556
2223
|
}
|
|
1557
2224
|
|
|
1558
2225
|
class UserFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1559
|
-
constructor(firestore) {
|
|
1560
|
-
super(
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
2226
|
+
constructor({ firestore, interceptors }) {
|
|
2227
|
+
super({
|
|
2228
|
+
firestore,
|
|
2229
|
+
collectionName: 'users',
|
|
2230
|
+
model: User,
|
|
2231
|
+
interceptors,
|
|
2232
|
+
});
|
|
1564
2233
|
}
|
|
1565
2234
|
get(identifiers) {
|
|
1566
2235
|
const _super = Object.create(null, {
|
|
@@ -1611,22 +2280,26 @@ class UserFirestoreRepository extends withCrudFirestore(withHelpers(withFirestor
|
|
|
1611
2280
|
}
|
|
1612
2281
|
|
|
1613
2282
|
class UserPaymentMethodFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), User) {
|
|
1614
|
-
constructor(firestore, parentRepository) {
|
|
1615
|
-
super(
|
|
1616
|
-
|
|
2283
|
+
constructor({ firestore, interceptors }, parentRepository) {
|
|
2284
|
+
super({
|
|
2285
|
+
firestore,
|
|
2286
|
+
collectionName: 'payment_method',
|
|
2287
|
+
parentIdField: 'userId',
|
|
2288
|
+
model: UserPaymentMethod,
|
|
2289
|
+
interceptors,
|
|
2290
|
+
});
|
|
1617
2291
|
this.parentRepository = parentRepository;
|
|
1618
|
-
this.collectionName = 'payment_method';
|
|
1619
|
-
this.parentIdField = 'userId';
|
|
1620
|
-
this.model = UserPaymentMethod;
|
|
1621
2292
|
}
|
|
1622
2293
|
}
|
|
1623
2294
|
|
|
1624
2295
|
class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1625
|
-
constructor(firestore) {
|
|
1626
|
-
super(
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
2296
|
+
constructor({ firestore, interceptors }) {
|
|
2297
|
+
super({
|
|
2298
|
+
firestore,
|
|
2299
|
+
collectionName: 'categories',
|
|
2300
|
+
model: Category,
|
|
2301
|
+
interceptors,
|
|
2302
|
+
});
|
|
1630
2303
|
}
|
|
1631
2304
|
getCategoryBySlug(slug, shop) {
|
|
1632
2305
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -1638,7 +2311,7 @@ class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFire
|
|
|
1638
2311
|
return categoryDocs.docs[0].data();
|
|
1639
2312
|
});
|
|
1640
2313
|
}
|
|
1641
|
-
getCategoriesForHome(categoryIds, limit = 4) {
|
|
2314
|
+
getCategoriesForHome(categoryIds, limit = 4, gender) {
|
|
1642
2315
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1643
2316
|
const categorySnap = yield getDocs(query(this.collection(this.collectionName), where('id', 'in', categoryIds.filter(Boolean)), where('published', '==', true)));
|
|
1644
2317
|
if (categorySnap.empty)
|
|
@@ -1647,7 +2320,7 @@ class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFire
|
|
|
1647
2320
|
const homeSections = yield Promise.all(categories.map((category) => __awaiter(this, void 0, void 0, function* () {
|
|
1648
2321
|
return ({
|
|
1649
2322
|
category,
|
|
1650
|
-
products: yield this.mountCategory(category, { limit, hasStock: true }),
|
|
2323
|
+
products: yield this.mountCategory(category, { limit, hasStock: true, gender }),
|
|
1651
2324
|
});
|
|
1652
2325
|
})));
|
|
1653
2326
|
return homeSections;
|
|
@@ -1666,6 +2339,8 @@ class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFire
|
|
|
1666
2339
|
wheres.push(where('published', '==', true), where('id', 'in', productIds));
|
|
1667
2340
|
if (options === null || options === void 0 ? void 0 : options.hasStock)
|
|
1668
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));
|
|
1669
2344
|
if (options === null || options === void 0 ? void 0 : options.limit)
|
|
1670
2345
|
wheres.push(limit(options === null || options === void 0 ? void 0 : options.limit));
|
|
1671
2346
|
const productSnap = yield getDocs(query(this.collection('productsErpVitrine'), ...wheres));
|
|
@@ -1676,15 +2351,26 @@ class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFire
|
|
|
1676
2351
|
return is(products);
|
|
1677
2352
|
});
|
|
1678
2353
|
}
|
|
2354
|
+
getCategoryByShop(shop) {
|
|
2355
|
+
return;
|
|
2356
|
+
}
|
|
2357
|
+
getChildren(parentId) {
|
|
2358
|
+
return;
|
|
2359
|
+
}
|
|
2360
|
+
isChild(id, parentId) {
|
|
2361
|
+
return;
|
|
2362
|
+
}
|
|
1679
2363
|
}
|
|
1680
2364
|
|
|
1681
2365
|
class ProductFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1682
|
-
constructor(firestore) {
|
|
1683
|
-
super(
|
|
1684
|
-
|
|
2366
|
+
constructor({ firestore, interceptors }) {
|
|
2367
|
+
super({
|
|
2368
|
+
firestore,
|
|
2369
|
+
collectionName: 'productsErpVitrine',
|
|
2370
|
+
model: Product,
|
|
2371
|
+
interceptors,
|
|
2372
|
+
});
|
|
1685
2373
|
this.reviews = {};
|
|
1686
|
-
this.collectionName = 'productsErpVitrine';
|
|
1687
|
-
this.model = Product;
|
|
1688
2374
|
}
|
|
1689
2375
|
getBySlug(slug) {
|
|
1690
2376
|
var _a;
|
|
@@ -1725,43 +2411,101 @@ class ProductFirestoreRepository extends withCrudFirestore(withHelpers(withFires
|
|
|
1725
2411
|
return this.reviews[status];
|
|
1726
2412
|
});
|
|
1727
2413
|
}
|
|
2414
|
+
cleanShoppingCountFromIds() {
|
|
2415
|
+
return;
|
|
2416
|
+
}
|
|
2417
|
+
findCatalog(params) {
|
|
2418
|
+
return this.find(params);
|
|
2419
|
+
}
|
|
1728
2420
|
}
|
|
1729
2421
|
|
|
1730
2422
|
class ProductVariantFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), Product) {
|
|
1731
|
-
constructor(firestore, parentRepository) {
|
|
1732
|
-
super(
|
|
1733
|
-
|
|
2423
|
+
constructor({ firestore, interceptors }, parentRepository) {
|
|
2424
|
+
super({
|
|
2425
|
+
firestore,
|
|
2426
|
+
collectionName: 'variants',
|
|
2427
|
+
parentIdField: 'productId',
|
|
2428
|
+
model: Variant,
|
|
2429
|
+
interceptors,
|
|
2430
|
+
});
|
|
1734
2431
|
this.parentRepository = parentRepository;
|
|
1735
|
-
this.collectionName = 'variants';
|
|
1736
|
-
this.parentIdField = 'productId';
|
|
1737
|
-
this.model = Variant;
|
|
1738
2432
|
}
|
|
1739
2433
|
}
|
|
1740
2434
|
|
|
1741
2435
|
class SubscriptionProductFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1742
|
-
constructor(firestore) {
|
|
1743
|
-
super(
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
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
|
+
});
|
|
1747
2476
|
}
|
|
1748
2477
|
}
|
|
1749
2478
|
|
|
1750
2479
|
class CheckoutFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1751
|
-
constructor(firestore) {
|
|
1752
|
-
super(
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
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
|
+
});
|
|
1756
2498
|
}
|
|
1757
2499
|
}
|
|
1758
2500
|
|
|
1759
2501
|
class CouponFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1760
|
-
constructor(firestore) {
|
|
1761
|
-
super(
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
2502
|
+
constructor({ firestore, interceptors }) {
|
|
2503
|
+
super({
|
|
2504
|
+
firestore,
|
|
2505
|
+
collectionName: 'coupons',
|
|
2506
|
+
model: Coupon,
|
|
2507
|
+
interceptors,
|
|
2508
|
+
});
|
|
1765
2509
|
}
|
|
1766
2510
|
buildModelInstance() {
|
|
1767
2511
|
const { fromFirestore, toFirestore } = super.buildModelInstance();
|
|
@@ -1783,9 +2527,16 @@ class CouponFirestoreRepository extends withCrudFirestore(withHelpers(withFirest
|
|
|
1783
2527
|
}
|
|
1784
2528
|
|
|
1785
2529
|
class OrderFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1786
|
-
constructor(firestore) {
|
|
1787
|
-
super(
|
|
1788
|
-
|
|
2530
|
+
constructor({ firestore, interceptors }) {
|
|
2531
|
+
super({
|
|
2532
|
+
firestore,
|
|
2533
|
+
collectionName: 'orders',
|
|
2534
|
+
model: Order,
|
|
2535
|
+
interceptors,
|
|
2536
|
+
fields: {
|
|
2537
|
+
status: FirestoreFieldType.String,
|
|
2538
|
+
},
|
|
2539
|
+
});
|
|
1789
2540
|
this.orderFromFirestore = (order) => {
|
|
1790
2541
|
var _a;
|
|
1791
2542
|
if (!!((_a = order === null || order === void 0 ? void 0 : order.lineItems) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
@@ -1799,11 +2550,6 @@ class OrderFirestoreRepository extends withCrudFirestore(withHelpers(withFiresto
|
|
|
1799
2550
|
}
|
|
1800
2551
|
return order;
|
|
1801
2552
|
};
|
|
1802
|
-
this.collectionName = 'orders';
|
|
1803
|
-
this.model = Order;
|
|
1804
|
-
this.fields = {
|
|
1805
|
-
status: FirestoreFieldType.String,
|
|
1806
|
-
};
|
|
1807
2553
|
}
|
|
1808
2554
|
buildModelInstance() {
|
|
1809
2555
|
const { fromFirestore, toFirestore } = super.buildModelInstance();
|
|
@@ -1817,86 +2563,62 @@ class OrderFirestoreRepository extends withCrudFirestore(withHelpers(withFiresto
|
|
|
1817
2563
|
}
|
|
1818
2564
|
}
|
|
1819
2565
|
|
|
1820
|
-
class
|
|
1821
|
-
constructor(firestore) {
|
|
1822
|
-
super(
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
2566
|
+
class LegacyOrderFirestoreRepository extends OrderFirestoreRepository {
|
|
2567
|
+
constructor({ firestore, interceptors }) {
|
|
2568
|
+
super({
|
|
2569
|
+
firestore,
|
|
2570
|
+
interceptors,
|
|
2571
|
+
});
|
|
2572
|
+
this.collectionName = 'legacyOrders';
|
|
1826
2573
|
}
|
|
1827
2574
|
}
|
|
1828
2575
|
|
|
1829
|
-
class
|
|
1830
|
-
constructor(firestore) {
|
|
1831
|
-
super(
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
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
|
+
});
|
|
1835
2584
|
}
|
|
1836
2585
|
}
|
|
1837
2586
|
|
|
1838
2587
|
class SubscriptionPlanFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1839
|
-
constructor(firestore) {
|
|
1840
|
-
super(
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
}
|
|
1846
|
-
|
|
1847
|
-
class Buy2WinFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1848
|
-
constructor(firestore) {
|
|
1849
|
-
super();
|
|
1850
|
-
this.firestore = firestore;
|
|
1851
|
-
this.collectionName = 'buy2win';
|
|
1852
|
-
this.model = Buy2Win;
|
|
1853
|
-
}
|
|
1854
|
-
}
|
|
1855
|
-
|
|
1856
|
-
class LegacyOrderFirestoreRepository extends OrderFirestoreRepository {
|
|
1857
|
-
constructor(firestore) {
|
|
1858
|
-
super(firestore);
|
|
1859
|
-
this.firestore = firestore;
|
|
1860
|
-
this.collectionName = 'legacyOrders';
|
|
2588
|
+
constructor({ firestore, interceptors, }) {
|
|
2589
|
+
super({
|
|
2590
|
+
firestore,
|
|
2591
|
+
collectionName: 'subscriptionPlans',
|
|
2592
|
+
model: SubscriptionPlan,
|
|
2593
|
+
interceptors,
|
|
2594
|
+
});
|
|
1861
2595
|
}
|
|
1862
2596
|
}
|
|
1863
2597
|
|
|
1864
2598
|
class HomeFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1865
|
-
constructor(firestore) {
|
|
1866
|
-
super(
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
home.data.data.discoverProducts = home.data.data.discoverProducts.map(this.homeCategoryGroupToPlain);
|
|
1872
|
-
home.data.data.featuredProducts = home.data.data.featuredProducts.map(this.homeCategoryGroupToPlain);
|
|
1873
|
-
home.data.data.verticalProducts = home.data.data.verticalProducts.map(this.homeCategoryGroupToPlain);
|
|
1874
|
-
}
|
|
1875
|
-
return home;
|
|
1876
|
-
};
|
|
1877
|
-
this.homeCategoryGroupToPlain = (homeCategoryGroup) => ({
|
|
1878
|
-
category: homeCategoryGroup.category.toPlain(),
|
|
1879
|
-
products: homeCategoryGroup.products.map((product) => product.toPlain()),
|
|
2599
|
+
constructor({ firestore, interceptors }) {
|
|
2600
|
+
super({
|
|
2601
|
+
firestore,
|
|
2602
|
+
collectionName: 'dms',
|
|
2603
|
+
model: Home,
|
|
2604
|
+
interceptors,
|
|
1880
2605
|
});
|
|
1881
|
-
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) => {
|
|
1882
2616
|
var _a;
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
home.data.createdAt =
|
|
1888
|
-
home.data.createdAt instanceof Timestamp ? home.data.createdAt.toDate() : home.data.createdAt;
|
|
1889
|
-
home.data.expiresAt =
|
|
1890
|
-
home.data.expiresAt instanceof Timestamp ? home.data.expiresAt.toDate() : home.data.expiresAt;
|
|
1891
|
-
}
|
|
1892
|
-
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
|
+
});
|
|
1893
2621
|
};
|
|
1894
|
-
this.plainToHomeCategoryGroup = (homeCategoryGroup) => ({
|
|
1895
|
-
category: Category.toInstance(homeCategoryGroup.category),
|
|
1896
|
-
products: homeCategoryGroup.products.map((product) => Product.toInstance(product)),
|
|
1897
|
-
});
|
|
1898
|
-
this.collectionName = 'dms';
|
|
1899
|
-
this.model = Home;
|
|
1900
2622
|
}
|
|
1901
2623
|
buildModelInstance() {
|
|
1902
2624
|
const { fromFirestore, toFirestore } = super.buildModelInstance();
|
|
@@ -1911,14 +2633,49 @@ class HomeFirestoreRepository extends withCrudFirestore(withHelpers(withFirestor
|
|
|
1911
2633
|
},
|
|
1912
2634
|
};
|
|
1913
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
|
+
}
|
|
1914
2658
|
}
|
|
1915
2659
|
|
|
1916
2660
|
class ShopMenuFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1917
|
-
constructor(firestore) {
|
|
1918
|
-
super(
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
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
|
+
});
|
|
1922
2679
|
}
|
|
1923
2680
|
}
|
|
1924
2681
|
|
|
@@ -2008,7 +2765,7 @@ class AttributeOptionHelper {
|
|
|
2008
2765
|
AttributeOptionHelper.FindByAttribute = (attributeName, fields) => {
|
|
2009
2766
|
var _a;
|
|
2010
2767
|
if (fields.includes(attributeName))
|
|
2011
|
-
return { columnName: attributeName.toString(), attributeName };
|
|
2768
|
+
return { columnName: attributeName.toString(), attributeName, to: (value) => value, from: (value) => value };
|
|
2012
2769
|
const field = fields.find((columnOption) => isObject(columnOption) && Object.keys(columnOption).includes(attributeName.toString()));
|
|
2013
2770
|
const fieldOption = (_a = is(field)) === null || _a === void 0 ? void 0 : _a[attributeName];
|
|
2014
2771
|
if (isNil(fieldOption))
|
|
@@ -2017,7 +2774,7 @@ AttributeOptionHelper.FindByAttribute = (attributeName, fields) => {
|
|
|
2017
2774
|
return { columnName: attributeName.toString(), attributeName, fields: fieldOption };
|
|
2018
2775
|
return Object.assign({ attributeName, columnName: attributeName.toString() }, fieldOption);
|
|
2019
2776
|
};
|
|
2020
|
-
AttributeOptionHelper.CheckIsColumnOption = (fieldValue) => !!fieldValue.columnName;
|
|
2777
|
+
AttributeOptionHelper.CheckIsColumnOption = (fieldValue) => !!(fieldValue === null || fieldValue === void 0 ? void 0 : fieldValue.columnName);
|
|
2021
2778
|
AttributeOptionHelper.FindColumnOptionFromList = (columnName, fields) => {
|
|
2022
2779
|
if (fields.includes(columnName))
|
|
2023
2780
|
return { columnName, attributeName: columnName };
|
|
@@ -2097,22 +2854,23 @@ BindFilterQueryHelper.MakeGraphQLWhere = (filter, fields) => Object.keys(filter)
|
|
|
2097
2854
|
}, {});
|
|
2098
2855
|
BindFilterQueryHelper.BuildWhereSentence = (field, options, fields) => {
|
|
2099
2856
|
const fieldSentenceOptions = AttributeOptionHelper.FindByAttribute(field, fields);
|
|
2100
|
-
|
|
2857
|
+
const isNestedField = !Array.isArray(options) &&
|
|
2101
2858
|
isObject(options) &&
|
|
2102
2859
|
isNil(options === null || options === void 0 ? void 0 : options.operator) &&
|
|
2103
2860
|
isNil(options === null || options === void 0 ? void 0 : options.value) &&
|
|
2104
|
-
isNil(fieldSentenceOptions === null || fieldSentenceOptions === void 0 ? void 0 : fieldSentenceOptions.to)
|
|
2861
|
+
isNil(fieldSentenceOptions === null || fieldSentenceOptions === void 0 ? void 0 : fieldSentenceOptions.to);
|
|
2862
|
+
if (isNestedField)
|
|
2105
2863
|
return Object.keys(options).reduce((variables, key) => {
|
|
2106
2864
|
const fieldOptions = AttributeOptionHelper.FindByAttribute(key, (fieldSentenceOptions === null || fieldSentenceOptions === void 0 ? void 0 : fieldSentenceOptions.fields) || fields);
|
|
2107
2865
|
const columnName = fieldOptions.columnName;
|
|
2108
2866
|
const columnFields = fieldOptions.fields;
|
|
2109
|
-
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) });
|
|
2110
2868
|
}, {});
|
|
2111
2869
|
if (!Array.isArray(options) && !isNil(fieldSentenceOptions.fields))
|
|
2112
2870
|
return {
|
|
2113
2871
|
[fieldSentenceOptions.fields[0]]: BindFilterQueryHelper.BuildOperatorSentence(options, fieldSentenceOptions),
|
|
2114
2872
|
};
|
|
2115
|
-
if (isObject(options) && !FilterOptionHelper.CheckIfIsFilterOption(options))
|
|
2873
|
+
if (!Array.isArray(options) && isObject(options) && !FilterOptionHelper.CheckIfIsFilterOption(options))
|
|
2116
2874
|
options = Object.values(options)[0];
|
|
2117
2875
|
return Array.isArray(options)
|
|
2118
2876
|
? options.reduce((whereSentence, option) => (Object.assign(Object.assign({}, whereSentence), BindFilterQueryHelper.BuildOperatorSentence(option, fieldSentenceOptions))), {})
|
|
@@ -2144,28 +2902,14 @@ GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields = (fields) => {
|
|
|
2144
2902
|
if (field === 'affected_rows')
|
|
2145
2903
|
return field;
|
|
2146
2904
|
const fieldName = Object.keys(field).shift();
|
|
2147
|
-
const fieldValue = field[fieldName];
|
|
2905
|
+
const fieldValue = is(field[fieldName]);
|
|
2148
2906
|
if (Array.isArray(fieldValue))
|
|
2149
2907
|
return { [fieldName]: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(fieldValue) };
|
|
2150
2908
|
if (!AttributeOptionHelper.CheckIsColumnOption(fieldValue))
|
|
2151
|
-
return
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
[fieldValue.columnName || fieldName]: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(fieldValue.fields),
|
|
2156
|
-
}
|
|
2157
|
-
: {
|
|
2158
|
-
operation: fieldValue.columnName || fieldName,
|
|
2159
|
-
fields: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(fieldValue.fields),
|
|
2160
|
-
variables: {
|
|
2161
|
-
[`${fieldValue.columnName}_where`]: {
|
|
2162
|
-
name: 'where',
|
|
2163
|
-
type: fieldValue.filters.filterType,
|
|
2164
|
-
value: BindFilterQueryHelper.MakeGraphQLWhere(fieldValue.filters.filters, fieldValue.fields),
|
|
2165
|
-
required: true,
|
|
2166
|
-
},
|
|
2167
|
-
},
|
|
2168
|
-
};
|
|
2909
|
+
return;
|
|
2910
|
+
const isNestedField = !!fieldValue.fields;
|
|
2911
|
+
if (isNestedField)
|
|
2912
|
+
return GraphQLFieldHelper.ConvertNestedFieldsToGraphQLFields(fieldName, fieldValue);
|
|
2169
2913
|
return fieldValue.columnName;
|
|
2170
2914
|
}).filter((field) => !!field);
|
|
2171
2915
|
};
|
|
@@ -2183,7 +2927,7 @@ GraphQLFieldHelper.ConvertFieldValueFrom = (data, fields) => Object.keys(data).r
|
|
|
2183
2927
|
}
|
|
2184
2928
|
if (!!from)
|
|
2185
2929
|
return Object.assign(Object.assign({}, result), { [attributeName]: from(data[columnName], data) });
|
|
2186
|
-
return Object.assign(Object.assign({}, result), { [attributeName]: parseDateTime(data[columnName].toString()) });
|
|
2930
|
+
return Object.assign(Object.assign({}, result), { [attributeName]: isString(data[columnName]) ? parseDateTime(data[columnName].toString()) : data[columnName] });
|
|
2187
2931
|
}, {});
|
|
2188
2932
|
GraphQLFieldHelper.ConvertFieldValueTo = (instance, fields, update = false) => {
|
|
2189
2933
|
var _a;
|
|
@@ -2199,7 +2943,8 @@ GraphQLFieldHelper.ConvertFieldValueTo = (instance, fields, update = false) => {
|
|
|
2199
2943
|
!Object.keys(foreignKeyColumn).filter((key) => { var _a; return !((_a = is(data[attributeName])) === null || _a === void 0 ? void 0 : _a[key]); }).length)
|
|
2200
2944
|
return Object.keys(foreignKeyColumn).reduce((object, current) => {
|
|
2201
2945
|
var _a;
|
|
2202
|
-
|
|
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] });
|
|
2203
2948
|
}, Object.assign({}, result));
|
|
2204
2949
|
if (update &&
|
|
2205
2950
|
isObject(data[attributeName]) &&
|
|
@@ -2227,6 +2972,25 @@ GraphQLFieldHelper.ConvertFieldValueTo = (instance, fields, update = false) => {
|
|
|
2227
2972
|
return Object.assign(Object.assign({}, result), { [columnName]: data[attributeName] });
|
|
2228
2973
|
}, {});
|
|
2229
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
|
+
};
|
|
2230
2994
|
|
|
2231
2995
|
const withCreateHasuraGraphQL = (MixinBase) => {
|
|
2232
2996
|
return class CreateHasuraGraphQLMixin extends MixinBase {
|
|
@@ -2238,6 +3002,7 @@ const withCreateHasuraGraphQL = (MixinBase) => {
|
|
|
2238
3002
|
}
|
|
2239
3003
|
create(data) {
|
|
2240
3004
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3005
|
+
this.logger = DebugHelper.from(this, 'create');
|
|
2241
3006
|
const newData = yield this.save(this.model.toInstance(data));
|
|
2242
3007
|
return this.model.toInstance(newData);
|
|
2243
3008
|
});
|
|
@@ -2250,12 +3015,11 @@ const withCreateHasuraGraphQL = (MixinBase) => {
|
|
|
2250
3015
|
const columnOptions = Object.values(field).shift();
|
|
2251
3016
|
return (AttributeOptionHelper.CheckIsColumnOption(columnOptions) &&
|
|
2252
3017
|
columnOptions.foreignKeyColumn && [
|
|
2253
|
-
...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; }),
|
|
2254
3019
|
{
|
|
2255
3020
|
[columnOptions.columnName]: Object.keys(columnOptions.foreignKeyColumn).map((foreignKeyField) => {
|
|
2256
3021
|
var _a;
|
|
2257
|
-
return ((_a = AttributeOptionHelper.FindByAttribute(foreignKeyField, columnOptions === null || columnOptions === void 0 ? void 0 : columnOptions.fields)) === null || _a === void 0 ? void 0 : _a.columnName) ||
|
|
2258
|
-
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;
|
|
2259
3023
|
}),
|
|
2260
3024
|
},
|
|
2261
3025
|
]);
|
|
@@ -2280,9 +3044,11 @@ const withDeleteHasuraGraphQL = (MixinBase) => {
|
|
|
2280
3044
|
}
|
|
2281
3045
|
delete(identifiers) {
|
|
2282
3046
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3047
|
+
this.logger = DebugHelper.from(this, 'delete');
|
|
2283
3048
|
const instance = this.model.toInstance(identifiers);
|
|
2284
3049
|
yield this.mutation(this.deleteGraphQLOperation, this.model.identifiersFields.map((field) => AttributeOptionHelper.FindByAttribute(field, this.fields).columnName), this.model.identifiersFields.reduce((ids, identifier) => {
|
|
2285
|
-
|
|
3050
|
+
const identifierBinded = identifier;
|
|
3051
|
+
if (isNil(instance.identifier[identifierBinded]))
|
|
2286
3052
|
return ids;
|
|
2287
3053
|
const columnOption = AttributeOptionHelper.FindByAttribute(identifier, this.fields);
|
|
2288
3054
|
const value = columnOption.to(identifiers[identifier], instance);
|
|
@@ -2307,11 +3073,16 @@ const withHasuraGraphQL = (MixinBase) => {
|
|
|
2307
3073
|
this.authOptions = options.authOptions;
|
|
2308
3074
|
this.model = options.model;
|
|
2309
3075
|
this.fields = options.fields || this.model.identifiersFields;
|
|
3076
|
+
this.logger = DebugHelper.from(this);
|
|
2310
3077
|
}
|
|
2311
3078
|
get headers() {
|
|
2312
|
-
|
|
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)
|
|
2313
3081
|
? {}
|
|
2314
|
-
: {
|
|
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
|
+
}));
|
|
2315
3086
|
}
|
|
2316
3087
|
mutation(operation, fields, variables) {
|
|
2317
3088
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -2324,32 +3095,32 @@ const withHasuraGraphQL = (MixinBase) => {
|
|
|
2324
3095
|
});
|
|
2325
3096
|
}
|
|
2326
3097
|
query(operation, fields, variables) {
|
|
3098
|
+
var _a, _b, _c, _d;
|
|
2327
3099
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2328
|
-
const
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
fields: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(fields),
|
|
2338
|
-
});
|
|
2339
|
-
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;
|
|
2340
3109
|
});
|
|
2341
3110
|
}
|
|
2342
3111
|
fetch(params) {
|
|
2343
3112
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3113
|
+
this.logger.with('params').log(params);
|
|
2344
3114
|
const headers = this.headers;
|
|
2345
|
-
const
|
|
3115
|
+
const { data: result } = yield axios({
|
|
3116
|
+
url: `${this.endpoint}`,
|
|
2346
3117
|
method: 'POST',
|
|
2347
|
-
|
|
3118
|
+
data: params,
|
|
2348
3119
|
headers,
|
|
2349
3120
|
});
|
|
2350
|
-
const result = yield response.json();
|
|
2351
3121
|
if (!isNil(result.errors))
|
|
2352
3122
|
throw new Error(JSON.stringify(result.errors));
|
|
3123
|
+
this.logger.with('returns').log(result);
|
|
2353
3124
|
return result.data;
|
|
2354
3125
|
});
|
|
2355
3126
|
}
|
|
@@ -2376,13 +3147,26 @@ const withHasuraGraphQL = (MixinBase) => {
|
|
|
2376
3147
|
return value;
|
|
2377
3148
|
return date;
|
|
2378
3149
|
}
|
|
2379
|
-
convertDataFromHasura(data) {
|
|
2380
|
-
const plain = GraphQLFieldHelper.ConvertFieldValueFrom(data, this.fields);
|
|
3150
|
+
convertDataFromHasura(data, fields) {
|
|
3151
|
+
const plain = GraphQLFieldHelper.ConvertFieldValueFrom(data, fields || this.fields);
|
|
2381
3152
|
return this.model.toInstance(plain);
|
|
2382
3153
|
}
|
|
2383
3154
|
convertDataToHasura(instance, update = false) {
|
|
2384
3155
|
return GraphQLFieldHelper.ConvertFieldValueTo(instance, this.fields, update);
|
|
2385
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
|
+
}
|
|
2386
3170
|
};
|
|
2387
3171
|
};
|
|
2388
3172
|
|
|
@@ -2406,6 +3190,7 @@ const withUpdateHasuraGraphQL = (MixinBase) => {
|
|
|
2406
3190
|
}
|
|
2407
3191
|
update(data) {
|
|
2408
3192
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3193
|
+
this.logger = DebugHelper.from(this, 'update');
|
|
2409
3194
|
const plainData = this.paramsToPlain(data);
|
|
2410
3195
|
yield this.mutation(this.updateGraphQLOperation, this.model.identifiersFields.map((field) => AttributeOptionHelper.FindByAttribute(field, this.fields).columnName), {
|
|
2411
3196
|
_set: {
|
|
@@ -2430,10 +3215,11 @@ const withUpdateHasuraGraphQL = (MixinBase) => {
|
|
|
2430
3215
|
const instance = this.model.toInstance(data);
|
|
2431
3216
|
return this.model.identifiersFields.reduce((ids, identifier) => {
|
|
2432
3217
|
var _a;
|
|
2433
|
-
|
|
3218
|
+
const identifierBinded = identifier;
|
|
3219
|
+
if (isNil(instance.identifier[identifierBinded]))
|
|
2434
3220
|
return ids;
|
|
2435
|
-
const columnOption = AttributeOptionHelper.FindByAttribute(
|
|
2436
|
-
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];
|
|
2437
3223
|
return Object.assign(Object.assign({}, ids), { [columnOption.columnName]: value });
|
|
2438
3224
|
}, {});
|
|
2439
3225
|
}
|
|
@@ -2449,10 +3235,12 @@ const withGetHasuraGraphQL = (MixinBase) => {
|
|
|
2449
3235
|
}
|
|
2450
3236
|
get(identifiers) {
|
|
2451
3237
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3238
|
+
this.logger = DebugHelper.from(this, 'get');
|
|
2452
3239
|
const instance = this.model.toInstance(identifiers);
|
|
2453
3240
|
const result = yield this.query(this.getGraphQLOperation, this.fields, this.model.identifiersFields.reduce((ids, identifier) => {
|
|
2454
3241
|
var _a;
|
|
2455
|
-
|
|
3242
|
+
const identifierBinded = identifier;
|
|
3243
|
+
if (isNil(instance[identifierBinded]))
|
|
2456
3244
|
return ids;
|
|
2457
3245
|
const columnOption = AttributeOptionHelper.FindByAttribute(identifier, this.fields);
|
|
2458
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)) ||
|
|
@@ -2474,10 +3262,46 @@ const withGetHasuraGraphQL = (MixinBase) => {
|
|
|
2474
3262
|
|
|
2475
3263
|
const withFindHasuraGraphQL = (MixinBase) => {
|
|
2476
3264
|
return class FindHasuraGraphQLMixin extends MixinBase {
|
|
2477
|
-
|
|
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;
|
|
2478
3300
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2479
|
-
|
|
2480
|
-
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)
|
|
2481
3305
|
? {}
|
|
2482
3306
|
: {
|
|
2483
3307
|
where: {
|
|
@@ -2485,13 +3309,26 @@ const withFindHasuraGraphQL = (MixinBase) => {
|
|
|
2485
3309
|
type: `${this.tableName}_bool_exp`,
|
|
2486
3310
|
required: true,
|
|
2487
3311
|
},
|
|
2488
|
-
}
|
|
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);
|
|
2489
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
|
+
];
|
|
2490
3327
|
const result = yield this.query([
|
|
2491
3328
|
{
|
|
2492
3329
|
operation: this.tableName,
|
|
2493
|
-
fields:
|
|
2494
|
-
?
|
|
3330
|
+
fields: params.fields
|
|
3331
|
+
? params.fields
|
|
2495
3332
|
.map((fieldName) => {
|
|
2496
3333
|
var _a;
|
|
2497
3334
|
return (_a = this.fields.find((fieldOption) => fieldOption === fieldName)) !== null && _a !== void 0 ? _a : this.fields.find((fieldOption) => Object.keys(fieldOption).shift() === fieldName);
|
|
@@ -2500,15 +3337,64 @@ const withFindHasuraGraphQL = (MixinBase) => {
|
|
|
2500
3337
|
: this.fields,
|
|
2501
3338
|
variables,
|
|
2502
3339
|
},
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
|
|
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
|
+
[]),
|
|
2508
3373
|
]);
|
|
2509
3374
|
const data = result[this.tableName].map((row) => this.convertDataFromHasura(row));
|
|
2510
|
-
|
|
2511
|
-
|
|
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
|
+
}));
|
|
2512
3398
|
});
|
|
2513
3399
|
}
|
|
2514
3400
|
};
|
|
@@ -2548,13 +3434,154 @@ class VariantHasuraGraphQL extends Variant {
|
|
|
2548
3434
|
}
|
|
2549
3435
|
}
|
|
2550
3436
|
|
|
3437
|
+
class CategoryCollectionChildrenHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
3438
|
+
constructor({ endpoint, authOptions, interceptors, }) {
|
|
3439
|
+
super({
|
|
3440
|
+
tableName: 'category_collection_children',
|
|
3441
|
+
model: CategoryCollectionChildren,
|
|
3442
|
+
endpoint,
|
|
3443
|
+
authOptions,
|
|
3444
|
+
interceptors,
|
|
3445
|
+
fields: [
|
|
3446
|
+
{ collectionId: { columnName: 'collection_id' } },
|
|
3447
|
+
{ categoryId: { columnName: 'category_id' } },
|
|
3448
|
+
'name',
|
|
3449
|
+
'slug',
|
|
3450
|
+
'reference',
|
|
3451
|
+
{ parentCollectionId: { columnName: 'parent_collection_id' } },
|
|
3452
|
+
{ parentCategoryId: { columnName: 'parent_category_id' } },
|
|
3453
|
+
{
|
|
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
|
+
|
|
2551
3577
|
class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
2552
|
-
constructor(endpoint, authOptions, productRepository) {
|
|
3578
|
+
constructor({ endpoint, authOptions, interceptors, }, productRepository, categoryFilterRepository) {
|
|
2553
3579
|
super({
|
|
2554
3580
|
tableName: 'category',
|
|
2555
3581
|
model: Category,
|
|
2556
3582
|
endpoint,
|
|
2557
3583
|
authOptions,
|
|
3584
|
+
interceptors,
|
|
2558
3585
|
fields: [
|
|
2559
3586
|
{ id: { columnName: 'id', to: (value) => +value, from: (value) => value.toString() } },
|
|
2560
3587
|
{ firestoreId: { columnName: 'firestore_id' } },
|
|
@@ -2563,6 +3590,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
2563
3590
|
'image',
|
|
2564
3591
|
'published',
|
|
2565
3592
|
'shop',
|
|
3593
|
+
{ shops: { columnName: 'shops', type: HasuraGraphQLColumnType.Jsonb } },
|
|
2566
3594
|
'slug',
|
|
2567
3595
|
{ brandCategory: { columnName: 'brand_category' } },
|
|
2568
3596
|
{ brandCategoryBanner: { columnName: 'brand_banner' } },
|
|
@@ -2588,7 +3616,17 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
2588
3616
|
},
|
|
2589
3617
|
},
|
|
2590
3618
|
},
|
|
2591
|
-
|
|
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)) || [],
|
|
3628
|
+
},
|
|
3629
|
+
},
|
|
2592
3630
|
{ createdAt: { columnName: 'created_at' } },
|
|
2593
3631
|
{ updatedAt: { columnName: 'updated_at' } },
|
|
2594
3632
|
{
|
|
@@ -2610,9 +3648,21 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
2610
3648
|
}),
|
|
2611
3649
|
},
|
|
2612
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
|
+
},
|
|
2613
3662
|
],
|
|
2614
3663
|
});
|
|
2615
3664
|
this.productRepository = productRepository;
|
|
3665
|
+
this.categoryFilterRepository = categoryFilterRepository;
|
|
2616
3666
|
}
|
|
2617
3667
|
create(params) {
|
|
2618
3668
|
const _super = Object.create(null, {
|
|
@@ -2620,7 +3670,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
2620
3670
|
});
|
|
2621
3671
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2622
3672
|
const { metadata } = params, data = __rest(params, ["metadata"]);
|
|
2623
|
-
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 } }));
|
|
2624
3674
|
});
|
|
2625
3675
|
}
|
|
2626
3676
|
get(identifiers) {
|
|
@@ -2630,7 +3680,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
2630
3680
|
var _a;
|
|
2631
3681
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2632
3682
|
return Number.isNaN(+identifiers.id)
|
|
2633
|
-
? (_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]
|
|
2634
3684
|
: _super.get.call(this, identifiers);
|
|
2635
3685
|
});
|
|
2636
3686
|
}
|
|
@@ -2639,12 +3689,13 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
2639
3689
|
update: { get: () => super.update }
|
|
2640
3690
|
});
|
|
2641
3691
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2642
|
-
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"]);
|
|
2643
3693
|
const plainData = this.paramsToPlain({ id: checkId });
|
|
2644
3694
|
const id = yield this.getId(plainData.id);
|
|
2645
|
-
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 }));
|
|
2646
3696
|
category.products = products && (yield this.updateProducts(+id, { products }));
|
|
2647
3697
|
category.metadata = metadata && (yield this.updateMetadata(+id, { metadata }));
|
|
3698
|
+
category.filters = filters && (yield this.updateFilters(+id, { filters }));
|
|
2648
3699
|
return category;
|
|
2649
3700
|
});
|
|
2650
3701
|
}
|
|
@@ -2652,15 +3703,42 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
2652
3703
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2653
3704
|
if (!slug)
|
|
2654
3705
|
return null;
|
|
2655
|
-
const { data
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
|
|
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)
|
|
2659
3718
|
throw new NotFoundError(`Category with slug ${slug} not found`);
|
|
3719
|
+
if (data.length > 1)
|
|
3720
|
+
throw new DuplicatedResultsError('Query returned duplicated values');
|
|
2660
3721
|
return data.shift();
|
|
2661
3722
|
});
|
|
2662
3723
|
}
|
|
2663
|
-
|
|
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) {
|
|
2664
3742
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2665
3743
|
if (!(categoryIds === null || categoryIds === void 0 ? void 0 : categoryIds.length))
|
|
2666
3744
|
return [];
|
|
@@ -2680,7 +3758,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
2680
3758
|
const homeSections = yield Promise.all(categories.map((category) => __awaiter(this, void 0, void 0, function* () {
|
|
2681
3759
|
return ({
|
|
2682
3760
|
category,
|
|
2683
|
-
products: yield this.mountCategory(category, { limit, hasStock: true }),
|
|
3761
|
+
products: yield this.mountCategory(category, { limit, hasStock: true, gender }),
|
|
2684
3762
|
});
|
|
2685
3763
|
})));
|
|
2686
3764
|
return homeSections;
|
|
@@ -2692,7 +3770,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
2692
3770
|
if (!((_a = category === null || category === void 0 ? void 0 : category.products) === null || _a === void 0 ? void 0 : _a.length))
|
|
2693
3771
|
return [];
|
|
2694
3772
|
const products = [];
|
|
2695
|
-
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: [
|
|
2696
3774
|
'id',
|
|
2697
3775
|
'name',
|
|
2698
3776
|
'slug',
|
|
@@ -2716,7 +3794,9 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
2716
3794
|
'tags',
|
|
2717
3795
|
'type',
|
|
2718
3796
|
'shoppingCount',
|
|
2719
|
-
|
|
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 } }));
|
|
2720
3800
|
products.push(...productsData);
|
|
2721
3801
|
return products;
|
|
2722
3802
|
});
|
|
@@ -2726,7 +3806,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
2726
3806
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2727
3807
|
if (!Number.isNaN(+id))
|
|
2728
3808
|
return id;
|
|
2729
|
-
const { data } = yield this.find({ filters: { firestoreId: id } });
|
|
3809
|
+
const { data } = yield this.find({ filters: { firestoreId: id }, options: { enableCount: false } });
|
|
2730
3810
|
if ((_a = data === null || data === void 0 ? void 0 : data[0]) === null || _a === void 0 ? void 0 : _a.id)
|
|
2731
3811
|
return (_b = data === null || data === void 0 ? void 0 : data[0]) === null || _b === void 0 ? void 0 : _b.id;
|
|
2732
3812
|
throw new NotFoundError(`Category with id ${id} not found`);
|
|
@@ -2784,15 +3864,220 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
2784
3864
|
return plainData.metadata;
|
|
2785
3865
|
});
|
|
2786
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
|
+
}
|
|
2787
4071
|
}
|
|
2788
4072
|
|
|
2789
4073
|
class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
2790
|
-
constructor(endpoint, authOptions) {
|
|
4074
|
+
constructor({ endpoint, authOptions, interceptors, }) {
|
|
2791
4075
|
super({
|
|
2792
4076
|
tableName: 'product',
|
|
2793
4077
|
model: ProductHasuraGraphQL,
|
|
2794
4078
|
endpoint,
|
|
2795
4079
|
authOptions,
|
|
4080
|
+
interceptors,
|
|
2796
4081
|
fields: [],
|
|
2797
4082
|
});
|
|
2798
4083
|
this.bindReviewToModel = (plain) => (Object.assign(Object.assign({}, is(omit(plain, ['product_id', 'created_at', 'updated_at', 'person_id', 'order_id']))), { createdAt: typeof plain.created_at === 'string' ? new Date(plain.created_at) : plain.created_at, updatedAt: typeof plain.updated_at === 'string' ? new Date(plain.updated_at) : plain.updated_at, personId: plain.person_id, orderId: plain.order_id }));
|
|
@@ -2815,26 +4100,29 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
2815
4100
|
whoMustUse: data.who_must_use,
|
|
2816
4101
|
howToUse: data.how_to_use,
|
|
2817
4102
|
brand: data.brand_description,
|
|
4103
|
+
ingredients: data.ingredients,
|
|
2818
4104
|
}),
|
|
2819
|
-
bindFindFilter: (
|
|
2820
|
-
|
|
2821
|
-
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 && {
|
|
2822
4107
|
who_must_use: filters.whoMustUse,
|
|
2823
4108
|
})), (filters.howToUse && {
|
|
2824
4109
|
how_to_use: filters.howToUse,
|
|
2825
4110
|
})), (filters.brand && {
|
|
2826
4111
|
brand_description: filters.brand,
|
|
4112
|
+
})), (filters.ingredients && {
|
|
4113
|
+
ingredients: filters.ingredients,
|
|
2827
4114
|
}));
|
|
2828
4115
|
},
|
|
2829
|
-
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 && {
|
|
2830
4117
|
who_must_use: descriptionData.whoMustUse,
|
|
2831
|
-
})), (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 }))),
|
|
2832
4119
|
},
|
|
2833
4120
|
},
|
|
2834
4121
|
{ differentials: { columnName: 'differentials' } },
|
|
2835
4122
|
{ whoMustUse: { columnName: 'who_must_use' } },
|
|
2836
4123
|
{ howToUse: { columnName: 'how_to_use' } },
|
|
2837
4124
|
{ brandDescription: { columnName: 'brand_description' } },
|
|
4125
|
+
{ ingredients: { columnName: 'ingredients' } },
|
|
2838
4126
|
{ hasVariants: { columnName: 'has_variants' } },
|
|
2839
4127
|
{
|
|
2840
4128
|
images: {
|
|
@@ -2858,8 +4146,7 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
2858
4146
|
subscriberDiscountPercentage: data.subscriber_discount_percentage,
|
|
2859
4147
|
subscriberPrice: data.subscriber_price,
|
|
2860
4148
|
}),
|
|
2861
|
-
bindFindFilter: (
|
|
2862
|
-
const filters = Object.values(sentence).shift();
|
|
4149
|
+
bindFindFilter: (filters) => {
|
|
2863
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) && {
|
|
2864
4151
|
subscriber_discount_percentage: filters.subscriberDiscountPercentage,
|
|
2865
4152
|
})), ((filters.subscriberPrice || filters.subscriberPrice === 0) && {
|
|
@@ -2883,27 +4170,29 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
2883
4170
|
to: (value) => (isNil(value === null || value === void 0 ? void 0 : value.quantity) ? value : value === null || value === void 0 ? void 0 : value.quantity),
|
|
2884
4171
|
},
|
|
2885
4172
|
},
|
|
4173
|
+
{ hasStock: { columnName: 'has_stock' } },
|
|
2886
4174
|
'slug',
|
|
2887
4175
|
'type',
|
|
2888
4176
|
'video',
|
|
2889
4177
|
'weight',
|
|
2890
4178
|
'gender',
|
|
4179
|
+
{ intGender: { columnName: 'int_gender' } },
|
|
2891
4180
|
{ tags: { columnName: 'tags', type: HasuraGraphQLColumnType.Jsonb } },
|
|
4181
|
+
{ filters: { columnName: 'filters', type: HasuraGraphQLColumnType.Jsonb } },
|
|
2892
4182
|
{ isKit: { columnName: 'is_kit' } },
|
|
2893
4183
|
{ createdAt: { columnName: 'created_at' } },
|
|
2894
4184
|
{ updatedAt: { columnName: 'updated_at' } },
|
|
4185
|
+
{ rate: { columnName: 'rating' } },
|
|
4186
|
+
{ reviewsTotal: { columnName: 'reviews_total' } },
|
|
4187
|
+
{ shoppingCount: { columnName: 'shopping_count' } },
|
|
4188
|
+
{ categoryId: { columnName: 'category_id' } },
|
|
2895
4189
|
{
|
|
2896
|
-
|
|
2897
|
-
columnName: '
|
|
2898
|
-
|
|
2899
|
-
|
|
2900
|
-
filterType: 'product_review_bool_exp',
|
|
2901
|
-
},
|
|
2902
|
-
fields: [{ aggregate: [{ avg: ['rate'] }] }],
|
|
2903
|
-
from: (value) => value.aggregate.avg.rate,
|
|
4190
|
+
category: {
|
|
4191
|
+
columnName: 'category',
|
|
4192
|
+
foreignKeyColumn: { id: 'categoryId' },
|
|
4193
|
+
fields: ['id', 'name', 'reference', 'slug'],
|
|
2904
4194
|
},
|
|
2905
4195
|
},
|
|
2906
|
-
{ shoppingCount: { columnName: 'shopping_count' } },
|
|
2907
4196
|
];
|
|
2908
4197
|
this.fields = [
|
|
2909
4198
|
...commonFields,
|
|
@@ -2990,7 +4279,7 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
2990
4279
|
var _a;
|
|
2991
4280
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2992
4281
|
const product = Number.isNaN(+identifiers.id)
|
|
2993
|
-
? (_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]
|
|
2994
4283
|
: yield _super.get.call(this, identifiers);
|
|
2995
4284
|
if (product.productId)
|
|
2996
4285
|
throw new NotFoundError('Product not found, it is a variant');
|
|
@@ -3002,13 +4291,29 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
3002
4291
|
const _super = Object.create(null, {
|
|
3003
4292
|
find: { get: () => super.find }
|
|
3004
4293
|
});
|
|
4294
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
3005
4295
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3006
|
-
const
|
|
4296
|
+
const _o = params || {}, { filters, fields } = _o, options = __rest(_o, ["filters", "fields"]);
|
|
3007
4297
|
const bindFields = fields ||
|
|
3008
4298
|
this.fields
|
|
3009
4299
|
.map((field) => (typeof field === 'string' ? field : Object.keys(field).shift()))
|
|
3010
4300
|
.filter((field) => field !== 'reviews');
|
|
3011
|
-
|
|
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
|
+
] }));
|
|
3012
4317
|
});
|
|
3013
4318
|
}
|
|
3014
4319
|
getBySlug(slug) {
|
|
@@ -3018,9 +4323,13 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
3018
4323
|
filters: {
|
|
3019
4324
|
slug,
|
|
3020
4325
|
},
|
|
4326
|
+
fields: this.fields.map((field) => typeof field === 'string' ? field : Object.keys(field).shift()),
|
|
4327
|
+
options: {
|
|
4328
|
+
enableCount: false,
|
|
4329
|
+
},
|
|
3021
4330
|
});
|
|
3022
4331
|
const product = (_a = result === null || result === void 0 ? void 0 : result.data) === null || _a === void 0 ? void 0 : _a.shift();
|
|
3023
|
-
|
|
4332
|
+
RoundProductPricesHelper.roundProductPrices(product);
|
|
3024
4333
|
return product;
|
|
3025
4334
|
});
|
|
3026
4335
|
}
|
|
@@ -3060,6 +4369,11 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
3060
4369
|
], []);
|
|
3061
4370
|
});
|
|
3062
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
|
+
}
|
|
3063
4377
|
updateCategories(productId, { categories }) {
|
|
3064
4378
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3065
4379
|
if ('action' in categories && categories.action === 'remove') {
|
|
@@ -3183,7 +4497,7 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
3183
4497
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3184
4498
|
if (!Number.isNaN(+id))
|
|
3185
4499
|
return id;
|
|
3186
|
-
const { data } = yield this.find({ filters: { firestoreId: id } });
|
|
4500
|
+
const { data } = yield this.find({ filters: { firestoreId: id }, options: { enableCount: false } });
|
|
3187
4501
|
if ((_a = data === null || data === void 0 ? void 0 : data[0]) === null || _a === void 0 ? void 0 : _a.id)
|
|
3188
4502
|
return (_b = data === null || data === void 0 ? void 0 : data[0]) === null || _b === void 0 ? void 0 : _b.id;
|
|
3189
4503
|
throw new NotFoundError(`Product with id ${id} not found`);
|
|
@@ -3239,15 +4553,31 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
3239
4553
|
return data && data[0] && this.bindReviewToModel(data[0]);
|
|
3240
4554
|
});
|
|
3241
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
|
+
}
|
|
3242
4571
|
}
|
|
3243
4572
|
|
|
3244
4573
|
class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
3245
|
-
constructor(endpoint, authOptions) {
|
|
4574
|
+
constructor({ endpoint, authOptions, interceptors, }) {
|
|
3246
4575
|
super({
|
|
3247
4576
|
tableName: 'product',
|
|
3248
4577
|
model: VariantHasuraGraphQL,
|
|
3249
4578
|
endpoint,
|
|
3250
4579
|
authOptions,
|
|
4580
|
+
interceptors,
|
|
3251
4581
|
fields: [
|
|
3252
4582
|
{ id: { columnName: 'id', to: (value) => +value, from: (value) => value.toString() } },
|
|
3253
4583
|
{ firestoreId: { columnName: 'firestore_id' } },
|
|
@@ -3277,9 +4607,9 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
3277
4607
|
subscriber_price: filters.subscriberPrice,
|
|
3278
4608
|
}));
|
|
3279
4609
|
},
|
|
3280
|
-
bindPersistData: (priceData) => (Object.assign(Object.assign(Object.assign(Object.assign({}, ((priceData === null || priceData === void 0 ? void 0 : priceData.price) >= 0 && { price: priceData.price })), (priceData.fullPrice >= 0 && { full_price: priceData.fullPrice })), (priceData.subscriberDiscountPercentage >= 0 && {
|
|
4610
|
+
bindPersistData: (priceData) => (Object.assign(Object.assign(Object.assign(Object.assign({}, (((priceData === null || priceData === void 0 ? void 0 : priceData.price) || 0) >= 0 && { price: priceData.price })), (((priceData === null || priceData === void 0 ? void 0 : priceData.fullPrice) || 0) >= 0 && { full_price: priceData.fullPrice })), (((priceData === null || priceData === void 0 ? void 0 : priceData.subscriberDiscountPercentage) || 0) >= 0 && {
|
|
3281
4611
|
subscriber_discount_percentage: priceData.subscriberDiscountPercentage,
|
|
3282
|
-
})), (priceData.subscriberPrice >= 0 && { subscriber_price: priceData.subscriberPrice }))),
|
|
4612
|
+
})), (((priceData === null || priceData === void 0 ? void 0 : priceData.subscriberPrice) || 0) >= 0 && { subscriber_price: priceData.subscriberPrice }))),
|
|
3283
4613
|
},
|
|
3284
4614
|
},
|
|
3285
4615
|
{ fullPrice: { columnName: 'full_price' } },
|
|
@@ -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
|