@infrab4a/connect 4.0.0-beta.3 → 4.0.0-beta.30
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-collection-children.d.ts +13 -0
- package/domain/catalog/models/category-filter.d.ts +11 -0
- package/domain/catalog/models/category.d.ts +10 -5
- 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 +4 -0
- package/domain/catalog/models/kit-product.d.ts +1 -1
- package/domain/catalog/models/product.d.ts +8 -3
- 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/variant.d.ts +1 -2
- package/domain/catalog/repositories/category-collection-children.repository.d.ts +4 -0
- package/domain/catalog/repositories/category-filter.repository.d.ts +5 -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 +4 -0
- package/domain/catalog/repositories/product.repository.d.ts +1 -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 +3 -0
- 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-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/index.d.ts +5 -4
- 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-collection-children.mjs +13 -0
- package/esm2020/domain/catalog/models/category-filter.mjs +14 -0
- package/esm2020/domain/catalog/models/category.mjs +12 -4
- 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 +5 -1
- package/esm2020/domain/catalog/models/kit-product.mjs +2 -2
- package/esm2020/domain/catalog/models/product.mjs +23 -3
- 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/variant.mjs +1 -4
- 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 +5 -1
- package/esm2020/domain/catalog/repositories/product.repository.mjs +1 -1
- 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-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/index.mjs +6 -5
- package/esm2020/domain/shopping/models/order.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/edition.mjs +1 -1
- package/esm2020/domain/users/models/subscription/payment.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-payment-method.mjs +1 -1
- package/esm2020/domain/users/models/user.mjs +2 -2
- package/esm2020/domain/users/use-cases/authentication.mjs +2 -2
- package/esm2020/infra/elasticsearch/adapters/axios.adapter.mjs +28 -11
- package/esm2020/infra/elasticsearch/adapters/elastic-search.adapter.mjs +1 -1
- package/esm2020/infra/elasticsearch/indexes/products-index.mjs +63 -51
- package/esm2020/infra/elasticsearch/types/elastic-search-result.mjs +1 -1
- package/esm2020/infra/firebase/firestore/mixins/with-create-firestore.mixin.mjs +8 -4
- package/esm2020/infra/firebase/firestore/mixins/with-crud-firestore.mixin.mjs +1 -1
- package/esm2020/infra/firebase/firestore/mixins/with-delete-firestore.mixin.mjs +6 -2
- package/esm2020/infra/firebase/firestore/mixins/with-find-firestore.mixin.mjs +10 -7
- 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 +11 -6
- 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 +2 -2
- package/esm2020/infra/hasura-graphql/mixins/helpers/bind-filter-query.helper.mjs +5 -4
- 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 +36 -15
- 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/repositories/catalog/category-collection-children-hasura-graphql.repository.mjs +38 -0
- package/esm2020/infra/hasura-graphql/repositories/catalog/category-filter-hasura-graphql.repository.mjs +56 -0
- package/esm2020/infra/hasura-graphql/repositories/catalog/category-hasura-graphql.repository.mjs +144 -12
- 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 +5 -1
- package/esm2020/infra/hasura-graphql/repositories/catalog/product-hasura-graphql.repository.mjs +43 -16
- package/esm2020/infra/hasura-graphql/repositories/catalog/variant-hasura-graphql.repository.mjs +8 -7
- 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 +1530 -389
- package/fesm2015/infrab4a-connect.mjs.map +1 -1
- package/fesm2020/infrab4a-connect.mjs +1496 -389
- 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 +4 -4
- 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 +8 -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 +12 -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 +14 -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 +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 +11 -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 +4 -0
- package/infra/hasura-graphql/repositories/catalog/product-hasura-graphql.repository.d.ts +4 -3
- package/infra/hasura-graphql/repositories/catalog/variant-hasura-graphql.repository.d.ts +4 -4
- package/infra/hasura-graphql/types/graphql.repository.type.d.ts +7 -5
- 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, 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();
|
|
467
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();
|
|
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));
|
|
468
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
|
+
};
|
|
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";
|
|
@@ -598,6 +1024,18 @@ __decorate([
|
|
|
598
1024
|
__metadata("design:type", BeautyProfile)
|
|
599
1025
|
], User.prototype, "beautyProfile", void 0);
|
|
600
1026
|
|
|
1027
|
+
class Address extends BaseModel {
|
|
1028
|
+
static get identifiersFields() {
|
|
1029
|
+
return ['id'];
|
|
1030
|
+
}
|
|
1031
|
+
}
|
|
1032
|
+
|
|
1033
|
+
class UserAddress extends Address {
|
|
1034
|
+
static get identifiersFields() {
|
|
1035
|
+
return ['id', 'userId'];
|
|
1036
|
+
}
|
|
1037
|
+
}
|
|
1038
|
+
|
|
601
1039
|
class Subscription extends BaseModel {
|
|
602
1040
|
static get identifiersFields() {
|
|
603
1041
|
return ['id'];
|
|
@@ -612,12 +1050,12 @@ __decorate([
|
|
|
612
1050
|
__metadata("design:type", SubscriptionPlan)
|
|
613
1051
|
], Subscription.prototype, "subscriptionPlan", void 0);
|
|
614
1052
|
__decorate([
|
|
615
|
-
Type(() =>
|
|
616
|
-
__metadata("design:type",
|
|
1053
|
+
Type(() => UserAddress),
|
|
1054
|
+
__metadata("design:type", UserAddress)
|
|
617
1055
|
], Subscription.prototype, "shippingAddress", void 0);
|
|
618
1056
|
__decorate([
|
|
619
|
-
Type(() =>
|
|
620
|
-
__metadata("design:type",
|
|
1057
|
+
Type(() => UserAddress),
|
|
1058
|
+
__metadata("design:type", UserAddress)
|
|
621
1059
|
], Subscription.prototype, "billingAddress", void 0);
|
|
622
1060
|
__decorate([
|
|
623
1061
|
Type(() => Coupon),
|
|
@@ -632,12 +1070,6 @@ __decorate([
|
|
|
632
1070
|
__metadata("design:type", Array)
|
|
633
1071
|
], Subscription.prototype, "payment", void 0);
|
|
634
1072
|
|
|
635
|
-
class UserAddress extends Address {
|
|
636
|
-
static get identifiersFields() {
|
|
637
|
-
return ['id', 'userId'];
|
|
638
|
-
}
|
|
639
|
-
}
|
|
640
|
-
|
|
641
1073
|
class UserPaymentMethod extends BaseModel {
|
|
642
1074
|
static get identifiersFields() {
|
|
643
1075
|
return ['id', 'userId'];
|
|
@@ -670,7 +1102,7 @@ class Authentication {
|
|
|
670
1102
|
return __awaiter(this, void 0, void 0, function* () {
|
|
671
1103
|
const method = this.getServiceByMethod(signInMethod);
|
|
672
1104
|
const userAuth = yield this.authService[method]({ email, password });
|
|
673
|
-
const user = this.userRepository.get(userAuth);
|
|
1105
|
+
const user = this.userRepository.get({ id: userAuth.id });
|
|
674
1106
|
if (!isNil(user))
|
|
675
1107
|
return user;
|
|
676
1108
|
if (/^.+@b4a.com.br$/.test(userAuth.email))
|
|
@@ -757,14 +1189,45 @@ class RecoveryPassword {
|
|
|
757
1189
|
}
|
|
758
1190
|
}
|
|
759
1191
|
|
|
1192
|
+
class Filter extends BaseModel {
|
|
1193
|
+
static get identifiersFields() {
|
|
1194
|
+
return ['id'];
|
|
1195
|
+
}
|
|
1196
|
+
}
|
|
1197
|
+
|
|
760
1198
|
class Category extends BaseModel {
|
|
761
|
-
|
|
1199
|
+
static get identifiersFields() {
|
|
762
1200
|
return ['id'];
|
|
763
1201
|
}
|
|
1202
|
+
}
|
|
1203
|
+
__decorate([
|
|
1204
|
+
Type(() => Category),
|
|
1205
|
+
__metadata("design:type", Category)
|
|
1206
|
+
], Category.prototype, "parent", void 0);
|
|
1207
|
+
__decorate([
|
|
1208
|
+
Type(() => Filter),
|
|
1209
|
+
__metadata("design:type", Array)
|
|
1210
|
+
], Category.prototype, "filters", void 0);
|
|
1211
|
+
|
|
1212
|
+
class CategoryCollectionChildren extends BaseModel {
|
|
1213
|
+
static get identifiersFields() {
|
|
1214
|
+
return ['collectionId', 'categoryId'];
|
|
1215
|
+
}
|
|
1216
|
+
}
|
|
1217
|
+
__decorate([
|
|
1218
|
+
Type(() => CategoryCollectionChildren),
|
|
1219
|
+
__metadata("design:type", CategoryCollectionChildren)
|
|
1220
|
+
], CategoryCollectionChildren.prototype, "parent", void 0);
|
|
1221
|
+
|
|
1222
|
+
class CategoryFilter extends BaseModel {
|
|
764
1223
|
static get identifiersFields() {
|
|
765
1224
|
return ['id'];
|
|
766
1225
|
}
|
|
767
1226
|
}
|
|
1227
|
+
__decorate([
|
|
1228
|
+
Type(() => Filter),
|
|
1229
|
+
__metadata("design:type", Filter)
|
|
1230
|
+
], CategoryFilter.prototype, "filter", void 0);
|
|
768
1231
|
|
|
769
1232
|
var GenderDestination;
|
|
770
1233
|
(function (GenderDestination) {
|
|
@@ -781,14 +1244,39 @@ var Shops;
|
|
|
781
1244
|
Shops["ALL"] = "ALL";
|
|
782
1245
|
})(Shops || (Shops = {}));
|
|
783
1246
|
|
|
784
|
-
class
|
|
785
|
-
|
|
1247
|
+
class FilterOption extends BaseModel {
|
|
1248
|
+
static get identifiersFields() {
|
|
786
1249
|
return ['id'];
|
|
787
1250
|
}
|
|
1251
|
+
}
|
|
1252
|
+
|
|
1253
|
+
class Product extends BaseModel {
|
|
1254
|
+
get evaluation() {
|
|
1255
|
+
return {
|
|
1256
|
+
reviews: this.reviews,
|
|
1257
|
+
count: this.reviewsTotal,
|
|
1258
|
+
rating: this.rate,
|
|
1259
|
+
};
|
|
1260
|
+
}
|
|
1261
|
+
set evaluation(evaluation) {
|
|
1262
|
+
if (!evaluation) {
|
|
1263
|
+
this.reviews = null;
|
|
1264
|
+
this.reviewsTotal = null;
|
|
1265
|
+
this.rate = null;
|
|
1266
|
+
return;
|
|
1267
|
+
}
|
|
1268
|
+
this.reviews = evaluation.reviews || this.reviews;
|
|
1269
|
+
this.reviewsTotal = evaluation.count || this.reviewsTotal;
|
|
1270
|
+
this.rate = evaluation.rating || this.rate;
|
|
1271
|
+
}
|
|
788
1272
|
static get identifiersFields() {
|
|
789
1273
|
return ['id'];
|
|
790
1274
|
}
|
|
791
1275
|
}
|
|
1276
|
+
__decorate([
|
|
1277
|
+
Type(() => Category),
|
|
1278
|
+
__metadata("design:type", Category)
|
|
1279
|
+
], Product.prototype, "category", void 0);
|
|
792
1280
|
__decorate([
|
|
793
1281
|
Type(() => KitProduct),
|
|
794
1282
|
__metadata("design:type", Array)
|
|
@@ -796,7 +1284,7 @@ __decorate([
|
|
|
796
1284
|
|
|
797
1285
|
class KitProduct extends BaseModel {
|
|
798
1286
|
static get identifiersFields() {
|
|
799
|
-
return ['productId', '
|
|
1287
|
+
return ['productId', 'kitProductId'];
|
|
800
1288
|
}
|
|
801
1289
|
}
|
|
802
1290
|
__decorate([
|
|
@@ -809,25 +1297,32 @@ __decorate([
|
|
|
809
1297
|
], KitProduct.prototype, "product", void 0);
|
|
810
1298
|
|
|
811
1299
|
class Variant extends BaseModel {
|
|
812
|
-
|
|
1300
|
+
static get identifiersFields() {
|
|
1301
|
+
return ['id', 'productId'];
|
|
1302
|
+
}
|
|
1303
|
+
}
|
|
1304
|
+
|
|
1305
|
+
class Buy2Win extends BaseModel {
|
|
1306
|
+
static get identifiersFields() {
|
|
813
1307
|
return ['id'];
|
|
814
1308
|
}
|
|
1309
|
+
}
|
|
1310
|
+
__decorate([
|
|
1311
|
+
Type(() => Category),
|
|
1312
|
+
__metadata("design:type", Array)
|
|
1313
|
+
], Buy2Win.prototype, "categories", void 0);
|
|
1314
|
+
|
|
1315
|
+
class CampaignDashboard extends BaseModel {
|
|
815
1316
|
static get identifiersFields() {
|
|
816
|
-
return ['id'
|
|
1317
|
+
return ['id'];
|
|
817
1318
|
}
|
|
818
1319
|
}
|
|
819
1320
|
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
OrderStatus["AGUARDANDO_ENVIO"] = "Aguardando Transaportadora";
|
|
826
|
-
OrderStatus["ENVIADO"] = "Enviado";
|
|
827
|
-
OrderStatus["ENTREGUE"] = "Entregue";
|
|
828
|
-
OrderStatus["CANCELADO"] = "Cancelado";
|
|
829
|
-
OrderStatus["CREDIT_CARD"] = "credit_card";
|
|
830
|
-
})(OrderStatus || (OrderStatus = {}));
|
|
1321
|
+
class CampaignHashtag extends BaseModel {
|
|
1322
|
+
static get identifiersFields() {
|
|
1323
|
+
return ['id'];
|
|
1324
|
+
}
|
|
1325
|
+
}
|
|
831
1326
|
|
|
832
1327
|
class LineItem extends Product {
|
|
833
1328
|
}
|
|
@@ -852,12 +1347,12 @@ __decorate([
|
|
|
852
1347
|
__metadata("design:type", User)
|
|
853
1348
|
], Checkout.prototype, "user", void 0);
|
|
854
1349
|
__decorate([
|
|
855
|
-
Type(() =>
|
|
856
|
-
__metadata("design:type",
|
|
1350
|
+
Type(() => UserAddress),
|
|
1351
|
+
__metadata("design:type", UserAddress)
|
|
857
1352
|
], Checkout.prototype, "shippingAddress", void 0);
|
|
858
1353
|
__decorate([
|
|
859
|
-
Type(() =>
|
|
860
|
-
__metadata("design:type",
|
|
1354
|
+
Type(() => UserAddress),
|
|
1355
|
+
__metadata("design:type", UserAddress)
|
|
861
1356
|
], Checkout.prototype, "billingAddress", void 0);
|
|
862
1357
|
__decorate([
|
|
863
1358
|
Type(() => ShippingMethod),
|
|
@@ -868,6 +1363,18 @@ __decorate([
|
|
|
868
1363
|
__metadata("design:type", Coupon)
|
|
869
1364
|
], Checkout.prototype, "coupon", void 0);
|
|
870
1365
|
|
|
1366
|
+
var OrderStatus;
|
|
1367
|
+
(function (OrderStatus) {
|
|
1368
|
+
OrderStatus["AGUARDANDO_PAGAMENTO"] = "Aguardando pagamento";
|
|
1369
|
+
OrderStatus["EM_PREPARO"] = "Preparando pedido";
|
|
1370
|
+
OrderStatus["NF_EMITIDA"] = "Nota Fiscal Emitida";
|
|
1371
|
+
OrderStatus["AGUARDANDO_ENVIO"] = "Aguardando Transaportadora";
|
|
1372
|
+
OrderStatus["ENVIADO"] = "Enviado";
|
|
1373
|
+
OrderStatus["ENTREGUE"] = "Entregue";
|
|
1374
|
+
OrderStatus["CANCELADO"] = "Cancelado";
|
|
1375
|
+
OrderStatus["CREDIT_CARD"] = "credit_card";
|
|
1376
|
+
})(OrderStatus || (OrderStatus = {}));
|
|
1377
|
+
|
|
871
1378
|
class Order extends Checkout {
|
|
872
1379
|
}
|
|
873
1380
|
__decorate([
|
|
@@ -881,12 +1388,12 @@ class CheckoutSubscription extends BaseModel {
|
|
|
881
1388
|
}
|
|
882
1389
|
}
|
|
883
1390
|
__decorate([
|
|
884
|
-
Type(() =>
|
|
885
|
-
__metadata("design:type",
|
|
1391
|
+
Type(() => UserAddress),
|
|
1392
|
+
__metadata("design:type", UserAddress)
|
|
886
1393
|
], CheckoutSubscription.prototype, "shippingAddress", void 0);
|
|
887
1394
|
__decorate([
|
|
888
|
-
Type(() =>
|
|
889
|
-
__metadata("design:type",
|
|
1395
|
+
Type(() => UserAddress),
|
|
1396
|
+
__metadata("design:type", UserAddress)
|
|
890
1397
|
], CheckoutSubscription.prototype, "billingAddress", void 0);
|
|
891
1398
|
__decorate([
|
|
892
1399
|
Type(() => SubscriptionPlan),
|
|
@@ -897,15 +1404,19 @@ __decorate([
|
|
|
897
1404
|
__metadata("design:type", Coupon)
|
|
898
1405
|
], CheckoutSubscription.prototype, "coupon", void 0);
|
|
899
1406
|
|
|
900
|
-
class
|
|
901
|
-
static
|
|
902
|
-
|
|
1407
|
+
class RoundProductPricesHelper {
|
|
1408
|
+
static roundProductPrices(product) {
|
|
1409
|
+
product.price.price = Number(product.price.price.toFixed(2));
|
|
1410
|
+
product.price.fullPrice = Number(product.price.fullPrice.toFixed(2));
|
|
1411
|
+
if (product.price.subscriberPrice) {
|
|
1412
|
+
product.price.subscriberPrice = Number(product.price.subscriberPrice.toFixed(2));
|
|
1413
|
+
}
|
|
1414
|
+
if (product instanceof LineItem && product.pricePaid) {
|
|
1415
|
+
product.pricePaid = Number(product.pricePaid.toFixed(2));
|
|
1416
|
+
}
|
|
1417
|
+
return product;
|
|
903
1418
|
}
|
|
904
1419
|
}
|
|
905
|
-
__decorate([
|
|
906
|
-
Type(() => Category),
|
|
907
|
-
__metadata("design:type", Array)
|
|
908
|
-
], Buy2Win.prototype, "categories", void 0);
|
|
909
1420
|
|
|
910
1421
|
var FilterType;
|
|
911
1422
|
(function (FilterType) {
|
|
@@ -1006,6 +1517,12 @@ class ShopMenu extends BaseModel {
|
|
|
1006
1517
|
}
|
|
1007
1518
|
}
|
|
1008
1519
|
|
|
1520
|
+
class ShopSettings extends BaseModel {
|
|
1521
|
+
static get identifiersFields() {
|
|
1522
|
+
return ['id'];
|
|
1523
|
+
}
|
|
1524
|
+
}
|
|
1525
|
+
|
|
1009
1526
|
class InvalidArgumentError extends CustomError {
|
|
1010
1527
|
constructor(message) {
|
|
1011
1528
|
super(message);
|
|
@@ -1036,13 +1553,17 @@ class AxiosAdapter {
|
|
|
1036
1553
|
constructor(config) {
|
|
1037
1554
|
this.config = config;
|
|
1038
1555
|
}
|
|
1039
|
-
get(index) {
|
|
1556
|
+
get(index, id) {
|
|
1040
1557
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1041
1558
|
try {
|
|
1042
1559
|
const { data } = yield axios({
|
|
1043
|
-
url: `${this.config.url}/${index}`,
|
|
1560
|
+
url: `${this.config.url}/${index}/_doc/${id}`,
|
|
1044
1561
|
method: 'GET',
|
|
1045
|
-
|
|
1562
|
+
responseType: 'json',
|
|
1563
|
+
headers: {
|
|
1564
|
+
'Content-Type': 'application/json',
|
|
1565
|
+
Authorization: `ApiKey ${this.config.credential}`,
|
|
1566
|
+
},
|
|
1046
1567
|
});
|
|
1047
1568
|
return data._source;
|
|
1048
1569
|
}
|
|
@@ -1056,9 +1577,14 @@ class AxiosAdapter {
|
|
|
1056
1577
|
query(index, query) {
|
|
1057
1578
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1058
1579
|
const { data } = yield axios({
|
|
1059
|
-
url: `${this.config.url}/${index}`,
|
|
1580
|
+
url: `${this.config.url}/${index}/_search`,
|
|
1060
1581
|
method: 'POST',
|
|
1061
|
-
|
|
1582
|
+
responseType: 'json',
|
|
1583
|
+
headers: {
|
|
1584
|
+
Accept: 'application/vnd.elasticsearch+json;compatible-with=7',
|
|
1585
|
+
'Content-Type': 'application/vnd.elasticsearch+json;compatible-with=7',
|
|
1586
|
+
Authorization: `ApiKey ${this.config.credential}`,
|
|
1587
|
+
},
|
|
1062
1588
|
data: query,
|
|
1063
1589
|
});
|
|
1064
1590
|
return {
|
|
@@ -1070,19 +1596,29 @@ class AxiosAdapter {
|
|
|
1070
1596
|
save(index, data) {
|
|
1071
1597
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1072
1598
|
yield axios({
|
|
1073
|
-
url: `${this.config.url}/${index}`,
|
|
1599
|
+
url: `${this.config.url}/${index}/_doc`,
|
|
1600
|
+
method: 'POST',
|
|
1601
|
+
headers: { Authorization: `ApiKey ${this.config.credential}` },
|
|
1602
|
+
data,
|
|
1603
|
+
});
|
|
1604
|
+
});
|
|
1605
|
+
}
|
|
1606
|
+
update(index, id, data) {
|
|
1607
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1608
|
+
yield axios({
|
|
1609
|
+
url: `${this.config.url}/${index}/_update/${id}`,
|
|
1074
1610
|
method: 'PUT',
|
|
1075
|
-
headers: { Authorization: `
|
|
1611
|
+
headers: { Authorization: `ApiKey ${this.config.credential}` },
|
|
1076
1612
|
data,
|
|
1077
1613
|
});
|
|
1078
1614
|
});
|
|
1079
1615
|
}
|
|
1080
|
-
delete(index) {
|
|
1616
|
+
delete(index, id) {
|
|
1081
1617
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1082
1618
|
yield axios({
|
|
1083
|
-
url: `${this.config.url}/${index}`,
|
|
1619
|
+
url: `${this.config.url}/${index}/_doc/${id}`,
|
|
1084
1620
|
method: 'DELETE',
|
|
1085
|
-
headers: { Authorization: `
|
|
1621
|
+
headers: { Authorization: `ApiKey ${this.config.credential}` },
|
|
1086
1622
|
});
|
|
1087
1623
|
});
|
|
1088
1624
|
}
|
|
@@ -1091,16 +1627,19 @@ class AxiosAdapter {
|
|
|
1091
1627
|
class ProductsIndex {
|
|
1092
1628
|
constructor(adapter) {
|
|
1093
1629
|
this.adapter = adapter;
|
|
1630
|
+
this.index = `products`;
|
|
1094
1631
|
}
|
|
1095
|
-
|
|
1632
|
+
getById(id) {
|
|
1096
1633
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1097
|
-
const data = yield this.adapter.get(
|
|
1634
|
+
const data = yield this.adapter.get(this.index, id);
|
|
1098
1635
|
return Product.toInstance(data);
|
|
1099
1636
|
});
|
|
1100
1637
|
}
|
|
1101
|
-
|
|
1638
|
+
search(searchTerm, total, shop) {
|
|
1102
1639
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1640
|
+
const size = total >= 10 ? 500 : 9;
|
|
1103
1641
|
const fields = [
|
|
1642
|
+
'EAN',
|
|
1104
1643
|
'brand',
|
|
1105
1644
|
'id',
|
|
1106
1645
|
'images',
|
|
@@ -1111,73 +1650,88 @@ class ProductsIndex {
|
|
|
1111
1650
|
'stock',
|
|
1112
1651
|
'slug',
|
|
1113
1652
|
'reviews',
|
|
1114
|
-
'pricePaid',
|
|
1115
|
-
'isGift',
|
|
1116
|
-
'stock',
|
|
1117
|
-
'weight',
|
|
1118
|
-
'tags',
|
|
1119
1653
|
'hasVariants',
|
|
1120
|
-
'
|
|
1654
|
+
'rate',
|
|
1121
1655
|
];
|
|
1122
|
-
const
|
|
1656
|
+
const filter = [{ term: { published: true } }];
|
|
1657
|
+
if (size > 9) {
|
|
1658
|
+
fields.push(...['pricePaid', 'isGift', 'stock', 'weight', 'tags']);
|
|
1659
|
+
}
|
|
1660
|
+
else {
|
|
1661
|
+
filter.push({ term: { tags: shop == Shops.GLAMSHOP ? 'feminino' : 'masculino' } });
|
|
1662
|
+
}
|
|
1663
|
+
const search = yield this.adapter.query(this.index, {
|
|
1664
|
+
size,
|
|
1665
|
+
_source: fields,
|
|
1666
|
+
query: {
|
|
1123
1667
|
bool: {
|
|
1124
|
-
|
|
1125
|
-
{
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1668
|
+
must: {
|
|
1669
|
+
multi_match: {
|
|
1670
|
+
query: `${searchTerm}`,
|
|
1671
|
+
type: 'bool_prefix',
|
|
1672
|
+
fields: [
|
|
1673
|
+
'name',
|
|
1674
|
+
'name.folded',
|
|
1675
|
+
'name.search',
|
|
1676
|
+
'description',
|
|
1677
|
+
'description.search',
|
|
1678
|
+
'description.folded',
|
|
1679
|
+
'brand',
|
|
1680
|
+
'brand.search',
|
|
1681
|
+
'brand.folded',
|
|
1682
|
+
],
|
|
1683
|
+
fuzziness: 2,
|
|
1129
1684
|
},
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1685
|
+
},
|
|
1686
|
+
should: {
|
|
1687
|
+
match_phrase_prefix: {
|
|
1688
|
+
'name.search': {
|
|
1689
|
+
query: `${searchTerm}`,
|
|
1690
|
+
slop: 10,
|
|
1133
1691
|
},
|
|
1134
1692
|
},
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
{
|
|
1138
|
-
range: {
|
|
1139
|
-
'stock.quantity': {
|
|
1140
|
-
gt: 0,
|
|
1141
|
-
},
|
|
1142
|
-
},
|
|
1143
|
-
},
|
|
1144
|
-
]
|
|
1145
|
-
: []),
|
|
1146
|
-
],
|
|
1693
|
+
},
|
|
1694
|
+
filter,
|
|
1147
1695
|
},
|
|
1148
|
-
}
|
|
1149
|
-
|
|
1696
|
+
},
|
|
1697
|
+
});
|
|
1698
|
+
search.hits = search.hits
|
|
1699
|
+
.filter((e) => e._source.name !== '')
|
|
1700
|
+
.map((hit) => {
|
|
1701
|
+
RoundProductPricesHelper.roundProductPrices(hit._source);
|
|
1702
|
+
return hit;
|
|
1703
|
+
});
|
|
1704
|
+
return search;
|
|
1150
1705
|
});
|
|
1151
1706
|
}
|
|
1152
1707
|
save(product) {
|
|
1153
1708
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1154
|
-
delete product.createdAt;
|
|
1155
|
-
delete product.updatedAt;
|
|
1156
|
-
delete product.kitProducts;
|
|
1157
1709
|
try {
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
yield this.get(product.firestoreId);
|
|
1161
|
-
yield this.adapter.save(`products/_doc/${product.firestoreId}`, product.toPlain());
|
|
1710
|
+
const { createdAt, updatedAt, kitProducts } = product, data = __rest(product, ["createdAt", "updatedAt", "kitProducts"]);
|
|
1711
|
+
this.adapter.save(this.index, data);
|
|
1162
1712
|
}
|
|
1163
1713
|
catch (error) {
|
|
1164
|
-
|
|
1165
|
-
throw error;
|
|
1166
|
-
console.error(error.message);
|
|
1167
|
-
yield this.adapter.save(`products/_doc/${product.id}`, product.toPlain());
|
|
1714
|
+
console.error(error);
|
|
1168
1715
|
}
|
|
1169
1716
|
});
|
|
1170
1717
|
}
|
|
1171
|
-
|
|
1718
|
+
update(product) {
|
|
1172
1719
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1173
|
-
if (!product.firestoreId)
|
|
1174
|
-
return;
|
|
1175
1720
|
try {
|
|
1176
|
-
yield this.
|
|
1177
|
-
yield this.adapter.delete(`products/_doc/${product.firestoreId}`);
|
|
1721
|
+
yield this.adapter.update(this.index, product.id, product);
|
|
1178
1722
|
}
|
|
1179
1723
|
catch (error) {
|
|
1180
|
-
|
|
1724
|
+
console.error(error);
|
|
1725
|
+
}
|
|
1726
|
+
});
|
|
1727
|
+
}
|
|
1728
|
+
delete(id) {
|
|
1729
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1730
|
+
try {
|
|
1731
|
+
yield this.adapter.delete(this.index, id);
|
|
1732
|
+
}
|
|
1733
|
+
catch (error) {
|
|
1734
|
+
console.error(error);
|
|
1181
1735
|
}
|
|
1182
1736
|
});
|
|
1183
1737
|
}
|
|
@@ -1205,17 +1759,39 @@ const withFirestore = (MixinBase) => {
|
|
|
1205
1759
|
? data[key].map((element) => (isObjectsAndNoDate(element) ? bindAllDateFromObject(element) : element))
|
|
1206
1760
|
: bindDate(data[key], key) })), {});
|
|
1207
1761
|
};
|
|
1762
|
+
const omitByRecursivelyInPlace = (value, iteratee) => {
|
|
1763
|
+
each(value, (v, k) => {
|
|
1764
|
+
if (iteratee(v, k)) {
|
|
1765
|
+
unset(value, k);
|
|
1766
|
+
}
|
|
1767
|
+
else if (isObject(v)) {
|
|
1768
|
+
omitByRecursivelyInPlace(v, iteratee);
|
|
1769
|
+
}
|
|
1770
|
+
});
|
|
1771
|
+
return value;
|
|
1772
|
+
};
|
|
1208
1773
|
return class extends MixinBase {
|
|
1209
|
-
constructor() {
|
|
1210
|
-
|
|
1774
|
+
constructor(...params) {
|
|
1775
|
+
const options = params[0];
|
|
1776
|
+
super(...params);
|
|
1777
|
+
this.fields = {};
|
|
1778
|
+
this.interceptors = {};
|
|
1211
1779
|
this.collectionName = '';
|
|
1780
|
+
this.firestore = options.firestore;
|
|
1781
|
+
this.collectionName = options.collectionName;
|
|
1782
|
+
this.model = options.model;
|
|
1783
|
+
this.fields = options.fields;
|
|
1784
|
+
this.interceptors = options.interceptors;
|
|
1212
1785
|
}
|
|
1213
1786
|
collection(path) {
|
|
1214
1787
|
return collection(this.firestore, path || this.collectionName).withConverter(this.buildModelInstance());
|
|
1215
1788
|
}
|
|
1216
1789
|
buildModelInstance() {
|
|
1217
1790
|
return {
|
|
1218
|
-
toFirestore: (data) =>
|
|
1791
|
+
toFirestore: (data) => {
|
|
1792
|
+
const plain = (data === null || data === void 0 ? void 0 : data.toPlain) ? data.toPlain() : data;
|
|
1793
|
+
return omitByRecursivelyInPlace(plain, (value) => value === undefined);
|
|
1794
|
+
},
|
|
1219
1795
|
fromFirestore: (snap) => {
|
|
1220
1796
|
const data = snap.data();
|
|
1221
1797
|
let bindedData = null;
|
|
@@ -1255,12 +1831,16 @@ const withHelpers = (MixinBase) => {
|
|
|
1255
1831
|
const withGetFirestore = (MixinBase) => {
|
|
1256
1832
|
return class GetFirestore extends MixinBase {
|
|
1257
1833
|
get(identifiers) {
|
|
1834
|
+
var _a, _b, _c, _d;
|
|
1258
1835
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1259
|
-
const
|
|
1836
|
+
const instance = this.model.toInstance(this.model.identifiersFields.reduce((acc, field) => (Object.assign(Object.assign({}, acc), { [field]: identifiers[field] })), {}));
|
|
1837
|
+
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 }));
|
|
1838
|
+
const builded = (intercepted === null || intercepted === void 0 ? void 0 : intercepted.instance) || instance;
|
|
1839
|
+
const docRef = yield getDoc(doc(yield this.collection(this.buildCollectionPathForGet(identifiers)), Object.values(builded.identifier).shift().toString()));
|
|
1260
1840
|
const data = docRef.data();
|
|
1261
1841
|
if (isNil(data))
|
|
1262
1842
|
throw new NotFoundError(`Document ${JSON.stringify(identifiers)} not found`);
|
|
1263
|
-
return data;
|
|
1843
|
+
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
1844
|
});
|
|
1265
1845
|
}
|
|
1266
1846
|
buildCollectionPathForGet(identifiers) {
|
|
@@ -1339,9 +1919,13 @@ const withFindFirestore = (MixinBase) => {
|
|
|
1339
1919
|
return Object.keys(fieldsToOrderBy).map((fieldName) => orderBy(fieldName, fieldsToOrderBy[fieldName]));
|
|
1340
1920
|
};
|
|
1341
1921
|
}
|
|
1342
|
-
find(
|
|
1922
|
+
find(find = {}) {
|
|
1923
|
+
var _a, _b, _c, _d, _e, _f;
|
|
1343
1924
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1344
|
-
const collection = this.collection(this.buildCollectionPathForFind(filters));
|
|
1925
|
+
const collection = this.collection(this.buildCollectionPathForFind(find.filters));
|
|
1926
|
+
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;
|
|
1927
|
+
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 }));
|
|
1928
|
+
const { filters, limits, orderBy } = intercepted.find || find;
|
|
1345
1929
|
const queries = this.makeFirestoreWhere(filters || {});
|
|
1346
1930
|
const ordination = this.makeFirestoreOrderBy(filters, orderBy);
|
|
1347
1931
|
const offsets = yield this.defineLimits(filters, limits);
|
|
@@ -1349,8 +1933,8 @@ const withFindFirestore = (MixinBase) => {
|
|
|
1349
1933
|
const docs = yield getDocs(query(collection, ...queryArgumments));
|
|
1350
1934
|
const data = docs.docs.map((doc) => doc.data());
|
|
1351
1935
|
return {
|
|
1352
|
-
data,
|
|
1353
|
-
count: this.calculateCount(data, limits),
|
|
1936
|
+
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,
|
|
1937
|
+
count: enableCount ? this.calculateCount(data, limits) : Infinity,
|
|
1354
1938
|
};
|
|
1355
1939
|
});
|
|
1356
1940
|
}
|
|
@@ -1362,11 +1946,12 @@ const withFindFirestore = (MixinBase) => {
|
|
|
1362
1946
|
return `${this.parentRepository.collectionName}/${parentId}/${this.collectionName}`;
|
|
1363
1947
|
}
|
|
1364
1948
|
defineLimits(filters, limits) {
|
|
1949
|
+
var _a;
|
|
1365
1950
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1366
1951
|
const queries = [];
|
|
1367
1952
|
if (limits === null || limits === void 0 ? void 0 : limits.offset) {
|
|
1368
1953
|
if (this.model.isModel(limits.offset))
|
|
1369
|
-
queries.push(startAfter(yield getDoc(doc(this.collection(this.buildCollectionPathForFind(filters)), limits.offset.identifier.shift()))));
|
|
1954
|
+
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
1955
|
else if (isNumber(limits.offset) || isString(limits.offset))
|
|
1371
1956
|
queries.push(startAt(limits.offset));
|
|
1372
1957
|
}
|
|
@@ -1388,16 +1973,21 @@ const withFindFirestore = (MixinBase) => {
|
|
|
1388
1973
|
const withCreateFirestore = (MixinBase) => {
|
|
1389
1974
|
return class CreateFirestore extends MixinBase {
|
|
1390
1975
|
create(data) {
|
|
1976
|
+
var _a, _b, _c, _d;
|
|
1391
1977
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1392
|
-
const
|
|
1978
|
+
const instance = this.model.toInstance(data);
|
|
1979
|
+
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 }));
|
|
1980
|
+
const builded = (intercepted === null || intercepted === void 0 ? void 0 : intercepted.instance) || instance;
|
|
1981
|
+
const docRef = yield this.save(builded);
|
|
1393
1982
|
const doc = yield getDoc(docRef);
|
|
1394
|
-
|
|
1983
|
+
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();
|
|
1984
|
+
return docBuilded;
|
|
1395
1985
|
});
|
|
1396
1986
|
}
|
|
1397
1987
|
save(data) {
|
|
1398
1988
|
var _a, _b;
|
|
1399
1989
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1400
|
-
const id = (_b =
|
|
1990
|
+
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
1991
|
const collectionPath = this.buildCollectionPathForAdd(data);
|
|
1402
1992
|
const collection = this.collection(collectionPath);
|
|
1403
1993
|
if (isEmpty(id))
|
|
@@ -1439,13 +2029,17 @@ const withUpdateFirestore = (MixinBase) => {
|
|
|
1439
2029
|
};
|
|
1440
2030
|
return class UpdateFirestore extends MixinBase {
|
|
1441
2031
|
update(data) {
|
|
2032
|
+
var _a, _b, _c, _d;
|
|
1442
2033
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1443
2034
|
const model = new this.model();
|
|
1444
2035
|
const keyField = model.identifiersFields.shift();
|
|
1445
2036
|
const docRef = doc(this.collection(this.buildCollectionPathForUpdate(data)), getValueFromParams(data, keyField).toString());
|
|
1446
|
-
|
|
1447
|
-
const
|
|
1448
|
-
|
|
2037
|
+
const plainFromData = this.model.toInstance(this.paramsToPlain(data));
|
|
2038
|
+
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 }));
|
|
2039
|
+
const builded = (intercepted === null || intercepted === void 0 ? void 0 : intercepted.instance) || plainFromData;
|
|
2040
|
+
yield setDoc(docRef, builded.toPlain(), { merge: true });
|
|
2041
|
+
const docData = yield getDoc(docRef).then((doc) => doc.data());
|
|
2042
|
+
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
2043
|
});
|
|
1450
2044
|
}
|
|
1451
2045
|
buildCollectionPathForUpdate(identifiers) {
|
|
@@ -1465,8 +2059,13 @@ const withUpdateFirestore = (MixinBase) => {
|
|
|
1465
2059
|
const withDeleteFirestore = (MixinBase) => {
|
|
1466
2060
|
return class DeleteFirestore extends MixinBase {
|
|
1467
2061
|
delete(identifiers) {
|
|
2062
|
+
var _a, _b, _c, _d;
|
|
1468
2063
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1469
|
-
|
|
2064
|
+
const instance = this.model.toInstance(this.model.identifiersFields.reduce((acc, field) => (Object.assign(Object.assign({}, acc), { [field]: identifiers[field] })), {}));
|
|
2065
|
+
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 }));
|
|
2066
|
+
const builded = (intercepted === null || intercepted === void 0 ? void 0 : intercepted.instance) || instance;
|
|
2067
|
+
yield deleteDoc(doc(this.collection(this.buildCollectionPathForRemove(identifiers)), Object.values(builded.identifier).shift().toString()));
|
|
2068
|
+
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
2069
|
});
|
|
1471
2070
|
}
|
|
1472
2071
|
buildCollectionPathForRemove(identifiers) {
|
|
@@ -1479,8 +2078,10 @@ const withDeleteFirestore = (MixinBase) => {
|
|
|
1479
2078
|
|
|
1480
2079
|
const withSubCollection = (MixinBase, ParentModel) => {
|
|
1481
2080
|
return class SubCollectionMix extends MixinBase {
|
|
1482
|
-
constructor(...
|
|
1483
|
-
|
|
2081
|
+
constructor(...params) {
|
|
2082
|
+
const options = params[0];
|
|
2083
|
+
super(...params);
|
|
2084
|
+
this.parentIdField = options.parentIdField;
|
|
1484
2085
|
}
|
|
1485
2086
|
collection(path) {
|
|
1486
2087
|
return super.collection(path);
|
|
@@ -1494,73 +2095,87 @@ const withCrudFirestore = (MixinBase) => {
|
|
|
1494
2095
|
};
|
|
1495
2096
|
|
|
1496
2097
|
class LeadFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1497
|
-
constructor(firestore) {
|
|
1498
|
-
super(
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
2098
|
+
constructor({ firestore, interceptors }) {
|
|
2099
|
+
super({
|
|
2100
|
+
firestore,
|
|
2101
|
+
collectionName: 'leads',
|
|
2102
|
+
model: Lead,
|
|
2103
|
+
interceptors,
|
|
2104
|
+
});
|
|
1502
2105
|
}
|
|
1503
2106
|
}
|
|
1504
2107
|
|
|
1505
2108
|
class SubscriptionEditionFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), Subscription) {
|
|
1506
|
-
constructor(firestore, parentRepository) {
|
|
1507
|
-
super(
|
|
1508
|
-
|
|
2109
|
+
constructor({ firestore, interceptors }, parentRepository) {
|
|
2110
|
+
super({
|
|
2111
|
+
firestore,
|
|
2112
|
+
collectionName: 'editions',
|
|
2113
|
+
parentIdField: 'subscriptionId',
|
|
2114
|
+
model: Edition,
|
|
2115
|
+
interceptors,
|
|
2116
|
+
});
|
|
1509
2117
|
this.parentRepository = parentRepository;
|
|
1510
|
-
this.collectionName = 'editions';
|
|
1511
|
-
this.parentIdField = 'subscriptionId';
|
|
1512
|
-
this.model = Edition;
|
|
1513
2118
|
}
|
|
1514
2119
|
}
|
|
1515
2120
|
|
|
1516
2121
|
class SubscriptionFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1517
|
-
constructor(firestore) {
|
|
1518
|
-
super(
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
2122
|
+
constructor({ firestore, interceptors, }) {
|
|
2123
|
+
super({
|
|
2124
|
+
firestore,
|
|
2125
|
+
collectionName: 'subscription',
|
|
2126
|
+
model: Subscription,
|
|
2127
|
+
interceptors,
|
|
2128
|
+
});
|
|
1522
2129
|
}
|
|
1523
2130
|
}
|
|
1524
2131
|
|
|
1525
2132
|
class SubscriptionPaymentFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), Subscription) {
|
|
1526
|
-
constructor(firestore, parentRepository) {
|
|
1527
|
-
super(
|
|
1528
|
-
|
|
2133
|
+
constructor({ firestore, interceptors }, parentRepository) {
|
|
2134
|
+
super({
|
|
2135
|
+
firestore,
|
|
2136
|
+
collectionName: 'payments',
|
|
2137
|
+
parentIdField: 'subscriptionId',
|
|
2138
|
+
model: SubscriptionPayment,
|
|
2139
|
+
interceptors,
|
|
2140
|
+
});
|
|
1529
2141
|
this.parentRepository = parentRepository;
|
|
1530
|
-
this.collectionName = 'payments';
|
|
1531
|
-
this.parentIdField = 'subscriptionId';
|
|
1532
|
-
this.model = SubscriptionPayment;
|
|
1533
2142
|
}
|
|
1534
2143
|
}
|
|
1535
2144
|
|
|
1536
2145
|
class UserAddressFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), User) {
|
|
1537
|
-
constructor(firestore, parentRepository) {
|
|
1538
|
-
super(
|
|
1539
|
-
|
|
2146
|
+
constructor({ firestore, interceptors }, parentRepository) {
|
|
2147
|
+
super({
|
|
2148
|
+
firestore,
|
|
2149
|
+
collectionName: 'address',
|
|
2150
|
+
parentIdField: 'userId',
|
|
2151
|
+
model: UserAddress,
|
|
2152
|
+
interceptors,
|
|
2153
|
+
});
|
|
1540
2154
|
this.parentRepository = parentRepository;
|
|
1541
|
-
this.collectionName = 'address';
|
|
1542
|
-
this.parentIdField = 'userId';
|
|
1543
|
-
this.model = UserAddress;
|
|
1544
2155
|
}
|
|
1545
2156
|
}
|
|
1546
2157
|
|
|
1547
2158
|
class UserBeautyProfileFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), User) {
|
|
1548
|
-
constructor(firestore, parentRepository) {
|
|
1549
|
-
super(
|
|
1550
|
-
|
|
2159
|
+
constructor({ firestore, interceptors }, parentRepository) {
|
|
2160
|
+
super({
|
|
2161
|
+
firestore,
|
|
2162
|
+
collectionName: 'CX',
|
|
2163
|
+
parentIdField: 'userId',
|
|
2164
|
+
model: BeautyProfile,
|
|
2165
|
+
interceptors,
|
|
2166
|
+
});
|
|
1551
2167
|
this.parentRepository = parentRepository;
|
|
1552
|
-
this.collectionName = 'CX';
|
|
1553
|
-
this.parentIdField = 'userId';
|
|
1554
|
-
this.model = BeautyProfile;
|
|
1555
2168
|
}
|
|
1556
2169
|
}
|
|
1557
2170
|
|
|
1558
2171
|
class UserFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1559
|
-
constructor(firestore) {
|
|
1560
|
-
super(
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
2172
|
+
constructor({ firestore, interceptors }) {
|
|
2173
|
+
super({
|
|
2174
|
+
firestore,
|
|
2175
|
+
collectionName: 'users',
|
|
2176
|
+
model: User,
|
|
2177
|
+
interceptors,
|
|
2178
|
+
});
|
|
1564
2179
|
}
|
|
1565
2180
|
get(identifiers) {
|
|
1566
2181
|
const _super = Object.create(null, {
|
|
@@ -1611,22 +2226,26 @@ class UserFirestoreRepository extends withCrudFirestore(withHelpers(withFirestor
|
|
|
1611
2226
|
}
|
|
1612
2227
|
|
|
1613
2228
|
class UserPaymentMethodFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), User) {
|
|
1614
|
-
constructor(firestore, parentRepository) {
|
|
1615
|
-
super(
|
|
1616
|
-
|
|
2229
|
+
constructor({ firestore, interceptors }, parentRepository) {
|
|
2230
|
+
super({
|
|
2231
|
+
firestore,
|
|
2232
|
+
collectionName: 'payment_method',
|
|
2233
|
+
parentIdField: 'userId',
|
|
2234
|
+
model: UserPaymentMethod,
|
|
2235
|
+
interceptors,
|
|
2236
|
+
});
|
|
1617
2237
|
this.parentRepository = parentRepository;
|
|
1618
|
-
this.collectionName = 'payment_method';
|
|
1619
|
-
this.parentIdField = 'userId';
|
|
1620
|
-
this.model = UserPaymentMethod;
|
|
1621
2238
|
}
|
|
1622
2239
|
}
|
|
1623
2240
|
|
|
1624
2241
|
class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1625
|
-
constructor(firestore) {
|
|
1626
|
-
super(
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
2242
|
+
constructor({ firestore, interceptors }) {
|
|
2243
|
+
super({
|
|
2244
|
+
firestore,
|
|
2245
|
+
collectionName: 'categories',
|
|
2246
|
+
model: Category,
|
|
2247
|
+
interceptors,
|
|
2248
|
+
});
|
|
1630
2249
|
}
|
|
1631
2250
|
getCategoryBySlug(slug, shop) {
|
|
1632
2251
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -1638,7 +2257,7 @@ class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFire
|
|
|
1638
2257
|
return categoryDocs.docs[0].data();
|
|
1639
2258
|
});
|
|
1640
2259
|
}
|
|
1641
|
-
getCategoriesForHome(categoryIds, limit = 4) {
|
|
2260
|
+
getCategoriesForHome(categoryIds, limit = 4, gender) {
|
|
1642
2261
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1643
2262
|
const categorySnap = yield getDocs(query(this.collection(this.collectionName), where('id', 'in', categoryIds.filter(Boolean)), where('published', '==', true)));
|
|
1644
2263
|
if (categorySnap.empty)
|
|
@@ -1647,7 +2266,7 @@ class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFire
|
|
|
1647
2266
|
const homeSections = yield Promise.all(categories.map((category) => __awaiter(this, void 0, void 0, function* () {
|
|
1648
2267
|
return ({
|
|
1649
2268
|
category,
|
|
1650
|
-
products: yield this.mountCategory(category, { limit, hasStock: true }),
|
|
2269
|
+
products: yield this.mountCategory(category, { limit, hasStock: true, gender }),
|
|
1651
2270
|
});
|
|
1652
2271
|
})));
|
|
1653
2272
|
return homeSections;
|
|
@@ -1666,6 +2285,8 @@ class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFire
|
|
|
1666
2285
|
wheres.push(where('published', '==', true), where('id', 'in', productIds));
|
|
1667
2286
|
if (options === null || options === void 0 ? void 0 : options.hasStock)
|
|
1668
2287
|
wheres.push(where('stock.quantity', '>', 0));
|
|
2288
|
+
if (options === null || options === void 0 ? void 0 : options.gender)
|
|
2289
|
+
wheres.push(where('tags', 'array-contains', options === null || options === void 0 ? void 0 : options.gender));
|
|
1669
2290
|
if (options === null || options === void 0 ? void 0 : options.limit)
|
|
1670
2291
|
wheres.push(limit(options === null || options === void 0 ? void 0 : options.limit));
|
|
1671
2292
|
const productSnap = yield getDocs(query(this.collection('productsErpVitrine'), ...wheres));
|
|
@@ -1676,15 +2297,26 @@ class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFire
|
|
|
1676
2297
|
return is(products);
|
|
1677
2298
|
});
|
|
1678
2299
|
}
|
|
2300
|
+
getCategoryByShop(shop) {
|
|
2301
|
+
return;
|
|
2302
|
+
}
|
|
2303
|
+
getChildren(parentId) {
|
|
2304
|
+
return;
|
|
2305
|
+
}
|
|
2306
|
+
isChild(id, parentId) {
|
|
2307
|
+
return;
|
|
2308
|
+
}
|
|
1679
2309
|
}
|
|
1680
2310
|
|
|
1681
2311
|
class ProductFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1682
|
-
constructor(firestore) {
|
|
1683
|
-
super(
|
|
1684
|
-
|
|
2312
|
+
constructor({ firestore, interceptors }) {
|
|
2313
|
+
super({
|
|
2314
|
+
firestore,
|
|
2315
|
+
collectionName: 'productsErpVitrine',
|
|
2316
|
+
model: Product,
|
|
2317
|
+
interceptors,
|
|
2318
|
+
});
|
|
1685
2319
|
this.reviews = {};
|
|
1686
|
-
this.collectionName = 'productsErpVitrine';
|
|
1687
|
-
this.model = Product;
|
|
1688
2320
|
}
|
|
1689
2321
|
getBySlug(slug) {
|
|
1690
2322
|
var _a;
|
|
@@ -1725,43 +2357,98 @@ class ProductFirestoreRepository extends withCrudFirestore(withHelpers(withFires
|
|
|
1725
2357
|
return this.reviews[status];
|
|
1726
2358
|
});
|
|
1727
2359
|
}
|
|
2360
|
+
cleanShoppingCountFromIds() {
|
|
2361
|
+
return;
|
|
2362
|
+
}
|
|
1728
2363
|
}
|
|
1729
2364
|
|
|
1730
2365
|
class ProductVariantFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), Product) {
|
|
1731
|
-
constructor(firestore, parentRepository) {
|
|
1732
|
-
super(
|
|
1733
|
-
|
|
2366
|
+
constructor({ firestore, interceptors }, parentRepository) {
|
|
2367
|
+
super({
|
|
2368
|
+
firestore,
|
|
2369
|
+
collectionName: 'variants',
|
|
2370
|
+
parentIdField: 'productId',
|
|
2371
|
+
model: Variant,
|
|
2372
|
+
interceptors,
|
|
2373
|
+
});
|
|
1734
2374
|
this.parentRepository = parentRepository;
|
|
1735
|
-
this.collectionName = 'variants';
|
|
1736
|
-
this.parentIdField = 'productId';
|
|
1737
|
-
this.model = Variant;
|
|
1738
2375
|
}
|
|
1739
2376
|
}
|
|
1740
2377
|
|
|
1741
2378
|
class SubscriptionProductFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1742
|
-
constructor(firestore) {
|
|
1743
|
-
super(
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
2379
|
+
constructor({ firestore, interceptors }) {
|
|
2380
|
+
super({
|
|
2381
|
+
firestore,
|
|
2382
|
+
collectionName: 'subscriptionProducts',
|
|
2383
|
+
model: Product,
|
|
2384
|
+
interceptors,
|
|
2385
|
+
});
|
|
2386
|
+
}
|
|
2387
|
+
}
|
|
2388
|
+
|
|
2389
|
+
class Buy2WinFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
2390
|
+
constructor({ firestore, interceptors }) {
|
|
2391
|
+
super({
|
|
2392
|
+
firestore,
|
|
2393
|
+
collectionName: 'buy2win',
|
|
2394
|
+
model: Buy2Win,
|
|
2395
|
+
interceptors,
|
|
2396
|
+
});
|
|
2397
|
+
}
|
|
2398
|
+
}
|
|
2399
|
+
|
|
2400
|
+
class CampaignDashboardFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
2401
|
+
constructor({ firestore, interceptors, }) {
|
|
2402
|
+
super({
|
|
2403
|
+
firestore,
|
|
2404
|
+
collectionName: 'dashboardCampaignsAuto',
|
|
2405
|
+
model: CampaignDashboard,
|
|
2406
|
+
interceptors,
|
|
2407
|
+
});
|
|
2408
|
+
}
|
|
2409
|
+
}
|
|
2410
|
+
|
|
2411
|
+
class CampaignHashtagFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
2412
|
+
constructor({ firestore, interceptors, }) {
|
|
2413
|
+
super({
|
|
2414
|
+
firestore,
|
|
2415
|
+
collectionName: 'hashtagCampaignsAuto',
|
|
2416
|
+
model: CampaignHashtag,
|
|
2417
|
+
interceptors,
|
|
2418
|
+
});
|
|
1747
2419
|
}
|
|
1748
2420
|
}
|
|
1749
2421
|
|
|
1750
2422
|
class CheckoutFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1751
|
-
constructor(firestore) {
|
|
1752
|
-
super(
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
2423
|
+
constructor({ firestore, interceptors }) {
|
|
2424
|
+
super({
|
|
2425
|
+
firestore,
|
|
2426
|
+
collectionName: 'checkouts',
|
|
2427
|
+
model: Checkout,
|
|
2428
|
+
interceptors,
|
|
2429
|
+
});
|
|
2430
|
+
}
|
|
2431
|
+
}
|
|
2432
|
+
|
|
2433
|
+
class CheckoutSubscriptionFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
2434
|
+
constructor({ firestore, interceptors, }) {
|
|
2435
|
+
super({
|
|
2436
|
+
firestore,
|
|
2437
|
+
collectionName: 'checkoutsSubscription',
|
|
2438
|
+
model: CheckoutSubscription,
|
|
2439
|
+
interceptors,
|
|
2440
|
+
});
|
|
1756
2441
|
}
|
|
1757
2442
|
}
|
|
1758
2443
|
|
|
1759
2444
|
class CouponFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1760
|
-
constructor(firestore) {
|
|
1761
|
-
super(
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
2445
|
+
constructor({ firestore, interceptors }) {
|
|
2446
|
+
super({
|
|
2447
|
+
firestore,
|
|
2448
|
+
collectionName: 'coupons',
|
|
2449
|
+
model: Coupon,
|
|
2450
|
+
interceptors,
|
|
2451
|
+
});
|
|
1765
2452
|
}
|
|
1766
2453
|
buildModelInstance() {
|
|
1767
2454
|
const { fromFirestore, toFirestore } = super.buildModelInstance();
|
|
@@ -1783,9 +2470,16 @@ class CouponFirestoreRepository extends withCrudFirestore(withHelpers(withFirest
|
|
|
1783
2470
|
}
|
|
1784
2471
|
|
|
1785
2472
|
class OrderFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1786
|
-
constructor(firestore) {
|
|
1787
|
-
super(
|
|
1788
|
-
|
|
2473
|
+
constructor({ firestore, interceptors }) {
|
|
2474
|
+
super({
|
|
2475
|
+
firestore,
|
|
2476
|
+
collectionName: 'orders',
|
|
2477
|
+
model: Order,
|
|
2478
|
+
interceptors,
|
|
2479
|
+
fields: {
|
|
2480
|
+
status: FirestoreFieldType.String,
|
|
2481
|
+
},
|
|
2482
|
+
});
|
|
1789
2483
|
this.orderFromFirestore = (order) => {
|
|
1790
2484
|
var _a;
|
|
1791
2485
|
if (!!((_a = order === null || order === void 0 ? void 0 : order.lineItems) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
@@ -1799,11 +2493,6 @@ class OrderFirestoreRepository extends withCrudFirestore(withHelpers(withFiresto
|
|
|
1799
2493
|
}
|
|
1800
2494
|
return order;
|
|
1801
2495
|
};
|
|
1802
|
-
this.collectionName = 'orders';
|
|
1803
|
-
this.model = Order;
|
|
1804
|
-
this.fields = {
|
|
1805
|
-
status: FirestoreFieldType.String,
|
|
1806
|
-
};
|
|
1807
2496
|
}
|
|
1808
2497
|
buildModelInstance() {
|
|
1809
2498
|
const { fromFirestore, toFirestore } = super.buildModelInstance();
|
|
@@ -1811,92 +2500,68 @@ class OrderFirestoreRepository extends withCrudFirestore(withHelpers(withFiresto
|
|
|
1811
2500
|
toFirestore: (data) => toFirestore((data === null || data === void 0 ? void 0 : data.toPlain) ? data.toPlain() : data),
|
|
1812
2501
|
fromFirestore: (snap) => {
|
|
1813
2502
|
const instance = fromFirestore(snap);
|
|
1814
|
-
return this.orderFromFirestore(instance);
|
|
1815
|
-
},
|
|
1816
|
-
};
|
|
1817
|
-
}
|
|
1818
|
-
}
|
|
1819
|
-
|
|
1820
|
-
class PaymentFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1821
|
-
constructor(firestore) {
|
|
1822
|
-
super();
|
|
1823
|
-
this.firestore = firestore;
|
|
1824
|
-
this.collectionName = 'payments';
|
|
1825
|
-
this.model = Payment;
|
|
1826
|
-
}
|
|
1827
|
-
}
|
|
1828
|
-
|
|
1829
|
-
class CheckoutSubscriptionFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1830
|
-
constructor(firestore) {
|
|
1831
|
-
super();
|
|
1832
|
-
this.firestore = firestore;
|
|
1833
|
-
this.collectionName = 'checkoutsSubscription';
|
|
1834
|
-
this.model = CheckoutSubscription;
|
|
2503
|
+
return this.orderFromFirestore(instance);
|
|
2504
|
+
},
|
|
2505
|
+
};
|
|
1835
2506
|
}
|
|
1836
2507
|
}
|
|
1837
2508
|
|
|
1838
|
-
class
|
|
1839
|
-
constructor(firestore) {
|
|
1840
|
-
super(
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
2509
|
+
class LegacyOrderFirestoreRepository extends OrderFirestoreRepository {
|
|
2510
|
+
constructor({ firestore, interceptors }) {
|
|
2511
|
+
super({
|
|
2512
|
+
firestore,
|
|
2513
|
+
interceptors,
|
|
2514
|
+
});
|
|
2515
|
+
this.collectionName = 'legacyOrders';
|
|
1844
2516
|
}
|
|
1845
2517
|
}
|
|
1846
2518
|
|
|
1847
|
-
class
|
|
1848
|
-
constructor(firestore) {
|
|
1849
|
-
super(
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
2519
|
+
class PaymentFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
2520
|
+
constructor({ firestore, interceptors }) {
|
|
2521
|
+
super({
|
|
2522
|
+
firestore,
|
|
2523
|
+
collectionName: 'payments',
|
|
2524
|
+
model: Payment,
|
|
2525
|
+
interceptors,
|
|
2526
|
+
});
|
|
1853
2527
|
}
|
|
1854
2528
|
}
|
|
1855
2529
|
|
|
1856
|
-
class
|
|
1857
|
-
constructor(firestore) {
|
|
1858
|
-
super(
|
|
1859
|
-
|
|
1860
|
-
|
|
2530
|
+
class SubscriptionPlanFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
2531
|
+
constructor({ firestore, interceptors, }) {
|
|
2532
|
+
super({
|
|
2533
|
+
firestore,
|
|
2534
|
+
collectionName: 'subscriptionPlans',
|
|
2535
|
+
model: SubscriptionPlan,
|
|
2536
|
+
interceptors,
|
|
2537
|
+
});
|
|
1861
2538
|
}
|
|
1862
2539
|
}
|
|
1863
2540
|
|
|
1864
2541
|
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()),
|
|
2542
|
+
constructor({ firestore, interceptors }) {
|
|
2543
|
+
super({
|
|
2544
|
+
firestore,
|
|
2545
|
+
collectionName: 'dms',
|
|
2546
|
+
model: Home,
|
|
2547
|
+
interceptors,
|
|
1880
2548
|
});
|
|
1881
|
-
this.
|
|
2549
|
+
this.homeCategoryGroupToPlain = (homeCategoryGroup) => {
|
|
2550
|
+
var _a, _b, _c;
|
|
2551
|
+
return ({
|
|
2552
|
+
category: ((_a = homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category) === null || _a === void 0 ? void 0 : _a.toPlain)
|
|
2553
|
+
? (_b = homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category) === null || _b === void 0 ? void 0 : _b.toPlain()
|
|
2554
|
+
: homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category,
|
|
2555
|
+
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)) || [],
|
|
2556
|
+
});
|
|
2557
|
+
};
|
|
2558
|
+
this.plainToHomeCategoryGroup = (homeCategoryGroup) => {
|
|
1882
2559
|
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;
|
|
2560
|
+
return ({
|
|
2561
|
+
category: Category.toInstance(homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category),
|
|
2562
|
+
products: (_a = homeCategoryGroup.products) === null || _a === void 0 ? void 0 : _a.map((product) => Product.toInstance(product)),
|
|
2563
|
+
});
|
|
1893
2564
|
};
|
|
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
2565
|
}
|
|
1901
2566
|
buildModelInstance() {
|
|
1902
2567
|
const { fromFirestore, toFirestore } = super.buildModelInstance();
|
|
@@ -1911,14 +2576,49 @@ class HomeFirestoreRepository extends withCrudFirestore(withHelpers(withFirestor
|
|
|
1911
2576
|
},
|
|
1912
2577
|
};
|
|
1913
2578
|
}
|
|
2579
|
+
homeToFirestore(home) {
|
|
2580
|
+
var _a, _b, _c, _d;
|
|
2581
|
+
if ((_a = home.data) === null || _a === void 0 ? void 0 : _a.data) {
|
|
2582
|
+
home.data.data.discoverProducts = ((_b = home.data.data.discoverProducts) === null || _b === void 0 ? void 0 : _b.map(this.homeCategoryGroupToPlain)) || [];
|
|
2583
|
+
home.data.data.featuredProducts = ((_c = home.data.data.featuredProducts) === null || _c === void 0 ? void 0 : _c.map(this.homeCategoryGroupToPlain)) || [];
|
|
2584
|
+
home.data.data.verticalProducts = ((_d = home.data.data.verticalProducts) === null || _d === void 0 ? void 0 : _d.map(this.homeCategoryGroupToPlain)) || [];
|
|
2585
|
+
}
|
|
2586
|
+
return home;
|
|
2587
|
+
}
|
|
2588
|
+
homeFromFirestore(home) {
|
|
2589
|
+
var _a;
|
|
2590
|
+
if ((_a = home.data) === null || _a === void 0 ? void 0 : _a.data) {
|
|
2591
|
+
home.data.data.discoverProducts = home.data.data.discoverProducts.map(this.plainToHomeCategoryGroup);
|
|
2592
|
+
home.data.data.featuredProducts = home.data.data.featuredProducts.map(this.plainToHomeCategoryGroup);
|
|
2593
|
+
home.data.data.verticalProducts = home.data.data.verticalProducts.map(this.plainToHomeCategoryGroup);
|
|
2594
|
+
home.data.createdAt =
|
|
2595
|
+
home.data.createdAt instanceof Timestamp ? home.data.createdAt.toDate() : home.data.createdAt;
|
|
2596
|
+
home.data.expiresAt =
|
|
2597
|
+
home.data.expiresAt instanceof Timestamp ? home.data.expiresAt.toDate() : home.data.expiresAt;
|
|
2598
|
+
}
|
|
2599
|
+
return home;
|
|
2600
|
+
}
|
|
1914
2601
|
}
|
|
1915
2602
|
|
|
1916
2603
|
class ShopMenuFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1917
|
-
constructor(firestore) {
|
|
1918
|
-
super(
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
2604
|
+
constructor({ firestore, interceptors }) {
|
|
2605
|
+
super({
|
|
2606
|
+
firestore,
|
|
2607
|
+
collectionName: 'shopMenus',
|
|
2608
|
+
model: ShopMenu,
|
|
2609
|
+
interceptors,
|
|
2610
|
+
});
|
|
2611
|
+
}
|
|
2612
|
+
}
|
|
2613
|
+
|
|
2614
|
+
class ShopSettingsFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
2615
|
+
constructor({ firestore, interceptors, }) {
|
|
2616
|
+
super({
|
|
2617
|
+
firestore,
|
|
2618
|
+
collectionName: 'shopSettings',
|
|
2619
|
+
model: ShopSettings,
|
|
2620
|
+
interceptors,
|
|
2621
|
+
});
|
|
1922
2622
|
}
|
|
1923
2623
|
}
|
|
1924
2624
|
|
|
@@ -2008,7 +2708,7 @@ class AttributeOptionHelper {
|
|
|
2008
2708
|
AttributeOptionHelper.FindByAttribute = (attributeName, fields) => {
|
|
2009
2709
|
var _a;
|
|
2010
2710
|
if (fields.includes(attributeName))
|
|
2011
|
-
return { columnName: attributeName.toString(), attributeName };
|
|
2711
|
+
return { columnName: attributeName.toString(), attributeName, to: (value) => value, from: (value) => value };
|
|
2012
2712
|
const field = fields.find((columnOption) => isObject(columnOption) && Object.keys(columnOption).includes(attributeName.toString()));
|
|
2013
2713
|
const fieldOption = (_a = is(field)) === null || _a === void 0 ? void 0 : _a[attributeName];
|
|
2014
2714
|
if (isNil(fieldOption))
|
|
@@ -2097,11 +2797,12 @@ BindFilterQueryHelper.MakeGraphQLWhere = (filter, fields) => Object.keys(filter)
|
|
|
2097
2797
|
}, {});
|
|
2098
2798
|
BindFilterQueryHelper.BuildWhereSentence = (field, options, fields) => {
|
|
2099
2799
|
const fieldSentenceOptions = AttributeOptionHelper.FindByAttribute(field, fields);
|
|
2100
|
-
|
|
2800
|
+
const isNestedField = !Array.isArray(options) &&
|
|
2101
2801
|
isObject(options) &&
|
|
2102
2802
|
isNil(options === null || options === void 0 ? void 0 : options.operator) &&
|
|
2103
2803
|
isNil(options === null || options === void 0 ? void 0 : options.value) &&
|
|
2104
|
-
isNil(fieldSentenceOptions === null || fieldSentenceOptions === void 0 ? void 0 : fieldSentenceOptions.to)
|
|
2804
|
+
isNil(fieldSentenceOptions === null || fieldSentenceOptions === void 0 ? void 0 : fieldSentenceOptions.to);
|
|
2805
|
+
if (isNestedField)
|
|
2105
2806
|
return Object.keys(options).reduce((variables, key) => {
|
|
2106
2807
|
const fieldOptions = AttributeOptionHelper.FindByAttribute(key, (fieldSentenceOptions === null || fieldSentenceOptions === void 0 ? void 0 : fieldSentenceOptions.fields) || fields);
|
|
2107
2808
|
const columnName = fieldOptions.columnName;
|
|
@@ -2112,7 +2813,7 @@ BindFilterQueryHelper.BuildWhereSentence = (field, options, fields) => {
|
|
|
2112
2813
|
return {
|
|
2113
2814
|
[fieldSentenceOptions.fields[0]]: BindFilterQueryHelper.BuildOperatorSentence(options, fieldSentenceOptions),
|
|
2114
2815
|
};
|
|
2115
|
-
if (isObject(options) && !FilterOptionHelper.CheckIfIsFilterOption(options))
|
|
2816
|
+
if (!Array.isArray(options) && isObject(options) && !FilterOptionHelper.CheckIfIsFilterOption(options))
|
|
2116
2817
|
options = Object.values(options)[0];
|
|
2117
2818
|
return Array.isArray(options)
|
|
2118
2819
|
? options.reduce((whereSentence, option) => (Object.assign(Object.assign({}, whereSentence), BindFilterQueryHelper.BuildOperatorSentence(option, fieldSentenceOptions))), {})
|
|
@@ -2144,28 +2845,14 @@ GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields = (fields) => {
|
|
|
2144
2845
|
if (field === 'affected_rows')
|
|
2145
2846
|
return field;
|
|
2146
2847
|
const fieldName = Object.keys(field).shift();
|
|
2147
|
-
const fieldValue = field[fieldName];
|
|
2848
|
+
const fieldValue = is(field[fieldName]);
|
|
2148
2849
|
if (Array.isArray(fieldValue))
|
|
2149
2850
|
return { [fieldName]: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(fieldValue) };
|
|
2150
2851
|
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
|
-
};
|
|
2852
|
+
return;
|
|
2853
|
+
const isNestedField = !!fieldValue.fields;
|
|
2854
|
+
if (isNestedField)
|
|
2855
|
+
return GraphQLFieldHelper.ConvertNestedFieldsToGraphQLFields(fieldName, fieldValue);
|
|
2169
2856
|
return fieldValue.columnName;
|
|
2170
2857
|
}).filter((field) => !!field);
|
|
2171
2858
|
};
|
|
@@ -2183,7 +2870,7 @@ GraphQLFieldHelper.ConvertFieldValueFrom = (data, fields) => Object.keys(data).r
|
|
|
2183
2870
|
}
|
|
2184
2871
|
if (!!from)
|
|
2185
2872
|
return Object.assign(Object.assign({}, result), { [attributeName]: from(data[columnName], data) });
|
|
2186
|
-
return Object.assign(Object.assign({}, result), { [attributeName]: parseDateTime(data[columnName].toString()) });
|
|
2873
|
+
return Object.assign(Object.assign({}, result), { [attributeName]: isString(data[columnName]) ? parseDateTime(data[columnName].toString()) : data[columnName] });
|
|
2187
2874
|
}, {});
|
|
2188
2875
|
GraphQLFieldHelper.ConvertFieldValueTo = (instance, fields, update = false) => {
|
|
2189
2876
|
var _a;
|
|
@@ -2199,7 +2886,8 @@ GraphQLFieldHelper.ConvertFieldValueTo = (instance, fields, update = false) => {
|
|
|
2199
2886
|
!Object.keys(foreignKeyColumn).filter((key) => { var _a; return !((_a = is(data[attributeName])) === null || _a === void 0 ? void 0 : _a[key]); }).length)
|
|
2200
2887
|
return Object.keys(foreignKeyColumn).reduce((object, current) => {
|
|
2201
2888
|
var _a;
|
|
2202
|
-
|
|
2889
|
+
const { columnName: foreignColumnName } = AttributeOptionHelper.FindByAttribute(foreignKeyColumn[current], fields);
|
|
2890
|
+
return Object.assign(Object.assign({}, object), { [foreignColumnName]: (_a = data[attributeName]) === null || _a === void 0 ? void 0 : _a[current] });
|
|
2203
2891
|
}, Object.assign({}, result));
|
|
2204
2892
|
if (update &&
|
|
2205
2893
|
isObject(data[attributeName]) &&
|
|
@@ -2227,6 +2915,25 @@ GraphQLFieldHelper.ConvertFieldValueTo = (instance, fields, update = false) => {
|
|
|
2227
2915
|
return Object.assign(Object.assign({}, result), { [columnName]: data[attributeName] });
|
|
2228
2916
|
}, {});
|
|
2229
2917
|
};
|
|
2918
|
+
GraphQLFieldHelper.ConvertNestedFieldsToGraphQLFields = (fieldName, fieldValue) => {
|
|
2919
|
+
const hasCustomFilters = !!fieldValue.filters;
|
|
2920
|
+
if (hasCustomFilters)
|
|
2921
|
+
return {
|
|
2922
|
+
operation: fieldValue.columnName || fieldName,
|
|
2923
|
+
fields: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(fieldValue.fields),
|
|
2924
|
+
variables: {
|
|
2925
|
+
[`${fieldValue.columnName}_where`]: {
|
|
2926
|
+
name: 'where',
|
|
2927
|
+
type: fieldValue.filters.filterType,
|
|
2928
|
+
value: BindFilterQueryHelper.MakeGraphQLWhere(fieldValue.filters.filters, fieldValue.fields),
|
|
2929
|
+
required: true,
|
|
2930
|
+
},
|
|
2931
|
+
},
|
|
2932
|
+
};
|
|
2933
|
+
return {
|
|
2934
|
+
[fieldValue.columnName || fieldName]: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(fieldValue.fields),
|
|
2935
|
+
};
|
|
2936
|
+
};
|
|
2230
2937
|
|
|
2231
2938
|
const withCreateHasuraGraphQL = (MixinBase) => {
|
|
2232
2939
|
return class CreateHasuraGraphQLMixin extends MixinBase {
|
|
@@ -2238,6 +2945,7 @@ const withCreateHasuraGraphQL = (MixinBase) => {
|
|
|
2238
2945
|
}
|
|
2239
2946
|
create(data) {
|
|
2240
2947
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2948
|
+
this.logger = DebugHelper.from(this, 'create');
|
|
2241
2949
|
const newData = yield this.save(this.model.toInstance(data));
|
|
2242
2950
|
return this.model.toInstance(newData);
|
|
2243
2951
|
});
|
|
@@ -2250,12 +2958,11 @@ const withCreateHasuraGraphQL = (MixinBase) => {
|
|
|
2250
2958
|
const columnOptions = Object.values(field).shift();
|
|
2251
2959
|
return (AttributeOptionHelper.CheckIsColumnOption(columnOptions) &&
|
|
2252
2960
|
columnOptions.foreignKeyColumn && [
|
|
2253
|
-
...Object.values(columnOptions.foreignKeyColumn),
|
|
2961
|
+
...Object.values(columnOptions.foreignKeyColumn).map((foreignKeyName) => { var _a; return (_a = AttributeOptionHelper.FindByAttribute(foreignKeyName, this.fields)) === null || _a === void 0 ? void 0 : _a.columnName; }),
|
|
2254
2962
|
{
|
|
2255
2963
|
[columnOptions.columnName]: Object.keys(columnOptions.foreignKeyColumn).map((foreignKeyField) => {
|
|
2256
2964
|
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;
|
|
2965
|
+
return ((_a = AttributeOptionHelper.FindByAttribute(foreignKeyField, columnOptions === null || columnOptions === void 0 ? void 0 : columnOptions.fields)) === null || _a === void 0 ? void 0 : _a.columnName) || foreignKeyField;
|
|
2259
2966
|
}),
|
|
2260
2967
|
},
|
|
2261
2968
|
]);
|
|
@@ -2280,9 +2987,11 @@ const withDeleteHasuraGraphQL = (MixinBase) => {
|
|
|
2280
2987
|
}
|
|
2281
2988
|
delete(identifiers) {
|
|
2282
2989
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2990
|
+
this.logger = DebugHelper.from(this, 'delete');
|
|
2283
2991
|
const instance = this.model.toInstance(identifiers);
|
|
2284
2992
|
yield this.mutation(this.deleteGraphQLOperation, this.model.identifiersFields.map((field) => AttributeOptionHelper.FindByAttribute(field, this.fields).columnName), this.model.identifiersFields.reduce((ids, identifier) => {
|
|
2285
|
-
|
|
2993
|
+
const identifierBinded = identifier;
|
|
2994
|
+
if (isNil(instance.identifier[identifierBinded]))
|
|
2286
2995
|
return ids;
|
|
2287
2996
|
const columnOption = AttributeOptionHelper.FindByAttribute(identifier, this.fields);
|
|
2288
2997
|
const value = columnOption.to(identifiers[identifier], instance);
|
|
@@ -2307,11 +3016,16 @@ const withHasuraGraphQL = (MixinBase) => {
|
|
|
2307
3016
|
this.authOptions = options.authOptions;
|
|
2308
3017
|
this.model = options.model;
|
|
2309
3018
|
this.fields = options.fields || this.model.identifiersFields;
|
|
3019
|
+
this.logger = DebugHelper.from(this);
|
|
2310
3020
|
}
|
|
2311
3021
|
get headers() {
|
|
2312
|
-
|
|
3022
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
3023
|
+
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
3024
|
? {}
|
|
2314
|
-
: {
|
|
3025
|
+
: {
|
|
3026
|
+
'X-Hasura-Role': this.authOptions.authRole.role,
|
|
3027
|
+
'X-Hasura-User-Id': (_g = (_f = this.authOptions) === null || _f === void 0 ? void 0 : _f.authRole) === null || _g === void 0 ? void 0 : _g.userId,
|
|
3028
|
+
}));
|
|
2315
3029
|
}
|
|
2316
3030
|
mutation(operation, fields, variables) {
|
|
2317
3031
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -2324,32 +3038,32 @@ const withHasuraGraphQL = (MixinBase) => {
|
|
|
2324
3038
|
});
|
|
2325
3039
|
}
|
|
2326
3040
|
query(operation, fields, variables) {
|
|
3041
|
+
var _a, _b, _c, _d;
|
|
2327
3042
|
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);
|
|
3043
|
+
const builded = this.buildHasuraQueryFields({
|
|
3044
|
+
operation,
|
|
3045
|
+
fields: fields,
|
|
3046
|
+
variables,
|
|
3047
|
+
});
|
|
3048
|
+
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;
|
|
3049
|
+
const resultQuery = query$1(interpected);
|
|
3050
|
+
const result = yield this.fetch(resultQuery);
|
|
3051
|
+
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
3052
|
});
|
|
2341
3053
|
}
|
|
2342
3054
|
fetch(params) {
|
|
2343
3055
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3056
|
+
this.logger.with('params').log(params);
|
|
2344
3057
|
const headers = this.headers;
|
|
2345
|
-
const
|
|
3058
|
+
const { data: result } = yield axios({
|
|
3059
|
+
url: `${this.endpoint}`,
|
|
2346
3060
|
method: 'POST',
|
|
2347
|
-
|
|
3061
|
+
data: params,
|
|
2348
3062
|
headers,
|
|
2349
3063
|
});
|
|
2350
|
-
const result = yield response.json();
|
|
2351
3064
|
if (!isNil(result.errors))
|
|
2352
3065
|
throw new Error(JSON.stringify(result.errors));
|
|
3066
|
+
this.logger.with('returns').log(result);
|
|
2353
3067
|
return result.data;
|
|
2354
3068
|
});
|
|
2355
3069
|
}
|
|
@@ -2376,13 +3090,26 @@ const withHasuraGraphQL = (MixinBase) => {
|
|
|
2376
3090
|
return value;
|
|
2377
3091
|
return date;
|
|
2378
3092
|
}
|
|
2379
|
-
convertDataFromHasura(data) {
|
|
2380
|
-
const plain = GraphQLFieldHelper.ConvertFieldValueFrom(data, this.fields);
|
|
3093
|
+
convertDataFromHasura(data, fields) {
|
|
3094
|
+
const plain = GraphQLFieldHelper.ConvertFieldValueFrom(data, fields || this.fields);
|
|
2381
3095
|
return this.model.toInstance(plain);
|
|
2382
3096
|
}
|
|
2383
3097
|
convertDataToHasura(instance, update = false) {
|
|
2384
3098
|
return GraphQLFieldHelper.ConvertFieldValueTo(instance, this.fields, update);
|
|
2385
3099
|
}
|
|
3100
|
+
buildHasuraQueryFields({ operation, fields, variables, }) {
|
|
3101
|
+
return GraphQLFieldHelper.CheckIsGraphQLParams(operation)
|
|
3102
|
+
? operation.map((option) => ({
|
|
3103
|
+
operation: option.operation,
|
|
3104
|
+
variables: option.variables,
|
|
3105
|
+
fields: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(option.fields),
|
|
3106
|
+
}))
|
|
3107
|
+
: {
|
|
3108
|
+
operation,
|
|
3109
|
+
variables,
|
|
3110
|
+
fields: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(fields),
|
|
3111
|
+
};
|
|
3112
|
+
}
|
|
2386
3113
|
};
|
|
2387
3114
|
};
|
|
2388
3115
|
|
|
@@ -2406,6 +3133,7 @@ const withUpdateHasuraGraphQL = (MixinBase) => {
|
|
|
2406
3133
|
}
|
|
2407
3134
|
update(data) {
|
|
2408
3135
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3136
|
+
this.logger = DebugHelper.from(this, 'update');
|
|
2409
3137
|
const plainData = this.paramsToPlain(data);
|
|
2410
3138
|
yield this.mutation(this.updateGraphQLOperation, this.model.identifiersFields.map((field) => AttributeOptionHelper.FindByAttribute(field, this.fields).columnName), {
|
|
2411
3139
|
_set: {
|
|
@@ -2430,10 +3158,11 @@ const withUpdateHasuraGraphQL = (MixinBase) => {
|
|
|
2430
3158
|
const instance = this.model.toInstance(data);
|
|
2431
3159
|
return this.model.identifiersFields.reduce((ids, identifier) => {
|
|
2432
3160
|
var _a;
|
|
2433
|
-
|
|
3161
|
+
const identifierBinded = identifier;
|
|
3162
|
+
if (isNil(instance.identifier[identifierBinded]))
|
|
2434
3163
|
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[
|
|
3164
|
+
const columnOption = AttributeOptionHelper.FindByAttribute(identifierBinded, this.fields);
|
|
3165
|
+
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
3166
|
return Object.assign(Object.assign({}, ids), { [columnOption.columnName]: value });
|
|
2438
3167
|
}, {});
|
|
2439
3168
|
}
|
|
@@ -2449,10 +3178,12 @@ const withGetHasuraGraphQL = (MixinBase) => {
|
|
|
2449
3178
|
}
|
|
2450
3179
|
get(identifiers) {
|
|
2451
3180
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3181
|
+
this.logger = DebugHelper.from(this, 'get');
|
|
2452
3182
|
const instance = this.model.toInstance(identifiers);
|
|
2453
3183
|
const result = yield this.query(this.getGraphQLOperation, this.fields, this.model.identifiersFields.reduce((ids, identifier) => {
|
|
2454
3184
|
var _a;
|
|
2455
|
-
|
|
3185
|
+
const identifierBinded = identifier;
|
|
3186
|
+
if (isNil(instance[identifierBinded]))
|
|
2456
3187
|
return ids;
|
|
2457
3188
|
const columnOption = AttributeOptionHelper.FindByAttribute(identifier, this.fields);
|
|
2458
3189
|
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 +3205,26 @@ const withGetHasuraGraphQL = (MixinBase) => {
|
|
|
2474
3205
|
|
|
2475
3206
|
const withFindHasuraGraphQL = (MixinBase) => {
|
|
2476
3207
|
return class FindHasuraGraphQLMixin extends MixinBase {
|
|
2477
|
-
|
|
3208
|
+
constructor() {
|
|
3209
|
+
super(...arguments);
|
|
3210
|
+
this.bindOrderByAttributes = (orderBy, fields) => Object.keys(orderBy).reduce((acc, current) => (Object.assign(Object.assign({}, acc), { [AttributeOptionHelper.FindByAttribute(current, fields)
|
|
3211
|
+
.columnName]: orderBy[current] })), {});
|
|
3212
|
+
}
|
|
3213
|
+
find(params) {
|
|
3214
|
+
var _a;
|
|
2478
3215
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2479
|
-
|
|
2480
|
-
const
|
|
3216
|
+
this.logger = DebugHelper.from(this, 'find');
|
|
3217
|
+
const { filters, limits, orderBy, options } = params || {};
|
|
3218
|
+
const enableCount = (_a = options === null || options === void 0 ? void 0 : options.enableCount) !== null && _a !== void 0 ? _a : true;
|
|
3219
|
+
const variablesCount = Object.assign(Object.assign({}, (isNil(orderBy)
|
|
3220
|
+
? {}
|
|
3221
|
+
: {
|
|
3222
|
+
order_by: {
|
|
3223
|
+
type: `${this.tableName}_order_by!`,
|
|
3224
|
+
list: true,
|
|
3225
|
+
value: this.bindOrderByAttributes(orderBy, this.fields),
|
|
3226
|
+
},
|
|
3227
|
+
})), (isNil(filters)
|
|
2481
3228
|
? {}
|
|
2482
3229
|
: {
|
|
2483
3230
|
where: {
|
|
@@ -2490,8 +3237,8 @@ const withFindHasuraGraphQL = (MixinBase) => {
|
|
|
2490
3237
|
const result = yield this.query([
|
|
2491
3238
|
{
|
|
2492
3239
|
operation: this.tableName,
|
|
2493
|
-
fields:
|
|
2494
|
-
?
|
|
3240
|
+
fields: params.fields
|
|
3241
|
+
? params.fields
|
|
2495
3242
|
.map((fieldName) => {
|
|
2496
3243
|
var _a;
|
|
2497
3244
|
return (_a = this.fields.find((fieldOption) => fieldOption === fieldName)) !== null && _a !== void 0 ? _a : this.fields.find((fieldOption) => Object.keys(fieldOption).shift() === fieldName);
|
|
@@ -2500,15 +3247,18 @@ const withFindHasuraGraphQL = (MixinBase) => {
|
|
|
2500
3247
|
: this.fields,
|
|
2501
3248
|
variables,
|
|
2502
3249
|
},
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
|
|
3250
|
+
...(enableCount
|
|
3251
|
+
? [
|
|
3252
|
+
{
|
|
3253
|
+
operation: `${this.tableName}_aggregate`,
|
|
3254
|
+
fields: [{ aggregate: ['count'] }],
|
|
3255
|
+
variables: variablesCount,
|
|
3256
|
+
},
|
|
3257
|
+
]
|
|
3258
|
+
: []),
|
|
2508
3259
|
]);
|
|
2509
3260
|
const data = result[this.tableName].map((row) => this.convertDataFromHasura(row));
|
|
2510
|
-
|
|
2511
|
-
return { count, data };
|
|
3261
|
+
return { data, count: enableCount ? result[`${this.tableName}_aggregate`].aggregate.count : Infinity };
|
|
2512
3262
|
});
|
|
2513
3263
|
}
|
|
2514
3264
|
};
|
|
@@ -2548,13 +3298,102 @@ class VariantHasuraGraphQL extends Variant {
|
|
|
2548
3298
|
}
|
|
2549
3299
|
}
|
|
2550
3300
|
|
|
3301
|
+
class CategoryCollectionChildrenHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
3302
|
+
constructor(endpoint, authOptions) {
|
|
3303
|
+
super({
|
|
3304
|
+
tableName: 'category_collection_children',
|
|
3305
|
+
model: CategoryCollectionChildren,
|
|
3306
|
+
endpoint,
|
|
3307
|
+
authOptions,
|
|
3308
|
+
fields: [
|
|
3309
|
+
{ collectionId: { columnName: 'collection_id' } },
|
|
3310
|
+
{ categoryId: { columnName: 'category_id' } },
|
|
3311
|
+
'name',
|
|
3312
|
+
'slug',
|
|
3313
|
+
'reference',
|
|
3314
|
+
{ parentCollectionId: { columnName: 'parent_collection_id' } },
|
|
3315
|
+
{ parentCategoryId: { columnName: 'parent_category_id' } },
|
|
3316
|
+
{
|
|
3317
|
+
parent: {
|
|
3318
|
+
columnName: 'parent',
|
|
3319
|
+
foreignKeyColumn: { collectionId: 'parentCollectionId', categoryId: 'parentCategoryId' },
|
|
3320
|
+
fields: [
|
|
3321
|
+
{ collectionId: { columnName: 'collection_id' } },
|
|
3322
|
+
{ categoryId: { columnName: 'category_id' } },
|
|
3323
|
+
'name',
|
|
3324
|
+
'slug',
|
|
3325
|
+
'reference',
|
|
3326
|
+
{ parentCollectionId: { columnName: 'parent_collection_id' } },
|
|
3327
|
+
{ parentCategoryId: { columnName: 'parent_category_id' } },
|
|
3328
|
+
],
|
|
3329
|
+
},
|
|
3330
|
+
},
|
|
3331
|
+
],
|
|
3332
|
+
});
|
|
3333
|
+
}
|
|
3334
|
+
}
|
|
3335
|
+
|
|
3336
|
+
class CategoryFilterHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
3337
|
+
constructor({ endpoint, authOptions, interceptors, }) {
|
|
3338
|
+
super({
|
|
3339
|
+
tableName: 'category_filter',
|
|
3340
|
+
model: CategoryFilter,
|
|
3341
|
+
endpoint,
|
|
3342
|
+
authOptions,
|
|
3343
|
+
interceptors,
|
|
3344
|
+
fields: [
|
|
3345
|
+
'id',
|
|
3346
|
+
{ filterId: { columnName: 'filter_id' } },
|
|
3347
|
+
{ categoryId: { columnName: 'category_id' } },
|
|
3348
|
+
{
|
|
3349
|
+
filter: {
|
|
3350
|
+
columnName: 'filter',
|
|
3351
|
+
foreignKeyColumn: { id: 'filterId' },
|
|
3352
|
+
fields: [
|
|
3353
|
+
'id',
|
|
3354
|
+
'description',
|
|
3355
|
+
'slug',
|
|
3356
|
+
'enabled',
|
|
3357
|
+
{ createdAt: { columnName: 'created_at' } },
|
|
3358
|
+
{ updatedAt: { columnName: 'updated_at' } },
|
|
3359
|
+
{
|
|
3360
|
+
options: {
|
|
3361
|
+
columnName: 'options',
|
|
3362
|
+
foreignKeyColumn: { filterId: 'id' },
|
|
3363
|
+
fields: [
|
|
3364
|
+
'id',
|
|
3365
|
+
{ filterId: { columnName: 'filter_id' } },
|
|
3366
|
+
'description',
|
|
3367
|
+
{ createdAt: { columnName: 'created_at' } },
|
|
3368
|
+
{ updatedAt: { columnName: 'updated_at' } },
|
|
3369
|
+
],
|
|
3370
|
+
},
|
|
3371
|
+
},
|
|
3372
|
+
],
|
|
3373
|
+
},
|
|
3374
|
+
},
|
|
3375
|
+
],
|
|
3376
|
+
});
|
|
3377
|
+
}
|
|
3378
|
+
deleteByCategoryAndFilter(categoryId, filterId) {
|
|
3379
|
+
return this.mutation('delete_category_filter', ['affected_rows'], {
|
|
3380
|
+
where: {
|
|
3381
|
+
type: 'category_filter_bool_exp',
|
|
3382
|
+
required: true,
|
|
3383
|
+
value: { category_id: { _eq: categoryId }, filter_id: { _eq: filterId } },
|
|
3384
|
+
},
|
|
3385
|
+
});
|
|
3386
|
+
}
|
|
3387
|
+
}
|
|
3388
|
+
|
|
2551
3389
|
class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
2552
|
-
constructor(endpoint, authOptions, productRepository) {
|
|
3390
|
+
constructor({ endpoint, authOptions, interceptors, }, productRepository, categoryFilterRepository) {
|
|
2553
3391
|
super({
|
|
2554
3392
|
tableName: 'category',
|
|
2555
3393
|
model: Category,
|
|
2556
3394
|
endpoint,
|
|
2557
3395
|
authOptions,
|
|
3396
|
+
interceptors,
|
|
2558
3397
|
fields: [
|
|
2559
3398
|
{ id: { columnName: 'id', to: (value) => +value, from: (value) => value.toString() } },
|
|
2560
3399
|
{ firestoreId: { columnName: 'firestore_id' } },
|
|
@@ -2563,6 +3402,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
2563
3402
|
'image',
|
|
2564
3403
|
'published',
|
|
2565
3404
|
'shop',
|
|
3405
|
+
{ shops: { columnName: 'shops', type: HasuraGraphQLColumnType.Jsonb } },
|
|
2566
3406
|
'slug',
|
|
2567
3407
|
{ brandCategory: { columnName: 'brand_category' } },
|
|
2568
3408
|
{ brandCategoryBanner: { columnName: 'brand_banner' } },
|
|
@@ -2588,7 +3428,17 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
2588
3428
|
},
|
|
2589
3429
|
},
|
|
2590
3430
|
},
|
|
2591
|
-
|
|
3431
|
+
{
|
|
3432
|
+
filters: {
|
|
3433
|
+
columnName: 'filters',
|
|
3434
|
+
foreignKeyColumn: { filter_id: 'id' },
|
|
3435
|
+
fields: [{ filter: ['id', 'description', 'slug', 'enabled'] }],
|
|
3436
|
+
bindPersistData: (value) => ({
|
|
3437
|
+
filters: { data: value.map((filter) => ({ filter_id: filter.id })) },
|
|
3438
|
+
}),
|
|
3439
|
+
from: (filters) => (filters === null || filters === void 0 ? void 0 : filters.map((filter) => filter === null || filter === void 0 ? void 0 : filter.filter)) || [],
|
|
3440
|
+
},
|
|
3441
|
+
},
|
|
2592
3442
|
{ createdAt: { columnName: 'created_at' } },
|
|
2593
3443
|
{ updatedAt: { columnName: 'updated_at' } },
|
|
2594
3444
|
{
|
|
@@ -2610,9 +3460,20 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
2610
3460
|
}),
|
|
2611
3461
|
},
|
|
2612
3462
|
},
|
|
3463
|
+
{ isCollection: { columnName: 'is_collection' } },
|
|
3464
|
+
'reference',
|
|
3465
|
+
{ parentId: { columnName: 'parent_id' } },
|
|
3466
|
+
{
|
|
3467
|
+
parent: {
|
|
3468
|
+
columnName: 'parent',
|
|
3469
|
+
foreignKeyColumn: { id: 'parentId' },
|
|
3470
|
+
fields: ['id', 'name', 'reference', 'slug'],
|
|
3471
|
+
},
|
|
3472
|
+
},
|
|
2613
3473
|
],
|
|
2614
3474
|
});
|
|
2615
3475
|
this.productRepository = productRepository;
|
|
3476
|
+
this.categoryFilterRepository = categoryFilterRepository;
|
|
2616
3477
|
}
|
|
2617
3478
|
create(params) {
|
|
2618
3479
|
const _super = Object.create(null, {
|
|
@@ -2630,7 +3491,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
2630
3491
|
var _a;
|
|
2631
3492
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2632
3493
|
return Number.isNaN(+identifiers.id)
|
|
2633
|
-
? (_a = (yield this.find({ filters: { firestoreId: identifiers.id } })).data) === null || _a === void 0 ? void 0 : _a[0]
|
|
3494
|
+
? (_a = (yield this.find({ filters: { firestoreId: identifiers.id }, options: { enableCount: false } })).data) === null || _a === void 0 ? void 0 : _a[0]
|
|
2634
3495
|
: _super.get.call(this, identifiers);
|
|
2635
3496
|
});
|
|
2636
3497
|
}
|
|
@@ -2639,12 +3500,13 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
2639
3500
|
update: { get: () => super.update }
|
|
2640
3501
|
});
|
|
2641
3502
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2642
|
-
const { products, id: checkId, metadata } = params, data = __rest(params, ["products", "id", "metadata"]);
|
|
3503
|
+
const { products, id: checkId, metadata, filters } = params, data = __rest(params, ["products", "id", "metadata", "filters"]);
|
|
2643
3504
|
const plainData = this.paramsToPlain({ id: checkId });
|
|
2644
3505
|
const id = yield this.getId(plainData.id);
|
|
2645
3506
|
const category = yield _super.update.call(this, Object.assign({ id }, data));
|
|
2646
3507
|
category.products = products && (yield this.updateProducts(+id, { products }));
|
|
2647
3508
|
category.metadata = metadata && (yield this.updateMetadata(+id, { metadata }));
|
|
3509
|
+
category.filters = filters && (yield this.updateFilters(+id, { filters }));
|
|
2648
3510
|
return category;
|
|
2649
3511
|
});
|
|
2650
3512
|
}
|
|
@@ -2652,15 +3514,40 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
2652
3514
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2653
3515
|
if (!slug)
|
|
2654
3516
|
return null;
|
|
2655
|
-
const { data
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
|
|
3517
|
+
const { data } = yield this.find({
|
|
3518
|
+
filters: {
|
|
3519
|
+
slug,
|
|
3520
|
+
shops: { operator: Where.IN, value: [shop] },
|
|
3521
|
+
published: { operator: Where.EQUALS, value: true },
|
|
3522
|
+
},
|
|
3523
|
+
options: {
|
|
3524
|
+
enableCount: false,
|
|
3525
|
+
},
|
|
3526
|
+
});
|
|
3527
|
+
if (!data.length)
|
|
2659
3528
|
throw new NotFoundError(`Category with slug ${slug} not found`);
|
|
3529
|
+
if (data.length > 1)
|
|
3530
|
+
throw new DuplicatedResultsError('Query returned duplicated values');
|
|
2660
3531
|
return data.shift();
|
|
2661
3532
|
});
|
|
2662
3533
|
}
|
|
2663
|
-
|
|
3534
|
+
getCategoryByShop(shop) {
|
|
3535
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
3536
|
+
if (!shop)
|
|
3537
|
+
return;
|
|
3538
|
+
const { data } = yield this.find({
|
|
3539
|
+
filters: {
|
|
3540
|
+
shops: { operator: Where.IN, value: [shop] },
|
|
3541
|
+
published: { operator: Where.EQUALS, value: true },
|
|
3542
|
+
},
|
|
3543
|
+
options: {
|
|
3544
|
+
enableCount: false,
|
|
3545
|
+
},
|
|
3546
|
+
});
|
|
3547
|
+
return data;
|
|
3548
|
+
});
|
|
3549
|
+
}
|
|
3550
|
+
getCategoriesForHome(categoryIds, limit = 4, gender) {
|
|
2664
3551
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2665
3552
|
if (!(categoryIds === null || categoryIds === void 0 ? void 0 : categoryIds.length))
|
|
2666
3553
|
return [];
|
|
@@ -2680,7 +3567,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
2680
3567
|
const homeSections = yield Promise.all(categories.map((category) => __awaiter(this, void 0, void 0, function* () {
|
|
2681
3568
|
return ({
|
|
2682
3569
|
category,
|
|
2683
|
-
products: yield this.mountCategory(category, { limit, hasStock: true }),
|
|
3570
|
+
products: yield this.mountCategory(category, { limit, hasStock: true, gender }),
|
|
2684
3571
|
});
|
|
2685
3572
|
})));
|
|
2686
3573
|
return homeSections;
|
|
@@ -2692,7 +3579,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
2692
3579
|
if (!((_a = category === null || category === void 0 ? void 0 : category.products) === null || _a === void 0 ? void 0 : _a.length))
|
|
2693
3580
|
return [];
|
|
2694
3581
|
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: [
|
|
3582
|
+
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
3583
|
'id',
|
|
2697
3584
|
'name',
|
|
2698
3585
|
'slug',
|
|
@@ -2716,7 +3603,9 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
2716
3603
|
'tags',
|
|
2717
3604
|
'type',
|
|
2718
3605
|
'shoppingCount',
|
|
2719
|
-
|
|
3606
|
+
'gender',
|
|
3607
|
+
'createdAt',
|
|
3608
|
+
] }, ((options === null || options === void 0 ? void 0 : options.limit) ? { limits: { limit: options === null || options === void 0 ? void 0 : options.limit } } : {})), { options: { enableCount: false } }));
|
|
2720
3609
|
products.push(...productsData);
|
|
2721
3610
|
return products;
|
|
2722
3611
|
});
|
|
@@ -2726,7 +3615,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
2726
3615
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2727
3616
|
if (!Number.isNaN(+id))
|
|
2728
3617
|
return id;
|
|
2729
|
-
const { data } = yield this.find({ filters: { firestoreId: id } });
|
|
3618
|
+
const { data } = yield this.find({ filters: { firestoreId: id }, options: { enableCount: false } });
|
|
2730
3619
|
if ((_a = data === null || data === void 0 ? void 0 : data[0]) === null || _a === void 0 ? void 0 : _a.id)
|
|
2731
3620
|
return (_b = data === null || data === void 0 ? void 0 : data[0]) === null || _b === void 0 ? void 0 : _b.id;
|
|
2732
3621
|
throw new NotFoundError(`Category with id ${id} not found`);
|
|
@@ -2784,15 +3673,238 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
2784
3673
|
return plainData.metadata;
|
|
2785
3674
|
});
|
|
2786
3675
|
}
|
|
3676
|
+
updateFilters(categoryId, { filters }) {
|
|
3677
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
3678
|
+
if ('action' in filters && filters.action === 'remove' && filters.value.length) {
|
|
3679
|
+
for (let i = 0; i < filters.value.length; i++) {
|
|
3680
|
+
yield this.categoryFilterRepository.deleteByCategoryAndFilter(categoryId, filters.value[i].id);
|
|
3681
|
+
}
|
|
3682
|
+
return [];
|
|
3683
|
+
}
|
|
3684
|
+
if ('action' in filters && filters.action === 'merge' && filters.value.length) {
|
|
3685
|
+
let filtersList = [];
|
|
3686
|
+
for (let i = 0; i < filters.value.length; i++) {
|
|
3687
|
+
try {
|
|
3688
|
+
const hasFilter = yield this.categoryFilterRepository
|
|
3689
|
+
.find({
|
|
3690
|
+
filters: {
|
|
3691
|
+
categoryId,
|
|
3692
|
+
filterId: filters.value[i].id,
|
|
3693
|
+
},
|
|
3694
|
+
})
|
|
3695
|
+
.then((data) => { var _a; return (_a = data.data.shift()) === null || _a === void 0 ? void 0 : _a.filter; });
|
|
3696
|
+
if (hasFilter) {
|
|
3697
|
+
filtersList.push(hasFilter);
|
|
3698
|
+
}
|
|
3699
|
+
else {
|
|
3700
|
+
yield this.categoryFilterRepository.create({
|
|
3701
|
+
filterId: filters.value[i].id,
|
|
3702
|
+
categoryId,
|
|
3703
|
+
});
|
|
3704
|
+
filtersList.push(filters.value[i]);
|
|
3705
|
+
}
|
|
3706
|
+
}
|
|
3707
|
+
catch (error) {
|
|
3708
|
+
console.log('catch error: ', error);
|
|
3709
|
+
}
|
|
3710
|
+
}
|
|
3711
|
+
return filtersList;
|
|
3712
|
+
}
|
|
3713
|
+
if (Array.isArray(filters) && filters.length) {
|
|
3714
|
+
let filtersList = [];
|
|
3715
|
+
for (let i = 0; i < filters.length; i++) {
|
|
3716
|
+
try {
|
|
3717
|
+
const hasFilter = yield this.categoryFilterRepository
|
|
3718
|
+
.find({
|
|
3719
|
+
filters: {
|
|
3720
|
+
categoryId,
|
|
3721
|
+
filterId: filters[i].id,
|
|
3722
|
+
},
|
|
3723
|
+
})
|
|
3724
|
+
.then((data) => { var _a; return (_a = data.data.shift()) === null || _a === void 0 ? void 0 : _a.filter; });
|
|
3725
|
+
if (hasFilter) {
|
|
3726
|
+
filtersList.push(hasFilter);
|
|
3727
|
+
}
|
|
3728
|
+
else {
|
|
3729
|
+
yield this.categoryFilterRepository.create({
|
|
3730
|
+
filterId: filters[i].id,
|
|
3731
|
+
categoryId,
|
|
3732
|
+
});
|
|
3733
|
+
filtersList.push(filters[i]);
|
|
3734
|
+
}
|
|
3735
|
+
}
|
|
3736
|
+
catch (error) {
|
|
3737
|
+
console.log('catch error: ', error);
|
|
3738
|
+
}
|
|
3739
|
+
}
|
|
3740
|
+
return filtersList;
|
|
3741
|
+
}
|
|
3742
|
+
return [];
|
|
3743
|
+
});
|
|
3744
|
+
}
|
|
3745
|
+
getChildren(parentId) {
|
|
3746
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
3747
|
+
const { category_tree } = yield this.query('category_tree', ['id', 'name', 'parent_id'], {
|
|
3748
|
+
args: {
|
|
3749
|
+
type: 'category_tree_args',
|
|
3750
|
+
value: { parentid: parentId },
|
|
3751
|
+
required: true,
|
|
3752
|
+
},
|
|
3753
|
+
});
|
|
3754
|
+
return category_tree.map((category) => Category.toInstance(category));
|
|
3755
|
+
});
|
|
3756
|
+
}
|
|
3757
|
+
isChild(id, parentId) {
|
|
3758
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
3759
|
+
const categoryTree = yield this.getChildren(parentId);
|
|
3760
|
+
return categoryTree.some((c) => c.id == id.toString());
|
|
3761
|
+
});
|
|
3762
|
+
}
|
|
3763
|
+
}
|
|
3764
|
+
|
|
3765
|
+
class FilterHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
3766
|
+
constructor({ endpoint, authOptions, interceptors, }, filterOptionRepository, categoryFilterRepository) {
|
|
3767
|
+
super({
|
|
3768
|
+
tableName: 'filter',
|
|
3769
|
+
model: Filter,
|
|
3770
|
+
endpoint,
|
|
3771
|
+
authOptions,
|
|
3772
|
+
interceptors,
|
|
3773
|
+
fields: [
|
|
3774
|
+
'id',
|
|
3775
|
+
'description',
|
|
3776
|
+
'slug',
|
|
3777
|
+
'enabled',
|
|
3778
|
+
{ createdAt: { columnName: 'created_at' } },
|
|
3779
|
+
{ updatedAt: { columnName: 'updated_at' } },
|
|
3780
|
+
{
|
|
3781
|
+
options: {
|
|
3782
|
+
columnName: 'options',
|
|
3783
|
+
foreignKeyColumn: { filterId: 'id' },
|
|
3784
|
+
fields: [
|
|
3785
|
+
'id',
|
|
3786
|
+
{ filterId: { columnName: 'filter_id' } },
|
|
3787
|
+
'description',
|
|
3788
|
+
{ createdAt: { columnName: 'created_at' } },
|
|
3789
|
+
{ updatedAt: { columnName: 'updated_at' } },
|
|
3790
|
+
],
|
|
3791
|
+
},
|
|
3792
|
+
},
|
|
3793
|
+
],
|
|
3794
|
+
});
|
|
3795
|
+
this.filterOptionRepository = filterOptionRepository;
|
|
3796
|
+
this.categoryFilterRepository = categoryFilterRepository;
|
|
3797
|
+
}
|
|
3798
|
+
update(params) {
|
|
3799
|
+
const _super = Object.create(null, {
|
|
3800
|
+
update: { get: () => super.update }
|
|
3801
|
+
});
|
|
3802
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
3803
|
+
const { options } = params, data = __rest(params, ["options"]);
|
|
3804
|
+
const filter = yield _super.update.call(this, data);
|
|
3805
|
+
filter.options = yield this.updateOptions(+data.id, { options });
|
|
3806
|
+
return filter;
|
|
3807
|
+
});
|
|
3808
|
+
}
|
|
3809
|
+
updateOptions(filterId, { options }) {
|
|
3810
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
3811
|
+
if (!options)
|
|
3812
|
+
return [];
|
|
3813
|
+
if ('action' in options && options.action === 'remove' && options.value.length) {
|
|
3814
|
+
for (let i = 0; i < options.value.length; i++) {
|
|
3815
|
+
yield this.filterOptionRepository.delete({ id: options.value[i].id });
|
|
3816
|
+
}
|
|
3817
|
+
return [];
|
|
3818
|
+
}
|
|
3819
|
+
if ('action' in options && options.action === 'merge' && options.value.length) {
|
|
3820
|
+
let filterOptions = [];
|
|
3821
|
+
for (let i = 0; i < options.value.length; i++) {
|
|
3822
|
+
try {
|
|
3823
|
+
const hasFilter = yield this.filterOptionRepository.get({ id: options.value[i].id });
|
|
3824
|
+
if (hasFilter)
|
|
3825
|
+
filterOptions.push(hasFilter);
|
|
3826
|
+
}
|
|
3827
|
+
catch (error) {
|
|
3828
|
+
const newOption = yield this.filterOptionRepository.create(Object.assign(Object.assign({}, options.value[i]), { filterId }));
|
|
3829
|
+
filterOptions.push(newOption);
|
|
3830
|
+
}
|
|
3831
|
+
}
|
|
3832
|
+
return filterOptions;
|
|
3833
|
+
}
|
|
3834
|
+
if (Array.isArray(options) && options.length) {
|
|
3835
|
+
let filterOptions = [];
|
|
3836
|
+
for (let i = 0; i < options.length; i++) {
|
|
3837
|
+
try {
|
|
3838
|
+
const hasFilter = yield this.filterOptionRepository.get({ id: options[i].id });
|
|
3839
|
+
if (hasFilter)
|
|
3840
|
+
filterOptions.push(hasFilter);
|
|
3841
|
+
}
|
|
3842
|
+
catch (error) {
|
|
3843
|
+
const newOption = yield this.filterOptionRepository.create(Object.assign(Object.assign({}, options[i]), { filterId }));
|
|
3844
|
+
filterOptions.push(newOption);
|
|
3845
|
+
}
|
|
3846
|
+
}
|
|
3847
|
+
}
|
|
3848
|
+
return [];
|
|
3849
|
+
});
|
|
3850
|
+
}
|
|
3851
|
+
delete(params) {
|
|
3852
|
+
const _super = Object.create(null, {
|
|
3853
|
+
delete: { get: () => super.delete }
|
|
3854
|
+
});
|
|
3855
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
3856
|
+
const { data: categoryFilters } = yield this.categoryFilterRepository.find({
|
|
3857
|
+
filters: {
|
|
3858
|
+
filterId: params.id,
|
|
3859
|
+
},
|
|
3860
|
+
});
|
|
3861
|
+
if (categoryFilters.length)
|
|
3862
|
+
throw new Error('Erro: o filtro está associado a uma ou mais categoria(s)');
|
|
3863
|
+
yield this.deleteOptions(+params.id);
|
|
3864
|
+
yield _super.delete.call(this, { id: +params.id });
|
|
3865
|
+
return;
|
|
3866
|
+
});
|
|
3867
|
+
}
|
|
3868
|
+
deleteOptions(filterId) {
|
|
3869
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
3870
|
+
yield this.mutation('delete_filter_option', ['affected_rows'], {
|
|
3871
|
+
where: {
|
|
3872
|
+
type: 'filter_option_bool_exp',
|
|
3873
|
+
required: true,
|
|
3874
|
+
value: { filter_id: { _eq: filterId } },
|
|
3875
|
+
},
|
|
3876
|
+
});
|
|
3877
|
+
});
|
|
3878
|
+
}
|
|
3879
|
+
}
|
|
3880
|
+
|
|
3881
|
+
class FilterOptionHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
3882
|
+
constructor({ endpoint, authOptions, interceptors, }) {
|
|
3883
|
+
super({
|
|
3884
|
+
tableName: 'filter_option',
|
|
3885
|
+
model: FilterOption,
|
|
3886
|
+
endpoint,
|
|
3887
|
+
authOptions,
|
|
3888
|
+
interceptors,
|
|
3889
|
+
fields: [
|
|
3890
|
+
'id',
|
|
3891
|
+
'description',
|
|
3892
|
+
{ filterId: { columnName: 'filter_id' } },
|
|
3893
|
+
{ createdAt: { columnName: 'created_at' } },
|
|
3894
|
+
{ updatedAt: { columnName: 'updated_at' } },
|
|
3895
|
+
],
|
|
3896
|
+
});
|
|
3897
|
+
}
|
|
2787
3898
|
}
|
|
2788
3899
|
|
|
2789
3900
|
class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
2790
|
-
constructor(endpoint, authOptions) {
|
|
3901
|
+
constructor({ endpoint, authOptions, interceptors, }) {
|
|
2791
3902
|
super({
|
|
2792
3903
|
tableName: 'product',
|
|
2793
3904
|
model: ProductHasuraGraphQL,
|
|
2794
3905
|
endpoint,
|
|
2795
3906
|
authOptions,
|
|
3907
|
+
interceptors,
|
|
2796
3908
|
fields: [],
|
|
2797
3909
|
});
|
|
2798
3910
|
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 }));
|
|
@@ -2889,21 +4001,21 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
2889
4001
|
'weight',
|
|
2890
4002
|
'gender',
|
|
2891
4003
|
{ tags: { columnName: 'tags', type: HasuraGraphQLColumnType.Jsonb } },
|
|
4004
|
+
{ filters: { columnName: 'filters', type: HasuraGraphQLColumnType.Jsonb } },
|
|
2892
4005
|
{ isKit: { columnName: 'is_kit' } },
|
|
2893
4006
|
{ createdAt: { columnName: 'created_at' } },
|
|
2894
4007
|
{ updatedAt: { columnName: 'updated_at' } },
|
|
4008
|
+
{ rate: { columnName: 'rating' } },
|
|
4009
|
+
{ reviewsTotal: { columnName: 'reviews_total' } },
|
|
4010
|
+
{ shoppingCount: { columnName: 'shopping_count' } },
|
|
4011
|
+
{ categoryId: { columnName: 'category_id' } },
|
|
2895
4012
|
{
|
|
2896
|
-
|
|
2897
|
-
columnName: '
|
|
2898
|
-
|
|
2899
|
-
|
|
2900
|
-
filterType: 'product_review_bool_exp',
|
|
2901
|
-
},
|
|
2902
|
-
fields: [{ aggregate: [{ avg: ['rate'] }] }],
|
|
2903
|
-
from: (value) => value.aggregate.avg.rate,
|
|
4013
|
+
category: {
|
|
4014
|
+
columnName: 'category',
|
|
4015
|
+
foreignKeyColumn: { id: 'categoryId' },
|
|
4016
|
+
fields: ['id', 'name', 'reference', 'slug'],
|
|
2904
4017
|
},
|
|
2905
4018
|
},
|
|
2906
|
-
{ shoppingCount: { columnName: 'shopping_count' } },
|
|
2907
4019
|
];
|
|
2908
4020
|
this.fields = [
|
|
2909
4021
|
...commonFields,
|
|
@@ -2990,7 +4102,7 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
2990
4102
|
var _a;
|
|
2991
4103
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2992
4104
|
const product = Number.isNaN(+identifiers.id)
|
|
2993
|
-
? (_a = (yield this.find({ filters: { firestoreId: identifiers.id } })).data) === null || _a === void 0 ? void 0 : _a[0]
|
|
4105
|
+
? (_a = (yield this.find({ filters: { firestoreId: identifiers.id }, options: { enableCount: false } })).data) === null || _a === void 0 ? void 0 : _a[0]
|
|
2994
4106
|
: yield _super.get.call(this, identifiers);
|
|
2995
4107
|
if (product.productId)
|
|
2996
4108
|
throw new NotFoundError('Product not found, it is a variant');
|
|
@@ -3008,7 +4120,16 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
3008
4120
|
this.fields
|
|
3009
4121
|
.map((field) => (typeof field === 'string' ? field : Object.keys(field).shift()))
|
|
3010
4122
|
.filter((field) => field !== 'reviews');
|
|
3011
|
-
return _super.find.call(this, Object.assign(Object.assign({}, options), { filters: Object.assign(Object.assign({}, filters), { productId: { operator: Where.ISNULL } }), fields:
|
|
4123
|
+
return _super.find.call(this, Object.assign(Object.assign({}, options), { filters: Object.assign(Object.assign({}, filters), { productId: { operator: Where.ISNULL } }), fields: [
|
|
4124
|
+
...bindFields,
|
|
4125
|
+
...(bindFields.includes('price')
|
|
4126
|
+
? [
|
|
4127
|
+
'subscriberPrice',
|
|
4128
|
+
'subscriberDiscountPercentage',
|
|
4129
|
+
'fullPrice',
|
|
4130
|
+
]
|
|
4131
|
+
: []),
|
|
4132
|
+
] }));
|
|
3012
4133
|
});
|
|
3013
4134
|
}
|
|
3014
4135
|
getBySlug(slug) {
|
|
@@ -3018,9 +4139,13 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
3018
4139
|
filters: {
|
|
3019
4140
|
slug,
|
|
3020
4141
|
},
|
|
4142
|
+
fields: this.fields.map((field) => typeof field === 'string' ? field : Object.keys(field).shift()),
|
|
4143
|
+
options: {
|
|
4144
|
+
enableCount: false,
|
|
4145
|
+
},
|
|
3021
4146
|
});
|
|
3022
4147
|
const product = (_a = result === null || result === void 0 ? void 0 : result.data) === null || _a === void 0 ? void 0 : _a.shift();
|
|
3023
|
-
|
|
4148
|
+
RoundProductPricesHelper.roundProductPrices(product);
|
|
3024
4149
|
return product;
|
|
3025
4150
|
});
|
|
3026
4151
|
}
|
|
@@ -3183,7 +4308,7 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
3183
4308
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3184
4309
|
if (!Number.isNaN(+id))
|
|
3185
4310
|
return id;
|
|
3186
|
-
const { data } = yield this.find({ filters: { firestoreId: id } });
|
|
4311
|
+
const { data } = yield this.find({ filters: { firestoreId: id }, options: { enableCount: false } });
|
|
3187
4312
|
if ((_a = data === null || data === void 0 ? void 0 : data[0]) === null || _a === void 0 ? void 0 : _a.id)
|
|
3188
4313
|
return (_b = data === null || data === void 0 ? void 0 : data[0]) === null || _b === void 0 ? void 0 : _b.id;
|
|
3189
4314
|
throw new NotFoundError(`Product with id ${id} not found`);
|
|
@@ -3239,15 +4364,31 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
3239
4364
|
return data && data[0] && this.bindReviewToModel(data[0]);
|
|
3240
4365
|
});
|
|
3241
4366
|
}
|
|
4367
|
+
cleanShoppingCountFromIds(ids) {
|
|
4368
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
4369
|
+
return yield this.mutation('update_product', ['affected_rows'], {
|
|
4370
|
+
where: {
|
|
4371
|
+
value: { id: { _nin: ids } },
|
|
4372
|
+
type: 'product_bool_exp',
|
|
4373
|
+
required: true,
|
|
4374
|
+
},
|
|
4375
|
+
_set: {
|
|
4376
|
+
value: { shopping_count: 0 },
|
|
4377
|
+
type: 'product_set_input',
|
|
4378
|
+
},
|
|
4379
|
+
});
|
|
4380
|
+
});
|
|
4381
|
+
}
|
|
3242
4382
|
}
|
|
3243
4383
|
|
|
3244
4384
|
class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
3245
|
-
constructor(endpoint, authOptions) {
|
|
4385
|
+
constructor({ endpoint, authOptions, interceptors, }) {
|
|
3246
4386
|
super({
|
|
3247
4387
|
tableName: 'product',
|
|
3248
4388
|
model: VariantHasuraGraphQL,
|
|
3249
4389
|
endpoint,
|
|
3250
4390
|
authOptions,
|
|
4391
|
+
interceptors,
|
|
3251
4392
|
fields: [
|
|
3252
4393
|
{ id: { columnName: 'id', to: (value) => +value, from: (value) => value.toString() } },
|
|
3253
4394
|
{ firestoreId: { columnName: 'firestore_id' } },
|
|
@@ -3277,9 +4418,9 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
3277
4418
|
subscriber_price: filters.subscriberPrice,
|
|
3278
4419
|
}));
|
|
3279
4420
|
},
|
|
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 && {
|
|
4421
|
+
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
4422
|
subscriber_discount_percentage: priceData.subscriberDiscountPercentage,
|
|
3282
|
-
})), (priceData.subscriberPrice >= 0 && { subscriber_price: priceData.subscriberPrice }))),
|
|
4423
|
+
})), (((priceData === null || priceData === void 0 ? void 0 : priceData.subscriberPrice) || 0) >= 0 && { subscriber_price: priceData.subscriberPrice }))),
|
|
3283
4424
|
},
|
|
3284
4425
|
},
|
|
3285
4426
|
{ fullPrice: { columnName: 'full_price' } },
|
|
@@ -3348,7 +4489,7 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
3348
4489
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3349
4490
|
if (!Number.isNaN(+id))
|
|
3350
4491
|
return id;
|
|
3351
|
-
const { data } = yield this.find({ filters: { firestoreId: id } });
|
|
4492
|
+
const { data } = yield this.find({ filters: { firestoreId: id }, options: { enableCount: false } });
|
|
3352
4493
|
if ((_a = data === null || data === void 0 ? void 0 : data[0]) === null || _a === void 0 ? void 0 : _a.id)
|
|
3353
4494
|
return (_b = data === null || data === void 0 ? void 0 : data[0]) === null || _b === void 0 ? void 0 : _b.id;
|
|
3354
4495
|
throw new NotFoundError(`Product with id ${id} not found`);
|
|
@@ -3360,5 +4501,5 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
3360
4501
|
* Generated bundle index. Do not edit.
|
|
3361
4502
|
*/
|
|
3362
4503
|
|
|
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,
|
|
4504
|
+
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, get, is, isDebuggable, isUUID, parseDateTime, withCreateFirestore, withCreateHasuraGraphQL, withCrudFirestore, withCrudHasuraGraphQL, withDeleteFirestore, withDeleteHasuraGraphQL, withFindFirestore, withFindHasuraGraphQL, withFirestore, withGetFirestore, withGetHasuraGraphQL, withHasuraGraphQL, withHelpers, withSubCollection, withUpdateFirestore, withUpdateHasuraGraphQL };
|
|
3364
4505
|
//# sourceMappingURL=infrab4a-connect.mjs.map
|