@infrab4a/connect 4.0.0-beta.29 → 4.0.0-beta.3
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/index.d.ts +0 -1
- package/domain/catalog/models/category.d.ts +5 -10
- package/domain/catalog/models/index.d.ts +0 -4
- package/domain/catalog/models/kit-product.d.ts +1 -1
- package/domain/catalog/models/product.d.ts +3 -8
- package/domain/catalog/models/types/category-filter.type.d.ts +4 -0
- package/domain/catalog/models/types/index.d.ts +1 -2
- package/domain/catalog/models/variant.d.ts +2 -1
- package/domain/catalog/repositories/category.repository.d.ts +3 -4
- package/domain/catalog/repositories/index.d.ts +0 -4
- package/domain/catalog/repositories/product.repository.d.ts +0 -1
- package/domain/generic/model/base.model.d.ts +5 -9
- package/domain/generic/model/types/base-model-builder.type.d.ts +2 -4
- package/domain/generic/model/types/identifier-model.type.d.ts +5 -6
- package/domain/generic/model/types/model-base-structure.type.d.ts +3 -9
- package/domain/generic/model/types/non-function-property-name.type.d.ts +3 -12
- package/domain/generic/repository/find.repository.d.ts +0 -3
- 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 +3 -5
- package/domain/shop-settings/models/index.d.ts +0 -1
- package/domain/shop-settings/models/types/index.d.ts +1 -6
- package/domain/shop-settings/repositories/index.d.ts +0 -1
- package/domain/shopping/models/buy-2-win.d.ts +1 -3
- package/domain/shopping/models/checkout.d.ts +6 -5
- package/domain/shopping/models/index.d.ts +4 -5
- package/domain/shopping/models/subscription/checkout.d.ts +4 -3
- package/domain/shopping/repositories/index.d.ts +2 -4
- package/domain/users/models/lead.d.ts +0 -1
- package/domain/users/models/subscription/subscription.d.ts +3 -3
- package/domain/users/models/user-address.d.ts +2 -1
- package/domain/users/models/user.d.ts +3 -2
- package/esm2020/domain/catalog/index.mjs +1 -2
- package/esm2020/domain/catalog/models/category.mjs +4 -12
- package/esm2020/domain/catalog/models/index.mjs +1 -5
- package/esm2020/domain/catalog/models/kit-product.mjs +2 -2
- package/esm2020/domain/catalog/models/product.mjs +3 -23
- package/esm2020/domain/catalog/models/types/category-filter.type.mjs +2 -0
- package/esm2020/domain/catalog/models/types/index.mjs +2 -3
- package/esm2020/domain/catalog/models/variant.mjs +4 -1
- package/esm2020/domain/catalog/repositories/category.repository.mjs +1 -1
- package/esm2020/domain/catalog/repositories/index.mjs +1 -5
- package/esm2020/domain/catalog/repositories/product.repository.mjs +1 -1
- package/esm2020/domain/generic/model/base.model.mjs +2 -3
- 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 +1 -2
- package/esm2020/domain/shop-settings/models/types/index.mjs +2 -7
- package/esm2020/domain/shop-settings/repositories/index.mjs +1 -2
- package/esm2020/domain/shopping/models/buy-2-win.mjs +2 -2
- package/esm2020/domain/shopping/models/checkout.mjs +7 -6
- package/esm2020/domain/shopping/models/index.mjs +5 -6
- package/esm2020/domain/shopping/models/order.mjs +1 -1
- package/esm2020/domain/shopping/models/subscription/checkout.mjs +6 -6
- package/esm2020/domain/shopping/repositories/index.mjs +3 -5
- 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 +11 -28
- package/esm2020/infra/elasticsearch/adapters/elastic-search.adapter.mjs +1 -1
- package/esm2020/infra/elasticsearch/indexes/products-index.mjs +51 -58
- package/esm2020/infra/elasticsearch/types/elastic-search-result.mjs +1 -1
- package/esm2020/infra/firebase/firestore/mixins/with-create-firestore.mixin.mjs +4 -8
- package/esm2020/infra/firebase/firestore/mixins/with-crud-firestore.mixin.mjs +1 -1
- package/esm2020/infra/firebase/firestore/mixins/with-delete-firestore.mixin.mjs +2 -6
- package/esm2020/infra/firebase/firestore/mixins/with-find-firestore.mixin.mjs +7 -10
- package/esm2020/infra/firebase/firestore/mixins/with-firestore.mixin.mjs +4 -27
- package/esm2020/infra/firebase/firestore/mixins/with-get-firestore.mixin.mjs +3 -6
- package/esm2020/infra/firebase/firestore/mixins/with-helpers.mixin.mjs +1 -1
- package/esm2020/infra/firebase/firestore/mixins/with-sub-collection.mixin.mjs +3 -5
- package/esm2020/infra/firebase/firestore/mixins/with-update-firestore.mixin.mjs +4 -7
- package/esm2020/infra/firebase/firestore/repositories/catalog/category-firestore.repository.mjs +8 -15
- package/esm2020/infra/firebase/firestore/repositories/catalog/product-firestore.repository.mjs +6 -11
- package/esm2020/infra/firebase/firestore/repositories/catalog/product-variant-firestore.repository.mjs +8 -10
- package/esm2020/infra/firebase/firestore/repositories/catalog/subscription-product-firestore.repository.mjs +6 -8
- package/esm2020/infra/firebase/firestore/repositories/shop-settings/home-firestore.repository.mjs +30 -36
- package/esm2020/infra/firebase/firestore/repositories/shop-settings/index.mjs +1 -2
- package/esm2020/infra/firebase/firestore/repositories/shop-settings/shop-menu-firestore.repository.mjs +6 -8
- package/esm2020/infra/firebase/firestore/repositories/shopping/buy-2-win-firestore.repository.mjs +6 -8
- package/esm2020/infra/firebase/firestore/repositories/shopping/checkout-firestore.repository.mjs +6 -8
- package/esm2020/infra/firebase/firestore/repositories/shopping/checkout-subscription-firestore.repository.mjs +6 -8
- package/esm2020/infra/firebase/firestore/repositories/shopping/coupon-firestore.repository.mjs +6 -8
- package/esm2020/infra/firebase/firestore/repositories/shopping/index.mjs +4 -6
- package/esm2020/infra/firebase/firestore/repositories/shopping/legacy-order-firestore.repository.mjs +4 -6
- package/esm2020/infra/firebase/firestore/repositories/shopping/order-firestore.repository.mjs +9 -11
- package/esm2020/infra/firebase/firestore/repositories/shopping/payment-firestore.repository.mjs +6 -8
- package/esm2020/infra/firebase/firestore/repositories/shopping/subscription-plan-firestore.repository.mjs +6 -8
- package/esm2020/infra/firebase/firestore/repositories/users/lead-firestore.repository.mjs +6 -8
- package/esm2020/infra/firebase/firestore/repositories/users/subscription-edition-firestore.repository.mjs +8 -10
- package/esm2020/infra/firebase/firestore/repositories/users/subscription-firestore.repository.mjs +6 -8
- package/esm2020/infra/firebase/firestore/repositories/users/subscription-payment-firestore.repository.mjs +8 -10
- package/esm2020/infra/firebase/firestore/repositories/users/user-address-firestore.repository.mjs +8 -10
- package/esm2020/infra/firebase/firestore/repositories/users/user-beauty-profile-firestore.repository.mjs +8 -10
- package/esm2020/infra/firebase/firestore/repositories/users/user-firestore.repository.mjs +6 -8
- package/esm2020/infra/firebase/firestore/repositories/users/user-payment-method-firestore.repository.mjs +8 -10
- 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 +3 -4
- 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 +4 -5
- package/esm2020/infra/hasura-graphql/mixins/helpers/filter-option.helper.mjs +1 -1
- package/esm2020/infra/hasura-graphql/mixins/helpers/graphql-field.helper.mjs +25 -36
- package/esm2020/infra/hasura-graphql/mixins/with-create-hasura-graphql.mixin.mjs +4 -6
- 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 +3 -5
- package/esm2020/infra/hasura-graphql/mixins/with-find-hasura-graphql.mixin.mjs +15 -36
- package/esm2020/infra/hasura-graphql/mixins/with-get-hasura-graphql.mixin.mjs +3 -5
- package/esm2020/infra/hasura-graphql/mixins/with-hasura-graphql.mixin.mjs +24 -40
- package/esm2020/infra/hasura-graphql/mixins/with-update-hasura-graphql.mixin.mjs +5 -7
- package/esm2020/infra/hasura-graphql/models/product-hasura-graphql.mjs +1 -1
- package/esm2020/infra/hasura-graphql/repositories/catalog/category-hasura-graphql.repository.mjs +12 -130
- package/esm2020/infra/hasura-graphql/repositories/catalog/index.mjs +1 -5
- package/esm2020/infra/hasura-graphql/repositories/catalog/product-hasura-graphql.repository.mjs +16 -43
- package/esm2020/infra/hasura-graphql/repositories/catalog/variant-hasura-graphql.repository.mjs +7 -8
- 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/index.mjs +4 -6
- package/fesm2015/infrab4a-connect.mjs +385 -1497
- package/fesm2015/infrab4a-connect.mjs.map +1 -1
- package/fesm2020/infrab4a-connect.mjs +391 -1473
- package/fesm2020/infrab4a-connect.mjs.map +1 -1
- package/infra/elasticsearch/adapters/axios.adapter.d.ts +5 -7
- package/infra/elasticsearch/adapters/elastic-search.adapter.d.ts +2 -3
- package/infra/elasticsearch/indexes/products-index.d.ts +10 -8
- package/infra/elasticsearch/types/elastic-search-result.d.ts +0 -2
- package/infra/firebase/firestore/mixins/with-create-firestore.mixin.d.ts +2 -2
- package/infra/firebase/firestore/mixins/with-crud-firestore.mixin.d.ts +1 -2
- 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 +4 -13
- 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 +4 -8
- package/infra/firebase/firestore/mixins/with-update-firestore.mixin.d.ts +3 -3
- package/infra/firebase/firestore/repositories/catalog/category-firestore.repository.d.ts +5 -6
- 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 +4 -3
- package/infra/firebase/firestore/repositories/catalog/subscription-product-firestore.repository.d.ts +4 -3
- package/infra/firebase/firestore/repositories/shop-settings/home-firestore.repository.d.ts +4 -4
- package/infra/firebase/firestore/repositories/shop-settings/index.d.ts +0 -1
- package/infra/firebase/firestore/repositories/shop-settings/shop-menu-firestore.repository.d.ts +4 -3
- package/infra/firebase/firestore/repositories/shopping/buy-2-win-firestore.repository.d.ts +4 -3
- package/infra/firebase/firestore/repositories/shopping/checkout-firestore.repository.d.ts +4 -3
- package/infra/firebase/firestore/repositories/shopping/checkout-subscription-firestore.repository.d.ts +4 -3
- package/infra/firebase/firestore/repositories/shopping/coupon-firestore.repository.d.ts +4 -4
- package/infra/firebase/firestore/repositories/shopping/index.d.ts +3 -5
- package/infra/firebase/firestore/repositories/shopping/legacy-order-firestore.repository.d.ts +4 -3
- package/infra/firebase/firestore/repositories/shopping/order-firestore.repository.d.ts +4 -4
- package/infra/firebase/firestore/repositories/shopping/payment-firestore.repository.d.ts +4 -3
- package/infra/firebase/firestore/repositories/shopping/subscription-plan-firestore.repository.d.ts +4 -3
- package/infra/firebase/firestore/repositories/users/lead-firestore.repository.d.ts +4 -3
- package/infra/firebase/firestore/repositories/users/subscription-edition-firestore.repository.d.ts +4 -3
- package/infra/firebase/firestore/repositories/users/subscription-firestore.repository.d.ts +4 -3
- package/infra/firebase/firestore/repositories/users/subscription-payment-firestore.repository.d.ts +4 -3
- package/infra/firebase/firestore/repositories/users/user-address-firestore.repository.d.ts +4 -3
- package/infra/firebase/firestore/repositories/users/user-beauty-profile-firestore.repository.d.ts +4 -3
- 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 +4 -3
- 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 +1 -3
- package/infra/firebase/firestore/types/index.d.ts +2 -3
- package/infra/hasura-graphql/mixins/helpers/attribute-option.helper.d.ts +3 -9
- 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 +2 -4
- package/infra/hasura-graphql/mixins/helpers/graphql-field.helper.d.ts +5 -8
- package/infra/hasura-graphql/mixins/with-create-hasura-graphql.mixin.d.ts +1 -2
- 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 +15 -12
- package/infra/hasura-graphql/mixins/with-get-hasura-graphql.mixin.d.ts +6 -7
- package/infra/hasura-graphql/mixins/with-hasura-graphql.mixin.d.ts +3 -14
- package/infra/hasura-graphql/mixins/with-update-hasura-graphql.mixin.d.ts +2 -2
- package/infra/hasura-graphql/models/product-hasura-graphql.d.ts +0 -1
- package/infra/hasura-graphql/repositories/catalog/category-hasura-graphql.repository.d.ts +5 -10
- package/infra/hasura-graphql/repositories/catalog/index.d.ts +0 -4
- package/infra/hasura-graphql/repositories/catalog/product-hasura-graphql.repository.d.ts +3 -4
- package/infra/hasura-graphql/repositories/catalog/variant-hasura-graphql.repository.d.ts +4 -4
- package/infra/hasura-graphql/types/graphql.repository.type.d.ts +5 -7
- package/infra/hasura-graphql/types/hasura-graphql-fields.type.d.ts +3 -7
- package/package.json +1 -2
- package/utils/index.d.ts +22 -5
- package/domain/catalog/helpers/RoundProdutcPriceHelper.d.ts +0 -4
- package/domain/catalog/helpers/index.d.ts +0 -1
- package/domain/catalog/models/category-collection-children.d.ts +0 -13
- package/domain/catalog/models/category-filter.d.ts +0 -11
- package/domain/catalog/models/filter-option.d.ts +0 -9
- package/domain/catalog/models/filter.d.ts +0 -12
- package/domain/catalog/models/types/category-product.d.ts +0 -4
- package/domain/catalog/models/types/product-evaluation.type.d.ts +0 -6
- package/domain/catalog/repositories/category-collection-children.repository.d.ts +0 -4
- package/domain/catalog/repositories/category-filter.repository.d.ts +0 -5
- package/domain/catalog/repositories/filter-option.repository.d.ts +0 -4
- package/domain/catalog/repositories/filter.repository.d.ts +0 -4
- package/domain/shop-settings/models/shop-settings.d.ts +0 -9
- package/domain/shop-settings/models/types/shop-banner.type.d.ts +0 -12
- package/domain/shop-settings/models/types/shop-brands.type.d.ts +0 -10
- package/domain/shop-settings/models/types/shop-carousel.type.d.ts +0 -5
- package/domain/shop-settings/models/types/shop-collection.type.d.ts +0 -9
- package/domain/shop-settings/models/types/shop-section.type.d.ts +0 -9
- package/domain/shop-settings/repositories/shop-settings.repository.d.ts +0 -4
- package/domain/shopping/models/campaign-dashboard.d.ts +0 -15
- package/domain/shopping/models/campaign-hashtag.d.ts +0 -18
- package/domain/shopping/repositories/campaign-dashboard.repository.d.ts +0 -4
- package/domain/shopping/repositories/campaign-hashtag.repository.d.ts +0 -4
- package/esm2020/domain/catalog/helpers/RoundProdutcPriceHelper.mjs +0 -15
- package/esm2020/domain/catalog/helpers/index.mjs +0 -2
- package/esm2020/domain/catalog/models/category-collection-children.mjs +0 -13
- package/esm2020/domain/catalog/models/category-filter.mjs +0 -14
- package/esm2020/domain/catalog/models/filter-option.mjs +0 -7
- package/esm2020/domain/catalog/models/filter.mjs +0 -7
- package/esm2020/domain/catalog/models/types/category-product.mjs +0 -2
- package/esm2020/domain/catalog/models/types/product-evaluation.type.mjs +0 -2
- package/esm2020/domain/catalog/repositories/category-collection-children.repository.mjs +0 -2
- package/esm2020/domain/catalog/repositories/category-filter.repository.mjs +0 -2
- package/esm2020/domain/catalog/repositories/filter-option.repository.mjs +0 -2
- package/esm2020/domain/catalog/repositories/filter.repository.mjs +0 -2
- package/esm2020/domain/shop-settings/models/shop-settings.mjs +0 -7
- package/esm2020/domain/shop-settings/models/types/shop-banner.type.mjs +0 -2
- package/esm2020/domain/shop-settings/models/types/shop-brands.type.mjs +0 -2
- package/esm2020/domain/shop-settings/models/types/shop-carousel.type.mjs +0 -2
- package/esm2020/domain/shop-settings/models/types/shop-collection.type.mjs +0 -2
- package/esm2020/domain/shop-settings/models/types/shop-section.type.mjs +0 -2
- package/esm2020/domain/shop-settings/repositories/shop-settings.repository.mjs +0 -2
- package/esm2020/domain/shopping/models/campaign-dashboard.mjs +0 -7
- package/esm2020/domain/shopping/models/campaign-hashtag.mjs +0 -7
- package/esm2020/domain/shopping/repositories/campaign-dashboard.repository.mjs +0 -2
- package/esm2020/domain/shopping/repositories/campaign-hashtag.repository.mjs +0 -2
- package/esm2020/infra/firebase/firestore/repositories/shop-settings/shop-settings-firestore.repository.mjs +0 -14
- package/esm2020/infra/firebase/firestore/repositories/shopping/campaign-dashboard-firestore.repository.mjs +0 -14
- package/esm2020/infra/firebase/firestore/repositories/shopping/campaign-hashtag-firestore.repository.mjs +0 -14
- package/esm2020/infra/firebase/firestore/types/firestore-interceptors.type.mjs +0 -2
- package/esm2020/infra/hasura-graphql/repositories/catalog/category-collection-children-hasura-graphql.repository.mjs +0 -38
- package/esm2020/infra/hasura-graphql/repositories/catalog/category-filter-hasura-graphql.repository.mjs +0 -56
- package/esm2020/infra/hasura-graphql/repositories/catalog/filter-hasura-graphql.repository.mjs +0 -105
- package/esm2020/infra/hasura-graphql/repositories/catalog/filter-option-hasura-graphql.repository.mjs +0 -22
- package/esm2020/utils/decorators/debug.class.decorator.mjs +0 -7
- package/esm2020/utils/decorators/index.mjs +0 -3
- package/esm2020/utils/decorators/trace.method.decorator.mjs +0 -81
- package/esm2020/utils/helpers/class-name.helper.mjs +0 -15
- package/esm2020/utils/helpers/debug-decorator.helper.mjs +0 -18
- package/esm2020/utils/helpers/debug.helper.mjs +0 -150
- package/esm2020/utils/helpers/index.mjs +0 -5
- package/esm2020/utils/helpers/reflect.helper.mjs +0 -165
- package/esm2020/utils/log.utils.mjs +0 -9
- package/infra/firebase/firestore/repositories/shop-settings/shop-settings-firestore.repository.d.ts +0 -7
- package/infra/firebase/firestore/repositories/shopping/campaign-dashboard-firestore.repository.d.ts +0 -8
- package/infra/firebase/firestore/repositories/shopping/campaign-hashtag-firestore.repository.d.ts +0 -8
- package/infra/firebase/firestore/types/firestore-interceptors.type.d.ts +0 -14
- package/infra/hasura-graphql/repositories/catalog/category-collection-children-hasura-graphql.repository.d.ts +0 -10
- package/infra/hasura-graphql/repositories/catalog/category-filter-hasura-graphql.repository.d.ts +0 -11
- package/infra/hasura-graphql/repositories/catalog/filter-hasura-graphql.repository.d.ts +0 -18
- package/infra/hasura-graphql/repositories/catalog/filter-option-hasura-graphql.repository.d.ts +0 -10
- package/utils/decorators/debug.class.decorator.d.ts +0 -2
- package/utils/decorators/index.d.ts +0 -2
- package/utils/decorators/trace.method.decorator.d.ts +0 -14
- package/utils/helpers/class-name.helper.d.ts +0 -3
- package/utils/helpers/debug-decorator.helper.d.ts +0 -9
- package/utils/helpers/debug.helper.d.ts +0 -60
- package/utils/helpers/index.d.ts +0 -4
- package/utils/helpers/reflect.helper.d.ts +0 -50
- package/utils/log.utils.d.ts +0 -7
|
@@ -3,21 +3,19 @@ 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
|
-
|
|
8
|
-
import { Subject } from 'rxjs';
|
|
9
|
-
import { debug } from 'debug';
|
|
6
|
+
import * as lodash from 'lodash';
|
|
7
|
+
import { get as get$1, isString as isString$1 } from 'lodash';
|
|
10
8
|
import { CustomError } from 'ts-custom-error';
|
|
11
9
|
import axios from 'axios';
|
|
12
10
|
import { collection, getDoc, doc, where, orderBy, getDocs, query, startAfter, startAt, limit, addDoc, setDoc, deleteField, arrayUnion, arrayRemove, deleteDoc, Timestamp } from 'firebase/firestore';
|
|
13
11
|
import { signInWithEmailAndPassword, signInWithPopup, GoogleAuthProvider, signInAnonymously, sendPasswordResetEmail, createUserWithEmailAndPassword, sendEmailVerification } from 'firebase/auth';
|
|
14
12
|
import { mutation, query as query$1 } from 'gql-query-builder';
|
|
13
|
+
import fetch from 'node-fetch';
|
|
15
14
|
|
|
16
15
|
class BaseModel {
|
|
17
16
|
get identifier() {
|
|
18
17
|
const fields = this.constructor.identifiersFields.filter((field) => field !== 'identifier');
|
|
19
|
-
|
|
20
|
-
return fields.reduce((object, field) => (Object.assign(Object.assign({}, object), { [field]: data[field] })), {});
|
|
18
|
+
return fields.reduce((object, field) => (Object.assign(Object.assign({}, object), { [field]: this[field] })), {});
|
|
21
19
|
}
|
|
22
20
|
get identifiersFields() {
|
|
23
21
|
return this.constructor.identifiersFields;
|
|
@@ -463,437 +461,11 @@ __decorate([
|
|
|
463
461
|
__metadata("design:type", Payment)
|
|
464
462
|
], SubscriptionPayment.prototype, "payment", void 0);
|
|
465
463
|
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
DebugNamespaces["TRACE"] = "trace";
|
|
470
|
-
DebugNamespaces["ERROR"] = "error";
|
|
471
|
-
})(DebugNamespaces || (DebugNamespaces = {}));
|
|
472
|
-
const Logger = debug(DebugNamespaces.ROOT);
|
|
473
|
-
|
|
474
|
-
class ReflectHelper {
|
|
475
|
-
static get items() {
|
|
476
|
-
return this._items;
|
|
477
|
-
}
|
|
478
|
-
static get keys() {
|
|
479
|
-
return Object.keys(ReflectHelper.items);
|
|
480
|
-
}
|
|
481
|
-
static has(key, target, property) {
|
|
482
|
-
return (!isNil(key) &&
|
|
483
|
-
!isNil(ReflectHelper.items[key]) &&
|
|
484
|
-
(isNil(target) ||
|
|
485
|
-
(!isNil(ReflectHelper.items[key][target]) &&
|
|
486
|
-
(isNil(property) || !isNil(ReflectHelper.items[key][target][String(property)])))));
|
|
487
|
-
}
|
|
488
|
-
static get({ key, target, property, own = true }) {
|
|
489
|
-
try {
|
|
490
|
-
if (own) {
|
|
491
|
-
return Reflect.getOwnMetadata(key, target, property) || null;
|
|
492
|
-
}
|
|
493
|
-
else {
|
|
494
|
-
return Reflect.getMetadata(key, target, property) || null;
|
|
495
|
-
}
|
|
496
|
-
}
|
|
497
|
-
catch (_err) {
|
|
498
|
-
return null;
|
|
499
|
-
}
|
|
500
|
-
}
|
|
501
|
-
static first({ key, target, property, own = true }) {
|
|
502
|
-
const values = ReflectHelper.get({ key, target, property, own });
|
|
503
|
-
return isArray(values) ? first(values) : values;
|
|
504
|
-
}
|
|
505
|
-
static last({ key, target, property, own = true }) {
|
|
506
|
-
const values = ReflectHelper.get({ key, target, property, own });
|
|
507
|
-
return isArray(values) ? last(values) : values;
|
|
508
|
-
}
|
|
509
|
-
static set({ key, target, property, value, propertyDescriptor }) {
|
|
510
|
-
Reflect.defineMetadata(key, value, target, property);
|
|
511
|
-
ReflectHelper.put({ key, target, property, value, propertyDescriptor });
|
|
512
|
-
}
|
|
513
|
-
static add({ key, target, property, value, propertyDescriptor }) {
|
|
514
|
-
let values = ReflectHelper.get({ key, target, property }) || new Array();
|
|
515
|
-
if (!Array.isArray(values))
|
|
516
|
-
values = [values];
|
|
517
|
-
values.push(value);
|
|
518
|
-
ReflectHelper.set({ key, target, property, value: values, propertyDescriptor });
|
|
519
|
-
}
|
|
520
|
-
static all({ key }) {
|
|
521
|
-
const items = ReflectHelper.items[key] || {};
|
|
522
|
-
return flatten(Object.keys(items).map((item) => flatten(this.allFrom(key, items[item]))));
|
|
523
|
-
}
|
|
524
|
-
static allFrom(key, target) {
|
|
525
|
-
return Object.keys(target)
|
|
526
|
-
.filter((property) => property !== 'object')
|
|
527
|
-
.map((property) => this.allValuesFrom(key, target, property));
|
|
528
|
-
}
|
|
529
|
-
static allValuesFrom(key, target, property) {
|
|
530
|
-
const values = target[property];
|
|
531
|
-
let value = values.value;
|
|
532
|
-
const propertyDescriptor = values.propertyDescriptor;
|
|
533
|
-
if (!isArray(value))
|
|
534
|
-
value = [value];
|
|
535
|
-
return flatten(value.map((val) => {
|
|
536
|
-
return {
|
|
537
|
-
key,
|
|
538
|
-
target: target.object,
|
|
539
|
-
property,
|
|
540
|
-
value: val,
|
|
541
|
-
propertyDescriptor,
|
|
542
|
-
};
|
|
543
|
-
}));
|
|
544
|
-
}
|
|
545
|
-
static delete({ key, target, property }) {
|
|
546
|
-
Reflect.deleteMetadata(key, target, property);
|
|
547
|
-
return ReflectHelper.remove(key, target, property);
|
|
548
|
-
}
|
|
549
|
-
static clear(key) {
|
|
550
|
-
if (!key) {
|
|
551
|
-
ReflectHelper.keys.forEach((storedKey) => {
|
|
552
|
-
ReflectHelper.clear(storedKey);
|
|
553
|
-
});
|
|
554
|
-
}
|
|
555
|
-
else {
|
|
556
|
-
if (ReflectHelper.keys.includes(key)) {
|
|
557
|
-
Object.values(ReflectHelper.items[key]).forEach((target) => {
|
|
558
|
-
if (ReflectHelper.has(key, target)) {
|
|
559
|
-
Object.values(ReflectHelper.items[key][target.toString()]).forEach((property) => {
|
|
560
|
-
ReflectHelper.delete({
|
|
561
|
-
key,
|
|
562
|
-
target: target.object,
|
|
563
|
-
property: String(property),
|
|
564
|
-
});
|
|
565
|
-
ReflectHelper.remove(key, target, String(property));
|
|
566
|
-
});
|
|
567
|
-
}
|
|
568
|
-
ReflectHelper.delete({ key, target: target.object });
|
|
569
|
-
ReflectHelper.remove(key, target);
|
|
570
|
-
});
|
|
571
|
-
}
|
|
572
|
-
}
|
|
573
|
-
}
|
|
574
|
-
static getType({ target, propertyKey }) {
|
|
575
|
-
return Reflect.getMetadata('design:type', target, propertyKey);
|
|
576
|
-
}
|
|
577
|
-
static getReturntype({ target, propertyKey }) {
|
|
578
|
-
return Reflect.getMetadata('design:returntype', target, propertyKey);
|
|
579
|
-
}
|
|
580
|
-
static getAllMethods(target) {
|
|
581
|
-
const props = [];
|
|
582
|
-
let obj = target;
|
|
583
|
-
do {
|
|
584
|
-
props.push(...Object.getOwnPropertyNames(obj));
|
|
585
|
-
} while ((obj = Object.getPrototypeOf(obj)));
|
|
586
|
-
return props.sort().filter((e, i, arr) => {
|
|
587
|
-
if ([
|
|
588
|
-
'__defineGetter__',
|
|
589
|
-
'__defineSetter__',
|
|
590
|
-
'__lookupGetter__',
|
|
591
|
-
'__lookupSetter__',
|
|
592
|
-
'constructor',
|
|
593
|
-
'hasOwnProperty',
|
|
594
|
-
'isPrototypeOf',
|
|
595
|
-
'propertyIsEnumerable',
|
|
596
|
-
'toLocaleString',
|
|
597
|
-
'toString',
|
|
598
|
-
'valueOf',
|
|
599
|
-
].includes(e))
|
|
600
|
-
return false;
|
|
601
|
-
if (e != arr[i + 1] && typeof target[e] === 'function')
|
|
602
|
-
return true;
|
|
603
|
-
});
|
|
604
|
-
}
|
|
605
|
-
static put({ key, target, property, value, propertyDescriptor }) {
|
|
606
|
-
const index = target.constructor.name;
|
|
607
|
-
ReflectHelper.items[key] = ReflectHelper.items[key] || {};
|
|
608
|
-
ReflectHelper.items[key][index] = ReflectHelper.items[key][index] || {};
|
|
609
|
-
ReflectHelper.items[key][index].object = target;
|
|
610
|
-
if (isNil(property)) {
|
|
611
|
-
ReflectHelper.items[key][index].value = {
|
|
612
|
-
value,
|
|
613
|
-
propertyDescriptor,
|
|
614
|
-
};
|
|
615
|
-
}
|
|
616
|
-
else {
|
|
617
|
-
ReflectHelper.items[key][index][String(property)] = ReflectHelper.items[key][index][String(property)] || {};
|
|
618
|
-
ReflectHelper.items[key][index][String(property)] = {
|
|
619
|
-
value,
|
|
620
|
-
propertyDescriptor,
|
|
621
|
-
};
|
|
622
|
-
}
|
|
623
|
-
}
|
|
624
|
-
static remove(key, target, property) {
|
|
625
|
-
if (ReflectHelper.has(key, target, property))
|
|
626
|
-
return delete ReflectHelper.items[key][target][String(property)];
|
|
627
|
-
else if (ReflectHelper.has(key, target))
|
|
628
|
-
return delete ReflectHelper.items[key][target];
|
|
629
|
-
else if (ReflectHelper.has(key))
|
|
630
|
-
return delete ReflectHelper.items[key];
|
|
631
|
-
else
|
|
632
|
-
return false;
|
|
633
|
-
}
|
|
634
|
-
}
|
|
635
|
-
ReflectHelper._items = {};
|
|
636
|
-
|
|
637
|
-
class DebugDecoratorHelper {
|
|
638
|
-
static set(target, options) {
|
|
639
|
-
ReflectHelper.add({
|
|
640
|
-
key: DebugDecoratorHelper.DebugNamingMetadataKey,
|
|
641
|
-
target,
|
|
642
|
-
value: options,
|
|
643
|
-
});
|
|
644
|
-
}
|
|
645
|
-
static get(target) {
|
|
646
|
-
return ReflectHelper.first({
|
|
647
|
-
key: DebugDecoratorHelper.DebugNamingMetadataKey,
|
|
648
|
-
target,
|
|
649
|
-
});
|
|
650
|
-
}
|
|
651
|
-
}
|
|
652
|
-
DebugDecoratorHelper.DebugNamingMetadataKey = 'model:naming:decorator';
|
|
653
|
-
|
|
654
|
-
class ClassNameHelper {
|
|
655
|
-
static get(clazz) {
|
|
656
|
-
if (!clazz)
|
|
657
|
-
return null;
|
|
658
|
-
const prototype = Object.getPrototypeOf(clazz);
|
|
659
|
-
const names = compact([
|
|
660
|
-
get$1(clazz, 'constructor.name'),
|
|
661
|
-
get$1(prototype, 'constructor.name'),
|
|
662
|
-
get$1(prototype, '__proto__.constructor.name'),
|
|
663
|
-
]);
|
|
664
|
-
return names.find((name) => name !== 'class_1');
|
|
665
|
-
}
|
|
666
|
-
}
|
|
667
|
-
|
|
668
|
-
const isDebuggable = (object) => {
|
|
669
|
-
return 'debug' in object;
|
|
670
|
-
};
|
|
671
|
-
class DebugHelper {
|
|
672
|
-
constructor(...namespace) {
|
|
673
|
-
this.namespaces = new Set();
|
|
674
|
-
this.push(...namespace);
|
|
675
|
-
}
|
|
676
|
-
static namespacesFor(target) {
|
|
677
|
-
if (isNil(target))
|
|
678
|
-
return [];
|
|
679
|
-
const decorator = DebugDecoratorHelper.get(Object.getPrototypeOf(target));
|
|
680
|
-
const namespaces = get$1(decorator, 'namespaces', []);
|
|
681
|
-
const name = get$1(decorator, 'name', ClassNameHelper.get(target));
|
|
682
|
-
return [...namespaces, name];
|
|
683
|
-
}
|
|
684
|
-
static as(...namespaces) {
|
|
685
|
-
return new DebugHelper(...namespaces);
|
|
686
|
-
}
|
|
687
|
-
static for(target, ...namespaces) {
|
|
688
|
-
const targetNamespaces = this.namespacesFor(target);
|
|
689
|
-
return new DebugHelper(...targetNamespaces, ...namespaces);
|
|
690
|
-
}
|
|
691
|
-
static from(target, ...namespaces) {
|
|
692
|
-
if (this.isDebuggable(target)) {
|
|
693
|
-
const debug = target.debug;
|
|
694
|
-
if (namespaces)
|
|
695
|
-
debug.push(...namespaces);
|
|
696
|
-
return debug;
|
|
697
|
-
}
|
|
698
|
-
return DebugHelper.for(target, ...namespaces);
|
|
699
|
-
}
|
|
700
|
-
static clonedFrom(target, ...namespaces) {
|
|
701
|
-
if (this.isDebuggable(target)) {
|
|
702
|
-
namespaces.push(...target.debug.entries);
|
|
703
|
-
}
|
|
704
|
-
else if (!isNil(target)) {
|
|
705
|
-
namespaces.push(...this.namespacesFor(target));
|
|
706
|
-
}
|
|
707
|
-
return DebugHelper.for(target, ...namespaces);
|
|
708
|
-
}
|
|
709
|
-
static clone(target, ...namespaces) {
|
|
710
|
-
let original;
|
|
711
|
-
if (this.isDebuggable(target)) {
|
|
712
|
-
original = target.debug;
|
|
713
|
-
namespaces.push(...original.entries);
|
|
714
|
-
}
|
|
715
|
-
return {
|
|
716
|
-
original,
|
|
717
|
-
debug: DebugHelper.for(target, ...namespaces),
|
|
718
|
-
};
|
|
719
|
-
}
|
|
720
|
-
static replace(target, attrs) {
|
|
721
|
-
if (this.isDebuggable(target))
|
|
722
|
-
target.debug = attrs.with;
|
|
723
|
-
}
|
|
724
|
-
static mock(target, ...namespaces) {
|
|
725
|
-
const { original, debug } = DebugHelper.clone(target, ...namespaces);
|
|
726
|
-
DebugHelper.replace(target, { with: debug });
|
|
727
|
-
return { original, debug };
|
|
728
|
-
}
|
|
729
|
-
get entries() {
|
|
730
|
-
return Array.from(get$1(this, 'namespaces', []));
|
|
731
|
-
}
|
|
732
|
-
get namespace() {
|
|
733
|
-
return compact(flatten(this.entries)).join(':');
|
|
734
|
-
}
|
|
735
|
-
log(message, ...args) {
|
|
736
|
-
this.logger(JSON.stringify(message), ...args.map((element) => JSON.stringify(element)));
|
|
737
|
-
DebugHelper.logs$.next({ namespace: this.namespace, message, args });
|
|
738
|
-
return this;
|
|
739
|
-
}
|
|
740
|
-
trace(message, ...args) {
|
|
741
|
-
this.logger.extend(DebugNamespaces.TRACE)(message, ...args);
|
|
742
|
-
DebugHelper.traces$.next({ namespace: this.namespace, message, args });
|
|
743
|
-
return this;
|
|
744
|
-
}
|
|
745
|
-
error(error, ...args) {
|
|
746
|
-
this.logger.extend(DebugNamespaces.ERROR)(JSON.stringify(error), ...args.map((element) => JSON.stringify(element)));
|
|
747
|
-
DebugHelper.errors$.next({ namespace: this.namespace, error, args });
|
|
748
|
-
return this;
|
|
749
|
-
}
|
|
750
|
-
build() {
|
|
751
|
-
this.logger = Logger;
|
|
752
|
-
this.tracer = Logger;
|
|
753
|
-
this.err = Logger;
|
|
754
|
-
this.entries.forEach((namespace) => {
|
|
755
|
-
this.logger = this.logger.extend(namespace);
|
|
756
|
-
this.tracer = this.tracer.extend(namespace);
|
|
757
|
-
this.err = this.err.extend(namespace);
|
|
758
|
-
});
|
|
759
|
-
return this;
|
|
760
|
-
}
|
|
761
|
-
with(...namespace) {
|
|
762
|
-
return new DebugHelper(...this.entries, ...namespace);
|
|
763
|
-
}
|
|
764
|
-
push(...namespace) {
|
|
765
|
-
if (namespace) {
|
|
766
|
-
namespace.filter((item) => Boolean(item)).forEach((item) => this.namespaces.add(item));
|
|
767
|
-
}
|
|
768
|
-
return this.build();
|
|
769
|
-
}
|
|
770
|
-
unshift(...namespace) {
|
|
771
|
-
if (namespace) {
|
|
772
|
-
return this.reset(...namespace, ...this.entries);
|
|
773
|
-
}
|
|
774
|
-
return this;
|
|
775
|
-
}
|
|
776
|
-
reset(...namespace) {
|
|
777
|
-
this.namespaces = new Set(flatten(compact(namespace)));
|
|
778
|
-
return this.build();
|
|
779
|
-
}
|
|
780
|
-
startWith(...namespace) {
|
|
781
|
-
const current = this.namespaces;
|
|
782
|
-
this.namespaces = new Set(flatten([compact(namespace), ...current]));
|
|
783
|
-
return this.build();
|
|
784
|
-
}
|
|
785
|
-
shift() {
|
|
786
|
-
const list = this.entries;
|
|
787
|
-
list.shift();
|
|
788
|
-
return this.reset(...list);
|
|
789
|
-
}
|
|
790
|
-
pop() {
|
|
791
|
-
const list = this.entries;
|
|
792
|
-
list.pop();
|
|
793
|
-
return this.reset(...list);
|
|
794
|
-
}
|
|
795
|
-
clear() {
|
|
796
|
-
return this.reset();
|
|
797
|
-
}
|
|
798
|
-
remove(...namespace) {
|
|
799
|
-
if (namespace) {
|
|
800
|
-
namespace.filter((item) => Boolean(item)).forEach((item) => this.namespaces.delete(item));
|
|
801
|
-
}
|
|
802
|
-
return this.build();
|
|
803
|
-
}
|
|
804
|
-
puts(...args) {
|
|
805
|
-
return [`[${this.namespace}]`, ...args].join(' ');
|
|
464
|
+
class Address extends BaseModel {
|
|
465
|
+
static get identifiersFields() {
|
|
466
|
+
return ['id'];
|
|
806
467
|
}
|
|
807
468
|
}
|
|
808
|
-
DebugHelper.logs$ = new Subject();
|
|
809
|
-
DebugHelper.traces$ = new Subject();
|
|
810
|
-
DebugHelper.errors$ = new Subject();
|
|
811
|
-
DebugHelper.isDebuggable = isDebuggable;
|
|
812
|
-
|
|
813
|
-
function Debug(opts) {
|
|
814
|
-
return function (target) {
|
|
815
|
-
DebugDecoratorHelper.set(target.prototype, opts);
|
|
816
|
-
};
|
|
817
|
-
}
|
|
818
|
-
|
|
819
|
-
const ASYNC_IDENTIFIER = 'async';
|
|
820
|
-
function Log(options = {}) {
|
|
821
|
-
return Trace(Object.assign({ level: 'log' }, options));
|
|
822
|
-
}
|
|
823
|
-
function Trace(options = {}) {
|
|
824
|
-
return function (target, propertyKey, propertyDescriptor) {
|
|
825
|
-
const method = propertyDescriptor.value;
|
|
826
|
-
const isPromise = method.toString().includes(ASYNC_IDENTIFIER);
|
|
827
|
-
const args = {
|
|
828
|
-
options,
|
|
829
|
-
method,
|
|
830
|
-
target,
|
|
831
|
-
propertyKey,
|
|
832
|
-
propertyDescriptor,
|
|
833
|
-
};
|
|
834
|
-
propertyDescriptor.value = isPromise ? promiseTracer(args) : functionTracer(args);
|
|
835
|
-
return propertyDescriptor;
|
|
836
|
-
};
|
|
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
|
-
};
|
|
897
469
|
|
|
898
470
|
const get = (object, path, defaultValue) => get$1(object, path, defaultValue);
|
|
899
471
|
|
|
@@ -901,7 +473,7 @@ function is(value) {
|
|
|
901
473
|
return value;
|
|
902
474
|
}
|
|
903
475
|
|
|
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);
|
|
476
|
+
const isUUID = (value) => isString$1(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);
|
|
905
477
|
|
|
906
478
|
class Base {
|
|
907
479
|
constructor(...args) {
|
|
@@ -910,7 +482,7 @@ class Base {
|
|
|
910
482
|
}
|
|
911
483
|
|
|
912
484
|
const parseDateTime = (value) => {
|
|
913
|
-
if (!isString(value))
|
|
485
|
+
if (!isString$1(value))
|
|
914
486
|
return value;
|
|
915
487
|
if (!/^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])$/.test(value) &&
|
|
916
488
|
!/^\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))
|
|
@@ -921,6 +493,8 @@ const parseDateTime = (value) => {
|
|
|
921
493
|
return date;
|
|
922
494
|
};
|
|
923
495
|
|
|
496
|
+
const { chunk, isBoolean, isDate, isEmpty, isInteger, isNaN: isNaN$1, isNil, isNumber, isObject, isString, now, omit, pick, set, } = lodash;
|
|
497
|
+
|
|
924
498
|
var CheckoutTypes;
|
|
925
499
|
(function (CheckoutTypes) {
|
|
926
500
|
CheckoutTypes[CheckoutTypes["ECOMMERCE"] = 1] = "ECOMMERCE";
|
|
@@ -1024,18 +598,6 @@ __decorate([
|
|
|
1024
598
|
__metadata("design:type", BeautyProfile)
|
|
1025
599
|
], User.prototype, "beautyProfile", void 0);
|
|
1026
600
|
|
|
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
|
-
|
|
1039
601
|
class Subscription extends BaseModel {
|
|
1040
602
|
static get identifiersFields() {
|
|
1041
603
|
return ['id'];
|
|
@@ -1050,12 +612,12 @@ __decorate([
|
|
|
1050
612
|
__metadata("design:type", SubscriptionPlan)
|
|
1051
613
|
], Subscription.prototype, "subscriptionPlan", void 0);
|
|
1052
614
|
__decorate([
|
|
1053
|
-
Type(() =>
|
|
1054
|
-
__metadata("design:type",
|
|
615
|
+
Type(() => Address),
|
|
616
|
+
__metadata("design:type", Address)
|
|
1055
617
|
], Subscription.prototype, "shippingAddress", void 0);
|
|
1056
618
|
__decorate([
|
|
1057
|
-
Type(() =>
|
|
1058
|
-
__metadata("design:type",
|
|
619
|
+
Type(() => Address),
|
|
620
|
+
__metadata("design:type", Address)
|
|
1059
621
|
], Subscription.prototype, "billingAddress", void 0);
|
|
1060
622
|
__decorate([
|
|
1061
623
|
Type(() => Coupon),
|
|
@@ -1070,6 +632,12 @@ __decorate([
|
|
|
1070
632
|
__metadata("design:type", Array)
|
|
1071
633
|
], Subscription.prototype, "payment", void 0);
|
|
1072
634
|
|
|
635
|
+
class UserAddress extends Address {
|
|
636
|
+
static get identifiersFields() {
|
|
637
|
+
return ['id', 'userId'];
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
|
|
1073
641
|
class UserPaymentMethod extends BaseModel {
|
|
1074
642
|
static get identifiersFields() {
|
|
1075
643
|
return ['id', 'userId'];
|
|
@@ -1102,7 +670,7 @@ class Authentication {
|
|
|
1102
670
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1103
671
|
const method = this.getServiceByMethod(signInMethod);
|
|
1104
672
|
const userAuth = yield this.authService[method]({ email, password });
|
|
1105
|
-
const user = this.userRepository.get(
|
|
673
|
+
const user = this.userRepository.get(userAuth);
|
|
1106
674
|
if (!isNil(user))
|
|
1107
675
|
return user;
|
|
1108
676
|
if (/^.+@b4a.com.br$/.test(userAuth.email))
|
|
@@ -1189,45 +757,14 @@ class RecoveryPassword {
|
|
|
1189
757
|
}
|
|
1190
758
|
}
|
|
1191
759
|
|
|
1192
|
-
class Filter extends BaseModel {
|
|
1193
|
-
static get identifiersFields() {
|
|
1194
|
-
return ['id'];
|
|
1195
|
-
}
|
|
1196
|
-
}
|
|
1197
|
-
|
|
1198
760
|
class Category extends BaseModel {
|
|
1199
|
-
|
|
761
|
+
identifierFields() {
|
|
1200
762
|
return ['id'];
|
|
1201
763
|
}
|
|
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 {
|
|
1223
764
|
static get identifiersFields() {
|
|
1224
765
|
return ['id'];
|
|
1225
766
|
}
|
|
1226
767
|
}
|
|
1227
|
-
__decorate([
|
|
1228
|
-
Type(() => Filter),
|
|
1229
|
-
__metadata("design:type", Filter)
|
|
1230
|
-
], CategoryFilter.prototype, "filter", void 0);
|
|
1231
768
|
|
|
1232
769
|
var GenderDestination;
|
|
1233
770
|
(function (GenderDestination) {
|
|
@@ -1244,39 +781,14 @@ var Shops;
|
|
|
1244
781
|
Shops["ALL"] = "ALL";
|
|
1245
782
|
})(Shops || (Shops = {}));
|
|
1246
783
|
|
|
1247
|
-
class FilterOption extends BaseModel {
|
|
1248
|
-
static get identifiersFields() {
|
|
1249
|
-
return ['id'];
|
|
1250
|
-
}
|
|
1251
|
-
}
|
|
1252
|
-
|
|
1253
784
|
class Product extends BaseModel {
|
|
1254
|
-
|
|
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;
|
|
785
|
+
identifierFields() {
|
|
786
|
+
return ['id'];
|
|
1271
787
|
}
|
|
1272
788
|
static get identifiersFields() {
|
|
1273
789
|
return ['id'];
|
|
1274
790
|
}
|
|
1275
791
|
}
|
|
1276
|
-
__decorate([
|
|
1277
|
-
Type(() => Category),
|
|
1278
|
-
__metadata("design:type", Category)
|
|
1279
|
-
], Product.prototype, "category", void 0);
|
|
1280
792
|
__decorate([
|
|
1281
793
|
Type(() => KitProduct),
|
|
1282
794
|
__metadata("design:type", Array)
|
|
@@ -1284,7 +796,7 @@ __decorate([
|
|
|
1284
796
|
|
|
1285
797
|
class KitProduct extends BaseModel {
|
|
1286
798
|
static get identifiersFields() {
|
|
1287
|
-
return ['productId', '
|
|
799
|
+
return ['productId', 'kitProducId'];
|
|
1288
800
|
}
|
|
1289
801
|
}
|
|
1290
802
|
__decorate([
|
|
@@ -1297,32 +809,25 @@ __decorate([
|
|
|
1297
809
|
], KitProduct.prototype, "product", void 0);
|
|
1298
810
|
|
|
1299
811
|
class Variant extends BaseModel {
|
|
1300
|
-
|
|
1301
|
-
return ['id', 'productId'];
|
|
1302
|
-
}
|
|
1303
|
-
}
|
|
1304
|
-
|
|
1305
|
-
class Buy2Win extends BaseModel {
|
|
1306
|
-
static get identifiersFields() {
|
|
812
|
+
identifierFields() {
|
|
1307
813
|
return ['id'];
|
|
1308
814
|
}
|
|
1309
|
-
}
|
|
1310
|
-
__decorate([
|
|
1311
|
-
Type(() => Category),
|
|
1312
|
-
__metadata("design:type", Array)
|
|
1313
|
-
], Buy2Win.prototype, "categories", void 0);
|
|
1314
|
-
|
|
1315
|
-
class CampaignDashboard extends BaseModel {
|
|
1316
815
|
static get identifiersFields() {
|
|
1317
|
-
return ['id'];
|
|
816
|
+
return ['id', 'productId'];
|
|
1318
817
|
}
|
|
1319
818
|
}
|
|
1320
819
|
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
820
|
+
var OrderStatus;
|
|
821
|
+
(function (OrderStatus) {
|
|
822
|
+
OrderStatus["AGUARDANDO_PAGAMENTO"] = "Aguardando pagamento";
|
|
823
|
+
OrderStatus["EM_PREPARO"] = "Preparando pedido";
|
|
824
|
+
OrderStatus["NF_EMITIDA"] = "Nota Fiscal Emitida";
|
|
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 = {}));
|
|
1326
831
|
|
|
1327
832
|
class LineItem extends Product {
|
|
1328
833
|
}
|
|
@@ -1347,12 +852,12 @@ __decorate([
|
|
|
1347
852
|
__metadata("design:type", User)
|
|
1348
853
|
], Checkout.prototype, "user", void 0);
|
|
1349
854
|
__decorate([
|
|
1350
|
-
Type(() =>
|
|
1351
|
-
__metadata("design:type",
|
|
855
|
+
Type(() => Address),
|
|
856
|
+
__metadata("design:type", Address)
|
|
1352
857
|
], Checkout.prototype, "shippingAddress", void 0);
|
|
1353
858
|
__decorate([
|
|
1354
|
-
Type(() =>
|
|
1355
|
-
__metadata("design:type",
|
|
859
|
+
Type(() => Address),
|
|
860
|
+
__metadata("design:type", Address)
|
|
1356
861
|
], Checkout.prototype, "billingAddress", void 0);
|
|
1357
862
|
__decorate([
|
|
1358
863
|
Type(() => ShippingMethod),
|
|
@@ -1363,18 +868,6 @@ __decorate([
|
|
|
1363
868
|
__metadata("design:type", Coupon)
|
|
1364
869
|
], Checkout.prototype, "coupon", void 0);
|
|
1365
870
|
|
|
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
|
-
|
|
1378
871
|
class Order extends Checkout {
|
|
1379
872
|
}
|
|
1380
873
|
__decorate([
|
|
@@ -1388,12 +881,12 @@ class CheckoutSubscription extends BaseModel {
|
|
|
1388
881
|
}
|
|
1389
882
|
}
|
|
1390
883
|
__decorate([
|
|
1391
|
-
Type(() =>
|
|
1392
|
-
__metadata("design:type",
|
|
884
|
+
Type(() => Address),
|
|
885
|
+
__metadata("design:type", Address)
|
|
1393
886
|
], CheckoutSubscription.prototype, "shippingAddress", void 0);
|
|
1394
887
|
__decorate([
|
|
1395
|
-
Type(() =>
|
|
1396
|
-
__metadata("design:type",
|
|
888
|
+
Type(() => Address),
|
|
889
|
+
__metadata("design:type", Address)
|
|
1397
890
|
], CheckoutSubscription.prototype, "billingAddress", void 0);
|
|
1398
891
|
__decorate([
|
|
1399
892
|
Type(() => SubscriptionPlan),
|
|
@@ -1404,19 +897,15 @@ __decorate([
|
|
|
1404
897
|
__metadata("design:type", Coupon)
|
|
1405
898
|
], CheckoutSubscription.prototype, "coupon", void 0);
|
|
1406
899
|
|
|
1407
|
-
class
|
|
1408
|
-
static
|
|
1409
|
-
|
|
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;
|
|
900
|
+
class Buy2Win extends BaseModel {
|
|
901
|
+
static get identifiersFields() {
|
|
902
|
+
return ['id'];
|
|
1418
903
|
}
|
|
1419
904
|
}
|
|
905
|
+
__decorate([
|
|
906
|
+
Type(() => Category),
|
|
907
|
+
__metadata("design:type", Array)
|
|
908
|
+
], Buy2Win.prototype, "categories", void 0);
|
|
1420
909
|
|
|
1421
910
|
var FilterType;
|
|
1422
911
|
(function (FilterType) {
|
|
@@ -1517,12 +1006,6 @@ class ShopMenu extends BaseModel {
|
|
|
1517
1006
|
}
|
|
1518
1007
|
}
|
|
1519
1008
|
|
|
1520
|
-
class ShopSettings extends BaseModel {
|
|
1521
|
-
static get identifiersFields() {
|
|
1522
|
-
return ['id'];
|
|
1523
|
-
}
|
|
1524
|
-
}
|
|
1525
|
-
|
|
1526
1009
|
class InvalidArgumentError extends CustomError {
|
|
1527
1010
|
constructor(message) {
|
|
1528
1011
|
super(message);
|
|
@@ -1553,17 +1036,13 @@ class AxiosAdapter {
|
|
|
1553
1036
|
constructor(config) {
|
|
1554
1037
|
this.config = config;
|
|
1555
1038
|
}
|
|
1556
|
-
get(index
|
|
1039
|
+
get(index) {
|
|
1557
1040
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1558
1041
|
try {
|
|
1559
1042
|
const { data } = yield axios({
|
|
1560
|
-
url: `${this.config.url}/${index}
|
|
1043
|
+
url: `${this.config.url}/${index}`,
|
|
1561
1044
|
method: 'GET',
|
|
1562
|
-
|
|
1563
|
-
headers: {
|
|
1564
|
-
'Content-Type': 'application/json',
|
|
1565
|
-
Authorization: `ApiKey ${this.config.credential}`,
|
|
1566
|
-
},
|
|
1045
|
+
headers: { Authorization: `Basic ${this.config.credential}` },
|
|
1567
1046
|
});
|
|
1568
1047
|
return data._source;
|
|
1569
1048
|
}
|
|
@@ -1577,14 +1056,9 @@ class AxiosAdapter {
|
|
|
1577
1056
|
query(index, query) {
|
|
1578
1057
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1579
1058
|
const { data } = yield axios({
|
|
1580
|
-
url: `${this.config.url}/${index}
|
|
1059
|
+
url: `${this.config.url}/${index}`,
|
|
1581
1060
|
method: 'POST',
|
|
1582
|
-
|
|
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
|
-
},
|
|
1061
|
+
headers: { Authorization: `Basic ${this.config.credential}` },
|
|
1588
1062
|
data: query,
|
|
1589
1063
|
});
|
|
1590
1064
|
return {
|
|
@@ -1596,29 +1070,19 @@ class AxiosAdapter {
|
|
|
1596
1070
|
save(index, data) {
|
|
1597
1071
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1598
1072
|
yield axios({
|
|
1599
|
-
url: `${this.config.url}/${index}
|
|
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}`,
|
|
1073
|
+
url: `${this.config.url}/${index}`,
|
|
1610
1074
|
method: 'PUT',
|
|
1611
|
-
headers: { Authorization: `
|
|
1075
|
+
headers: { Authorization: `Basic ${this.config.credential}` },
|
|
1612
1076
|
data,
|
|
1613
1077
|
});
|
|
1614
1078
|
});
|
|
1615
1079
|
}
|
|
1616
|
-
delete(index
|
|
1080
|
+
delete(index) {
|
|
1617
1081
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1618
1082
|
yield axios({
|
|
1619
|
-
url: `${this.config.url}/${index}
|
|
1083
|
+
url: `${this.config.url}/${index}`,
|
|
1620
1084
|
method: 'DELETE',
|
|
1621
|
-
headers: { Authorization: `
|
|
1085
|
+
headers: { Authorization: `Basic ${this.config.credential}` },
|
|
1622
1086
|
});
|
|
1623
1087
|
});
|
|
1624
1088
|
}
|
|
@@ -1627,19 +1091,16 @@ class AxiosAdapter {
|
|
|
1627
1091
|
class ProductsIndex {
|
|
1628
1092
|
constructor(adapter) {
|
|
1629
1093
|
this.adapter = adapter;
|
|
1630
|
-
this.index = `products`;
|
|
1631
1094
|
}
|
|
1632
|
-
|
|
1095
|
+
get(id) {
|
|
1633
1096
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1634
|
-
const data = yield this.adapter.get(
|
|
1097
|
+
const data = yield this.adapter.get(`products/_doc/${id}`);
|
|
1635
1098
|
return Product.toInstance(data);
|
|
1636
1099
|
});
|
|
1637
1100
|
}
|
|
1638
|
-
|
|
1101
|
+
findById(ids, options) {
|
|
1639
1102
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1640
|
-
const size = total >= 10 ? 500 : 9;
|
|
1641
1103
|
const fields = [
|
|
1642
|
-
'EAN',
|
|
1643
1104
|
'brand',
|
|
1644
1105
|
'id',
|
|
1645
1106
|
'images',
|
|
@@ -1650,83 +1111,73 @@ class ProductsIndex {
|
|
|
1650
1111
|
'stock',
|
|
1651
1112
|
'slug',
|
|
1652
1113
|
'reviews',
|
|
1114
|
+
'pricePaid',
|
|
1115
|
+
'isGift',
|
|
1116
|
+
'stock',
|
|
1117
|
+
'weight',
|
|
1118
|
+
'tags',
|
|
1653
1119
|
'hasVariants',
|
|
1654
|
-
'
|
|
1120
|
+
'type',
|
|
1655
1121
|
];
|
|
1656
|
-
const
|
|
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: {
|
|
1122
|
+
const { hits } = yield this.adapter.query('products/_search', Object.assign({ _source: fields, query: {
|
|
1667
1123
|
bool: {
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
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,
|
|
1124
|
+
filter: [
|
|
1125
|
+
{
|
|
1126
|
+
terms: {
|
|
1127
|
+
_id: ids,
|
|
1128
|
+
},
|
|
1684
1129
|
},
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
'name.search': {
|
|
1689
|
-
query: `${searchTerm}`,
|
|
1690
|
-
slop: 10,
|
|
1130
|
+
{
|
|
1131
|
+
term: {
|
|
1132
|
+
published: true,
|
|
1691
1133
|
},
|
|
1692
1134
|
},
|
|
1693
|
-
|
|
1694
|
-
|
|
1135
|
+
...((options === null || options === void 0 ? void 0 : options.hasStock)
|
|
1136
|
+
? [
|
|
1137
|
+
{
|
|
1138
|
+
range: {
|
|
1139
|
+
'stock.quantity': {
|
|
1140
|
+
gt: 0,
|
|
1141
|
+
},
|
|
1142
|
+
},
|
|
1143
|
+
},
|
|
1144
|
+
]
|
|
1145
|
+
: []),
|
|
1146
|
+
],
|
|
1695
1147
|
},
|
|
1696
|
-
},
|
|
1697
|
-
|
|
1698
|
-
search.hits = search.hits.filter((e) => e._source.name !== '');
|
|
1699
|
-
return search;
|
|
1148
|
+
} }, ((options === null || options === void 0 ? void 0 : options.size) ? { size: options === null || options === void 0 ? void 0 : options.size } : {})));
|
|
1149
|
+
return hits.map((hit) => Product.toInstance(hit._source));
|
|
1700
1150
|
});
|
|
1701
1151
|
}
|
|
1702
1152
|
save(product) {
|
|
1703
1153
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1154
|
+
delete product.createdAt;
|
|
1155
|
+
delete product.updatedAt;
|
|
1156
|
+
delete product.kitProducts;
|
|
1704
1157
|
try {
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
console.error(error);
|
|
1710
|
-
}
|
|
1711
|
-
});
|
|
1712
|
-
}
|
|
1713
|
-
update(product) {
|
|
1714
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1715
|
-
try {
|
|
1716
|
-
yield this.adapter.update(this.index, product.id, product);
|
|
1158
|
+
if (!product.firestoreId)
|
|
1159
|
+
throw new Error('Is not a product from firestore');
|
|
1160
|
+
yield this.get(product.firestoreId);
|
|
1161
|
+
yield this.adapter.save(`products/_doc/${product.firestoreId}`, product.toPlain());
|
|
1717
1162
|
}
|
|
1718
1163
|
catch (error) {
|
|
1719
|
-
|
|
1164
|
+
if (!(error instanceof Error))
|
|
1165
|
+
throw error;
|
|
1166
|
+
console.error(error.message);
|
|
1167
|
+
yield this.adapter.save(`products/_doc/${product.id}`, product.toPlain());
|
|
1720
1168
|
}
|
|
1721
1169
|
});
|
|
1722
1170
|
}
|
|
1723
|
-
delete(
|
|
1171
|
+
delete(product) {
|
|
1724
1172
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1173
|
+
if (!product.firestoreId)
|
|
1174
|
+
return;
|
|
1725
1175
|
try {
|
|
1726
|
-
yield this.
|
|
1176
|
+
yield this.get(product.firestoreId);
|
|
1177
|
+
yield this.adapter.delete(`products/_doc/${product.firestoreId}`);
|
|
1727
1178
|
}
|
|
1728
1179
|
catch (error) {
|
|
1729
|
-
|
|
1180
|
+
yield this.adapter.delete(`products/_doc/${product.id}`);
|
|
1730
1181
|
}
|
|
1731
1182
|
});
|
|
1732
1183
|
}
|
|
@@ -1754,39 +1205,17 @@ const withFirestore = (MixinBase) => {
|
|
|
1754
1205
|
? data[key].map((element) => (isObjectsAndNoDate(element) ? bindAllDateFromObject(element) : element))
|
|
1755
1206
|
: bindDate(data[key], key) })), {});
|
|
1756
1207
|
};
|
|
1757
|
-
const omitByRecursivelyInPlace = (value, iteratee) => {
|
|
1758
|
-
each(value, (v, k) => {
|
|
1759
|
-
if (iteratee(v, k)) {
|
|
1760
|
-
unset(value, k);
|
|
1761
|
-
}
|
|
1762
|
-
else if (isObject(v)) {
|
|
1763
|
-
omitByRecursivelyInPlace(v, iteratee);
|
|
1764
|
-
}
|
|
1765
|
-
});
|
|
1766
|
-
return value;
|
|
1767
|
-
};
|
|
1768
1208
|
return class extends MixinBase {
|
|
1769
|
-
constructor(
|
|
1770
|
-
|
|
1771
|
-
super(...params);
|
|
1772
|
-
this.fields = {};
|
|
1773
|
-
this.interceptors = {};
|
|
1209
|
+
constructor() {
|
|
1210
|
+
super(...arguments);
|
|
1774
1211
|
this.collectionName = '';
|
|
1775
|
-
this.firestore = options.firestore;
|
|
1776
|
-
this.collectionName = options.collectionName;
|
|
1777
|
-
this.model = options.model;
|
|
1778
|
-
this.fields = options.fields;
|
|
1779
|
-
this.interceptors = options.interceptors;
|
|
1780
1212
|
}
|
|
1781
1213
|
collection(path) {
|
|
1782
1214
|
return collection(this.firestore, path || this.collectionName).withConverter(this.buildModelInstance());
|
|
1783
1215
|
}
|
|
1784
1216
|
buildModelInstance() {
|
|
1785
1217
|
return {
|
|
1786
|
-
toFirestore: (data) =>
|
|
1787
|
-
const plain = (data === null || data === void 0 ? void 0 : data.toPlain) ? data.toPlain() : data;
|
|
1788
|
-
return omitByRecursivelyInPlace(plain, (value) => value === undefined);
|
|
1789
|
-
},
|
|
1218
|
+
toFirestore: (data) => ((data === null || data === void 0 ? void 0 : data.toPlain) ? data.toPlain() : data),
|
|
1790
1219
|
fromFirestore: (snap) => {
|
|
1791
1220
|
const data = snap.data();
|
|
1792
1221
|
let bindedData = null;
|
|
@@ -1826,16 +1255,12 @@ const withHelpers = (MixinBase) => {
|
|
|
1826
1255
|
const withGetFirestore = (MixinBase) => {
|
|
1827
1256
|
return class GetFirestore extends MixinBase {
|
|
1828
1257
|
get(identifiers) {
|
|
1829
|
-
var _a, _b, _c, _d;
|
|
1830
1258
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1831
|
-
const
|
|
1832
|
-
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 }));
|
|
1833
|
-
const builded = (intercepted === null || intercepted === void 0 ? void 0 : intercepted.instance) || instance;
|
|
1834
|
-
const docRef = yield getDoc(doc(yield this.collection(this.buildCollectionPathForGet(identifiers)), Object.values(builded.identifier).shift().toString()));
|
|
1259
|
+
const docRef = yield getDoc(doc(yield this.collection(this.buildCollectionPathForGet(identifiers)), Object.values(identifiers).shift().toString()));
|
|
1835
1260
|
const data = docRef.data();
|
|
1836
1261
|
if (isNil(data))
|
|
1837
1262
|
throw new NotFoundError(`Document ${JSON.stringify(identifiers)} not found`);
|
|
1838
|
-
return
|
|
1263
|
+
return data;
|
|
1839
1264
|
});
|
|
1840
1265
|
}
|
|
1841
1266
|
buildCollectionPathForGet(identifiers) {
|
|
@@ -1914,13 +1339,9 @@ const withFindFirestore = (MixinBase) => {
|
|
|
1914
1339
|
return Object.keys(fieldsToOrderBy).map((fieldName) => orderBy(fieldName, fieldsToOrderBy[fieldName]));
|
|
1915
1340
|
};
|
|
1916
1341
|
}
|
|
1917
|
-
find(
|
|
1918
|
-
var _a, _b, _c, _d, _e, _f;
|
|
1342
|
+
find({ filters, limits, orderBy, } = {}) {
|
|
1919
1343
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1920
|
-
const collection = this.collection(this.buildCollectionPathForFind(
|
|
1921
|
-
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;
|
|
1922
|
-
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 }));
|
|
1923
|
-
const { filters, limits, orderBy } = intercepted.find || find;
|
|
1344
|
+
const collection = this.collection(this.buildCollectionPathForFind(filters));
|
|
1924
1345
|
const queries = this.makeFirestoreWhere(filters || {});
|
|
1925
1346
|
const ordination = this.makeFirestoreOrderBy(filters, orderBy);
|
|
1926
1347
|
const offsets = yield this.defineLimits(filters, limits);
|
|
@@ -1928,8 +1349,8 @@ const withFindFirestore = (MixinBase) => {
|
|
|
1928
1349
|
const docs = yield getDocs(query(collection, ...queryArgumments));
|
|
1929
1350
|
const data = docs.docs.map((doc) => doc.data());
|
|
1930
1351
|
return {
|
|
1931
|
-
data
|
|
1932
|
-
count:
|
|
1352
|
+
data,
|
|
1353
|
+
count: this.calculateCount(data, limits),
|
|
1933
1354
|
};
|
|
1934
1355
|
});
|
|
1935
1356
|
}
|
|
@@ -1941,12 +1362,11 @@ const withFindFirestore = (MixinBase) => {
|
|
|
1941
1362
|
return `${this.parentRepository.collectionName}/${parentId}/${this.collectionName}`;
|
|
1942
1363
|
}
|
|
1943
1364
|
defineLimits(filters, limits) {
|
|
1944
|
-
var _a;
|
|
1945
1365
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1946
1366
|
const queries = [];
|
|
1947
1367
|
if (limits === null || limits === void 0 ? void 0 : limits.offset) {
|
|
1948
1368
|
if (this.model.isModel(limits.offset))
|
|
1949
|
-
queries.push(startAfter(yield getDoc(doc(this.collection(this.buildCollectionPathForFind(filters)),
|
|
1369
|
+
queries.push(startAfter(yield getDoc(doc(this.collection(this.buildCollectionPathForFind(filters)), limits.offset.identifier.shift()))));
|
|
1950
1370
|
else if (isNumber(limits.offset) || isString(limits.offset))
|
|
1951
1371
|
queries.push(startAt(limits.offset));
|
|
1952
1372
|
}
|
|
@@ -1968,21 +1388,16 @@ const withFindFirestore = (MixinBase) => {
|
|
|
1968
1388
|
const withCreateFirestore = (MixinBase) => {
|
|
1969
1389
|
return class CreateFirestore extends MixinBase {
|
|
1970
1390
|
create(data) {
|
|
1971
|
-
var _a, _b, _c, _d;
|
|
1972
1391
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1973
|
-
const
|
|
1974
|
-
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 }));
|
|
1975
|
-
const builded = (intercepted === null || intercepted === void 0 ? void 0 : intercepted.instance) || instance;
|
|
1976
|
-
const docRef = yield this.save(builded);
|
|
1392
|
+
const docRef = yield this.save(this.model.toInstance(data));
|
|
1977
1393
|
const doc = yield getDoc(docRef);
|
|
1978
|
-
|
|
1979
|
-
return docBuilded;
|
|
1394
|
+
return doc.data();
|
|
1980
1395
|
});
|
|
1981
1396
|
}
|
|
1982
1397
|
save(data) {
|
|
1983
1398
|
var _a, _b;
|
|
1984
1399
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1985
|
-
const id = (_b = (_a =
|
|
1400
|
+
const id = (_b = data.identifier[(_a = data.identifiersFields) === null || _a === void 0 ? void 0 : _a.shift()]) === null || _b === void 0 ? void 0 : _b.toString();
|
|
1986
1401
|
const collectionPath = this.buildCollectionPathForAdd(data);
|
|
1987
1402
|
const collection = this.collection(collectionPath);
|
|
1988
1403
|
if (isEmpty(id))
|
|
@@ -2024,17 +1439,13 @@ const withUpdateFirestore = (MixinBase) => {
|
|
|
2024
1439
|
};
|
|
2025
1440
|
return class UpdateFirestore extends MixinBase {
|
|
2026
1441
|
update(data) {
|
|
2027
|
-
var _a, _b, _c, _d;
|
|
2028
1442
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2029
1443
|
const model = new this.model();
|
|
2030
1444
|
const keyField = model.identifiersFields.shift();
|
|
2031
1445
|
const docRef = doc(this.collection(this.buildCollectionPathForUpdate(data)), getValueFromParams(data, keyField).toString());
|
|
2032
|
-
|
|
2033
|
-
const
|
|
2034
|
-
|
|
2035
|
-
yield setDoc(docRef, builded.toPlain(), { merge: true });
|
|
2036
|
-
const docData = yield getDoc(docRef).then((doc) => doc.data());
|
|
2037
|
-
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;
|
|
1446
|
+
yield setDoc(docRef, this.paramsToPlain(data), { merge: true });
|
|
1447
|
+
const docData = yield getDoc(docRef);
|
|
1448
|
+
return docData.data();
|
|
2038
1449
|
});
|
|
2039
1450
|
}
|
|
2040
1451
|
buildCollectionPathForUpdate(identifiers) {
|
|
@@ -2054,13 +1465,8 @@ const withUpdateFirestore = (MixinBase) => {
|
|
|
2054
1465
|
const withDeleteFirestore = (MixinBase) => {
|
|
2055
1466
|
return class DeleteFirestore extends MixinBase {
|
|
2056
1467
|
delete(identifiers) {
|
|
2057
|
-
var _a, _b, _c, _d;
|
|
2058
1468
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2059
|
-
|
|
2060
|
-
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 }));
|
|
2061
|
-
const builded = (intercepted === null || intercepted === void 0 ? void 0 : intercepted.instance) || instance;
|
|
2062
|
-
yield deleteDoc(doc(this.collection(this.buildCollectionPathForRemove(identifiers)), Object.values(builded.identifier).shift().toString()));
|
|
2063
|
-
yield ((_d = (_c = this.interceptors) === null || _c === void 0 ? void 0 : _c.response) === null || _d === void 0 ? void 0 : _d.call(_c, instance, intercepted));
|
|
1469
|
+
yield deleteDoc(doc(this.collection(this.buildCollectionPathForRemove(identifiers)), Object.values(identifiers).shift().toString()));
|
|
2064
1470
|
});
|
|
2065
1471
|
}
|
|
2066
1472
|
buildCollectionPathForRemove(identifiers) {
|
|
@@ -2073,10 +1479,8 @@ const withDeleteFirestore = (MixinBase) => {
|
|
|
2073
1479
|
|
|
2074
1480
|
const withSubCollection = (MixinBase, ParentModel) => {
|
|
2075
1481
|
return class SubCollectionMix extends MixinBase {
|
|
2076
|
-
constructor(...
|
|
2077
|
-
|
|
2078
|
-
super(...params);
|
|
2079
|
-
this.parentIdField = options.parentIdField;
|
|
1482
|
+
constructor(...args) {
|
|
1483
|
+
super(args);
|
|
2080
1484
|
}
|
|
2081
1485
|
collection(path) {
|
|
2082
1486
|
return super.collection(path);
|
|
@@ -2090,87 +1494,73 @@ const withCrudFirestore = (MixinBase) => {
|
|
|
2090
1494
|
};
|
|
2091
1495
|
|
|
2092
1496
|
class LeadFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
2093
|
-
constructor(
|
|
2094
|
-
super(
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
interceptors,
|
|
2099
|
-
});
|
|
1497
|
+
constructor(firestore) {
|
|
1498
|
+
super();
|
|
1499
|
+
this.firestore = firestore;
|
|
1500
|
+
this.collectionName = 'leads';
|
|
1501
|
+
this.model = Lead;
|
|
2100
1502
|
}
|
|
2101
1503
|
}
|
|
2102
1504
|
|
|
2103
1505
|
class SubscriptionEditionFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), Subscription) {
|
|
2104
|
-
constructor(
|
|
2105
|
-
super(
|
|
2106
|
-
|
|
2107
|
-
collectionName: 'editions',
|
|
2108
|
-
parentIdField: 'subscriptionId',
|
|
2109
|
-
model: Edition,
|
|
2110
|
-
interceptors,
|
|
2111
|
-
});
|
|
1506
|
+
constructor(firestore, parentRepository) {
|
|
1507
|
+
super();
|
|
1508
|
+
this.firestore = firestore;
|
|
2112
1509
|
this.parentRepository = parentRepository;
|
|
1510
|
+
this.collectionName = 'editions';
|
|
1511
|
+
this.parentIdField = 'subscriptionId';
|
|
1512
|
+
this.model = Edition;
|
|
2113
1513
|
}
|
|
2114
1514
|
}
|
|
2115
1515
|
|
|
2116
1516
|
class SubscriptionFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
2117
|
-
constructor(
|
|
2118
|
-
super(
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
interceptors,
|
|
2123
|
-
});
|
|
1517
|
+
constructor(firestore) {
|
|
1518
|
+
super();
|
|
1519
|
+
this.firestore = firestore;
|
|
1520
|
+
this.collectionName = 'subscription';
|
|
1521
|
+
this.model = Subscription;
|
|
2124
1522
|
}
|
|
2125
1523
|
}
|
|
2126
1524
|
|
|
2127
1525
|
class SubscriptionPaymentFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), Subscription) {
|
|
2128
|
-
constructor(
|
|
2129
|
-
super(
|
|
2130
|
-
|
|
2131
|
-
collectionName: 'payments',
|
|
2132
|
-
parentIdField: 'subscriptionId',
|
|
2133
|
-
model: SubscriptionPayment,
|
|
2134
|
-
interceptors,
|
|
2135
|
-
});
|
|
1526
|
+
constructor(firestore, parentRepository) {
|
|
1527
|
+
super();
|
|
1528
|
+
this.firestore = firestore;
|
|
2136
1529
|
this.parentRepository = parentRepository;
|
|
1530
|
+
this.collectionName = 'payments';
|
|
1531
|
+
this.parentIdField = 'subscriptionId';
|
|
1532
|
+
this.model = SubscriptionPayment;
|
|
2137
1533
|
}
|
|
2138
1534
|
}
|
|
2139
1535
|
|
|
2140
1536
|
class UserAddressFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), User) {
|
|
2141
|
-
constructor(
|
|
2142
|
-
super(
|
|
2143
|
-
|
|
2144
|
-
collectionName: 'address',
|
|
2145
|
-
parentIdField: 'userId',
|
|
2146
|
-
model: UserAddress,
|
|
2147
|
-
interceptors,
|
|
2148
|
-
});
|
|
1537
|
+
constructor(firestore, parentRepository) {
|
|
1538
|
+
super();
|
|
1539
|
+
this.firestore = firestore;
|
|
2149
1540
|
this.parentRepository = parentRepository;
|
|
1541
|
+
this.collectionName = 'address';
|
|
1542
|
+
this.parentIdField = 'userId';
|
|
1543
|
+
this.model = UserAddress;
|
|
2150
1544
|
}
|
|
2151
1545
|
}
|
|
2152
1546
|
|
|
2153
1547
|
class UserBeautyProfileFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), User) {
|
|
2154
|
-
constructor(
|
|
2155
|
-
super(
|
|
2156
|
-
|
|
2157
|
-
collectionName: 'CX',
|
|
2158
|
-
parentIdField: 'userId',
|
|
2159
|
-
model: BeautyProfile,
|
|
2160
|
-
interceptors,
|
|
2161
|
-
});
|
|
1548
|
+
constructor(firestore, parentRepository) {
|
|
1549
|
+
super();
|
|
1550
|
+
this.firestore = firestore;
|
|
2162
1551
|
this.parentRepository = parentRepository;
|
|
1552
|
+
this.collectionName = 'CX';
|
|
1553
|
+
this.parentIdField = 'userId';
|
|
1554
|
+
this.model = BeautyProfile;
|
|
2163
1555
|
}
|
|
2164
1556
|
}
|
|
2165
1557
|
|
|
2166
1558
|
class UserFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
2167
|
-
constructor(
|
|
2168
|
-
super(
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
interceptors,
|
|
2173
|
-
});
|
|
1559
|
+
constructor(firestore) {
|
|
1560
|
+
super();
|
|
1561
|
+
this.firestore = firestore;
|
|
1562
|
+
this.collectionName = 'users';
|
|
1563
|
+
this.model = User;
|
|
2174
1564
|
}
|
|
2175
1565
|
get(identifiers) {
|
|
2176
1566
|
const _super = Object.create(null, {
|
|
@@ -2221,26 +1611,22 @@ class UserFirestoreRepository extends withCrudFirestore(withHelpers(withFirestor
|
|
|
2221
1611
|
}
|
|
2222
1612
|
|
|
2223
1613
|
class UserPaymentMethodFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), User) {
|
|
2224
|
-
constructor(
|
|
2225
|
-
super(
|
|
2226
|
-
|
|
2227
|
-
collectionName: 'payment_method',
|
|
2228
|
-
parentIdField: 'userId',
|
|
2229
|
-
model: UserPaymentMethod,
|
|
2230
|
-
interceptors,
|
|
2231
|
-
});
|
|
1614
|
+
constructor(firestore, parentRepository) {
|
|
1615
|
+
super();
|
|
1616
|
+
this.firestore = firestore;
|
|
2232
1617
|
this.parentRepository = parentRepository;
|
|
1618
|
+
this.collectionName = 'payment_method';
|
|
1619
|
+
this.parentIdField = 'userId';
|
|
1620
|
+
this.model = UserPaymentMethod;
|
|
2233
1621
|
}
|
|
2234
1622
|
}
|
|
2235
1623
|
|
|
2236
1624
|
class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
2237
|
-
constructor(
|
|
2238
|
-
super(
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
interceptors,
|
|
2243
|
-
});
|
|
1625
|
+
constructor(firestore) {
|
|
1626
|
+
super();
|
|
1627
|
+
this.firestore = firestore;
|
|
1628
|
+
this.collectionName = 'categories';
|
|
1629
|
+
this.model = Category;
|
|
2244
1630
|
}
|
|
2245
1631
|
getCategoryBySlug(slug, shop) {
|
|
2246
1632
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -2252,7 +1638,7 @@ class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFire
|
|
|
2252
1638
|
return categoryDocs.docs[0].data();
|
|
2253
1639
|
});
|
|
2254
1640
|
}
|
|
2255
|
-
getCategoriesForHome(categoryIds, limit = 4
|
|
1641
|
+
getCategoriesForHome(categoryIds, limit = 4) {
|
|
2256
1642
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2257
1643
|
const categorySnap = yield getDocs(query(this.collection(this.collectionName), where('id', 'in', categoryIds.filter(Boolean)), where('published', '==', true)));
|
|
2258
1644
|
if (categorySnap.empty)
|
|
@@ -2261,7 +1647,7 @@ class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFire
|
|
|
2261
1647
|
const homeSections = yield Promise.all(categories.map((category) => __awaiter(this, void 0, void 0, function* () {
|
|
2262
1648
|
return ({
|
|
2263
1649
|
category,
|
|
2264
|
-
products: yield this.mountCategory(category, { limit, hasStock: true
|
|
1650
|
+
products: yield this.mountCategory(category, { limit, hasStock: true }),
|
|
2265
1651
|
});
|
|
2266
1652
|
})));
|
|
2267
1653
|
return homeSections;
|
|
@@ -2280,8 +1666,6 @@ class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFire
|
|
|
2280
1666
|
wheres.push(where('published', '==', true), where('id', 'in', productIds));
|
|
2281
1667
|
if (options === null || options === void 0 ? void 0 : options.hasStock)
|
|
2282
1668
|
wheres.push(where('stock.quantity', '>', 0));
|
|
2283
|
-
if (options === null || options === void 0 ? void 0 : options.gender)
|
|
2284
|
-
wheres.push(where('tags', 'array-contains', options === null || options === void 0 ? void 0 : options.gender));
|
|
2285
1669
|
if (options === null || options === void 0 ? void 0 : options.limit)
|
|
2286
1670
|
wheres.push(limit(options === null || options === void 0 ? void 0 : options.limit));
|
|
2287
1671
|
const productSnap = yield getDocs(query(this.collection('productsErpVitrine'), ...wheres));
|
|
@@ -2292,20 +1676,15 @@ class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFire
|
|
|
2292
1676
|
return is(products);
|
|
2293
1677
|
});
|
|
2294
1678
|
}
|
|
2295
|
-
getCategoryByShop(shop) {
|
|
2296
|
-
return;
|
|
2297
|
-
}
|
|
2298
1679
|
}
|
|
2299
1680
|
|
|
2300
1681
|
class ProductFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
2301
|
-
constructor(
|
|
2302
|
-
super(
|
|
2303
|
-
|
|
2304
|
-
collectionName: 'productsErpVitrine',
|
|
2305
|
-
model: Product,
|
|
2306
|
-
interceptors,
|
|
2307
|
-
});
|
|
1682
|
+
constructor(firestore) {
|
|
1683
|
+
super();
|
|
1684
|
+
this.firestore = firestore;
|
|
2308
1685
|
this.reviews = {};
|
|
1686
|
+
this.collectionName = 'productsErpVitrine';
|
|
1687
|
+
this.model = Product;
|
|
2309
1688
|
}
|
|
2310
1689
|
getBySlug(slug) {
|
|
2311
1690
|
var _a;
|
|
@@ -2346,98 +1725,43 @@ class ProductFirestoreRepository extends withCrudFirestore(withHelpers(withFires
|
|
|
2346
1725
|
return this.reviews[status];
|
|
2347
1726
|
});
|
|
2348
1727
|
}
|
|
2349
|
-
cleanShoppingCountFromIds() {
|
|
2350
|
-
return;
|
|
2351
|
-
}
|
|
2352
1728
|
}
|
|
2353
1729
|
|
|
2354
1730
|
class ProductVariantFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), Product) {
|
|
2355
|
-
constructor(
|
|
2356
|
-
super(
|
|
2357
|
-
|
|
2358
|
-
collectionName: 'variants',
|
|
2359
|
-
parentIdField: 'productId',
|
|
2360
|
-
model: Variant,
|
|
2361
|
-
interceptors,
|
|
2362
|
-
});
|
|
1731
|
+
constructor(firestore, parentRepository) {
|
|
1732
|
+
super();
|
|
1733
|
+
this.firestore = firestore;
|
|
2363
1734
|
this.parentRepository = parentRepository;
|
|
1735
|
+
this.collectionName = 'variants';
|
|
1736
|
+
this.parentIdField = 'productId';
|
|
1737
|
+
this.model = Variant;
|
|
2364
1738
|
}
|
|
2365
1739
|
}
|
|
2366
1740
|
|
|
2367
1741
|
class SubscriptionProductFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
2368
|
-
constructor(
|
|
2369
|
-
super(
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
interceptors,
|
|
2374
|
-
});
|
|
2375
|
-
}
|
|
2376
|
-
}
|
|
2377
|
-
|
|
2378
|
-
class Buy2WinFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
2379
|
-
constructor({ firestore, interceptors }) {
|
|
2380
|
-
super({
|
|
2381
|
-
firestore,
|
|
2382
|
-
collectionName: 'buy2win',
|
|
2383
|
-
model: Buy2Win,
|
|
2384
|
-
interceptors,
|
|
2385
|
-
});
|
|
2386
|
-
}
|
|
2387
|
-
}
|
|
2388
|
-
|
|
2389
|
-
class CampaignDashboardFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
2390
|
-
constructor({ firestore, interceptors, }) {
|
|
2391
|
-
super({
|
|
2392
|
-
firestore,
|
|
2393
|
-
collectionName: 'dashboardCampaignsAuto',
|
|
2394
|
-
model: CampaignDashboard,
|
|
2395
|
-
interceptors,
|
|
2396
|
-
});
|
|
2397
|
-
}
|
|
2398
|
-
}
|
|
2399
|
-
|
|
2400
|
-
class CampaignHashtagFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
2401
|
-
constructor({ firestore, interceptors, }) {
|
|
2402
|
-
super({
|
|
2403
|
-
firestore,
|
|
2404
|
-
collectionName: 'hashtagCampaignsAuto',
|
|
2405
|
-
model: CampaignHashtag,
|
|
2406
|
-
interceptors,
|
|
2407
|
-
});
|
|
1742
|
+
constructor(firestore) {
|
|
1743
|
+
super();
|
|
1744
|
+
this.firestore = firestore;
|
|
1745
|
+
this.collectionName = 'subscriptionProducts';
|
|
1746
|
+
this.model = Product;
|
|
2408
1747
|
}
|
|
2409
1748
|
}
|
|
2410
1749
|
|
|
2411
1750
|
class CheckoutFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
2412
|
-
constructor(
|
|
2413
|
-
super(
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
interceptors,
|
|
2418
|
-
});
|
|
2419
|
-
}
|
|
2420
|
-
}
|
|
2421
|
-
|
|
2422
|
-
class CheckoutSubscriptionFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
2423
|
-
constructor({ firestore, interceptors, }) {
|
|
2424
|
-
super({
|
|
2425
|
-
firestore,
|
|
2426
|
-
collectionName: 'checkoutsSubscription',
|
|
2427
|
-
model: CheckoutSubscription,
|
|
2428
|
-
interceptors,
|
|
2429
|
-
});
|
|
1751
|
+
constructor(firestore) {
|
|
1752
|
+
super();
|
|
1753
|
+
this.firestore = firestore;
|
|
1754
|
+
this.collectionName = 'checkouts';
|
|
1755
|
+
this.model = Checkout;
|
|
2430
1756
|
}
|
|
2431
1757
|
}
|
|
2432
1758
|
|
|
2433
1759
|
class CouponFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
2434
|
-
constructor(
|
|
2435
|
-
super(
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
interceptors,
|
|
2440
|
-
});
|
|
1760
|
+
constructor(firestore) {
|
|
1761
|
+
super();
|
|
1762
|
+
this.firestore = firestore;
|
|
1763
|
+
this.collectionName = 'coupons';
|
|
1764
|
+
this.model = Coupon;
|
|
2441
1765
|
}
|
|
2442
1766
|
buildModelInstance() {
|
|
2443
1767
|
const { fromFirestore, toFirestore } = super.buildModelInstance();
|
|
@@ -2459,16 +1783,9 @@ class CouponFirestoreRepository extends withCrudFirestore(withHelpers(withFirest
|
|
|
2459
1783
|
}
|
|
2460
1784
|
|
|
2461
1785
|
class OrderFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
2462
|
-
constructor(
|
|
2463
|
-
super(
|
|
2464
|
-
|
|
2465
|
-
collectionName: 'orders',
|
|
2466
|
-
model: Order,
|
|
2467
|
-
interceptors,
|
|
2468
|
-
fields: {
|
|
2469
|
-
status: FirestoreFieldType.String,
|
|
2470
|
-
},
|
|
2471
|
-
});
|
|
1786
|
+
constructor(firestore) {
|
|
1787
|
+
super();
|
|
1788
|
+
this.firestore = firestore;
|
|
2472
1789
|
this.orderFromFirestore = (order) => {
|
|
2473
1790
|
var _a;
|
|
2474
1791
|
if (!!((_a = order === null || order === void 0 ? void 0 : order.lineItems) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
@@ -2482,6 +1799,11 @@ class OrderFirestoreRepository extends withCrudFirestore(withHelpers(withFiresto
|
|
|
2482
1799
|
}
|
|
2483
1800
|
return order;
|
|
2484
1801
|
};
|
|
1802
|
+
this.collectionName = 'orders';
|
|
1803
|
+
this.model = Order;
|
|
1804
|
+
this.fields = {
|
|
1805
|
+
status: FirestoreFieldType.String,
|
|
1806
|
+
};
|
|
2485
1807
|
}
|
|
2486
1808
|
buildModelInstance() {
|
|
2487
1809
|
const { fromFirestore, toFirestore } = super.buildModelInstance();
|
|
@@ -2495,62 +1817,86 @@ class OrderFirestoreRepository extends withCrudFirestore(withHelpers(withFiresto
|
|
|
2495
1817
|
}
|
|
2496
1818
|
}
|
|
2497
1819
|
|
|
2498
|
-
class
|
|
2499
|
-
constructor(
|
|
2500
|
-
super(
|
|
2501
|
-
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
this.collectionName = 'legacyOrders';
|
|
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;
|
|
2505
1826
|
}
|
|
2506
1827
|
}
|
|
2507
1828
|
|
|
2508
|
-
class
|
|
2509
|
-
constructor(
|
|
2510
|
-
super(
|
|
2511
|
-
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
interceptors,
|
|
2515
|
-
});
|
|
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;
|
|
2516
1835
|
}
|
|
2517
1836
|
}
|
|
2518
1837
|
|
|
2519
1838
|
class SubscriptionPlanFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
2520
|
-
constructor(
|
|
2521
|
-
super(
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
|
|
1839
|
+
constructor(firestore) {
|
|
1840
|
+
super();
|
|
1841
|
+
this.firestore = firestore;
|
|
1842
|
+
this.collectionName = 'subscriptionPlans';
|
|
1843
|
+
this.model = SubscriptionPlan;
|
|
1844
|
+
}
|
|
1845
|
+
}
|
|
1846
|
+
|
|
1847
|
+
class Buy2WinFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1848
|
+
constructor(firestore) {
|
|
1849
|
+
super();
|
|
1850
|
+
this.firestore = firestore;
|
|
1851
|
+
this.collectionName = 'buy2win';
|
|
1852
|
+
this.model = Buy2Win;
|
|
1853
|
+
}
|
|
1854
|
+
}
|
|
1855
|
+
|
|
1856
|
+
class LegacyOrderFirestoreRepository extends OrderFirestoreRepository {
|
|
1857
|
+
constructor(firestore) {
|
|
1858
|
+
super(firestore);
|
|
1859
|
+
this.firestore = firestore;
|
|
1860
|
+
this.collectionName = 'legacyOrders';
|
|
2527
1861
|
}
|
|
2528
1862
|
}
|
|
2529
1863
|
|
|
2530
1864
|
class HomeFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
2531
|
-
constructor(
|
|
2532
|
-
super(
|
|
2533
|
-
|
|
2534
|
-
|
|
2535
|
-
|
|
2536
|
-
|
|
2537
|
-
|
|
2538
|
-
|
|
2539
|
-
|
|
2540
|
-
|
|
2541
|
-
|
|
2542
|
-
? (_b = homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category) === null || _b === void 0 ? void 0 : _b.toPlain()
|
|
2543
|
-
: homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category,
|
|
2544
|
-
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)) || [],
|
|
2545
|
-
});
|
|
1865
|
+
constructor(firestore) {
|
|
1866
|
+
super();
|
|
1867
|
+
this.firestore = firestore;
|
|
1868
|
+
this.homeToFirestore = (home) => {
|
|
1869
|
+
var _a;
|
|
1870
|
+
if ((_a = home.data) === null || _a === void 0 ? void 0 : _a.data) {
|
|
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;
|
|
2546
1876
|
};
|
|
2547
|
-
this.
|
|
1877
|
+
this.homeCategoryGroupToPlain = (homeCategoryGroup) => ({
|
|
1878
|
+
category: homeCategoryGroup.category.toPlain(),
|
|
1879
|
+
products: homeCategoryGroup.products.map((product) => product.toPlain()),
|
|
1880
|
+
});
|
|
1881
|
+
this.homeFromFirestore = (home) => {
|
|
2548
1882
|
var _a;
|
|
2549
|
-
|
|
2550
|
-
|
|
2551
|
-
|
|
2552
|
-
|
|
1883
|
+
if ((_a = home.data) === null || _a === void 0 ? void 0 : _a.data) {
|
|
1884
|
+
home.data.data.discoverProducts = home.data.data.discoverProducts.map(this.plainToHomeCategoryGroup);
|
|
1885
|
+
home.data.data.featuredProducts = home.data.data.featuredProducts.map(this.plainToHomeCategoryGroup);
|
|
1886
|
+
home.data.data.verticalProducts = home.data.data.verticalProducts.map(this.plainToHomeCategoryGroup);
|
|
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;
|
|
2553
1893
|
};
|
|
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;
|
|
2554
1900
|
}
|
|
2555
1901
|
buildModelInstance() {
|
|
2556
1902
|
const { fromFirestore, toFirestore } = super.buildModelInstance();
|
|
@@ -2565,49 +1911,14 @@ class HomeFirestoreRepository extends withCrudFirestore(withHelpers(withFirestor
|
|
|
2565
1911
|
},
|
|
2566
1912
|
};
|
|
2567
1913
|
}
|
|
2568
|
-
homeToFirestore(home) {
|
|
2569
|
-
var _a, _b, _c, _d;
|
|
2570
|
-
if ((_a = home.data) === null || _a === void 0 ? void 0 : _a.data) {
|
|
2571
|
-
home.data.data.discoverProducts = ((_b = home.data.data.discoverProducts) === null || _b === void 0 ? void 0 : _b.map(this.homeCategoryGroupToPlain)) || [];
|
|
2572
|
-
home.data.data.featuredProducts = ((_c = home.data.data.featuredProducts) === null || _c === void 0 ? void 0 : _c.map(this.homeCategoryGroupToPlain)) || [];
|
|
2573
|
-
home.data.data.verticalProducts = ((_d = home.data.data.verticalProducts) === null || _d === void 0 ? void 0 : _d.map(this.homeCategoryGroupToPlain)) || [];
|
|
2574
|
-
}
|
|
2575
|
-
return home;
|
|
2576
|
-
}
|
|
2577
|
-
homeFromFirestore(home) {
|
|
2578
|
-
var _a;
|
|
2579
|
-
if ((_a = home.data) === null || _a === void 0 ? void 0 : _a.data) {
|
|
2580
|
-
home.data.data.discoverProducts = home.data.data.discoverProducts.map(this.plainToHomeCategoryGroup);
|
|
2581
|
-
home.data.data.featuredProducts = home.data.data.featuredProducts.map(this.plainToHomeCategoryGroup);
|
|
2582
|
-
home.data.data.verticalProducts = home.data.data.verticalProducts.map(this.plainToHomeCategoryGroup);
|
|
2583
|
-
home.data.createdAt =
|
|
2584
|
-
home.data.createdAt instanceof Timestamp ? home.data.createdAt.toDate() : home.data.createdAt;
|
|
2585
|
-
home.data.expiresAt =
|
|
2586
|
-
home.data.expiresAt instanceof Timestamp ? home.data.expiresAt.toDate() : home.data.expiresAt;
|
|
2587
|
-
}
|
|
2588
|
-
return home;
|
|
2589
|
-
}
|
|
2590
1914
|
}
|
|
2591
1915
|
|
|
2592
1916
|
class ShopMenuFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
2593
|
-
constructor(
|
|
2594
|
-
super(
|
|
2595
|
-
|
|
2596
|
-
|
|
2597
|
-
|
|
2598
|
-
interceptors,
|
|
2599
|
-
});
|
|
2600
|
-
}
|
|
2601
|
-
}
|
|
2602
|
-
|
|
2603
|
-
class ShopSettingsFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
2604
|
-
constructor({ firestore, interceptors, }) {
|
|
2605
|
-
super({
|
|
2606
|
-
firestore,
|
|
2607
|
-
collectionName: 'shopSettings',
|
|
2608
|
-
model: ShopSettings,
|
|
2609
|
-
interceptors,
|
|
2610
|
-
});
|
|
1917
|
+
constructor(firestore) {
|
|
1918
|
+
super();
|
|
1919
|
+
this.firestore = firestore;
|
|
1920
|
+
this.collectionName = 'shopMenus';
|
|
1921
|
+
this.model = ShopMenu;
|
|
2611
1922
|
}
|
|
2612
1923
|
}
|
|
2613
1924
|
|
|
@@ -2697,7 +2008,7 @@ class AttributeOptionHelper {
|
|
|
2697
2008
|
AttributeOptionHelper.FindByAttribute = (attributeName, fields) => {
|
|
2698
2009
|
var _a;
|
|
2699
2010
|
if (fields.includes(attributeName))
|
|
2700
|
-
return { columnName: attributeName.toString(), attributeName
|
|
2011
|
+
return { columnName: attributeName.toString(), attributeName };
|
|
2701
2012
|
const field = fields.find((columnOption) => isObject(columnOption) && Object.keys(columnOption).includes(attributeName.toString()));
|
|
2702
2013
|
const fieldOption = (_a = is(field)) === null || _a === void 0 ? void 0 : _a[attributeName];
|
|
2703
2014
|
if (isNil(fieldOption))
|
|
@@ -2786,12 +2097,11 @@ BindFilterQueryHelper.MakeGraphQLWhere = (filter, fields) => Object.keys(filter)
|
|
|
2786
2097
|
}, {});
|
|
2787
2098
|
BindFilterQueryHelper.BuildWhereSentence = (field, options, fields) => {
|
|
2788
2099
|
const fieldSentenceOptions = AttributeOptionHelper.FindByAttribute(field, fields);
|
|
2789
|
-
|
|
2100
|
+
if (!Array.isArray(options) &&
|
|
2790
2101
|
isObject(options) &&
|
|
2791
2102
|
isNil(options === null || options === void 0 ? void 0 : options.operator) &&
|
|
2792
2103
|
isNil(options === null || options === void 0 ? void 0 : options.value) &&
|
|
2793
|
-
isNil(fieldSentenceOptions === null || fieldSentenceOptions === void 0 ? void 0 : fieldSentenceOptions.to)
|
|
2794
|
-
if (isNestedField)
|
|
2104
|
+
isNil(fieldSentenceOptions === null || fieldSentenceOptions === void 0 ? void 0 : fieldSentenceOptions.to))
|
|
2795
2105
|
return Object.keys(options).reduce((variables, key) => {
|
|
2796
2106
|
const fieldOptions = AttributeOptionHelper.FindByAttribute(key, (fieldSentenceOptions === null || fieldSentenceOptions === void 0 ? void 0 : fieldSentenceOptions.fields) || fields);
|
|
2797
2107
|
const columnName = fieldOptions.columnName;
|
|
@@ -2802,7 +2112,7 @@ BindFilterQueryHelper.BuildWhereSentence = (field, options, fields) => {
|
|
|
2802
2112
|
return {
|
|
2803
2113
|
[fieldSentenceOptions.fields[0]]: BindFilterQueryHelper.BuildOperatorSentence(options, fieldSentenceOptions),
|
|
2804
2114
|
};
|
|
2805
|
-
if (
|
|
2115
|
+
if (isObject(options) && !FilterOptionHelper.CheckIfIsFilterOption(options))
|
|
2806
2116
|
options = Object.values(options)[0];
|
|
2807
2117
|
return Array.isArray(options)
|
|
2808
2118
|
? options.reduce((whereSentence, option) => (Object.assign(Object.assign({}, whereSentence), BindFilterQueryHelper.BuildOperatorSentence(option, fieldSentenceOptions))), {})
|
|
@@ -2834,14 +2144,28 @@ GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields = (fields) => {
|
|
|
2834
2144
|
if (field === 'affected_rows')
|
|
2835
2145
|
return field;
|
|
2836
2146
|
const fieldName = Object.keys(field).shift();
|
|
2837
|
-
const fieldValue =
|
|
2147
|
+
const fieldValue = field[fieldName];
|
|
2838
2148
|
if (Array.isArray(fieldValue))
|
|
2839
2149
|
return { [fieldName]: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(fieldValue) };
|
|
2840
2150
|
if (!AttributeOptionHelper.CheckIsColumnOption(fieldValue))
|
|
2841
|
-
return;
|
|
2842
|
-
|
|
2843
|
-
|
|
2844
|
-
|
|
2151
|
+
return null;
|
|
2152
|
+
if (fieldValue.fields)
|
|
2153
|
+
return !fieldValue.filters
|
|
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
|
+
};
|
|
2845
2169
|
return fieldValue.columnName;
|
|
2846
2170
|
}).filter((field) => !!field);
|
|
2847
2171
|
};
|
|
@@ -2859,7 +2183,7 @@ GraphQLFieldHelper.ConvertFieldValueFrom = (data, fields) => Object.keys(data).r
|
|
|
2859
2183
|
}
|
|
2860
2184
|
if (!!from)
|
|
2861
2185
|
return Object.assign(Object.assign({}, result), { [attributeName]: from(data[columnName], data) });
|
|
2862
|
-
return Object.assign(Object.assign({}, result), { [attributeName]:
|
|
2186
|
+
return Object.assign(Object.assign({}, result), { [attributeName]: parseDateTime(data[columnName].toString()) });
|
|
2863
2187
|
}, {});
|
|
2864
2188
|
GraphQLFieldHelper.ConvertFieldValueTo = (instance, fields, update = false) => {
|
|
2865
2189
|
var _a;
|
|
@@ -2875,8 +2199,7 @@ GraphQLFieldHelper.ConvertFieldValueTo = (instance, fields, update = false) => {
|
|
|
2875
2199
|
!Object.keys(foreignKeyColumn).filter((key) => { var _a; return !((_a = is(data[attributeName])) === null || _a === void 0 ? void 0 : _a[key]); }).length)
|
|
2876
2200
|
return Object.keys(foreignKeyColumn).reduce((object, current) => {
|
|
2877
2201
|
var _a;
|
|
2878
|
-
|
|
2879
|
-
return Object.assign(Object.assign({}, object), { [foreignColumnName]: (_a = data[attributeName]) === null || _a === void 0 ? void 0 : _a[current] });
|
|
2202
|
+
return (Object.assign(Object.assign({}, object), { [foreignKeyColumn[current]]: (_a = data[attributeName]) === null || _a === void 0 ? void 0 : _a[current] }));
|
|
2880
2203
|
}, Object.assign({}, result));
|
|
2881
2204
|
if (update &&
|
|
2882
2205
|
isObject(data[attributeName]) &&
|
|
@@ -2904,25 +2227,6 @@ GraphQLFieldHelper.ConvertFieldValueTo = (instance, fields, update = false) => {
|
|
|
2904
2227
|
return Object.assign(Object.assign({}, result), { [columnName]: data[attributeName] });
|
|
2905
2228
|
}, {});
|
|
2906
2229
|
};
|
|
2907
|
-
GraphQLFieldHelper.ConvertNestedFieldsToGraphQLFields = (fieldName, fieldValue) => {
|
|
2908
|
-
const hasCustomFilters = !!fieldValue.filters;
|
|
2909
|
-
if (hasCustomFilters)
|
|
2910
|
-
return {
|
|
2911
|
-
operation: fieldValue.columnName || fieldName,
|
|
2912
|
-
fields: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(fieldValue.fields),
|
|
2913
|
-
variables: {
|
|
2914
|
-
[`${fieldValue.columnName}_where`]: {
|
|
2915
|
-
name: 'where',
|
|
2916
|
-
type: fieldValue.filters.filterType,
|
|
2917
|
-
value: BindFilterQueryHelper.MakeGraphQLWhere(fieldValue.filters.filters, fieldValue.fields),
|
|
2918
|
-
required: true,
|
|
2919
|
-
},
|
|
2920
|
-
},
|
|
2921
|
-
};
|
|
2922
|
-
return {
|
|
2923
|
-
[fieldValue.columnName || fieldName]: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(fieldValue.fields),
|
|
2924
|
-
};
|
|
2925
|
-
};
|
|
2926
2230
|
|
|
2927
2231
|
const withCreateHasuraGraphQL = (MixinBase) => {
|
|
2928
2232
|
return class CreateHasuraGraphQLMixin extends MixinBase {
|
|
@@ -2934,7 +2238,6 @@ const withCreateHasuraGraphQL = (MixinBase) => {
|
|
|
2934
2238
|
}
|
|
2935
2239
|
create(data) {
|
|
2936
2240
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2937
|
-
this.logger = DebugHelper.from(this, 'create');
|
|
2938
2241
|
const newData = yield this.save(this.model.toInstance(data));
|
|
2939
2242
|
return this.model.toInstance(newData);
|
|
2940
2243
|
});
|
|
@@ -2947,11 +2250,12 @@ const withCreateHasuraGraphQL = (MixinBase) => {
|
|
|
2947
2250
|
const columnOptions = Object.values(field).shift();
|
|
2948
2251
|
return (AttributeOptionHelper.CheckIsColumnOption(columnOptions) &&
|
|
2949
2252
|
columnOptions.foreignKeyColumn && [
|
|
2950
|
-
...Object.values(columnOptions.foreignKeyColumn)
|
|
2253
|
+
...Object.values(columnOptions.foreignKeyColumn),
|
|
2951
2254
|
{
|
|
2952
2255
|
[columnOptions.columnName]: Object.keys(columnOptions.foreignKeyColumn).map((foreignKeyField) => {
|
|
2953
2256
|
var _a;
|
|
2954
|
-
return ((_a = AttributeOptionHelper.FindByAttribute(foreignKeyField, columnOptions === null || columnOptions === void 0 ? void 0 : columnOptions.fields)) === null || _a === void 0 ? void 0 : _a.columnName) ||
|
|
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;
|
|
2955
2259
|
}),
|
|
2956
2260
|
},
|
|
2957
2261
|
]);
|
|
@@ -2976,11 +2280,9 @@ const withDeleteHasuraGraphQL = (MixinBase) => {
|
|
|
2976
2280
|
}
|
|
2977
2281
|
delete(identifiers) {
|
|
2978
2282
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2979
|
-
this.logger = DebugHelper.from(this, 'delete');
|
|
2980
2283
|
const instance = this.model.toInstance(identifiers);
|
|
2981
2284
|
yield this.mutation(this.deleteGraphQLOperation, this.model.identifiersFields.map((field) => AttributeOptionHelper.FindByAttribute(field, this.fields).columnName), this.model.identifiersFields.reduce((ids, identifier) => {
|
|
2982
|
-
|
|
2983
|
-
if (isNil(instance.identifier[identifierBinded]))
|
|
2285
|
+
if (isNil(instance[identifier]))
|
|
2984
2286
|
return ids;
|
|
2985
2287
|
const columnOption = AttributeOptionHelper.FindByAttribute(identifier, this.fields);
|
|
2986
2288
|
const value = columnOption.to(identifiers[identifier], instance);
|
|
@@ -3005,16 +2307,11 @@ const withHasuraGraphQL = (MixinBase) => {
|
|
|
3005
2307
|
this.authOptions = options.authOptions;
|
|
3006
2308
|
this.model = options.model;
|
|
3007
2309
|
this.fields = options.fields || this.model.identifiersFields;
|
|
3008
|
-
this.logger = DebugHelper.from(this);
|
|
3009
2310
|
}
|
|
3010
2311
|
get headers() {
|
|
3011
|
-
|
|
3012
|
-
return Object.assign(Object.assign(Object.assign({ 'Content-Type': 'application/json' }, (isNil((_a = this.authOptions) === null || _a === void 0 ? void 0 : _a.authToken) ? {} : { Authorization: (_b = this.authOptions) === null || _b === void 0 ? void 0 : _b.authToken })), (isNil((_c = this.authOptions) === null || _c === void 0 ? void 0 : _c.adminSecret) ? {} : { 'X-Hasura-Admin-Secret': (_d = this.authOptions) === null || _d === void 0 ? void 0 : _d.adminSecret })), (isNil((_e = this.authOptions) === null || _e === void 0 ? void 0 : _e.authRole)
|
|
2312
|
+
return Object.assign(Object.assign(Object.assign({ 'Content-Type': 'application/json' }, (isNil(this.authOptions.authToken) ? {} : { Authorization: this.authOptions.authToken })), (isNil(this.authOptions.adminSecret) ? {} : { 'X-Hasura-Admin-Secret': this.authOptions.adminSecret })), (isNil(this.authOptions.authRole)
|
|
3013
2313
|
? {}
|
|
3014
|
-
: {
|
|
3015
|
-
'X-Hasura-Role': this.authOptions.authRole.role,
|
|
3016
|
-
'X-Hasura-User-Id': (_g = (_f = this.authOptions) === null || _f === void 0 ? void 0 : _f.authRole) === null || _g === void 0 ? void 0 : _g.userId,
|
|
3017
|
-
}));
|
|
2314
|
+
: { 'X-Hasura-Role': this.authOptions.authRole.role, 'X-Hasura-User-Id': this.authOptions.authRole.userId }));
|
|
3018
2315
|
}
|
|
3019
2316
|
mutation(operation, fields, variables) {
|
|
3020
2317
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -3027,32 +2324,32 @@ const withHasuraGraphQL = (MixinBase) => {
|
|
|
3027
2324
|
});
|
|
3028
2325
|
}
|
|
3029
2326
|
query(operation, fields, variables) {
|
|
3030
|
-
var _a, _b, _c, _d;
|
|
3031
2327
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3032
|
-
const
|
|
3033
|
-
operation
|
|
3034
|
-
|
|
3035
|
-
|
|
3036
|
-
|
|
3037
|
-
|
|
3038
|
-
|
|
3039
|
-
|
|
3040
|
-
|
|
2328
|
+
const resultQuery = GraphQLFieldHelper.CheckIsGraphQLParams(operation)
|
|
2329
|
+
? query$1(operation.map((option) => ({
|
|
2330
|
+
operation: option.operation,
|
|
2331
|
+
variables: option.variables,
|
|
2332
|
+
fields: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(option.fields),
|
|
2333
|
+
})))
|
|
2334
|
+
: query$1({
|
|
2335
|
+
operation,
|
|
2336
|
+
variables,
|
|
2337
|
+
fields: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(fields),
|
|
2338
|
+
});
|
|
2339
|
+
return this.fetch(resultQuery);
|
|
3041
2340
|
});
|
|
3042
2341
|
}
|
|
3043
2342
|
fetch(params) {
|
|
3044
2343
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3045
|
-
this.logger.with('params').log(params);
|
|
3046
2344
|
const headers = this.headers;
|
|
3047
|
-
const
|
|
3048
|
-
url: `${this.endpoint}`,
|
|
2345
|
+
const response = yield fetch(`${this.endpoint}`, {
|
|
3049
2346
|
method: 'POST',
|
|
3050
|
-
|
|
2347
|
+
body: JSON.stringify(params),
|
|
3051
2348
|
headers,
|
|
3052
2349
|
});
|
|
2350
|
+
const result = yield response.json();
|
|
3053
2351
|
if (!isNil(result.errors))
|
|
3054
2352
|
throw new Error(JSON.stringify(result.errors));
|
|
3055
|
-
this.logger.with('returns').log(result);
|
|
3056
2353
|
return result.data;
|
|
3057
2354
|
});
|
|
3058
2355
|
}
|
|
@@ -3079,26 +2376,13 @@ const withHasuraGraphQL = (MixinBase) => {
|
|
|
3079
2376
|
return value;
|
|
3080
2377
|
return date;
|
|
3081
2378
|
}
|
|
3082
|
-
convertDataFromHasura(data
|
|
3083
|
-
const plain = GraphQLFieldHelper.ConvertFieldValueFrom(data,
|
|
2379
|
+
convertDataFromHasura(data) {
|
|
2380
|
+
const plain = GraphQLFieldHelper.ConvertFieldValueFrom(data, this.fields);
|
|
3084
2381
|
return this.model.toInstance(plain);
|
|
3085
2382
|
}
|
|
3086
2383
|
convertDataToHasura(instance, update = false) {
|
|
3087
2384
|
return GraphQLFieldHelper.ConvertFieldValueTo(instance, this.fields, update);
|
|
3088
2385
|
}
|
|
3089
|
-
buildHasuraQueryFields({ operation, fields, variables, }) {
|
|
3090
|
-
return GraphQLFieldHelper.CheckIsGraphQLParams(operation)
|
|
3091
|
-
? operation.map((option) => ({
|
|
3092
|
-
operation: option.operation,
|
|
3093
|
-
variables: option.variables,
|
|
3094
|
-
fields: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(option.fields),
|
|
3095
|
-
}))
|
|
3096
|
-
: {
|
|
3097
|
-
operation,
|
|
3098
|
-
variables,
|
|
3099
|
-
fields: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(fields),
|
|
3100
|
-
};
|
|
3101
|
-
}
|
|
3102
2386
|
};
|
|
3103
2387
|
};
|
|
3104
2388
|
|
|
@@ -3122,7 +2406,6 @@ const withUpdateHasuraGraphQL = (MixinBase) => {
|
|
|
3122
2406
|
}
|
|
3123
2407
|
update(data) {
|
|
3124
2408
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3125
|
-
this.logger = DebugHelper.from(this, 'update');
|
|
3126
2409
|
const plainData = this.paramsToPlain(data);
|
|
3127
2410
|
yield this.mutation(this.updateGraphQLOperation, this.model.identifiersFields.map((field) => AttributeOptionHelper.FindByAttribute(field, this.fields).columnName), {
|
|
3128
2411
|
_set: {
|
|
@@ -3147,11 +2430,10 @@ const withUpdateHasuraGraphQL = (MixinBase) => {
|
|
|
3147
2430
|
const instance = this.model.toInstance(data);
|
|
3148
2431
|
return this.model.identifiersFields.reduce((ids, identifier) => {
|
|
3149
2432
|
var _a;
|
|
3150
|
-
|
|
3151
|
-
if (isNil(instance.identifier[identifierBinded]))
|
|
2433
|
+
if (isNil(instance[identifier]))
|
|
3152
2434
|
return ids;
|
|
3153
|
-
const columnOption = AttributeOptionHelper.FindByAttribute(
|
|
3154
|
-
const value = ((_a = columnOption === null || columnOption === void 0 ? void 0 : columnOption.to) === null || _a === void 0 ? void 0 : _a.call(columnOption, data[
|
|
2435
|
+
const columnOption = AttributeOptionHelper.FindByAttribute(identifier, this.fields);
|
|
2436
|
+
const value = ((_a = columnOption === null || columnOption === void 0 ? void 0 : columnOption.to) === null || _a === void 0 ? void 0 : _a.call(columnOption, data[identifier], instance)) || data[columnOption.attributeName];
|
|
3155
2437
|
return Object.assign(Object.assign({}, ids), { [columnOption.columnName]: value });
|
|
3156
2438
|
}, {});
|
|
3157
2439
|
}
|
|
@@ -3167,12 +2449,10 @@ const withGetHasuraGraphQL = (MixinBase) => {
|
|
|
3167
2449
|
}
|
|
3168
2450
|
get(identifiers) {
|
|
3169
2451
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3170
|
-
this.logger = DebugHelper.from(this, 'get');
|
|
3171
2452
|
const instance = this.model.toInstance(identifiers);
|
|
3172
2453
|
const result = yield this.query(this.getGraphQLOperation, this.fields, this.model.identifiersFields.reduce((ids, identifier) => {
|
|
3173
2454
|
var _a;
|
|
3174
|
-
|
|
3175
|
-
if (isNil(instance[identifierBinded]))
|
|
2455
|
+
if (isNil(instance[identifier]))
|
|
3176
2456
|
return ids;
|
|
3177
2457
|
const columnOption = AttributeOptionHelper.FindByAttribute(identifier, this.fields);
|
|
3178
2458
|
const value = ((_a = columnOption === null || columnOption === void 0 ? void 0 : columnOption.to) === null || _a === void 0 ? void 0 : _a.call(columnOption, identifiers[identifier], instance)) ||
|
|
@@ -3194,26 +2474,10 @@ const withGetHasuraGraphQL = (MixinBase) => {
|
|
|
3194
2474
|
|
|
3195
2475
|
const withFindHasuraGraphQL = (MixinBase) => {
|
|
3196
2476
|
return class FindHasuraGraphQLMixin extends MixinBase {
|
|
3197
|
-
|
|
3198
|
-
super(...arguments);
|
|
3199
|
-
this.bindOrderByAttributes = (orderBy, fields) => Object.keys(orderBy).reduce((acc, current) => (Object.assign(Object.assign({}, acc), { [AttributeOptionHelper.FindByAttribute(current, fields)
|
|
3200
|
-
.columnName]: orderBy[current] })), {});
|
|
3201
|
-
}
|
|
3202
|
-
find(params) {
|
|
3203
|
-
var _a;
|
|
2477
|
+
find(options) {
|
|
3204
2478
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3205
|
-
|
|
3206
|
-
const
|
|
3207
|
-
const enableCount = (_a = options === null || options === void 0 ? void 0 : options.enableCount) !== null && _a !== void 0 ? _a : true;
|
|
3208
|
-
const variablesCount = Object.assign(Object.assign({}, (isNil(orderBy)
|
|
3209
|
-
? {}
|
|
3210
|
-
: {
|
|
3211
|
-
order_by: {
|
|
3212
|
-
type: `${this.tableName}_order_by!`,
|
|
3213
|
-
list: true,
|
|
3214
|
-
value: this.bindOrderByAttributes(orderBy, this.fields),
|
|
3215
|
-
},
|
|
3216
|
-
})), (isNil(filters)
|
|
2479
|
+
const { filters, limits, orderBy } = options || {};
|
|
2480
|
+
const variablesCount = Object.assign(Object.assign({}, (isNil(orderBy) ? {} : { order_by: { type: `${this.tableName}_order_by!`, list: true, value: orderBy } })), (isNil(filters)
|
|
3217
2481
|
? {}
|
|
3218
2482
|
: {
|
|
3219
2483
|
where: {
|
|
@@ -3226,8 +2490,8 @@ const withFindHasuraGraphQL = (MixinBase) => {
|
|
|
3226
2490
|
const result = yield this.query([
|
|
3227
2491
|
{
|
|
3228
2492
|
operation: this.tableName,
|
|
3229
|
-
fields:
|
|
3230
|
-
?
|
|
2493
|
+
fields: options.fields
|
|
2494
|
+
? options.fields
|
|
3231
2495
|
.map((fieldName) => {
|
|
3232
2496
|
var _a;
|
|
3233
2497
|
return (_a = this.fields.find((fieldOption) => fieldOption === fieldName)) !== null && _a !== void 0 ? _a : this.fields.find((fieldOption) => Object.keys(fieldOption).shift() === fieldName);
|
|
@@ -3236,18 +2500,15 @@ const withFindHasuraGraphQL = (MixinBase) => {
|
|
|
3236
2500
|
: this.fields,
|
|
3237
2501
|
variables,
|
|
3238
2502
|
},
|
|
3239
|
-
|
|
3240
|
-
|
|
3241
|
-
|
|
3242
|
-
|
|
3243
|
-
|
|
3244
|
-
variables: variablesCount,
|
|
3245
|
-
},
|
|
3246
|
-
]
|
|
3247
|
-
: []),
|
|
2503
|
+
{
|
|
2504
|
+
operation: `${this.tableName}_aggregate`,
|
|
2505
|
+
fields: [{ aggregate: ['count'] }],
|
|
2506
|
+
variables: variablesCount,
|
|
2507
|
+
},
|
|
3248
2508
|
]);
|
|
3249
2509
|
const data = result[this.tableName].map((row) => this.convertDataFromHasura(row));
|
|
3250
|
-
|
|
2510
|
+
const count = result[`${this.tableName}_aggregate`].aggregate.count;
|
|
2511
|
+
return { count, data };
|
|
3251
2512
|
});
|
|
3252
2513
|
}
|
|
3253
2514
|
};
|
|
@@ -3287,102 +2548,13 @@ class VariantHasuraGraphQL extends Variant {
|
|
|
3287
2548
|
}
|
|
3288
2549
|
}
|
|
3289
2550
|
|
|
3290
|
-
class CategoryCollectionChildrenHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
3291
|
-
constructor(endpoint, authOptions) {
|
|
3292
|
-
super({
|
|
3293
|
-
tableName: 'category_collection_children',
|
|
3294
|
-
model: CategoryCollectionChildren,
|
|
3295
|
-
endpoint,
|
|
3296
|
-
authOptions,
|
|
3297
|
-
fields: [
|
|
3298
|
-
{ collectionId: { columnName: 'collection_id' } },
|
|
3299
|
-
{ categoryId: { columnName: 'category_id' } },
|
|
3300
|
-
'name',
|
|
3301
|
-
'slug',
|
|
3302
|
-
'reference',
|
|
3303
|
-
{ parentCollectionId: { columnName: 'parent_collection_id' } },
|
|
3304
|
-
{ parentCategoryId: { columnName: 'parent_category_id' } },
|
|
3305
|
-
{
|
|
3306
|
-
parent: {
|
|
3307
|
-
columnName: 'parent',
|
|
3308
|
-
foreignKeyColumn: { collectionId: 'parentCollectionId', categoryId: 'parentCategoryId' },
|
|
3309
|
-
fields: [
|
|
3310
|
-
{ collectionId: { columnName: 'collection_id' } },
|
|
3311
|
-
{ categoryId: { columnName: 'category_id' } },
|
|
3312
|
-
'name',
|
|
3313
|
-
'slug',
|
|
3314
|
-
'reference',
|
|
3315
|
-
{ parentCollectionId: { columnName: 'parent_collection_id' } },
|
|
3316
|
-
{ parentCategoryId: { columnName: 'parent_category_id' } },
|
|
3317
|
-
],
|
|
3318
|
-
},
|
|
3319
|
-
},
|
|
3320
|
-
],
|
|
3321
|
-
});
|
|
3322
|
-
}
|
|
3323
|
-
}
|
|
3324
|
-
|
|
3325
|
-
class CategoryFilterHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
3326
|
-
constructor({ endpoint, authOptions, interceptors, }) {
|
|
3327
|
-
super({
|
|
3328
|
-
tableName: 'category_filter',
|
|
3329
|
-
model: CategoryFilter,
|
|
3330
|
-
endpoint,
|
|
3331
|
-
authOptions,
|
|
3332
|
-
interceptors,
|
|
3333
|
-
fields: [
|
|
3334
|
-
'id',
|
|
3335
|
-
{ filterId: { columnName: 'filter_id' } },
|
|
3336
|
-
{ categoryId: { columnName: 'category_id' } },
|
|
3337
|
-
{
|
|
3338
|
-
filter: {
|
|
3339
|
-
columnName: 'filter',
|
|
3340
|
-
foreignKeyColumn: { id: 'filterId' },
|
|
3341
|
-
fields: [
|
|
3342
|
-
'id',
|
|
3343
|
-
'description',
|
|
3344
|
-
'slug',
|
|
3345
|
-
'enabled',
|
|
3346
|
-
{ createdAt: { columnName: 'created_at' } },
|
|
3347
|
-
{ updatedAt: { columnName: 'updated_at' } },
|
|
3348
|
-
{
|
|
3349
|
-
options: {
|
|
3350
|
-
columnName: 'options',
|
|
3351
|
-
foreignKeyColumn: { filterId: 'id' },
|
|
3352
|
-
fields: [
|
|
3353
|
-
'id',
|
|
3354
|
-
{ filterId: { columnName: 'filter_id' } },
|
|
3355
|
-
'description',
|
|
3356
|
-
{ createdAt: { columnName: 'created_at' } },
|
|
3357
|
-
{ updatedAt: { columnName: 'updated_at' } },
|
|
3358
|
-
],
|
|
3359
|
-
},
|
|
3360
|
-
},
|
|
3361
|
-
],
|
|
3362
|
-
},
|
|
3363
|
-
},
|
|
3364
|
-
],
|
|
3365
|
-
});
|
|
3366
|
-
}
|
|
3367
|
-
deleteByCategoryAndFilter(categoryId, filterId) {
|
|
3368
|
-
return this.mutation('delete_category_filter', ['affected_rows'], {
|
|
3369
|
-
where: {
|
|
3370
|
-
type: 'category_filter_bool_exp',
|
|
3371
|
-
required: true,
|
|
3372
|
-
value: { category_id: { _eq: categoryId }, filter_id: { _eq: filterId } },
|
|
3373
|
-
},
|
|
3374
|
-
});
|
|
3375
|
-
}
|
|
3376
|
-
}
|
|
3377
|
-
|
|
3378
2551
|
class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
3379
|
-
constructor(
|
|
2552
|
+
constructor(endpoint, authOptions, productRepository) {
|
|
3380
2553
|
super({
|
|
3381
2554
|
tableName: 'category',
|
|
3382
2555
|
model: Category,
|
|
3383
2556
|
endpoint,
|
|
3384
2557
|
authOptions,
|
|
3385
|
-
interceptors,
|
|
3386
2558
|
fields: [
|
|
3387
2559
|
{ id: { columnName: 'id', to: (value) => +value, from: (value) => value.toString() } },
|
|
3388
2560
|
{ firestoreId: { columnName: 'firestore_id' } },
|
|
@@ -3391,7 +2563,6 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
3391
2563
|
'image',
|
|
3392
2564
|
'published',
|
|
3393
2565
|
'shop',
|
|
3394
|
-
{ shops: { columnName: 'shops', type: HasuraGraphQLColumnType.Jsonb } },
|
|
3395
2566
|
'slug',
|
|
3396
2567
|
{ brandCategory: { columnName: 'brand_category' } },
|
|
3397
2568
|
{ brandCategoryBanner: { columnName: 'brand_banner' } },
|
|
@@ -3417,17 +2588,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
3417
2588
|
},
|
|
3418
2589
|
},
|
|
3419
2590
|
},
|
|
3420
|
-
|
|
3421
|
-
filters: {
|
|
3422
|
-
columnName: 'filters',
|
|
3423
|
-
foreignKeyColumn: { filter_id: 'id' },
|
|
3424
|
-
fields: [{ filter: ['id', 'description', 'slug', 'enabled'] }],
|
|
3425
|
-
bindPersistData: (value) => ({
|
|
3426
|
-
filters: { data: value.map((filter) => ({ filter_id: filter.id })) },
|
|
3427
|
-
}),
|
|
3428
|
-
from: (filters) => (filters === null || filters === void 0 ? void 0 : filters.map((filter) => filter === null || filter === void 0 ? void 0 : filter.filter)) || [],
|
|
3429
|
-
},
|
|
3430
|
-
},
|
|
2591
|
+
'filters',
|
|
3431
2592
|
{ createdAt: { columnName: 'created_at' } },
|
|
3432
2593
|
{ updatedAt: { columnName: 'updated_at' } },
|
|
3433
2594
|
{
|
|
@@ -3449,20 +2610,9 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
3449
2610
|
}),
|
|
3450
2611
|
},
|
|
3451
2612
|
},
|
|
3452
|
-
{ isCollection: { columnName: 'is_collection' } },
|
|
3453
|
-
'reference',
|
|
3454
|
-
{ parentId: { columnName: 'parent_id' } },
|
|
3455
|
-
{
|
|
3456
|
-
parent: {
|
|
3457
|
-
columnName: 'parent',
|
|
3458
|
-
foreignKeyColumn: { id: 'parentId' },
|
|
3459
|
-
fields: ['id', 'name', 'reference', 'slug'],
|
|
3460
|
-
},
|
|
3461
|
-
},
|
|
3462
2613
|
],
|
|
3463
2614
|
});
|
|
3464
2615
|
this.productRepository = productRepository;
|
|
3465
|
-
this.categoryFilterRepository = categoryFilterRepository;
|
|
3466
2616
|
}
|
|
3467
2617
|
create(params) {
|
|
3468
2618
|
const _super = Object.create(null, {
|
|
@@ -3480,7 +2630,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
3480
2630
|
var _a;
|
|
3481
2631
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3482
2632
|
return Number.isNaN(+identifiers.id)
|
|
3483
|
-
? (_a = (yield this.find({ filters: { firestoreId: identifiers.id }
|
|
2633
|
+
? (_a = (yield this.find({ filters: { firestoreId: identifiers.id } })).data) === null || _a === void 0 ? void 0 : _a[0]
|
|
3484
2634
|
: _super.get.call(this, identifiers);
|
|
3485
2635
|
});
|
|
3486
2636
|
}
|
|
@@ -3489,13 +2639,12 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
3489
2639
|
update: { get: () => super.update }
|
|
3490
2640
|
});
|
|
3491
2641
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3492
|
-
const { products, id: checkId, metadata
|
|
2642
|
+
const { products, id: checkId, metadata } = params, data = __rest(params, ["products", "id", "metadata"]);
|
|
3493
2643
|
const plainData = this.paramsToPlain({ id: checkId });
|
|
3494
2644
|
const id = yield this.getId(plainData.id);
|
|
3495
2645
|
const category = yield _super.update.call(this, Object.assign({ id }, data));
|
|
3496
2646
|
category.products = products && (yield this.updateProducts(+id, { products }));
|
|
3497
2647
|
category.metadata = metadata && (yield this.updateMetadata(+id, { metadata }));
|
|
3498
|
-
category.filters = filters && (yield this.updateFilters(+id, { filters }));
|
|
3499
2648
|
return category;
|
|
3500
2649
|
});
|
|
3501
2650
|
}
|
|
@@ -3503,40 +2652,15 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
3503
2652
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3504
2653
|
if (!slug)
|
|
3505
2654
|
return null;
|
|
3506
|
-
const { data } = yield this.find({
|
|
3507
|
-
|
|
3508
|
-
slug,
|
|
3509
|
-
shops: { operator: Where.IN, value: [shop] },
|
|
3510
|
-
published: { operator: Where.EQUALS, value: true },
|
|
3511
|
-
},
|
|
3512
|
-
options: {
|
|
3513
|
-
enableCount: false,
|
|
3514
|
-
},
|
|
3515
|
-
});
|
|
3516
|
-
if (!data.length)
|
|
3517
|
-
throw new NotFoundError(`Category with slug ${slug} not found`);
|
|
3518
|
-
if (data.length > 1)
|
|
2655
|
+
const { data, count } = yield this.find({ filters: { slug, shop, published: true } });
|
|
2656
|
+
if (count > 1)
|
|
3519
2657
|
throw new DuplicatedResultsError('Query returned duplicated values');
|
|
2658
|
+
if (!count)
|
|
2659
|
+
throw new NotFoundError(`Category with slug ${slug} not found`);
|
|
3520
2660
|
return data.shift();
|
|
3521
2661
|
});
|
|
3522
2662
|
}
|
|
3523
|
-
|
|
3524
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
3525
|
-
if (!shop)
|
|
3526
|
-
return;
|
|
3527
|
-
const { data } = yield this.find({
|
|
3528
|
-
filters: {
|
|
3529
|
-
shops: { operator: Where.IN, value: [shop] },
|
|
3530
|
-
published: { operator: Where.EQUALS, value: true },
|
|
3531
|
-
},
|
|
3532
|
-
options: {
|
|
3533
|
-
enableCount: false,
|
|
3534
|
-
},
|
|
3535
|
-
});
|
|
3536
|
-
return data;
|
|
3537
|
-
});
|
|
3538
|
-
}
|
|
3539
|
-
getCategoriesForHome(categoryIds, limit = 4, gender) {
|
|
2663
|
+
getCategoriesForHome(categoryIds, limit = 4) {
|
|
3540
2664
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3541
2665
|
if (!(categoryIds === null || categoryIds === void 0 ? void 0 : categoryIds.length))
|
|
3542
2666
|
return [];
|
|
@@ -3556,7 +2680,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
3556
2680
|
const homeSections = yield Promise.all(categories.map((category) => __awaiter(this, void 0, void 0, function* () {
|
|
3557
2681
|
return ({
|
|
3558
2682
|
category,
|
|
3559
|
-
products: yield this.mountCategory(category, { limit, hasStock: true
|
|
2683
|
+
products: yield this.mountCategory(category, { limit, hasStock: true }),
|
|
3560
2684
|
});
|
|
3561
2685
|
})));
|
|
3562
2686
|
return homeSections;
|
|
@@ -3568,7 +2692,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
3568
2692
|
if (!((_a = category === null || category === void 0 ? void 0 : category.products) === null || _a === void 0 ? void 0 : _a.length))
|
|
3569
2693
|
return [];
|
|
3570
2694
|
const products = [];
|
|
3571
|
-
const { data: productsData } = yield this.productRepository.find(Object.assign(
|
|
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: [
|
|
3572
2696
|
'id',
|
|
3573
2697
|
'name',
|
|
3574
2698
|
'slug',
|
|
@@ -3592,9 +2716,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
3592
2716
|
'tags',
|
|
3593
2717
|
'type',
|
|
3594
2718
|
'shoppingCount',
|
|
3595
|
-
|
|
3596
|
-
'createdAt',
|
|
3597
|
-
] }, ((options === null || options === void 0 ? void 0 : options.limit) ? { limits: { limit: options === null || options === void 0 ? void 0 : options.limit } } : {})), { options: { enableCount: false } }));
|
|
2719
|
+
] }, ((options === null || options === void 0 ? void 0 : options.limit) ? { limits: { limit: options === null || options === void 0 ? void 0 : options.limit } } : {})));
|
|
3598
2720
|
products.push(...productsData);
|
|
3599
2721
|
return products;
|
|
3600
2722
|
});
|
|
@@ -3604,7 +2726,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
3604
2726
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3605
2727
|
if (!Number.isNaN(+id))
|
|
3606
2728
|
return id;
|
|
3607
|
-
const { data } = yield this.find({ filters: { firestoreId: id }
|
|
2729
|
+
const { data } = yield this.find({ filters: { firestoreId: id } });
|
|
3608
2730
|
if ((_a = data === null || data === void 0 ? void 0 : data[0]) === null || _a === void 0 ? void 0 : _a.id)
|
|
3609
2731
|
return (_b = data === null || data === void 0 ? void 0 : data[0]) === null || _b === void 0 ? void 0 : _b.id;
|
|
3610
2732
|
throw new NotFoundError(`Category with id ${id} not found`);
|
|
@@ -3662,220 +2784,15 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
3662
2784
|
return plainData.metadata;
|
|
3663
2785
|
});
|
|
3664
2786
|
}
|
|
3665
|
-
updateFilters(categoryId, { filters }) {
|
|
3666
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
3667
|
-
if ('action' in filters && filters.action === 'remove' && filters.value.length) {
|
|
3668
|
-
for (let i = 0; i < filters.value.length; i++) {
|
|
3669
|
-
yield this.categoryFilterRepository.deleteByCategoryAndFilter(categoryId, filters.value[i].id);
|
|
3670
|
-
}
|
|
3671
|
-
return [];
|
|
3672
|
-
}
|
|
3673
|
-
if ('action' in filters && filters.action === 'merge' && filters.value.length) {
|
|
3674
|
-
let filtersList = [];
|
|
3675
|
-
for (let i = 0; i < filters.value.length; i++) {
|
|
3676
|
-
try {
|
|
3677
|
-
const hasFilter = yield this.categoryFilterRepository
|
|
3678
|
-
.find({
|
|
3679
|
-
filters: {
|
|
3680
|
-
categoryId,
|
|
3681
|
-
filterId: filters.value[i].id,
|
|
3682
|
-
},
|
|
3683
|
-
})
|
|
3684
|
-
.then((data) => { var _a; return (_a = data.data.shift()) === null || _a === void 0 ? void 0 : _a.filter; });
|
|
3685
|
-
if (hasFilter) {
|
|
3686
|
-
filtersList.push(hasFilter);
|
|
3687
|
-
}
|
|
3688
|
-
else {
|
|
3689
|
-
yield this.categoryFilterRepository.create({
|
|
3690
|
-
filterId: filters.value[i].id,
|
|
3691
|
-
categoryId,
|
|
3692
|
-
});
|
|
3693
|
-
filtersList.push(filters.value[i]);
|
|
3694
|
-
}
|
|
3695
|
-
}
|
|
3696
|
-
catch (error) {
|
|
3697
|
-
console.log('catch error: ', error);
|
|
3698
|
-
}
|
|
3699
|
-
}
|
|
3700
|
-
return filtersList;
|
|
3701
|
-
}
|
|
3702
|
-
if (Array.isArray(filters) && filters.length) {
|
|
3703
|
-
let filtersList = [];
|
|
3704
|
-
for (let i = 0; i < filters.length; i++) {
|
|
3705
|
-
try {
|
|
3706
|
-
const hasFilter = yield this.categoryFilterRepository
|
|
3707
|
-
.find({
|
|
3708
|
-
filters: {
|
|
3709
|
-
categoryId,
|
|
3710
|
-
filterId: filters[i].id,
|
|
3711
|
-
},
|
|
3712
|
-
})
|
|
3713
|
-
.then((data) => { var _a; return (_a = data.data.shift()) === null || _a === void 0 ? void 0 : _a.filter; });
|
|
3714
|
-
if (hasFilter) {
|
|
3715
|
-
filtersList.push(hasFilter);
|
|
3716
|
-
}
|
|
3717
|
-
else {
|
|
3718
|
-
yield this.categoryFilterRepository.create({
|
|
3719
|
-
filterId: filters[i].id,
|
|
3720
|
-
categoryId,
|
|
3721
|
-
});
|
|
3722
|
-
filtersList.push(filters[i]);
|
|
3723
|
-
}
|
|
3724
|
-
}
|
|
3725
|
-
catch (error) {
|
|
3726
|
-
console.log('catch error: ', error);
|
|
3727
|
-
}
|
|
3728
|
-
}
|
|
3729
|
-
return filtersList;
|
|
3730
|
-
}
|
|
3731
|
-
return [];
|
|
3732
|
-
});
|
|
3733
|
-
}
|
|
3734
|
-
}
|
|
3735
|
-
|
|
3736
|
-
class FilterHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
3737
|
-
constructor({ endpoint, authOptions, interceptors, }, filterOptionRepository, categoryFilterRepository) {
|
|
3738
|
-
super({
|
|
3739
|
-
tableName: 'filter',
|
|
3740
|
-
model: Filter,
|
|
3741
|
-
endpoint,
|
|
3742
|
-
authOptions,
|
|
3743
|
-
interceptors,
|
|
3744
|
-
fields: [
|
|
3745
|
-
'id',
|
|
3746
|
-
'description',
|
|
3747
|
-
'slug',
|
|
3748
|
-
'enabled',
|
|
3749
|
-
{ createdAt: { columnName: 'created_at' } },
|
|
3750
|
-
{ updatedAt: { columnName: 'updated_at' } },
|
|
3751
|
-
{
|
|
3752
|
-
options: {
|
|
3753
|
-
columnName: 'options',
|
|
3754
|
-
foreignKeyColumn: { filterId: 'id' },
|
|
3755
|
-
fields: [
|
|
3756
|
-
'id',
|
|
3757
|
-
{ filterId: { columnName: 'filter_id' } },
|
|
3758
|
-
'description',
|
|
3759
|
-
{ createdAt: { columnName: 'created_at' } },
|
|
3760
|
-
{ updatedAt: { columnName: 'updated_at' } },
|
|
3761
|
-
],
|
|
3762
|
-
},
|
|
3763
|
-
},
|
|
3764
|
-
],
|
|
3765
|
-
});
|
|
3766
|
-
this.filterOptionRepository = filterOptionRepository;
|
|
3767
|
-
this.categoryFilterRepository = categoryFilterRepository;
|
|
3768
|
-
}
|
|
3769
|
-
update(params) {
|
|
3770
|
-
const _super = Object.create(null, {
|
|
3771
|
-
update: { get: () => super.update }
|
|
3772
|
-
});
|
|
3773
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
3774
|
-
const { options } = params, data = __rest(params, ["options"]);
|
|
3775
|
-
const filter = yield _super.update.call(this, data);
|
|
3776
|
-
filter.options = yield this.updateOptions(+data.id, { options });
|
|
3777
|
-
return filter;
|
|
3778
|
-
});
|
|
3779
|
-
}
|
|
3780
|
-
updateOptions(filterId, { options }) {
|
|
3781
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
3782
|
-
if (!options)
|
|
3783
|
-
return [];
|
|
3784
|
-
if ('action' in options && options.action === 'remove' && options.value.length) {
|
|
3785
|
-
for (let i = 0; i < options.value.length; i++) {
|
|
3786
|
-
yield this.filterOptionRepository.delete({ id: options.value[i].id });
|
|
3787
|
-
}
|
|
3788
|
-
return [];
|
|
3789
|
-
}
|
|
3790
|
-
if ('action' in options && options.action === 'merge' && options.value.length) {
|
|
3791
|
-
let filterOptions = [];
|
|
3792
|
-
for (let i = 0; i < options.value.length; i++) {
|
|
3793
|
-
try {
|
|
3794
|
-
const hasFilter = yield this.filterOptionRepository.get({ id: options.value[i].id });
|
|
3795
|
-
if (hasFilter)
|
|
3796
|
-
filterOptions.push(hasFilter);
|
|
3797
|
-
}
|
|
3798
|
-
catch (error) {
|
|
3799
|
-
const newOption = yield this.filterOptionRepository.create(Object.assign(Object.assign({}, options.value[i]), { filterId }));
|
|
3800
|
-
filterOptions.push(newOption);
|
|
3801
|
-
}
|
|
3802
|
-
}
|
|
3803
|
-
return filterOptions;
|
|
3804
|
-
}
|
|
3805
|
-
if (Array.isArray(options) && options.length) {
|
|
3806
|
-
let filterOptions = [];
|
|
3807
|
-
for (let i = 0; i < options.length; i++) {
|
|
3808
|
-
try {
|
|
3809
|
-
const hasFilter = yield this.filterOptionRepository.get({ id: options[i].id });
|
|
3810
|
-
if (hasFilter)
|
|
3811
|
-
filterOptions.push(hasFilter);
|
|
3812
|
-
}
|
|
3813
|
-
catch (error) {
|
|
3814
|
-
const newOption = yield this.filterOptionRepository.create(Object.assign(Object.assign({}, options[i]), { filterId }));
|
|
3815
|
-
filterOptions.push(newOption);
|
|
3816
|
-
}
|
|
3817
|
-
}
|
|
3818
|
-
}
|
|
3819
|
-
return [];
|
|
3820
|
-
});
|
|
3821
|
-
}
|
|
3822
|
-
delete(params) {
|
|
3823
|
-
const _super = Object.create(null, {
|
|
3824
|
-
delete: { get: () => super.delete }
|
|
3825
|
-
});
|
|
3826
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
3827
|
-
const { data: categoryFilters } = yield this.categoryFilterRepository.find({
|
|
3828
|
-
filters: {
|
|
3829
|
-
filterId: params.id,
|
|
3830
|
-
},
|
|
3831
|
-
});
|
|
3832
|
-
if (categoryFilters.length)
|
|
3833
|
-
throw new Error('Erro: o filtro está associado a uma ou mais categoria(s)');
|
|
3834
|
-
yield this.deleteOptions(+params.id);
|
|
3835
|
-
yield _super.delete.call(this, { id: +params.id });
|
|
3836
|
-
return;
|
|
3837
|
-
});
|
|
3838
|
-
}
|
|
3839
|
-
deleteOptions(filterId) {
|
|
3840
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
3841
|
-
yield this.mutation('delete_filter_option', ['affected_rows'], {
|
|
3842
|
-
where: {
|
|
3843
|
-
type: 'filter_option_bool_exp',
|
|
3844
|
-
required: true,
|
|
3845
|
-
value: { filter_id: { _eq: filterId } },
|
|
3846
|
-
},
|
|
3847
|
-
});
|
|
3848
|
-
});
|
|
3849
|
-
}
|
|
3850
|
-
}
|
|
3851
|
-
|
|
3852
|
-
class FilterOptionHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
3853
|
-
constructor({ endpoint, authOptions, interceptors, }) {
|
|
3854
|
-
super({
|
|
3855
|
-
tableName: 'filter_option',
|
|
3856
|
-
model: FilterOption,
|
|
3857
|
-
endpoint,
|
|
3858
|
-
authOptions,
|
|
3859
|
-
interceptors,
|
|
3860
|
-
fields: [
|
|
3861
|
-
'id',
|
|
3862
|
-
'description',
|
|
3863
|
-
{ filterId: { columnName: 'filter_id' } },
|
|
3864
|
-
{ createdAt: { columnName: 'created_at' } },
|
|
3865
|
-
{ updatedAt: { columnName: 'updated_at' } },
|
|
3866
|
-
],
|
|
3867
|
-
});
|
|
3868
|
-
}
|
|
3869
2787
|
}
|
|
3870
2788
|
|
|
3871
2789
|
class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
3872
|
-
constructor(
|
|
2790
|
+
constructor(endpoint, authOptions) {
|
|
3873
2791
|
super({
|
|
3874
2792
|
tableName: 'product',
|
|
3875
2793
|
model: ProductHasuraGraphQL,
|
|
3876
2794
|
endpoint,
|
|
3877
2795
|
authOptions,
|
|
3878
|
-
interceptors,
|
|
3879
2796
|
fields: [],
|
|
3880
2797
|
});
|
|
3881
2798
|
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 }));
|
|
@@ -3972,21 +2889,21 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
3972
2889
|
'weight',
|
|
3973
2890
|
'gender',
|
|
3974
2891
|
{ tags: { columnName: 'tags', type: HasuraGraphQLColumnType.Jsonb } },
|
|
3975
|
-
{ filters: { columnName: 'filters', type: HasuraGraphQLColumnType.Jsonb } },
|
|
3976
2892
|
{ isKit: { columnName: 'is_kit' } },
|
|
3977
2893
|
{ createdAt: { columnName: 'created_at' } },
|
|
3978
2894
|
{ updatedAt: { columnName: 'updated_at' } },
|
|
3979
|
-
{ rate: { columnName: 'rating' } },
|
|
3980
|
-
{ reviewsTotal: { columnName: 'reviews_total' } },
|
|
3981
|
-
{ shoppingCount: { columnName: 'shopping_count' } },
|
|
3982
|
-
{ categoryId: { columnName: 'category_id' } },
|
|
3983
2895
|
{
|
|
3984
|
-
|
|
3985
|
-
columnName: '
|
|
3986
|
-
|
|
3987
|
-
|
|
2896
|
+
rate: {
|
|
2897
|
+
columnName: 'reviews_aggregate',
|
|
2898
|
+
filters: {
|
|
2899
|
+
filters: { status: true },
|
|
2900
|
+
filterType: 'product_review_bool_exp',
|
|
2901
|
+
},
|
|
2902
|
+
fields: [{ aggregate: [{ avg: ['rate'] }] }],
|
|
2903
|
+
from: (value) => value.aggregate.avg.rate,
|
|
3988
2904
|
},
|
|
3989
2905
|
},
|
|
2906
|
+
{ shoppingCount: { columnName: 'shopping_count' } },
|
|
3990
2907
|
];
|
|
3991
2908
|
this.fields = [
|
|
3992
2909
|
...commonFields,
|
|
@@ -4073,7 +2990,7 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
4073
2990
|
var _a;
|
|
4074
2991
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4075
2992
|
const product = Number.isNaN(+identifiers.id)
|
|
4076
|
-
? (_a = (yield this.find({ filters: { firestoreId: identifiers.id }
|
|
2993
|
+
? (_a = (yield this.find({ filters: { firestoreId: identifiers.id } })).data) === null || _a === void 0 ? void 0 : _a[0]
|
|
4077
2994
|
: yield _super.get.call(this, identifiers);
|
|
4078
2995
|
if (product.productId)
|
|
4079
2996
|
throw new NotFoundError('Product not found, it is a variant');
|
|
@@ -4091,16 +3008,7 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
4091
3008
|
this.fields
|
|
4092
3009
|
.map((field) => (typeof field === 'string' ? field : Object.keys(field).shift()))
|
|
4093
3010
|
.filter((field) => field !== 'reviews');
|
|
4094
|
-
return _super.find.call(this, Object.assign(Object.assign({}, options), { filters: Object.assign(Object.assign({}, filters), { productId: { operator: Where.ISNULL } }), fields:
|
|
4095
|
-
...bindFields,
|
|
4096
|
-
...(bindFields.includes('price')
|
|
4097
|
-
? [
|
|
4098
|
-
'subscriberPrice',
|
|
4099
|
-
'subscriberDiscountPercentage',
|
|
4100
|
-
'fullPrice',
|
|
4101
|
-
]
|
|
4102
|
-
: []),
|
|
4103
|
-
] }));
|
|
3011
|
+
return _super.find.call(this, Object.assign(Object.assign({}, options), { filters: Object.assign(Object.assign({}, filters), { productId: { operator: Where.ISNULL } }), fields: bindFields }));
|
|
4104
3012
|
});
|
|
4105
3013
|
}
|
|
4106
3014
|
getBySlug(slug) {
|
|
@@ -4110,13 +3018,9 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
4110
3018
|
filters: {
|
|
4111
3019
|
slug,
|
|
4112
3020
|
},
|
|
4113
|
-
fields: this.fields.map((field) => typeof field === 'string' ? field : Object.keys(field).shift()),
|
|
4114
|
-
options: {
|
|
4115
|
-
enableCount: false,
|
|
4116
|
-
},
|
|
4117
3021
|
});
|
|
4118
3022
|
const product = (_a = result === null || result === void 0 ? void 0 : result.data) === null || _a === void 0 ? void 0 : _a.shift();
|
|
4119
|
-
|
|
3023
|
+
product.reviews = yield this.findReviewsByProduct(+product.id);
|
|
4120
3024
|
return product;
|
|
4121
3025
|
});
|
|
4122
3026
|
}
|
|
@@ -4279,7 +3183,7 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
4279
3183
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4280
3184
|
if (!Number.isNaN(+id))
|
|
4281
3185
|
return id;
|
|
4282
|
-
const { data } = yield this.find({ filters: { firestoreId: id }
|
|
3186
|
+
const { data } = yield this.find({ filters: { firestoreId: id } });
|
|
4283
3187
|
if ((_a = data === null || data === void 0 ? void 0 : data[0]) === null || _a === void 0 ? void 0 : _a.id)
|
|
4284
3188
|
return (_b = data === null || data === void 0 ? void 0 : data[0]) === null || _b === void 0 ? void 0 : _b.id;
|
|
4285
3189
|
throw new NotFoundError(`Product with id ${id} not found`);
|
|
@@ -4335,31 +3239,15 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
4335
3239
|
return data && data[0] && this.bindReviewToModel(data[0]);
|
|
4336
3240
|
});
|
|
4337
3241
|
}
|
|
4338
|
-
cleanShoppingCountFromIds(ids) {
|
|
4339
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
4340
|
-
return yield this.mutation('update_product', ['affected_rows'], {
|
|
4341
|
-
where: {
|
|
4342
|
-
value: { id: { _nin: ids } },
|
|
4343
|
-
type: 'product_bool_exp',
|
|
4344
|
-
required: true,
|
|
4345
|
-
},
|
|
4346
|
-
_set: {
|
|
4347
|
-
value: { shopping_count: 0 },
|
|
4348
|
-
type: 'product_set_input',
|
|
4349
|
-
},
|
|
4350
|
-
});
|
|
4351
|
-
});
|
|
4352
|
-
}
|
|
4353
3242
|
}
|
|
4354
3243
|
|
|
4355
3244
|
class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
4356
|
-
constructor(
|
|
3245
|
+
constructor(endpoint, authOptions) {
|
|
4357
3246
|
super({
|
|
4358
3247
|
tableName: 'product',
|
|
4359
3248
|
model: VariantHasuraGraphQL,
|
|
4360
3249
|
endpoint,
|
|
4361
3250
|
authOptions,
|
|
4362
|
-
interceptors,
|
|
4363
3251
|
fields: [
|
|
4364
3252
|
{ id: { columnName: 'id', to: (value) => +value, from: (value) => value.toString() } },
|
|
4365
3253
|
{ firestoreId: { columnName: 'firestore_id' } },
|
|
@@ -4389,9 +3277,9 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
4389
3277
|
subscriber_price: filters.subscriberPrice,
|
|
4390
3278
|
}));
|
|
4391
3279
|
},
|
|
4392
|
-
bindPersistData: (priceData) => (Object.assign(Object.assign(Object.assign(Object.assign({}, ((
|
|
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 && {
|
|
4393
3281
|
subscriber_discount_percentage: priceData.subscriberDiscountPercentage,
|
|
4394
|
-
})), (
|
|
3282
|
+
})), (priceData.subscriberPrice >= 0 && { subscriber_price: priceData.subscriberPrice }))),
|
|
4395
3283
|
},
|
|
4396
3284
|
},
|
|
4397
3285
|
{ fullPrice: { columnName: 'full_price' } },
|
|
@@ -4460,7 +3348,7 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
4460
3348
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4461
3349
|
if (!Number.isNaN(+id))
|
|
4462
3350
|
return id;
|
|
4463
|
-
const { data } = yield this.find({ filters: { firestoreId: id }
|
|
3351
|
+
const { data } = yield this.find({ filters: { firestoreId: id } });
|
|
4464
3352
|
if ((_a = data === null || data === void 0 ? void 0 : data[0]) === null || _a === void 0 ? void 0 : _a.id)
|
|
4465
3353
|
return (_b = data === null || data === void 0 ? void 0 : data[0]) === null || _b === void 0 ? void 0 : _b.id;
|
|
4466
3354
|
throw new NotFoundError(`Product with id ${id} not found`);
|
|
@@ -4472,5 +3360,5 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
4472
3360
|
* Generated bundle index. Do not edit.
|
|
4473
3361
|
*/
|
|
4474
3362
|
|
|
4475
|
-
export { AccessoryImportances, Address, Area, Authentication, AuthenticationFirebaseAuthService, AxiosAdapter, Base, BaseModel, BeardProblems, BeardSizes, BeautyProductImportances, BeautyProfile, BeautyQuestionsHelper, BillingStatus, BodyProblems, BodyShapes, BodyTattoos, Buy2Win, Buy2WinFirestoreRepository,
|
|
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, chunk, get, is, isBoolean, isDate, isEmpty, isInteger, isNaN$1 as isNaN, isNil, isNumber, isObject, isString, isUUID, now, omit, parseDateTime, pick, set, withCreateFirestore, withCreateHasuraGraphQL, withCrudFirestore, withCrudHasuraGraphQL, withDeleteFirestore, withDeleteHasuraGraphQL, withFindFirestore, withFindHasuraGraphQL, withFirestore, withGetFirestore, withGetHasuraGraphQL, withHasuraGraphQL, withHelpers, withSubCollection, withUpdateFirestore, withUpdateHasuraGraphQL };
|
|
4476
3364
|
//# sourceMappingURL=infrab4a-connect.mjs.map
|