@infrab4a/connect 3.16.0-beta.1 → 4.0.0-beta.10
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 +22 -5
- package/domain/catalog/models/index.d.ts +0 -5
- package/domain/catalog/models/kit-product.d.ts +4 -4
- package/domain/catalog/models/product.d.ts +35 -5
- 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/types/shop-description.type.d.ts +0 -1
- package/domain/catalog/models/variant.d.ts +2 -1
- package/domain/catalog/repositories/category.repository.d.ts +3 -6
- package/domain/catalog/repositories/index.d.ts +0 -5
- package/domain/catalog/repositories/product.repository.d.ts +1 -4
- 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/create.repository.d.ts +2 -2
- package/domain/generic/repository/find.repository.d.ts +1 -7
- package/domain/generic/repository/get.repository.d.ts +2 -2
- package/domain/generic/repository/types/repository-find-filters.type.d.ts +3 -3
- package/domain/generic/repository/types/repository-find-result.type.d.ts +1 -11
- 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/enums/index.d.ts +0 -1
- package/domain/shop-settings/models/index.d.ts +0 -3
- package/domain/shop-settings/models/types/index.d.ts +1 -10
- package/domain/shop-settings/repositories/index.d.ts +0 -3
- package/domain/shopping/models/buy-2-win.d.ts +1 -3
- package/domain/shopping/models/checkout.d.ts +6 -5
- package/domain/shopping/models/coupons/coupon.d.ts +6 -34
- package/domain/shopping/models/index.d.ts +4 -5
- package/domain/shopping/models/order.d.ts +0 -1
- package/domain/shopping/models/shipping-method.d.ts +0 -1
- package/domain/shopping/models/subscription/checkout.d.ts +4 -3
- package/domain/shopping/repositories/index.d.ts +2 -4
- package/domain/users/errors/unauthorized.error.d.ts +1 -2
- package/domain/users/errors/user-already-registered.error.d.ts +1 -2
- package/domain/users/errors/weak-password.error.d.ts +0 -1
- 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 +1 -1
- package/domain/users/models/user.d.ts +4 -3
- package/domain/users/use-cases/authentication.d.ts +1 -1
- package/errors/duplicated-results.error.d.ts +1 -2
- package/errors/invalid-argument.error.d.ts +1 -2
- package/errors/not-found.error.d.ts +1 -2
- package/{esm2015/domain/catalog/index.js → esm2020/domain/catalog/index.mjs} +1 -2
- package/esm2020/domain/catalog/models/category.mjs +10 -0
- package/esm2020/domain/catalog/models/index.mjs +7 -0
- package/esm2020/domain/catalog/models/kit-product.mjs +18 -0
- package/esm2020/domain/catalog/models/product.mjs +17 -0
- package/esm2020/domain/catalog/models/types/category-filter.type.mjs +2 -0
- package/esm2020/domain/catalog/models/types/index.mjs +11 -0
- package/{esm2015/domain/catalog/models/types/shop-description.type.js → esm2020/domain/catalog/models/types/shop-description.type.mjs} +1 -1
- package/esm2020/domain/catalog/models/variant.mjs +10 -0
- package/esm2020/domain/catalog/repositories/category.repository.mjs +2 -0
- package/esm2020/domain/catalog/repositories/index.mjs +5 -0
- package/esm2020/domain/catalog/repositories/product.repository.mjs +2 -0
- package/esm2020/domain/generic/model/base.model.mjs +23 -0
- package/esm2020/domain/generic/model/types/base-model-builder.type.mjs +2 -0
- package/esm2020/domain/generic/model/types/identifier-model.type.mjs +2 -0
- package/esm2020/domain/generic/model/types/model-base-structure.type.mjs +2 -0
- package/esm2020/domain/generic/model/types/non-function-property-name.type.mjs +2 -0
- package/esm2020/domain/generic/repository/create.repository.mjs +2 -0
- package/esm2020/domain/generic/repository/find.repository.mjs +2 -0
- package/esm2020/domain/generic/repository/get.repository.mjs +2 -0
- package/esm2020/domain/generic/repository/types/repository-find-filters.type.mjs +2 -0
- package/esm2020/domain/generic/repository/types/repository-find-result.type.mjs +2 -0
- package/{esm2015/domain/generic/repository/types/repository-order-by-list.type.js → esm2020/domain/generic/repository/types/repository-order-by-list.type.mjs} +1 -1
- package/esm2020/domain/generic/repository/types/repository-update-params.type.mjs +2 -0
- package/esm2020/domain/location/models/address.mjs +7 -0
- package/{esm2015/domain/shop-settings/enums/index.js → esm2020/domain/shop-settings/enums/index.mjs} +1 -2
- package/{esm2015/domain/shop-settings/helpers/beauty-questions.helper.js → esm2020/domain/shop-settings/helpers/beauty-questions.helper.mjs} +3 -2
- package/esm2020/domain/shop-settings/models/index.mjs +4 -0
- package/esm2020/domain/shop-settings/models/types/index.mjs +6 -0
- package/esm2020/domain/shop-settings/repositories/index.mjs +3 -0
- package/esm2020/domain/shopping/models/buy-2-win.mjs +14 -0
- package/esm2020/domain/shopping/models/checkout.mjs +38 -0
- package/esm2020/domain/shopping/models/coupons/coupon.mjs +38 -0
- package/esm2020/domain/shopping/models/index.mjs +12 -0
- package/{esm2015/domain/shopping/models/order.js → esm2020/domain/shopping/models/order.mjs} +1 -1
- package/{esm2015/domain/shopping/models/payment.js → esm2020/domain/shopping/models/payment.mjs} +1 -1
- package/{esm2015/domain/shopping/models/shipping-method.js → esm2020/domain/shopping/models/shipping-method.mjs} +1 -1
- package/esm2020/domain/shopping/models/subscription/checkout.mjs +28 -0
- package/esm2020/domain/shopping/repositories/index.mjs +8 -0
- package/{esm2015/domain/users/errors/unauthorized.error.js → esm2020/domain/users/errors/unauthorized.error.mjs} +1 -2
- package/{esm2015/domain/users/errors/user-already-registered.error.js → esm2020/domain/users/errors/user-already-registered.error.mjs} +1 -2
- package/{esm2015/domain/users/errors/weak-password.error.js → esm2020/domain/users/errors/weak-password.error.mjs} +1 -2
- package/esm2020/domain/users/models/beauty-profile.mjs +12 -0
- package/{esm2015/domain/users/models/lead.js → esm2020/domain/users/models/lead.mjs} +1 -1
- package/esm2020/domain/users/models/subscription/edition.mjs +7 -0
- package/esm2020/domain/users/models/subscription/payment.mjs +14 -0
- package/esm2020/domain/users/models/subscription/subscription.mjs +43 -0
- package/{esm2015/domain/users/models/user-address.js → esm2020/domain/users/models/user-address.mjs} +1 -1
- package/esm2020/domain/users/models/user-payment-method.mjs +7 -0
- package/esm2020/domain/users/models/user.mjs +26 -0
- package/esm2020/domain/users/use-cases/authentication.mjs +43 -0
- package/esm2020/domain/users/use-cases/recovery-password.mjs +9 -0
- package/esm2020/domain/users/use-cases/register.mjs +38 -0
- package/esm2020/domain/users/use-cases/signout.mjs +9 -0
- package/{esm2015/errors/duplicated-results.error.js → esm2020/errors/duplicated-results.error.mjs} +1 -2
- package/{esm2015/errors/invalid-argument.error.js → esm2020/errors/invalid-argument.error.mjs} +1 -2
- package/{esm2015/errors/not-found.error.js → esm2020/errors/not-found.error.mjs} +1 -2
- package/esm2020/infra/elasticsearch/adapters/axios.adapter.mjs +50 -0
- package/{esm2015/infra/elasticsearch/adapters/elastic-search.adapter.js → esm2020/infra/elasticsearch/adapters/elastic-search.adapter.mjs} +1 -1
- package/esm2020/infra/elasticsearch/indexes/products-index.mjs +92 -0
- package/{esm2015/infra/elasticsearch/types/elastic-search-result.js → esm2020/infra/elasticsearch/types/elastic-search-result.mjs} +1 -1
- package/esm2020/infra/firebase/auth/authentication-firebase-auth.service.mjs +41 -0
- package/esm2020/infra/firebase/auth/register-firebase-auth.service.mjs +33 -0
- package/{esm2015/infra/firebase/auth/types/firebase-user-with-id.type.js → esm2020/infra/firebase/auth/types/firebase-user-with-id.type.mjs} +1 -1
- package/esm2020/infra/firebase/firestore/mixins/with-create-firestore.mixin.mjs +27 -0
- package/esm2020/infra/firebase/firestore/mixins/with-crud-firestore.mixin.mjs +10 -0
- package/esm2020/infra/firebase/firestore/mixins/with-delete-firestore.mixin.mjs +14 -0
- package/esm2020/infra/firebase/firestore/mixins/with-find-firestore.mixin.mjs +107 -0
- package/esm2020/infra/firebase/firestore/mixins/with-firestore.mixin.mjs +57 -0
- package/esm2020/infra/firebase/firestore/mixins/with-get-firestore.mixin.mjs +20 -0
- package/esm2020/infra/firebase/firestore/mixins/with-helpers.mixin.mjs +17 -0
- package/esm2020/infra/firebase/firestore/mixins/with-sub-collection.mixin.mjs +11 -0
- package/esm2020/infra/firebase/firestore/mixins/with-update-firestore.mixin.mjs +48 -0
- package/esm2020/infra/firebase/firestore/repositories/catalog/category-firestore.repository.mjs +54 -0
- package/esm2020/infra/firebase/firestore/repositories/catalog/product-firestore.repository.mjs +46 -0
- package/esm2020/infra/firebase/firestore/repositories/catalog/product-variant-firestore.repository.mjs +14 -0
- package/esm2020/infra/firebase/firestore/repositories/catalog/subscription-product-firestore.repository.mjs +12 -0
- package/esm2020/infra/firebase/firestore/repositories/shop-settings/home-firestore.repository.mjs +54 -0
- package/esm2020/infra/firebase/firestore/repositories/shop-settings/index.mjs +3 -0
- package/{esm2015/infra/firebase/firestore/repositories/shop-settings/shop-menu-firestore.repository.js → esm2020/infra/firebase/firestore/repositories/shop-settings/shop-menu-firestore.repository.mjs} +1 -1
- package/{esm2015/infra/firebase/firestore/repositories/shopping/buy-2-win-firestore.repository.js → esm2020/infra/firebase/firestore/repositories/shopping/buy-2-win-firestore.repository.mjs} +2 -2
- package/esm2020/infra/firebase/firestore/repositories/shopping/checkout-firestore.repository.mjs +12 -0
- package/esm2020/infra/firebase/firestore/repositories/shopping/checkout-subscription-firestore.repository.mjs +12 -0
- package/esm2020/infra/firebase/firestore/repositories/shopping/coupon-firestore.repository.mjs +29 -0
- package/esm2020/infra/firebase/firestore/repositories/shopping/index.mjs +9 -0
- package/esm2020/infra/firebase/firestore/repositories/shopping/legacy-order-firestore.repository.mjs +9 -0
- package/esm2020/infra/firebase/firestore/repositories/shopping/order-firestore.repository.mjs +38 -0
- package/esm2020/infra/firebase/firestore/repositories/shopping/payment-firestore.repository.mjs +12 -0
- package/{esm2015/infra/firebase/firestore/repositories/shopping/subscription-plan-firestore.repository.js → esm2020/infra/firebase/firestore/repositories/shopping/subscription-plan-firestore.repository.mjs} +2 -2
- package/esm2020/infra/firebase/firestore/repositories/users/lead-firestore.repository.mjs +12 -0
- package/esm2020/infra/firebase/firestore/repositories/users/subscription-edition-firestore.repository.mjs +14 -0
- package/{esm2015/infra/firebase/firestore/repositories/users/subscription-firestore.repository.js → esm2020/infra/firebase/firestore/repositories/users/subscription-firestore.repository.mjs} +2 -2
- package/esm2020/infra/firebase/firestore/repositories/users/subscription-payment-firestore.repository.mjs +14 -0
- package/esm2020/infra/firebase/firestore/repositories/users/user-address-firestore.repository.mjs +14 -0
- package/esm2020/infra/firebase/firestore/repositories/users/user-beauty-profile-firestore.repository.mjs +14 -0
- package/esm2020/infra/firebase/firestore/repositories/users/user-firestore.repository.mjs +48 -0
- package/esm2020/infra/firebase/firestore/repositories/users/user-payment-method-firestore.repository.mjs +14 -0
- package/esm2020/infra/firebase/firestore/types/firestore-sub.repository.type.mjs +2 -0
- package/esm2020/infra/firebase/firestore/types/firestore.helpers.type.mjs +2 -0
- package/esm2020/infra/firebase/firestore/types/firestore.repository.type.mjs +2 -0
- package/{esm2015/infra/hasura-graphql/enums/hasura-graphql-where.enum.js → esm2020/infra/hasura-graphql/enums/hasura-graphql-where.enum.mjs} +3 -1
- package/esm2020/infra/hasura-graphql/mixins/helpers/attribute-option.helper.mjs +35 -0
- package/esm2020/infra/hasura-graphql/mixins/helpers/bind-filter-query.helper.mjs +70 -0
- package/esm2020/infra/hasura-graphql/mixins/helpers/filter-option.helper.mjs +22 -0
- package/esm2020/infra/hasura-graphql/mixins/helpers/graphql-field.helper.mjs +114 -0
- package/esm2020/infra/hasura-graphql/mixins/with-create-hasura-graphql.mixin.mjs +37 -0
- package/{esm2015/infra/hasura-graphql/mixins/with-crud-hasura-graphql.mixin.js → 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 +29 -0
- package/esm2020/infra/hasura-graphql/mixins/with-find-hasura-graphql.mixin.mjs +46 -0
- package/esm2020/infra/hasura-graphql/mixins/with-get-hasura-graphql.mixin.mjs +35 -0
- package/esm2020/infra/hasura-graphql/mixins/with-hasura-graphql.mixin.mjs +96 -0
- package/esm2020/infra/hasura-graphql/mixins/with-update-hasura-graphql.mixin.mjs +60 -0
- package/{esm2015/infra/hasura-graphql/models/kit-product-hasura-graphql.js → esm2020/infra/hasura-graphql/models/kit-product-hasura-graphql.mjs} +1 -1
- package/esm2020/infra/hasura-graphql/models/product-hasura-graphql.mjs +11 -0
- package/{esm2015/infra/hasura-graphql/models/variant-hasura-graphql.js → esm2020/infra/hasura-graphql/models/variant-hasura-graphql.mjs} +1 -1
- package/esm2020/infra/hasura-graphql/repositories/catalog/category-hasura-graphql.repository.mjs +223 -0
- package/esm2020/infra/hasura-graphql/repositories/catalog/index.mjs +4 -0
- package/esm2020/infra/hasura-graphql/repositories/catalog/product-hasura-graphql.repository.mjs +467 -0
- package/esm2020/infra/hasura-graphql/repositories/catalog/variant-hasura-graphql.repository.mjs +113 -0
- package/esm2020/infra/hasura-graphql/types/graphql.repository.type.mjs +2 -0
- package/esm2020/infra/hasura-graphql/types/hasura-graphql-fields.type.mjs +2 -0
- package/esm2020/utils/get.mjs +3 -0
- package/esm2020/utils/index.mjs +10 -0
- package/esm2020/utils/is.mjs +4 -0
- package/{esm2015/utils/mixins/merge-constructor-params.type.js → esm2020/utils/mixins/merge-constructor-params.type.mjs} +1 -1
- package/fesm2015/{infrab4a-connect.js → infrab4a-connect.mjs} +498 -1989
- package/fesm2015/infrab4a-connect.mjs.map +1 -0
- package/fesm2020/infrab4a-connect.mjs +3319 -0
- package/fesm2020/infrab4a-connect.mjs.map +1 -0
- 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/auth/authentication-firebase-auth.service.d.ts +2 -2
- package/infra/firebase/auth/register-firebase-auth.service.d.ts +2 -2
- package/infra/firebase/auth/types/firebase-user-with-id.type.d.ts +3 -1
- package/infra/firebase/firestore/mixins/with-create-firestore.mixin.d.ts +2 -2
- package/infra/firebase/firestore/mixins/with-crud-firestore.mixin.d.ts +2 -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 +3 -3
- package/infra/firebase/firestore/mixins/with-firestore.mixin.d.ts +1 -1
- package/infra/firebase/firestore/mixins/with-get-firestore.mixin.d.ts +2 -2
- package/infra/firebase/firestore/mixins/with-helpers.mixin.d.ts +3 -3
- package/infra/firebase/firestore/mixins/with-sub-collection.mixin.d.ts +4 -4
- package/infra/firebase/firestore/mixins/with-update-firestore.mixin.d.ts +3 -3
- package/infra/firebase/firestore/repositories/catalog/category-firestore.repository.d.ts +5 -9
- package/infra/firebase/firestore/repositories/catalog/product-firestore.repository.d.ts +5 -7
- package/infra/firebase/firestore/repositories/catalog/product-variant-firestore.repository.d.ts +4 -4
- package/infra/firebase/firestore/repositories/catalog/subscription-product-firestore.repository.d.ts +4 -4
- package/infra/firebase/firestore/repositories/shop-settings/home-firestore.repository.d.ts +4 -4
- package/infra/firebase/firestore/repositories/shop-settings/index.d.ts +0 -3
- package/infra/firebase/firestore/repositories/shop-settings/shop-menu-firestore.repository.d.ts +4 -4
- package/infra/firebase/firestore/repositories/shopping/buy-2-win-firestore.repository.d.ts +4 -4
- package/infra/firebase/firestore/repositories/shopping/checkout-firestore.repository.d.ts +4 -4
- package/infra/firebase/firestore/repositories/shopping/checkout-subscription-firestore.repository.d.ts +4 -4
- 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 +3 -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 -4
- package/infra/firebase/firestore/repositories/shopping/subscription-plan-firestore.repository.d.ts +4 -4
- package/infra/firebase/firestore/repositories/users/lead-firestore.repository.d.ts +4 -4
- package/infra/firebase/firestore/repositories/users/subscription-edition-firestore.repository.d.ts +5 -5
- package/infra/firebase/firestore/repositories/users/subscription-firestore.repository.d.ts +4 -4
- package/infra/firebase/firestore/repositories/users/subscription-payment-firestore.repository.d.ts +5 -5
- package/infra/firebase/firestore/repositories/users/user-address-firestore.repository.d.ts +4 -4
- package/infra/firebase/firestore/repositories/users/user-beauty-profile-firestore.repository.d.ts +4 -4
- package/infra/firebase/firestore/repositories/users/user-firestore.repository.d.ts +4 -4
- package/infra/firebase/firestore/repositories/users/user-payment-method-firestore.repository.d.ts +4 -4
- package/infra/firebase/firestore/types/firestore-sub.repository.type.d.ts +3 -3
- package/infra/firebase/firestore/types/firestore.helpers.type.d.ts +5 -5
- package/infra/firebase/firestore/types/firestore.repository.type.d.ts +3 -3
- package/infra/hasura-graphql/enums/hasura-graphql-where.enum.d.ts +3 -1
- package/infra/hasura-graphql/mixins/helpers/attribute-option.helper.d.ts +3 -5
- 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 -6
- 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 +2 -2
- 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 -24
- 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 +14 -3
- package/infra/hasura-graphql/mixins/with-update-hasura-graphql.mixin.d.ts +3 -3
- package/infra/hasura-graphql/models/product-hasura-graphql.d.ts +0 -4
- package/infra/hasura-graphql/models/variant-hasura-graphql.d.ts +0 -1
- package/infra/hasura-graphql/repositories/catalog/category-hasura-graphql.repository.d.ts +5 -12
- package/infra/hasura-graphql/repositories/catalog/index.d.ts +0 -5
- package/infra/hasura-graphql/repositories/catalog/product-hasura-graphql.repository.d.ts +4 -6
- package/infra/hasura-graphql/repositories/catalog/variant-hasura-graphql.repository.d.ts +4 -4
- package/infra/hasura-graphql/types/graphql.repository.type.d.ts +6 -9
- package/infra/hasura-graphql/types/hasura-graphql-fields.type.d.ts +3 -7
- package/package.json +21 -9
- package/utils/get.d.ts +1 -0
- package/utils/index.d.ts +6 -6
- package/utils/is.d.ts +1 -0
- package/utils/mixins/merge-constructor-params.type.d.ts +2 -2
- package/bundles/infrab4a-connect.umd.js +0 -7238
- package/bundles/infrab4a-connect.umd.js.map +0 -1
- package/domain/catalog/helpers/index.d.ts +0 -1
- package/domain/catalog/helpers/round-product-price.helper.d.ts +0 -4
- package/domain/catalog/models/category-base.d.ts +0 -30
- package/domain/catalog/models/category-collection-children.d.ts +0 -13
- package/domain/catalog/models/category-filter.d.ts +0 -13
- package/domain/catalog/models/category-for-product.d.ts +0 -5
- package/domain/catalog/models/filter-option.d.ts +0 -9
- package/domain/catalog/models/filter.d.ts +0 -12
- package/domain/catalog/models/product-base.d.ts +0 -40
- package/domain/catalog/models/product-for-category.d.ts +0 -7
- package/domain/catalog/models/product-for-kit.d.ts +0 -7
- 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/models/wishlist.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 -6
- package/domain/catalog/repositories/filter-option.repository.d.ts +0 -4
- package/domain/catalog/repositories/filter.repository.d.ts +0 -4
- package/domain/catalog/repositories/wishlist.repository.d.ts +0 -6
- package/domain/shop-settings/enums/shop-page-name.enum.d.ts +0 -19
- package/domain/shop-settings/models/campaign-banner.d.ts +0 -11
- package/domain/shop-settings/models/campaign.d.ts +0 -10
- package/domain/shop-settings/models/shop-settings.d.ts +0 -10
- package/domain/shop-settings/models/types/campaign-page.d.ts +0 -17
- package/domain/shop-settings/models/types/sections.type.d.ts +0 -17
- 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-gift.type.d.ts +0 -8
- package/domain/shop-settings/models/types/shop-post.type.d.ts +0 -7
- package/domain/shop-settings/models/types/shop-section.type.d.ts +0 -12
- package/domain/shop-settings/repositories/campaign-banner.repository.d.ts +0 -4
- package/domain/shop-settings/repositories/campaign.repository.d.ts +0 -4
- 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/esm2015/domain/catalog/helpers/index.js +0 -2
- package/esm2015/domain/catalog/helpers/round-product-price.helper.js +0 -15
- package/esm2015/domain/catalog/models/category-base.js +0 -18
- package/esm2015/domain/catalog/models/category-collection-children.js +0 -13
- package/esm2015/domain/catalog/models/category-filter.js +0 -19
- package/esm2015/domain/catalog/models/category-for-product.js +0 -7
- package/esm2015/domain/catalog/models/category.js +0 -14
- package/esm2015/domain/catalog/models/filter-option.js +0 -7
- package/esm2015/domain/catalog/models/filter.js +0 -7
- package/esm2015/domain/catalog/models/index.js +0 -12
- package/esm2015/domain/catalog/models/kit-product.js +0 -18
- package/esm2015/domain/catalog/models/product-base.js +0 -25
- package/esm2015/domain/catalog/models/product-for-category.js +0 -14
- package/esm2015/domain/catalog/models/product-for-kit.js +0 -14
- package/esm2015/domain/catalog/models/product.js +0 -19
- package/esm2015/domain/catalog/models/types/category-product.js +0 -2
- package/esm2015/domain/catalog/models/types/index.js +0 -12
- package/esm2015/domain/catalog/models/types/product-evaluation.type.js +0 -2
- package/esm2015/domain/catalog/models/variant.js +0 -7
- package/esm2015/domain/catalog/models/wishlist.js +0 -7
- package/esm2015/domain/catalog/repositories/category-collection-children.repository.js +0 -2
- package/esm2015/domain/catalog/repositories/category-filter.repository.js +0 -2
- package/esm2015/domain/catalog/repositories/category.repository.js +0 -2
- package/esm2015/domain/catalog/repositories/filter-option.repository.js +0 -2
- package/esm2015/domain/catalog/repositories/filter.repository.js +0 -2
- package/esm2015/domain/catalog/repositories/index.js +0 -10
- package/esm2015/domain/catalog/repositories/product.repository.js +0 -2
- package/esm2015/domain/catalog/repositories/wishlist.repository.js +0 -2
- package/esm2015/domain/generic/model/base.model.js +0 -24
- package/esm2015/domain/generic/model/types/base-model-builder.type.js +0 -2
- package/esm2015/domain/generic/model/types/identifier-model.type.js +0 -2
- package/esm2015/domain/generic/model/types/model-base-structure.type.js +0 -2
- package/esm2015/domain/generic/model/types/non-function-property-name.type.js +0 -2
- package/esm2015/domain/generic/repository/create.repository.js +0 -2
- package/esm2015/domain/generic/repository/find.repository.js +0 -2
- package/esm2015/domain/generic/repository/get.repository.js +0 -2
- package/esm2015/domain/generic/repository/types/repository-find-filters.type.js +0 -2
- package/esm2015/domain/generic/repository/types/repository-find-result.type.js +0 -2
- package/esm2015/domain/generic/repository/types/repository-update-params.type.js +0 -2
- package/esm2015/domain/location/models/address.js +0 -7
- package/esm2015/domain/shop-settings/enums/shop-page-name.enum.js +0 -21
- package/esm2015/domain/shop-settings/models/campaign-banner.js +0 -7
- package/esm2015/domain/shop-settings/models/campaign.js +0 -7
- package/esm2015/domain/shop-settings/models/index.js +0 -7
- package/esm2015/domain/shop-settings/models/shop-settings.js +0 -7
- package/esm2015/domain/shop-settings/models/types/campaign-page.js +0 -2
- package/esm2015/domain/shop-settings/models/types/index.js +0 -15
- package/esm2015/domain/shop-settings/models/types/sections.type.js +0 -2
- package/esm2015/domain/shop-settings/models/types/shop-banner.type.js +0 -2
- package/esm2015/domain/shop-settings/models/types/shop-brands.type.js +0 -2
- package/esm2015/domain/shop-settings/models/types/shop-carousel.type.js +0 -2
- package/esm2015/domain/shop-settings/models/types/shop-collection.type.js +0 -2
- package/esm2015/domain/shop-settings/models/types/shop-gift.type.js +0 -2
- package/esm2015/domain/shop-settings/models/types/shop-post.type.js +0 -2
- package/esm2015/domain/shop-settings/models/types/shop-section.type.js +0 -2
- package/esm2015/domain/shop-settings/repositories/campaign-banner.repository.js +0 -2
- package/esm2015/domain/shop-settings/repositories/campaign.repository.js +0 -2
- package/esm2015/domain/shop-settings/repositories/index.js +0 -6
- package/esm2015/domain/shop-settings/repositories/shop-settings.repository.js +0 -2
- package/esm2015/domain/shopping/models/buy-2-win.js +0 -14
- package/esm2015/domain/shopping/models/campaign-dashboard.js +0 -7
- package/esm2015/domain/shopping/models/campaign-hashtag.js +0 -7
- package/esm2015/domain/shopping/models/checkout.js +0 -37
- package/esm2015/domain/shopping/models/coupons/coupon.js +0 -38
- package/esm2015/domain/shopping/models/index.js +0 -13
- package/esm2015/domain/shopping/models/subscription/checkout.js +0 -28
- package/esm2015/domain/shopping/repositories/campaign-dashboard.repository.js +0 -2
- package/esm2015/domain/shopping/repositories/campaign-hashtag.repository.js +0 -2
- package/esm2015/domain/shopping/repositories/index.js +0 -10
- package/esm2015/domain/users/models/beauty-profile.js +0 -12
- package/esm2015/domain/users/models/subscription/edition.js +0 -7
- package/esm2015/domain/users/models/subscription/payment.js +0 -14
- package/esm2015/domain/users/models/subscription/subscription.js +0 -43
- package/esm2015/domain/users/models/user-payment-method.js +0 -7
- package/esm2015/domain/users/models/user.js +0 -26
- package/esm2015/domain/users/use-cases/authentication.js +0 -40
- package/esm2015/domain/users/use-cases/recovery-password.js +0 -12
- package/esm2015/domain/users/use-cases/register.js +0 -34
- package/esm2015/domain/users/use-cases/signout.js +0 -12
- package/esm2015/infra/elasticsearch/adapters/axios.adapter.js +0 -76
- package/esm2015/infra/elasticsearch/indexes/products-index.js +0 -115
- package/esm2015/infra/firebase/auth/authentication-firebase-auth.service.js +0 -52
- package/esm2015/infra/firebase/auth/register-firebase-auth.service.js +0 -26
- package/esm2015/infra/firebase/firestore/mixins/with-create-firestore.mixin.js +0 -31
- package/esm2015/infra/firebase/firestore/mixins/with-crud-firestore.mixin.js +0 -10
- package/esm2015/infra/firebase/firestore/mixins/with-delete-firestore.mixin.js +0 -18
- package/esm2015/infra/firebase/firestore/mixins/with-find-firestore.mixin.js +0 -98
- package/esm2015/infra/firebase/firestore/mixins/with-firestore.mixin.js +0 -64
- package/esm2015/infra/firebase/firestore/mixins/with-get-firestore.mixin.js +0 -24
- package/esm2015/infra/firebase/firestore/mixins/with-helpers.mixin.js +0 -17
- package/esm2015/infra/firebase/firestore/mixins/with-sub-collection.mixin.js +0 -11
- package/esm2015/infra/firebase/firestore/mixins/with-update-firestore.mixin.js +0 -45
- package/esm2015/infra/firebase/firestore/repositories/catalog/category-firestore.repository.js +0 -82
- package/esm2015/infra/firebase/firestore/repositories/catalog/product-firestore.repository.js +0 -58
- package/esm2015/infra/firebase/firestore/repositories/catalog/product-variant-firestore.repository.js +0 -14
- package/esm2015/infra/firebase/firestore/repositories/catalog/subscription-product-firestore.repository.js +0 -12
- package/esm2015/infra/firebase/firestore/repositories/shop-settings/campaign-banner-firestore.repository.js +0 -12
- package/esm2015/infra/firebase/firestore/repositories/shop-settings/campaign-firestore.repository.js +0 -12
- package/esm2015/infra/firebase/firestore/repositories/shop-settings/home-firestore.repository.js +0 -56
- package/esm2015/infra/firebase/firestore/repositories/shop-settings/index.js +0 -6
- package/esm2015/infra/firebase/firestore/repositories/shop-settings/shop-settings-firestore.repository.js +0 -12
- package/esm2015/infra/firebase/firestore/repositories/shopping/campaign-dashboard-firestore.repository.js +0 -12
- package/esm2015/infra/firebase/firestore/repositories/shopping/campaign-hashtag-firestore.repository.js +0 -12
- package/esm2015/infra/firebase/firestore/repositories/shopping/checkout-firestore.repository.js +0 -12
- package/esm2015/infra/firebase/firestore/repositories/shopping/checkout-subscription-firestore.repository.js +0 -12
- package/esm2015/infra/firebase/firestore/repositories/shopping/coupon-firestore.repository.js +0 -29
- package/esm2015/infra/firebase/firestore/repositories/shopping/index.js +0 -11
- package/esm2015/infra/firebase/firestore/repositories/shopping/legacy-order-firestore.repository.js +0 -9
- package/esm2015/infra/firebase/firestore/repositories/shopping/order-firestore.repository.js +0 -40
- package/esm2015/infra/firebase/firestore/repositories/shopping/payment-firestore.repository.js +0 -12
- package/esm2015/infra/firebase/firestore/repositories/users/lead-firestore.repository.js +0 -12
- package/esm2015/infra/firebase/firestore/repositories/users/subscription-edition-firestore.repository.js +0 -14
- package/esm2015/infra/firebase/firestore/repositories/users/subscription-payment-firestore.repository.js +0 -14
- package/esm2015/infra/firebase/firestore/repositories/users/user-address-firestore.repository.js +0 -14
- package/esm2015/infra/firebase/firestore/repositories/users/user-beauty-profile-firestore.repository.js +0 -14
- package/esm2015/infra/firebase/firestore/repositories/users/user-firestore.repository.js +0 -68
- package/esm2015/infra/firebase/firestore/repositories/users/user-payment-method-firestore.repository.js +0 -14
- package/esm2015/infra/firebase/firestore/types/firestore-sub.repository.type.js +0 -2
- package/esm2015/infra/firebase/firestore/types/firestore.helpers.type.js +0 -2
- package/esm2015/infra/firebase/firestore/types/firestore.repository.type.js +0 -2
- package/esm2015/infra/hasura-graphql/mixins/helpers/attribute-option.helper.js +0 -31
- package/esm2015/infra/hasura-graphql/mixins/helpers/bind-filter-query.helper.js +0 -58
- package/esm2015/infra/hasura-graphql/mixins/helpers/filter-option.helper.js +0 -22
- package/esm2015/infra/hasura-graphql/mixins/helpers/graphql-field.helper.js +0 -95
- package/esm2015/infra/hasura-graphql/mixins/with-create-hasura-graphql.mixin.js +0 -61
- package/esm2015/infra/hasura-graphql/mixins/with-delete-hasura-graphql.mixin.js +0 -31
- package/esm2015/infra/hasura-graphql/mixins/with-find-hasura-graphql.mixin.js +0 -139
- package/esm2015/infra/hasura-graphql/mixins/with-get-hasura-graphql.mixin.js +0 -37
- package/esm2015/infra/hasura-graphql/mixins/with-hasura-graphql.mixin.js +0 -97
- package/esm2015/infra/hasura-graphql/mixins/with-update-hasura-graphql.mixin.js +0 -58
- package/esm2015/infra/hasura-graphql/models/product-hasura-graphql.js +0 -11
- package/esm2015/infra/hasura-graphql/repositories/catalog/category-collection-children-hasura-graphql.repository.js +0 -38
- package/esm2015/infra/hasura-graphql/repositories/catalog/category-filter-hasura-graphql.repository.js +0 -106
- package/esm2015/infra/hasura-graphql/repositories/catalog/category-hasura-graphql.repository.js +0 -363
- package/esm2015/infra/hasura-graphql/repositories/catalog/filter-hasura-graphql.repository.js +0 -123
- package/esm2015/infra/hasura-graphql/repositories/catalog/filter-option-hasura-graphql.repository.js +0 -21
- package/esm2015/infra/hasura-graphql/repositories/catalog/index.js +0 -9
- package/esm2015/infra/hasura-graphql/repositories/catalog/product-hasura-graphql.repository.js +0 -506
- package/esm2015/infra/hasura-graphql/repositories/catalog/variant-hasura-graphql.repository.js +0 -117
- package/esm2015/infra/hasura-graphql/repositories/catalog/wishlist-hasura-graphql.repository.js +0 -252
- package/esm2015/infra/hasura-graphql/types/graphql.repository.type.js +0 -2
- package/esm2015/infra/hasura-graphql/types/hasura-graphql-fields.type.js +0 -2
- package/esm2015/utils/decorators/debug.class.decorator.js +0 -7
- package/esm2015/utils/decorators/index.js +0 -3
- package/esm2015/utils/decorators/trace.method.decorator.js +0 -81
- package/esm2015/utils/helpers/class-name.helper.js +0 -15
- package/esm2015/utils/helpers/debug-decorator.helper.js +0 -18
- package/esm2015/utils/helpers/debug.helper.js +0 -150
- package/esm2015/utils/helpers/index.js +0 -5
- package/esm2015/utils/helpers/reflect.helper.js +0 -165
- package/esm2015/utils/index.js +0 -11
- package/esm2015/utils/log.utils.js +0 -9
- package/fesm2015/infrab4a-connect.js.map +0 -1
- package/infra/firebase/firestore/repositories/shop-settings/campaign-banner-firestore.repository.d.ts +0 -8
- package/infra/firebase/firestore/repositories/shop-settings/campaign-firestore.repository.d.ts +0 -8
- package/infra/firebase/firestore/repositories/shop-settings/shop-settings-firestore.repository.d.ts +0 -8
- package/infra/firebase/firestore/repositories/shopping/campaign-dashboard-firestore.repository.d.ts +0 -9
- package/infra/firebase/firestore/repositories/shopping/campaign-hashtag-firestore.repository.d.ts +0 -9
- 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 -12
- 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/infra/hasura-graphql/repositories/catalog/wishlist-hasura-graphql.repository.d.ts +0 -27
- package/infrab4a-connect.d.ts +0 -5
- 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
- /package/{esm2015/domain/catalog/models/enums/index.js → esm2020/domain/catalog/models/enums/index.mjs} +0 -0
- /package/{esm2015/domain/catalog/models/enums/product-genders.enum.js → esm2020/domain/catalog/models/enums/product-genders.enum.mjs} +0 -0
- /package/{esm2015/domain/catalog/models/enums/shops.enum.js → esm2020/domain/catalog/models/enums/shops.enum.mjs} +0 -0
- /package/{esm2015/domain/catalog/models/types/category-condition.type.js → esm2020/domain/catalog/models/types/category-condition.type.mjs} +0 -0
- /package/{esm2015/domain/catalog/models/types/category-metadata.type.js → esm2020/domain/catalog/models/types/category-metadata.type.mjs} +0 -0
- /package/{esm2015/domain/catalog/models/types/product-gender.type.js → esm2020/domain/catalog/models/types/product-gender.type.mjs} +0 -0
- /package/{esm2015/domain/catalog/models/types/product-metadata.type.js → esm2020/domain/catalog/models/types/product-metadata.type.mjs} +0 -0
- /package/{esm2015/domain/catalog/models/types/product-review.type.js → esm2020/domain/catalog/models/types/product-review.type.mjs} +0 -0
- /package/{esm2015/domain/catalog/models/types/shop-price.type.js → esm2020/domain/catalog/models/types/shop-price.type.mjs} +0 -0
- /package/{esm2015/domain/catalog/models/types/stock.type.js → esm2020/domain/catalog/models/types/stock.type.mjs} +0 -0
- /package/{esm2015/domain/catalog/models/types/variant-grade.type.js → esm2020/domain/catalog/models/types/variant-grade.type.mjs} +0 -0
- /package/{esm2015/domain/catalog/repositories/subscription-product.repository.js → esm2020/domain/catalog/repositories/subscription-product.repository.mjs} +0 -0
- /package/{esm2015/domain/catalog/repositories/variant.repository.js → esm2020/domain/catalog/repositories/variant.repository.mjs} +0 -0
- /package/{esm2015/domain/generic/index.js → esm2020/domain/generic/index.mjs} +0 -0
- /package/{esm2015/domain/generic/model/identifier-fields.js → esm2020/domain/generic/model/identifier-fields.mjs} +0 -0
- /package/{esm2015/domain/generic/model/index.js → esm2020/domain/generic/model/index.mjs} +0 -0
- /package/{esm2015/domain/generic/model/types/index.js → esm2020/domain/generic/model/types/index.mjs} +0 -0
- /package/{esm2015/domain/generic/model/types/non-function-properties.type.js → esm2020/domain/generic/model/types/non-function-properties.type.mjs} +0 -0
- /package/{esm2015/domain/generic/repository/crud.repository.js → esm2020/domain/generic/repository/crud.repository.mjs} +0 -0
- /package/{esm2015/domain/generic/repository/delete.repository.js → esm2020/domain/generic/repository/delete.repository.mjs} +0 -0
- /package/{esm2015/domain/generic/repository/enums/index.js → esm2020/domain/generic/repository/enums/index.mjs} +0 -0
- /package/{esm2015/domain/generic/repository/enums/update-option-actions.enum.js → esm2020/domain/generic/repository/enums/update-option-actions.enum.mjs} +0 -0
- /package/{esm2015/domain/generic/repository/enums/where.enum.js → esm2020/domain/generic/repository/enums/where.enum.mjs} +0 -0
- /package/{esm2015/domain/generic/repository/index.js → esm2020/domain/generic/repository/index.mjs} +0 -0
- /package/{esm2015/domain/generic/repository/read.repository.js → esm2020/domain/generic/repository/read.repository.mjs} +0 -0
- /package/{esm2015/domain/generic/repository/types/index.js → esm2020/domain/generic/repository/types/index.mjs} +0 -0
- /package/{esm2015/domain/generic/repository/types/repository-limit-options.type.js → esm2020/domain/generic/repository/types/repository-limit-options.type.mjs} +0 -0
- /package/{esm2015/domain/generic/repository/types/where-options.type.js → esm2020/domain/generic/repository/types/where-options.type.mjs} +0 -0
- /package/{esm2015/domain/generic/repository/update.repository.js → esm2020/domain/generic/repository/update.repository.mjs} +0 -0
- /package/{esm2015/domain/index.js → esm2020/domain/index.mjs} +0 -0
- /package/{esm2015/domain/location/index.js → esm2020/domain/location/index.mjs} +0 -0
- /package/{esm2015/domain/location/models/index.js → esm2020/domain/location/models/index.mjs} +0 -0
- /package/{esm2015/domain/location/models/types/index.js → esm2020/domain/location/models/types/index.mjs} +0 -0
- /package/{esm2015/domain/location/models/types/location-bound.type.js → esm2020/domain/location/models/types/location-bound.type.mjs} +0 -0
- /package/{esm2015/domain/location/models/types/location-geometry.type.js → esm2020/domain/location/models/types/location-geometry.type.mjs} +0 -0
- /package/{esm2015/domain/location/models/types/location-lat-lng.type.js → esm2020/domain/location/models/types/location-lat-lng.type.mjs} +0 -0
- /package/{esm2015/domain/shop-settings/enums/filter-type.enum.js → esm2020/domain/shop-settings/enums/filter-type.enum.mjs} +0 -0
- /package/{esm2015/domain/shop-settings/enums/questions-filters.enum.js → esm2020/domain/shop-settings/enums/questions-filters.enum.mjs} +0 -0
- /package/{esm2015/domain/shop-settings/helpers/index.js → esm2020/domain/shop-settings/helpers/index.mjs} +0 -0
- /package/{esm2015/domain/shop-settings/index.js → esm2020/domain/shop-settings/index.mjs} +0 -0
- /package/{esm2015/domain/shop-settings/models/home.js → esm2020/domain/shop-settings/models/home.mjs} +0 -0
- /package/{esm2015/domain/shop-settings/models/shop-menu.js → esm2020/domain/shop-settings/models/shop-menu.mjs} +0 -0
- /package/{esm2015/domain/shop-settings/models/types/banner.type.js → esm2020/domain/shop-settings/models/types/banner.type.mjs} +0 -0
- /package/{esm2015/domain/shop-settings/models/types/benefit.type.js → esm2020/domain/shop-settings/models/types/benefit.type.mjs} +0 -0
- /package/{esm2015/domain/shop-settings/models/types/home-data.type.js → esm2020/domain/shop-settings/models/types/home-data.type.mjs} +0 -0
- /package/{esm2015/domain/shop-settings/models/types/menu-nav.type.js → esm2020/domain/shop-settings/models/types/menu-nav.type.mjs} +0 -0
- /package/{esm2015/domain/shop-settings/models/types/sub-menu.type.js → esm2020/domain/shop-settings/models/types/sub-menu.type.mjs} +0 -0
- /package/{esm2015/domain/shop-settings/repositories/home.repository.js → esm2020/domain/shop-settings/repositories/home.repository.mjs} +0 -0
- /package/{esm2015/domain/shop-settings/repositories/shop-menu.repository.js → esm2020/domain/shop-settings/repositories/shop-menu.repository.mjs} +0 -0
- /package/{esm2015/domain/shopping/index.js → esm2020/domain/shopping/index.mjs} +0 -0
- /package/{esm2015/domain/shopping/models/coupons/enums/coupon-club-mens.enum.js → esm2020/domain/shopping/models/coupons/enums/coupon-club-mens.enum.mjs} +0 -0
- /package/{esm2015/domain/shopping/models/coupons/enums/coupon-subtypes.enum.js → esm2020/domain/shopping/models/coupons/enums/coupon-subtypes.enum.mjs} +0 -0
- /package/{esm2015/domain/shopping/models/coupons/enums/coupon-types.enum.js → esm2020/domain/shopping/models/coupons/enums/coupon-types.enum.mjs} +0 -0
- /package/{esm2015/domain/shopping/models/coupons/enums/exclusivities.enum.js → esm2020/domain/shopping/models/coupons/enums/exclusivities.enum.mjs} +0 -0
- /package/{esm2015/domain/shopping/models/coupons/enums/index.js → esm2020/domain/shopping/models/coupons/enums/index.mjs} +0 -0
- /package/{esm2015/domain/shopping/models/coupons/index.js → esm2020/domain/shopping/models/coupons/index.mjs} +0 -0
- /package/{esm2015/domain/shopping/models/enums/checkout-types.enum.js → esm2020/domain/shopping/models/enums/checkout-types.enum.mjs} +0 -0
- /package/{esm2015/domain/shopping/models/enums/index.js → esm2020/domain/shopping/models/enums/index.mjs} +0 -0
- /package/{esm2015/domain/shopping/models/enums/order-status.enum.js → esm2020/domain/shopping/models/enums/order-status.enum.mjs} +0 -0
- /package/{esm2015/domain/shopping/models/line-item.js → esm2020/domain/shopping/models/line-item.mjs} +0 -0
- /package/{esm2015/domain/shopping/models/subscription/index.js → esm2020/domain/shopping/models/subscription/index.mjs} +0 -0
- /package/{esm2015/domain/shopping/models/subscription/plan.js → esm2020/domain/shopping/models/subscription/plan.mjs} +0 -0
- /package/{esm2015/domain/shopping/models/types/index.js → esm2020/domain/shopping/models/types/index.mjs} +0 -0
- /package/{esm2015/domain/shopping/models/types/payment-address.type.js → esm2020/domain/shopping/models/types/payment-address.type.mjs} +0 -0
- /package/{esm2015/domain/shopping/models/types/payment-billing.type.js → esm2020/domain/shopping/models/types/payment-billing.type.mjs} +0 -0
- /package/{esm2015/domain/shopping/models/types/payment-card.type.js → esm2020/domain/shopping/models/types/payment-card.type.mjs} +0 -0
- /package/{esm2015/domain/shopping/models/types/payment-customer.type.js → esm2020/domain/shopping/models/types/payment-customer.type.mjs} +0 -0
- /package/{esm2015/domain/shopping/models/types/payment-document.type.js → esm2020/domain/shopping/models/types/payment-document.type.mjs} +0 -0
- /package/{esm2015/domain/shopping/models/types/payment-item.type.js → esm2020/domain/shopping/models/types/payment-item.type.mjs} +0 -0
- /package/{esm2015/domain/shopping/models/types/payment-shipping.type.js → esm2020/domain/shopping/models/types/payment-shipping.type.mjs} +0 -0
- /package/{esm2015/domain/shopping/repositories/buy-2-win.repository.js → esm2020/domain/shopping/repositories/buy-2-win.repository.mjs} +0 -0
- /package/{esm2015/domain/shopping/repositories/checkout.repository.js → esm2020/domain/shopping/repositories/checkout.repository.mjs} +0 -0
- /package/{esm2015/domain/shopping/repositories/coupon.repository.js → esm2020/domain/shopping/repositories/coupon.repository.mjs} +0 -0
- /package/{esm2015/domain/shopping/repositories/legacy-order.repository.js → esm2020/domain/shopping/repositories/legacy-order.repository.mjs} +0 -0
- /package/{esm2015/domain/shopping/repositories/order.repository.js → esm2020/domain/shopping/repositories/order.repository.mjs} +0 -0
- /package/{esm2015/domain/shopping/repositories/payment.repository.js → esm2020/domain/shopping/repositories/payment.repository.mjs} +0 -0
- /package/{esm2015/domain/shopping/repositories/subscription/checkout.repository.js → esm2020/domain/shopping/repositories/subscription/checkout.repository.mjs} +0 -0
- /package/{esm2015/domain/shopping/repositories/subscription/index.js → esm2020/domain/shopping/repositories/subscription/index.mjs} +0 -0
- /package/{esm2015/domain/shopping/repositories/subscription/plan.repository.js → esm2020/domain/shopping/repositories/subscription/plan.repository.mjs} +0 -0
- /package/{esm2015/domain/users/errors/index.js → esm2020/domain/users/errors/index.mjs} +0 -0
- /package/{esm2015/domain/users/index.js → esm2020/domain/users/index.mjs} +0 -0
- /package/{esm2015/domain/users/models/enums/accessory-importances.enum.js → esm2020/domain/users/models/enums/accessory-importances.enum.mjs} +0 -0
- /package/{esm2015/domain/users/models/enums/area.enum.js → esm2020/domain/users/models/enums/area.enum.mjs} +0 -0
- /package/{esm2015/domain/users/models/enums/beard-problems.enum.js → esm2020/domain/users/models/enums/beard-problems.enum.mjs} +0 -0
- /package/{esm2015/domain/users/models/enums/beard-sizes.enum.js → esm2020/domain/users/models/enums/beard-sizes.enum.mjs} +0 -0
- /package/{esm2015/domain/users/models/enums/beauty-product-importances.enum.js → esm2020/domain/users/models/enums/beauty-product-importances.enum.mjs} +0 -0
- /package/{esm2015/domain/users/models/enums/body-problems.enum.js → esm2020/domain/users/models/enums/body-problems.enum.mjs} +0 -0
- /package/{esm2015/domain/users/models/enums/body-shapes.enum.js → esm2020/domain/users/models/enums/body-shapes.enum.mjs} +0 -0
- /package/{esm2015/domain/users/models/enums/body-tattoos.enum.js → esm2020/domain/users/models/enums/body-tattoos.enum.mjs} +0 -0
- /package/{esm2015/domain/users/models/enums/face-skin-oilinesses.enum.js → esm2020/domain/users/models/enums/face-skin-oilinesses.enum.mjs} +0 -0
- /package/{esm2015/domain/users/models/enums/face-skin-problems.enum.js → esm2020/domain/users/models/enums/face-skin-problems.enum.mjs} +0 -0
- /package/{esm2015/domain/users/models/enums/face-skin-tones.enum.js → esm2020/domain/users/models/enums/face-skin-tones.enum.mjs} +0 -0
- /package/{esm2015/domain/users/models/enums/family-incomes.enum.js → esm2020/domain/users/models/enums/family-incomes.enum.mjs} +0 -0
- /package/{esm2015/domain/users/models/enums/fragrance-importances.enum.js → esm2020/domain/users/models/enums/fragrance-importances.enum.mjs} +0 -0
- /package/{esm2015/domain/users/models/enums/hair-colors.enum.js → esm2020/domain/users/models/enums/hair-colors.enum.mjs} +0 -0
- /package/{esm2015/domain/users/models/enums/hair-problems.enum.js → esm2020/domain/users/models/enums/hair-problems.enum.mjs} +0 -0
- /package/{esm2015/domain/users/models/enums/hair-strands.enum.js → esm2020/domain/users/models/enums/hair-strands.enum.mjs} +0 -0
- /package/{esm2015/domain/users/models/enums/hair-types.enum.js → esm2020/domain/users/models/enums/hair-types.enum.mjs} +0 -0
- /package/{esm2015/domain/users/models/enums/index.js → esm2020/domain/users/models/enums/index.mjs} +0 -0
- /package/{esm2015/domain/users/models/enums/office-position.enum.js → esm2020/domain/users/models/enums/office-position.enum.mjs} +0 -0
- /package/{esm2015/domain/users/models/enums/product-spents.enum.js → esm2020/domain/users/models/enums/product-spents.enum.mjs} +0 -0
- /package/{esm2015/domain/users/models/enums/user-type.enum.js → esm2020/domain/users/models/enums/user-type.enum.mjs} +0 -0
- /package/{esm2015/domain/users/models/index.js → esm2020/domain/users/models/index.mjs} +0 -0
- /package/{esm2015/domain/users/models/subscription/enums/billing-status.enum.js → esm2020/domain/users/models/subscription/enums/billing-status.enum.mjs} +0 -0
- /package/{esm2015/domain/users/models/subscription/enums/edition-status.enum.js → esm2020/domain/users/models/subscription/enums/edition-status.enum.mjs} +0 -0
- /package/{esm2015/domain/users/models/subscription/enums/index.js → esm2020/domain/users/models/subscription/enums/index.mjs} +0 -0
- /package/{esm2015/domain/users/models/subscription/enums/payment-type.enum.js → esm2020/domain/users/models/subscription/enums/payment-type.enum.mjs} +0 -0
- /package/{esm2015/domain/users/models/subscription/enums/status.enum.js → esm2020/domain/users/models/subscription/enums/status.enum.mjs} +0 -0
- /package/{esm2015/domain/users/models/subscription/index.js → esm2020/domain/users/models/subscription/index.mjs} +0 -0
- /package/{esm2015/domain/users/repositories/beauty-profile.repository.js → esm2020/domain/users/repositories/beauty-profile.repository.mjs} +0 -0
- /package/{esm2015/domain/users/repositories/edition.repository.js → esm2020/domain/users/repositories/edition.repository.mjs} +0 -0
- /package/{esm2015/domain/users/repositories/index.js → esm2020/domain/users/repositories/index.mjs} +0 -0
- /package/{esm2015/domain/users/repositories/lead.repository.js → esm2020/domain/users/repositories/lead.repository.mjs} +0 -0
- /package/{esm2015/domain/users/repositories/subscription-payment.repository.js → esm2020/domain/users/repositories/subscription-payment.repository.mjs} +0 -0
- /package/{esm2015/domain/users/repositories/subscription.repository.js → esm2020/domain/users/repositories/subscription.repository.mjs} +0 -0
- /package/{esm2015/domain/users/repositories/user-address.repository.js → esm2020/domain/users/repositories/user-address.repository.mjs} +0 -0
- /package/{esm2015/domain/users/repositories/user-payment-method.repository.js → esm2020/domain/users/repositories/user-payment-method.repository.mjs} +0 -0
- /package/{esm2015/domain/users/repositories/user.repository.js → esm2020/domain/users/repositories/user.repository.mjs} +0 -0
- /package/{esm2015/domain/users/services/authentication.service.js → esm2020/domain/users/services/authentication.service.mjs} +0 -0
- /package/{esm2015/domain/users/services/index.js → esm2020/domain/users/services/index.mjs} +0 -0
- /package/{esm2015/domain/users/services/register.service.js → esm2020/domain/users/services/register.service.mjs} +0 -0
- /package/{esm2015/domain/users/services/types/basic-user-data.type.js → esm2020/domain/users/services/types/basic-user-data.type.mjs} +0 -0
- /package/{esm2015/domain/users/services/types/index.js → esm2020/domain/users/services/types/index.mjs} +0 -0
- /package/{esm2015/domain/users/use-cases/index.js → esm2020/domain/users/use-cases/index.mjs} +0 -0
- /package/{esm2015/errors/index.js → esm2020/errors/index.mjs} +0 -0
- /package/{esm2015/errors/required-argument.error.js → esm2020/errors/required-argument.error.mjs} +0 -0
- /package/{esm2015/index.js → esm2020/index.mjs} +0 -0
- /package/{esm2015/infra/elasticsearch/adapters/index.js → esm2020/infra/elasticsearch/adapters/index.mjs} +0 -0
- /package/{esm2015/infra/elasticsearch/index.js → esm2020/infra/elasticsearch/index.mjs} +0 -0
- /package/{esm2015/infra/elasticsearch/indexes/index.js → esm2020/infra/elasticsearch/indexes/index.mjs} +0 -0
- /package/{esm2015/infra/elasticsearch/types/index.js → esm2020/infra/elasticsearch/types/index.mjs} +0 -0
- /package/{esm2015/infra/firebase/auth/index.js → esm2020/infra/firebase/auth/index.mjs} +0 -0
- /package/{esm2015/infra/firebase/firestore/enums/firestore-field-type.enum.js → esm2020/infra/firebase/firestore/enums/firestore-field-type.enum.mjs} +0 -0
- /package/{esm2015/infra/firebase/firestore/enums/index.js → esm2020/infra/firebase/firestore/enums/index.mjs} +0 -0
- /package/{esm2015/infra/firebase/firestore/index.js → esm2020/infra/firebase/firestore/index.mjs} +0 -0
- /package/{esm2015/infra/firebase/firestore/mixins/index.js → esm2020/infra/firebase/firestore/mixins/index.mjs} +0 -0
- /package/{esm2015/infra/firebase/firestore/repositories/catalog/index.js → esm2020/infra/firebase/firestore/repositories/catalog/index.mjs} +0 -0
- /package/{esm2015/infra/firebase/firestore/repositories/index.js → esm2020/infra/firebase/firestore/repositories/index.mjs} +0 -0
- /package/{esm2015/infra/firebase/firestore/repositories/users/index.js → esm2020/infra/firebase/firestore/repositories/users/index.mjs} +0 -0
- /package/{esm2015/infra/firebase/firestore/types/index.js → esm2020/infra/firebase/firestore/types/index.mjs} +0 -0
- /package/{esm2015/infra/firebase/index.js → esm2020/infra/firebase/index.mjs} +0 -0
- /package/{esm2015/infra/hasura-graphql/enums/hasura-graphql-column-type.enum.js → esm2020/infra/hasura-graphql/enums/hasura-graphql-column-type.enum.mjs} +0 -0
- /package/{esm2015/infra/hasura-graphql/enums/index.js → esm2020/infra/hasura-graphql/enums/index.mjs} +0 -0
- /package/{esm2015/infra/hasura-graphql/index.js → esm2020/infra/hasura-graphql/index.mjs} +0 -0
- /package/{esm2015/infra/hasura-graphql/mixins/helpers/index.js → esm2020/infra/hasura-graphql/mixins/helpers/index.mjs} +0 -0
- /package/{esm2015/infra/hasura-graphql/mixins/index.js → esm2020/infra/hasura-graphql/mixins/index.mjs} +0 -0
- /package/{esm2015/infra/hasura-graphql/models/category-hasura-graphql.js → esm2020/infra/hasura-graphql/models/category-hasura-graphql.mjs} +0 -0
- /package/{esm2015/infra/hasura-graphql/models/index.js → esm2020/infra/hasura-graphql/models/index.mjs} +0 -0
- /package/{esm2015/infra/hasura-graphql/repositories/index.js → esm2020/infra/hasura-graphql/repositories/index.mjs} +0 -0
- /package/{esm2015/infra/hasura-graphql/types/fields.type.js → esm2020/infra/hasura-graphql/types/fields.type.mjs} +0 -0
- /package/{esm2015/infra/hasura-graphql/types/hasura-graphql-auth-options.type.js → esm2020/infra/hasura-graphql/types/hasura-graphql-auth-options.type.mjs} +0 -0
- /package/{esm2015/infra/hasura-graphql/types/hasura-graphql-headers.type.js → esm2020/infra/hasura-graphql/types/hasura-graphql-headers.type.mjs} +0 -0
- /package/{esm2015/infra/hasura-graphql/types/index.js → esm2020/infra/hasura-graphql/types/index.mjs} +0 -0
- /package/{esm2015/infra/hasura-graphql/types/nested-field.type.js → esm2020/infra/hasura-graphql/types/nested-field.type.mjs} +0 -0
- /package/{esm2015/infra/hasura-graphql/types/query-builder-options.type.js → esm2020/infra/hasura-graphql/types/query-builder-options.type.mjs} +0 -0
- /package/{esm2015/infra/hasura-graphql/types/variable-options.type.js → esm2020/infra/hasura-graphql/types/variable-options.type.mjs} +0 -0
- /package/{esm2015/infra/index.js → esm2020/infra/index.mjs} +0 -0
- /package/{esm2015/infrab4a-connect.js → esm2020/infrab4a-connect.mjs} +0 -0
- /package/{esm2015/utils/is-uuid.js → esm2020/utils/is-uuid.mjs} +0 -0
- /package/{esm2015/utils/mixins/base.mixin.js → esm2020/utils/mixins/base.mixin.mjs} +0 -0
- /package/{esm2015/utils/mixins/index.js → esm2020/utils/mixins/index.mjs} +0 -0
- /package/{esm2015/utils/mixins/mixin-ctor.type.js → esm2020/utils/mixins/mixin-ctor.type.mjs} +0 -0
- /package/{esm2015/utils/parse-datetime.js → esm2020/utils/parse-datetime.mjs} +0 -0
- /package/{esm2015/utils/types/array-element.type.js → esm2020/utils/types/array-element.type.mjs} +0 -0
- /package/{esm2015/utils/types/index.js → esm2020/utils/types/index.mjs} +0 -0
- /package/{esm2015/utils/types/prop.type.js → esm2020/utils/types/prop.type.mjs} +0 -0
|
@@ -3,20 +3,18 @@ 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
|
-
export { chunk,
|
|
8
|
-
import { Subject } from 'rxjs';
|
|
9
|
-
import { debug } from 'debug';
|
|
6
|
+
import { get as get$1, isString, isNil, isNumber, isDate, set, isObject, isEmpty, chunk, isBoolean, isInteger, isNaN as isNaN$1, omit } from 'lodash';
|
|
7
|
+
export { chunk, isBoolean, isDate, isEmpty, isInteger, isNaN, isNil, isNumber, isObject, isString, now, omit, pick, set } from 'lodash';
|
|
10
8
|
import { CustomError } from 'ts-custom-error';
|
|
11
9
|
import axios from 'axios';
|
|
12
|
-
import
|
|
13
|
-
import {
|
|
10
|
+
import { collection, getDoc, doc, where, orderBy, getDocs, query, startAfter, startAt, limit, addDoc, setDoc, deleteField, arrayUnion, arrayRemove, deleteDoc, Timestamp } from 'firebase/firestore';
|
|
11
|
+
import { signInWithEmailAndPassword, signInWithPopup, GoogleAuthProvider, signInAnonymously, sendPasswordResetEmail, createUserWithEmailAndPassword, sendEmailVerification } from 'firebase/auth';
|
|
12
|
+
import { mutation, query as query$1 } from 'gql-query-builder';
|
|
14
13
|
|
|
15
14
|
class BaseModel {
|
|
16
15
|
get identifier() {
|
|
17
16
|
const fields = this.constructor.identifiersFields.filter((field) => field !== 'identifier');
|
|
18
|
-
|
|
19
|
-
return fields.reduce((object, field) => (Object.assign(Object.assign({}, object), { [field]: data[field] })), {});
|
|
17
|
+
return fields.reduce((object, field) => (Object.assign(Object.assign({}, object), { [field]: this[field] })), {});
|
|
20
18
|
}
|
|
21
19
|
get identifiersFields() {
|
|
22
20
|
return this.constructor.identifiersFields;
|
|
@@ -462,438 +460,18 @@ __decorate([
|
|
|
462
460
|
__metadata("design:type", Payment)
|
|
463
461
|
], SubscriptionPayment.prototype, "payment", void 0);
|
|
464
462
|
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
DebugNamespaces["TRACE"] = "trace";
|
|
469
|
-
DebugNamespaces["ERROR"] = "error";
|
|
470
|
-
})(DebugNamespaces || (DebugNamespaces = {}));
|
|
471
|
-
const Logger = debug(DebugNamespaces.ROOT);
|
|
472
|
-
|
|
473
|
-
class ReflectHelper {
|
|
474
|
-
static get items() {
|
|
475
|
-
return this._items;
|
|
476
|
-
}
|
|
477
|
-
static get keys() {
|
|
478
|
-
return Object.keys(ReflectHelper.items);
|
|
479
|
-
}
|
|
480
|
-
static has(key, target, property) {
|
|
481
|
-
return (!isNil(key) &&
|
|
482
|
-
!isNil(ReflectHelper.items[key]) &&
|
|
483
|
-
(isNil(target) ||
|
|
484
|
-
(!isNil(ReflectHelper.items[key][target]) &&
|
|
485
|
-
(isNil(property) || !isNil(ReflectHelper.items[key][target][String(property)])))));
|
|
486
|
-
}
|
|
487
|
-
static get({ key, target, property, own = true }) {
|
|
488
|
-
try {
|
|
489
|
-
if (own) {
|
|
490
|
-
return Reflect.getOwnMetadata(key, target, property) || null;
|
|
491
|
-
}
|
|
492
|
-
else {
|
|
493
|
-
return Reflect.getMetadata(key, target, property) || null;
|
|
494
|
-
}
|
|
495
|
-
}
|
|
496
|
-
catch (_err) {
|
|
497
|
-
return null;
|
|
498
|
-
}
|
|
499
|
-
}
|
|
500
|
-
static first({ key, target, property, own = true }) {
|
|
501
|
-
const values = ReflectHelper.get({ key, target, property, own });
|
|
502
|
-
return isArray(values) ? first(values) : values;
|
|
503
|
-
}
|
|
504
|
-
static last({ key, target, property, own = true }) {
|
|
505
|
-
const values = ReflectHelper.get({ key, target, property, own });
|
|
506
|
-
return isArray(values) ? last(values) : values;
|
|
507
|
-
}
|
|
508
|
-
static set({ key, target, property, value, propertyDescriptor }) {
|
|
509
|
-
Reflect.defineMetadata(key, value, target, property);
|
|
510
|
-
ReflectHelper.put({ key, target, property, value, propertyDescriptor });
|
|
511
|
-
}
|
|
512
|
-
static add({ key, target, property, value, propertyDescriptor }) {
|
|
513
|
-
let values = ReflectHelper.get({ key, target, property }) || new Array();
|
|
514
|
-
if (!Array.isArray(values))
|
|
515
|
-
values = [values];
|
|
516
|
-
values.push(value);
|
|
517
|
-
ReflectHelper.set({ key, target, property, value: values, propertyDescriptor });
|
|
518
|
-
}
|
|
519
|
-
static all({ key }) {
|
|
520
|
-
const items = ReflectHelper.items[key] || {};
|
|
521
|
-
return flatten(Object.keys(items).map((item) => flatten(this.allFrom(key, items[item]))));
|
|
522
|
-
}
|
|
523
|
-
static allFrom(key, target) {
|
|
524
|
-
return Object.keys(target)
|
|
525
|
-
.filter((property) => property !== 'object')
|
|
526
|
-
.map((property) => this.allValuesFrom(key, target, property));
|
|
527
|
-
}
|
|
528
|
-
static allValuesFrom(key, target, property) {
|
|
529
|
-
const values = target[property];
|
|
530
|
-
let value = values.value;
|
|
531
|
-
const propertyDescriptor = values.propertyDescriptor;
|
|
532
|
-
if (!isArray(value))
|
|
533
|
-
value = [value];
|
|
534
|
-
return flatten(value.map((val) => {
|
|
535
|
-
return {
|
|
536
|
-
key,
|
|
537
|
-
target: target.object,
|
|
538
|
-
property,
|
|
539
|
-
value: val,
|
|
540
|
-
propertyDescriptor,
|
|
541
|
-
};
|
|
542
|
-
}));
|
|
543
|
-
}
|
|
544
|
-
static delete({ key, target, property }) {
|
|
545
|
-
Reflect.deleteMetadata(key, target, property);
|
|
546
|
-
return ReflectHelper.remove(key, target, property);
|
|
547
|
-
}
|
|
548
|
-
static clear(key) {
|
|
549
|
-
if (!key) {
|
|
550
|
-
ReflectHelper.keys.forEach((storedKey) => {
|
|
551
|
-
ReflectHelper.clear(storedKey);
|
|
552
|
-
});
|
|
553
|
-
}
|
|
554
|
-
else {
|
|
555
|
-
if (ReflectHelper.keys.includes(key)) {
|
|
556
|
-
Object.values(ReflectHelper.items[key]).forEach((target) => {
|
|
557
|
-
if (ReflectHelper.has(key, target)) {
|
|
558
|
-
Object.values(ReflectHelper.items[key][target]).forEach((property) => {
|
|
559
|
-
ReflectHelper.delete({
|
|
560
|
-
key,
|
|
561
|
-
target: target.object,
|
|
562
|
-
property: String(property),
|
|
563
|
-
});
|
|
564
|
-
ReflectHelper.remove(key, target, String(property));
|
|
565
|
-
});
|
|
566
|
-
}
|
|
567
|
-
ReflectHelper.delete({ key, target: target.object });
|
|
568
|
-
ReflectHelper.remove(key, target);
|
|
569
|
-
});
|
|
570
|
-
}
|
|
571
|
-
}
|
|
572
|
-
}
|
|
573
|
-
static getType({ target, propertyKey }) {
|
|
574
|
-
return Reflect.getMetadata('design:type', target, propertyKey);
|
|
575
|
-
}
|
|
576
|
-
static getReturntype({ target, propertyKey }) {
|
|
577
|
-
return Reflect.getMetadata('design:returntype', target, propertyKey);
|
|
578
|
-
}
|
|
579
|
-
static getAllMethods(target) {
|
|
580
|
-
const props = [];
|
|
581
|
-
let obj = target;
|
|
582
|
-
do {
|
|
583
|
-
props.push(...Object.getOwnPropertyNames(obj));
|
|
584
|
-
} while ((obj = Object.getPrototypeOf(obj)));
|
|
585
|
-
return props.sort().filter((e, i, arr) => {
|
|
586
|
-
if ([
|
|
587
|
-
'__defineGetter__',
|
|
588
|
-
'__defineSetter__',
|
|
589
|
-
'__lookupGetter__',
|
|
590
|
-
'__lookupSetter__',
|
|
591
|
-
'constructor',
|
|
592
|
-
'hasOwnProperty',
|
|
593
|
-
'isPrototypeOf',
|
|
594
|
-
'propertyIsEnumerable',
|
|
595
|
-
'toLocaleString',
|
|
596
|
-
'toString',
|
|
597
|
-
'valueOf',
|
|
598
|
-
].includes(e))
|
|
599
|
-
return false;
|
|
600
|
-
if (e != arr[i + 1] && typeof target[e] === 'function')
|
|
601
|
-
return true;
|
|
602
|
-
});
|
|
603
|
-
}
|
|
604
|
-
static put({ key, target, property, value, propertyDescriptor }) {
|
|
605
|
-
const index = target.constructor.name;
|
|
606
|
-
ReflectHelper.items[key] = ReflectHelper.items[key] || {};
|
|
607
|
-
ReflectHelper.items[key][index] = ReflectHelper.items[key][index] || {};
|
|
608
|
-
ReflectHelper.items[key][index].object = target;
|
|
609
|
-
if (isNil(property)) {
|
|
610
|
-
ReflectHelper.items[key][index].value = {
|
|
611
|
-
value,
|
|
612
|
-
propertyDescriptor,
|
|
613
|
-
};
|
|
614
|
-
}
|
|
615
|
-
else {
|
|
616
|
-
ReflectHelper.items[key][index][String(property)] = ReflectHelper.items[key][index][String(property)] || {};
|
|
617
|
-
ReflectHelper.items[key][index][String(property)] = {
|
|
618
|
-
value,
|
|
619
|
-
propertyDescriptor,
|
|
620
|
-
};
|
|
621
|
-
}
|
|
622
|
-
}
|
|
623
|
-
static remove(key, target, property) {
|
|
624
|
-
if (ReflectHelper.has(key, target, property))
|
|
625
|
-
return delete ReflectHelper.items[key][target][String(property)];
|
|
626
|
-
else if (ReflectHelper.has(key, target))
|
|
627
|
-
return delete ReflectHelper.items[key][target];
|
|
628
|
-
else if (ReflectHelper.has(key))
|
|
629
|
-
return delete ReflectHelper.items[key];
|
|
630
|
-
else
|
|
631
|
-
return false;
|
|
632
|
-
}
|
|
633
|
-
}
|
|
634
|
-
ReflectHelper._items = {};
|
|
635
|
-
|
|
636
|
-
class DebugDecoratorHelper {
|
|
637
|
-
static set(target, options) {
|
|
638
|
-
ReflectHelper.add({
|
|
639
|
-
key: DebugDecoratorHelper.DebugNamingMetadataKey,
|
|
640
|
-
target,
|
|
641
|
-
value: options,
|
|
642
|
-
});
|
|
643
|
-
}
|
|
644
|
-
static get(target) {
|
|
645
|
-
return ReflectHelper.first({
|
|
646
|
-
key: DebugDecoratorHelper.DebugNamingMetadataKey,
|
|
647
|
-
target,
|
|
648
|
-
});
|
|
463
|
+
class Address extends BaseModel {
|
|
464
|
+
static get identifiersFields() {
|
|
465
|
+
return ['id'];
|
|
649
466
|
}
|
|
650
467
|
}
|
|
651
|
-
DebugDecoratorHelper.DebugNamingMetadataKey = 'model:naming:decorator';
|
|
652
468
|
|
|
653
|
-
|
|
654
|
-
static get(clazz) {
|
|
655
|
-
if (!clazz)
|
|
656
|
-
return null;
|
|
657
|
-
const prototype = Object.getPrototypeOf(clazz);
|
|
658
|
-
const names = compact([
|
|
659
|
-
get(clazz, 'constructor.name'),
|
|
660
|
-
get(prototype, 'constructor.name'),
|
|
661
|
-
get(prototype, '__proto__.constructor.name'),
|
|
662
|
-
]);
|
|
663
|
-
return names.find((name) => name !== 'class_1');
|
|
664
|
-
}
|
|
665
|
-
}
|
|
469
|
+
const get = (object, path, defaultValue) => get$1(object, path, defaultValue);
|
|
666
470
|
|
|
667
|
-
|
|
668
|
-
return
|
|
669
|
-
};
|
|
670
|
-
class DebugHelper {
|
|
671
|
-
constructor(...namespace) {
|
|
672
|
-
this.namespaces = new Set();
|
|
673
|
-
this.push(...namespace);
|
|
674
|
-
}
|
|
675
|
-
static namespacesFor(target) {
|
|
676
|
-
if (isNil(target))
|
|
677
|
-
return [];
|
|
678
|
-
const decorator = DebugDecoratorHelper.get(Object.getPrototypeOf(target));
|
|
679
|
-
const namespaces = get(decorator, 'namespaces', []);
|
|
680
|
-
const name = get(decorator, 'name', ClassNameHelper.get(target));
|
|
681
|
-
return [...namespaces, name];
|
|
682
|
-
}
|
|
683
|
-
static as(...namespaces) {
|
|
684
|
-
return new DebugHelper(...namespaces);
|
|
685
|
-
}
|
|
686
|
-
static for(target, ...namespaces) {
|
|
687
|
-
const targetNamespaces = this.namespacesFor(target);
|
|
688
|
-
return new DebugHelper(...targetNamespaces, ...namespaces);
|
|
689
|
-
}
|
|
690
|
-
static from(target, ...namespaces) {
|
|
691
|
-
if (this.isDebuggable(target)) {
|
|
692
|
-
const debug = target.debug;
|
|
693
|
-
if (namespaces)
|
|
694
|
-
debug.push(...namespaces);
|
|
695
|
-
return debug;
|
|
696
|
-
}
|
|
697
|
-
return DebugHelper.for(target, ...namespaces);
|
|
698
|
-
}
|
|
699
|
-
static clonedFrom(target, ...namespaces) {
|
|
700
|
-
if (this.isDebuggable(target)) {
|
|
701
|
-
namespaces.push(...target.debug.entries);
|
|
702
|
-
}
|
|
703
|
-
else if (!isNil(target)) {
|
|
704
|
-
namespaces.push(...this.namespacesFor(target));
|
|
705
|
-
}
|
|
706
|
-
return DebugHelper.for(target, ...namespaces);
|
|
707
|
-
}
|
|
708
|
-
static clone(target, ...namespaces) {
|
|
709
|
-
let original;
|
|
710
|
-
if (this.isDebuggable(target)) {
|
|
711
|
-
original = target.debug;
|
|
712
|
-
namespaces.push(...original.entries);
|
|
713
|
-
}
|
|
714
|
-
return {
|
|
715
|
-
original,
|
|
716
|
-
debug: DebugHelper.for(target, ...namespaces),
|
|
717
|
-
};
|
|
718
|
-
}
|
|
719
|
-
static replace(target, attrs) {
|
|
720
|
-
if (this.isDebuggable(target))
|
|
721
|
-
target.debug = attrs.with;
|
|
722
|
-
}
|
|
723
|
-
static mock(target, ...namespaces) {
|
|
724
|
-
const { original, debug } = DebugHelper.clone(target, ...namespaces);
|
|
725
|
-
DebugHelper.replace(target, { with: debug });
|
|
726
|
-
return { original, debug };
|
|
727
|
-
}
|
|
728
|
-
get entries() {
|
|
729
|
-
return Array.from(get(this, 'namespaces', []));
|
|
730
|
-
}
|
|
731
|
-
get namespace() {
|
|
732
|
-
return compact(flatten(this.entries)).join(':');
|
|
733
|
-
}
|
|
734
|
-
log(message, ...args) {
|
|
735
|
-
this.logger(JSON.stringify(message), ...args.map((element) => JSON.stringify(element)));
|
|
736
|
-
DebugHelper.logs$.next({ namespace: this.namespace, message, args });
|
|
737
|
-
return this;
|
|
738
|
-
}
|
|
739
|
-
trace(message, ...args) {
|
|
740
|
-
this.logger.extend(DebugNamespaces.TRACE)(message, ...args);
|
|
741
|
-
DebugHelper.traces$.next({ namespace: this.namespace, message, args });
|
|
742
|
-
return this;
|
|
743
|
-
}
|
|
744
|
-
error(error, ...args) {
|
|
745
|
-
this.logger.extend(DebugNamespaces.ERROR)(JSON.stringify(error), ...args.map((element) => JSON.stringify(element)));
|
|
746
|
-
DebugHelper.errors$.next({ namespace: this.namespace, error, args });
|
|
747
|
-
return this;
|
|
748
|
-
}
|
|
749
|
-
build() {
|
|
750
|
-
this.logger = Logger;
|
|
751
|
-
this.tracer = Logger;
|
|
752
|
-
this.err = Logger;
|
|
753
|
-
this.entries.forEach((namespace) => {
|
|
754
|
-
this.logger = this.logger.extend(namespace);
|
|
755
|
-
this.tracer = this.tracer.extend(namespace);
|
|
756
|
-
this.err = this.err.extend(namespace);
|
|
757
|
-
});
|
|
758
|
-
return this;
|
|
759
|
-
}
|
|
760
|
-
with(...namespace) {
|
|
761
|
-
return new DebugHelper(...this.entries, ...namespace);
|
|
762
|
-
}
|
|
763
|
-
push(...namespace) {
|
|
764
|
-
if (namespace) {
|
|
765
|
-
namespace.filter((item) => Boolean(item)).forEach((item) => this.namespaces.add(item));
|
|
766
|
-
}
|
|
767
|
-
return this.build();
|
|
768
|
-
}
|
|
769
|
-
unshift(...namespace) {
|
|
770
|
-
if (namespace) {
|
|
771
|
-
return this.reset(...namespace, ...this.entries);
|
|
772
|
-
}
|
|
773
|
-
return this;
|
|
774
|
-
}
|
|
775
|
-
reset(...namespace) {
|
|
776
|
-
this.namespaces = new Set(flatten(compact(namespace)));
|
|
777
|
-
return this.build();
|
|
778
|
-
}
|
|
779
|
-
startWith(...namespace) {
|
|
780
|
-
const current = this.namespaces;
|
|
781
|
-
this.namespaces = new Set(flatten([compact(namespace), ...current]));
|
|
782
|
-
return this.build();
|
|
783
|
-
}
|
|
784
|
-
shift() {
|
|
785
|
-
const list = this.entries;
|
|
786
|
-
list.shift();
|
|
787
|
-
return this.reset(...list);
|
|
788
|
-
}
|
|
789
|
-
pop() {
|
|
790
|
-
const list = this.entries;
|
|
791
|
-
list.pop();
|
|
792
|
-
return this.reset(...list);
|
|
793
|
-
}
|
|
794
|
-
clear() {
|
|
795
|
-
return this.reset();
|
|
796
|
-
}
|
|
797
|
-
remove(...namespace) {
|
|
798
|
-
if (namespace) {
|
|
799
|
-
namespace.filter((item) => Boolean(item)).forEach((item) => this.namespaces.delete(item));
|
|
800
|
-
}
|
|
801
|
-
return this.build();
|
|
802
|
-
}
|
|
803
|
-
puts(...args) {
|
|
804
|
-
return [`[${this.namespace}]`, ...args].join(' ');
|
|
805
|
-
}
|
|
806
|
-
}
|
|
807
|
-
DebugHelper.logs$ = new Subject();
|
|
808
|
-
DebugHelper.traces$ = new Subject();
|
|
809
|
-
DebugHelper.errors$ = new Subject();
|
|
810
|
-
DebugHelper.isDebuggable = isDebuggable;
|
|
811
|
-
|
|
812
|
-
function Debug(opts) {
|
|
813
|
-
return function (target) {
|
|
814
|
-
DebugDecoratorHelper.set(target.prototype, opts);
|
|
815
|
-
};
|
|
471
|
+
function is(value) {
|
|
472
|
+
return value;
|
|
816
473
|
}
|
|
817
474
|
|
|
818
|
-
const ASYNC_IDENTIFIER = 'async';
|
|
819
|
-
function Log(options = {}) {
|
|
820
|
-
return Trace(Object.assign({ level: 'log' }, options));
|
|
821
|
-
}
|
|
822
|
-
function Trace(options = {}) {
|
|
823
|
-
return function (target, propertyKey, propertyDescriptor) {
|
|
824
|
-
const method = propertyDescriptor.value;
|
|
825
|
-
const isPromise = method.toString().includes(ASYNC_IDENTIFIER);
|
|
826
|
-
const args = {
|
|
827
|
-
options,
|
|
828
|
-
method,
|
|
829
|
-
target,
|
|
830
|
-
propertyKey,
|
|
831
|
-
propertyDescriptor,
|
|
832
|
-
};
|
|
833
|
-
propertyDescriptor.value = isPromise ? promiseTracer(args) : functionTracer(args);
|
|
834
|
-
return propertyDescriptor;
|
|
835
|
-
};
|
|
836
|
-
}
|
|
837
|
-
const traceCall = ({ target, propertyKey, propertyDescriptor, args }) => {
|
|
838
|
-
if (!target.debug)
|
|
839
|
-
target.debug = DebugHelper.for(target, propertyKey);
|
|
840
|
-
return target.debug.push(propertyKey).trace('called', { target, propertyKey, propertyDescriptor, args });
|
|
841
|
-
};
|
|
842
|
-
const promiseTracer = function ({ options, method, propertyKey, propertyDescriptor }) {
|
|
843
|
-
return function (...args) {
|
|
844
|
-
return new Promise((resolve, reject) => {
|
|
845
|
-
const debug = traceCall({ target: this, propertyDescriptor, propertyKey, args });
|
|
846
|
-
if (get(options, 'level', '') === 'log') {
|
|
847
|
-
debug.with('params').log(args);
|
|
848
|
-
}
|
|
849
|
-
return method
|
|
850
|
-
.apply(this, args)
|
|
851
|
-
.then((result) => {
|
|
852
|
-
if (options.callbackFn) {
|
|
853
|
-
options.callbackFn({ target: this, result, args, namespace: [propertyKey] });
|
|
854
|
-
}
|
|
855
|
-
if (get(options, 'level', '') === 'log') {
|
|
856
|
-
debug.with('returns').log(result === undefined ? 'void' : result);
|
|
857
|
-
}
|
|
858
|
-
return resolve(result);
|
|
859
|
-
})
|
|
860
|
-
.catch((error) => {
|
|
861
|
-
debug.error(error, ...args);
|
|
862
|
-
debug.with('stack').error(error.stack).pop();
|
|
863
|
-
return reject(error);
|
|
864
|
-
})
|
|
865
|
-
.finally(() => {
|
|
866
|
-
return debug.trace('finally', { args }).pop();
|
|
867
|
-
});
|
|
868
|
-
});
|
|
869
|
-
};
|
|
870
|
-
};
|
|
871
|
-
const functionTracer = function ({ options, target, method, propertyKey, propertyDescriptor, }) {
|
|
872
|
-
return function (...args) {
|
|
873
|
-
const debug = traceCall({ target: this || target, propertyDescriptor, propertyKey, args });
|
|
874
|
-
if (get(options, 'level', '') === 'log') {
|
|
875
|
-
debug.with('params').log(args);
|
|
876
|
-
}
|
|
877
|
-
let result;
|
|
878
|
-
try {
|
|
879
|
-
result = method.apply(this, args);
|
|
880
|
-
if (options.callbackFn)
|
|
881
|
-
options.callbackFn({ target: this, result, args, namespace: [propertyKey] });
|
|
882
|
-
if (get(options, 'level', '') === 'log') {
|
|
883
|
-
debug.with('returns').log(result === undefined ? 'void' : result);
|
|
884
|
-
}
|
|
885
|
-
return result;
|
|
886
|
-
}
|
|
887
|
-
catch (error) {
|
|
888
|
-
debug.error(error, ...args).pop();
|
|
889
|
-
throw error;
|
|
890
|
-
}
|
|
891
|
-
finally {
|
|
892
|
-
debug.trace('finally', { args }).pop();
|
|
893
|
-
}
|
|
894
|
-
};
|
|
895
|
-
};
|
|
896
|
-
|
|
897
475
|
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);
|
|
898
476
|
|
|
899
477
|
class Base {
|
|
@@ -958,28 +536,26 @@ class Coupon extends BaseModel {
|
|
|
958
536
|
static createCoupon(userId) {
|
|
959
537
|
return this.toInstance({
|
|
960
538
|
nickname: `${Date.now()}`,
|
|
539
|
+
type: CouponTypes.ABSOLUTE,
|
|
961
540
|
checkoutType: CheckoutTypes.ECOMMERCE,
|
|
962
|
-
discount:
|
|
963
|
-
subscriber: {
|
|
964
|
-
type: CouponTypes.ABSOLUTE,
|
|
965
|
-
value: 10,
|
|
966
|
-
},
|
|
967
|
-
non_subscriber: {
|
|
968
|
-
type: CouponTypes.ABSOLUTE,
|
|
969
|
-
value: 10,
|
|
970
|
-
},
|
|
971
|
-
subscription: {
|
|
972
|
-
type: CouponTypes.ABSOLUTE,
|
|
973
|
-
value: 10,
|
|
974
|
-
},
|
|
975
|
-
},
|
|
541
|
+
discount: 30,
|
|
976
542
|
user: userId,
|
|
543
|
+
useLimit: 1,
|
|
544
|
+
useLimitPerUser: true,
|
|
977
545
|
createdAt: new Date(Date.now()),
|
|
978
546
|
beginAt: new Date(Date.now()),
|
|
979
547
|
expiresIn: new Date(Date.now() + COUPON_EXPIRATION),
|
|
980
548
|
});
|
|
981
549
|
}
|
|
982
550
|
}
|
|
551
|
+
__decorate([
|
|
552
|
+
Expose({ name: 'checkout_type' }),
|
|
553
|
+
__metadata("design:type", Number)
|
|
554
|
+
], Coupon.prototype, "checkoutType", void 0);
|
|
555
|
+
__decorate([
|
|
556
|
+
Expose({ name: 'exclusivity_type' }),
|
|
557
|
+
__metadata("design:type", Number)
|
|
558
|
+
], Coupon.prototype, "exclusivityType", void 0);
|
|
983
559
|
|
|
984
560
|
class SubscriptionPlan extends BaseModel {
|
|
985
561
|
static get identifiersFields() {
|
|
@@ -1019,18 +595,6 @@ __decorate([
|
|
|
1019
595
|
__metadata("design:type", BeautyProfile)
|
|
1020
596
|
], User.prototype, "beautyProfile", void 0);
|
|
1021
597
|
|
|
1022
|
-
class Address extends BaseModel {
|
|
1023
|
-
static get identifiersFields() {
|
|
1024
|
-
return ['id'];
|
|
1025
|
-
}
|
|
1026
|
-
}
|
|
1027
|
-
|
|
1028
|
-
class UserAddress extends Address {
|
|
1029
|
-
static get identifiersFields() {
|
|
1030
|
-
return ['id', 'userId'];
|
|
1031
|
-
}
|
|
1032
|
-
}
|
|
1033
|
-
|
|
1034
598
|
class Subscription extends BaseModel {
|
|
1035
599
|
static get identifiersFields() {
|
|
1036
600
|
return ['id'];
|
|
@@ -1045,12 +609,12 @@ __decorate([
|
|
|
1045
609
|
__metadata("design:type", SubscriptionPlan)
|
|
1046
610
|
], Subscription.prototype, "subscriptionPlan", void 0);
|
|
1047
611
|
__decorate([
|
|
1048
|
-
Type(() =>
|
|
1049
|
-
__metadata("design:type",
|
|
612
|
+
Type(() => Address),
|
|
613
|
+
__metadata("design:type", Address)
|
|
1050
614
|
], Subscription.prototype, "shippingAddress", void 0);
|
|
1051
615
|
__decorate([
|
|
1052
|
-
Type(() =>
|
|
1053
|
-
__metadata("design:type",
|
|
616
|
+
Type(() => Address),
|
|
617
|
+
__metadata("design:type", Address)
|
|
1054
618
|
], Subscription.prototype, "billingAddress", void 0);
|
|
1055
619
|
__decorate([
|
|
1056
620
|
Type(() => Coupon),
|
|
@@ -1065,6 +629,12 @@ __decorate([
|
|
|
1065
629
|
__metadata("design:type", Array)
|
|
1066
630
|
], Subscription.prototype, "payment", void 0);
|
|
1067
631
|
|
|
632
|
+
class UserAddress extends Address {
|
|
633
|
+
static get identifiersFields() {
|
|
634
|
+
return ['id', 'userId'];
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
|
|
1068
638
|
class UserPaymentMethod extends BaseModel {
|
|
1069
639
|
static get identifiersFields() {
|
|
1070
640
|
return ['id', 'userId'];
|
|
@@ -1080,7 +650,6 @@ class Lead extends BaseModel {
|
|
|
1080
650
|
class UnauthorizedError extends CustomError {
|
|
1081
651
|
constructor(message) {
|
|
1082
652
|
super(message);
|
|
1083
|
-
this.message = message;
|
|
1084
653
|
}
|
|
1085
654
|
}
|
|
1086
655
|
|
|
@@ -1123,14 +692,12 @@ class Authentication {
|
|
|
1123
692
|
class UserAlreadyRegisteredError extends CustomError {
|
|
1124
693
|
constructor(message) {
|
|
1125
694
|
super(message);
|
|
1126
|
-
this.message = message;
|
|
1127
695
|
}
|
|
1128
696
|
}
|
|
1129
697
|
|
|
1130
698
|
class WeakPasswordError extends CustomError {
|
|
1131
699
|
constructor(message = 'Weak password') {
|
|
1132
700
|
super(message);
|
|
1133
|
-
this.message = message;
|
|
1134
701
|
}
|
|
1135
702
|
}
|
|
1136
703
|
|
|
@@ -1187,123 +754,14 @@ class RecoveryPassword {
|
|
|
1187
754
|
}
|
|
1188
755
|
}
|
|
1189
756
|
|
|
1190
|
-
class
|
|
1191
|
-
|
|
1192
|
-
return ['id'];
|
|
1193
|
-
}
|
|
1194
|
-
}
|
|
1195
|
-
|
|
1196
|
-
class CategoryBase extends BaseModel {
|
|
1197
|
-
static get identifiersFields() {
|
|
1198
|
-
return ['id'];
|
|
1199
|
-
}
|
|
1200
|
-
}
|
|
1201
|
-
__decorate([
|
|
1202
|
-
Type(() => CategoryBase),
|
|
1203
|
-
__metadata("design:type", CategoryBase)
|
|
1204
|
-
], CategoryBase.prototype, "parent", void 0);
|
|
1205
|
-
__decorate([
|
|
1206
|
-
Type(() => Filter),
|
|
1207
|
-
__metadata("design:type", Array)
|
|
1208
|
-
], CategoryBase.prototype, "filters", void 0);
|
|
1209
|
-
|
|
1210
|
-
class CategoryForProduct extends CategoryBase {
|
|
1211
|
-
static get identifiersFields() {
|
|
1212
|
-
return ['id'];
|
|
1213
|
-
}
|
|
1214
|
-
}
|
|
1215
|
-
|
|
1216
|
-
class ProductBase extends BaseModel {
|
|
1217
|
-
get evaluation() {
|
|
1218
|
-
return {
|
|
1219
|
-
reviews: this.reviews,
|
|
1220
|
-
count: this.reviewsTotal,
|
|
1221
|
-
rating: this.rate,
|
|
1222
|
-
};
|
|
1223
|
-
}
|
|
1224
|
-
set evaluation(evaluation) {
|
|
1225
|
-
if (!evaluation) {
|
|
1226
|
-
this.reviews = null;
|
|
1227
|
-
this.reviewsTotal = null;
|
|
1228
|
-
this.rate = null;
|
|
1229
|
-
return;
|
|
1230
|
-
}
|
|
1231
|
-
this.reviews = evaluation.reviews || this.reviews;
|
|
1232
|
-
this.reviewsTotal = evaluation.count || this.reviewsTotal;
|
|
1233
|
-
this.rate = evaluation.rating || this.rate;
|
|
1234
|
-
}
|
|
1235
|
-
static get identifiersFields() {
|
|
757
|
+
class Category extends BaseModel {
|
|
758
|
+
identifierFields() {
|
|
1236
759
|
return ['id'];
|
|
1237
760
|
}
|
|
1238
|
-
}
|
|
1239
|
-
|
|
1240
|
-
class ProductForKit extends ProductBase {
|
|
1241
761
|
static get identifiersFields() {
|
|
1242
762
|
return ['id'];
|
|
1243
763
|
}
|
|
1244
764
|
}
|
|
1245
|
-
__decorate([
|
|
1246
|
-
Type(() => CategoryForProduct),
|
|
1247
|
-
__metadata("design:type", CategoryForProduct)
|
|
1248
|
-
], ProductForKit.prototype, "category", void 0);
|
|
1249
|
-
|
|
1250
|
-
class KitProduct extends BaseModel {
|
|
1251
|
-
static get identifiersFields() {
|
|
1252
|
-
return ['productId', 'kitProductId'];
|
|
1253
|
-
}
|
|
1254
|
-
}
|
|
1255
|
-
__decorate([
|
|
1256
|
-
Type(() => ProductForKit),
|
|
1257
|
-
__metadata("design:type", ProductForKit)
|
|
1258
|
-
], KitProduct.prototype, "kit", void 0);
|
|
1259
|
-
__decorate([
|
|
1260
|
-
Type(() => ProductForKit),
|
|
1261
|
-
__metadata("design:type", ProductForKit)
|
|
1262
|
-
], KitProduct.prototype, "product", void 0);
|
|
1263
|
-
|
|
1264
|
-
class ProductForCategory extends ProductBase {
|
|
1265
|
-
static get identifiersFields() {
|
|
1266
|
-
return ['id'];
|
|
1267
|
-
}
|
|
1268
|
-
}
|
|
1269
|
-
__decorate([
|
|
1270
|
-
Type(() => KitProduct),
|
|
1271
|
-
__metadata("design:type", Array)
|
|
1272
|
-
], ProductForCategory.prototype, "kitProducts", void 0);
|
|
1273
|
-
|
|
1274
|
-
class Category extends CategoryBase {
|
|
1275
|
-
static get identifiersFields() {
|
|
1276
|
-
return ['id'];
|
|
1277
|
-
}
|
|
1278
|
-
}
|
|
1279
|
-
__decorate([
|
|
1280
|
-
Type(() => ProductForCategory),
|
|
1281
|
-
__metadata("design:type", Array)
|
|
1282
|
-
], Category.prototype, "childrenProducts", void 0);
|
|
1283
|
-
|
|
1284
|
-
class CategoryCollectionChildren extends BaseModel {
|
|
1285
|
-
static get identifiersFields() {
|
|
1286
|
-
return ['collectionId', 'categoryId'];
|
|
1287
|
-
}
|
|
1288
|
-
}
|
|
1289
|
-
__decorate([
|
|
1290
|
-
Type(() => CategoryCollectionChildren),
|
|
1291
|
-
__metadata("design:type", CategoryCollectionChildren)
|
|
1292
|
-
], CategoryCollectionChildren.prototype, "parent", void 0);
|
|
1293
|
-
|
|
1294
|
-
class CategoryFilter extends BaseModel {
|
|
1295
|
-
static get identifiersFields() {
|
|
1296
|
-
return ['id'];
|
|
1297
|
-
}
|
|
1298
|
-
}
|
|
1299
|
-
__decorate([
|
|
1300
|
-
Type(() => Filter),
|
|
1301
|
-
__metadata("design:type", Filter)
|
|
1302
|
-
], CategoryFilter.prototype, "filter", void 0);
|
|
1303
|
-
__decorate([
|
|
1304
|
-
Type(() => Category),
|
|
1305
|
-
__metadata("design:type", Category)
|
|
1306
|
-
], CategoryFilter.prototype, "category", void 0);
|
|
1307
765
|
|
|
1308
766
|
var GenderDestination;
|
|
1309
767
|
(function (GenderDestination) {
|
|
@@ -1320,60 +778,54 @@ var Shops;
|
|
|
1320
778
|
Shops["ALL"] = "ALL";
|
|
1321
779
|
})(Shops || (Shops = {}));
|
|
1322
780
|
|
|
1323
|
-
class
|
|
1324
|
-
|
|
781
|
+
class Product extends BaseModel {
|
|
782
|
+
identifierFields() {
|
|
1325
783
|
return ['id'];
|
|
1326
784
|
}
|
|
1327
|
-
}
|
|
1328
|
-
|
|
1329
|
-
class Product extends ProductBase {
|
|
1330
785
|
static get identifiersFields() {
|
|
1331
786
|
return ['id'];
|
|
1332
787
|
}
|
|
1333
788
|
}
|
|
1334
|
-
__decorate([
|
|
1335
|
-
Type(() => CategoryForProduct),
|
|
1336
|
-
__metadata("design:type", CategoryForProduct)
|
|
1337
|
-
], Product.prototype, "category", void 0);
|
|
1338
789
|
__decorate([
|
|
1339
790
|
Type(() => KitProduct),
|
|
1340
791
|
__metadata("design:type", Array)
|
|
1341
792
|
], Product.prototype, "kitProducts", void 0);
|
|
1342
793
|
|
|
1343
|
-
class
|
|
1344
|
-
static get identifiersFields() {
|
|
1345
|
-
return ['id', 'productId'];
|
|
1346
|
-
}
|
|
1347
|
-
}
|
|
1348
|
-
|
|
1349
|
-
class Wishlist extends Category {
|
|
1350
|
-
static get identifiersFields() {
|
|
1351
|
-
return ['id'];
|
|
1352
|
-
}
|
|
1353
|
-
}
|
|
1354
|
-
|
|
1355
|
-
class Buy2Win extends BaseModel {
|
|
794
|
+
class KitProduct extends BaseModel {
|
|
1356
795
|
static get identifiersFields() {
|
|
1357
|
-
return ['
|
|
796
|
+
return ['productId', 'kitProducId'];
|
|
1358
797
|
}
|
|
1359
798
|
}
|
|
1360
799
|
__decorate([
|
|
1361
|
-
Type(() =>
|
|
1362
|
-
__metadata("design:type",
|
|
1363
|
-
],
|
|
800
|
+
Type(() => Product),
|
|
801
|
+
__metadata("design:type", Product)
|
|
802
|
+
], KitProduct.prototype, "kit", void 0);
|
|
803
|
+
__decorate([
|
|
804
|
+
Type(() => Product),
|
|
805
|
+
__metadata("design:type", Product)
|
|
806
|
+
], KitProduct.prototype, "product", void 0);
|
|
1364
807
|
|
|
1365
|
-
class
|
|
1366
|
-
|
|
808
|
+
class Variant extends BaseModel {
|
|
809
|
+
identifierFields() {
|
|
1367
810
|
return ['id'];
|
|
1368
811
|
}
|
|
1369
|
-
}
|
|
1370
|
-
|
|
1371
|
-
class CampaignHashtag extends BaseModel {
|
|
1372
812
|
static get identifiersFields() {
|
|
1373
|
-
return ['id'];
|
|
813
|
+
return ['id', 'productId'];
|
|
1374
814
|
}
|
|
1375
815
|
}
|
|
1376
816
|
|
|
817
|
+
var OrderStatus;
|
|
818
|
+
(function (OrderStatus) {
|
|
819
|
+
OrderStatus["AGUARDANDO_PAGAMENTO"] = "Aguardando pagamento";
|
|
820
|
+
OrderStatus["EM_PREPARO"] = "Preparando pedido";
|
|
821
|
+
OrderStatus["NF_EMITIDA"] = "Nota Fiscal Emitida";
|
|
822
|
+
OrderStatus["AGUARDANDO_ENVIO"] = "Aguardando Transaportadora";
|
|
823
|
+
OrderStatus["ENVIADO"] = "Enviado";
|
|
824
|
+
OrderStatus["ENTREGUE"] = "Entregue";
|
|
825
|
+
OrderStatus["CANCELADO"] = "Cancelado";
|
|
826
|
+
OrderStatus["CREDIT_CARD"] = "credit_card";
|
|
827
|
+
})(OrderStatus || (OrderStatus = {}));
|
|
828
|
+
|
|
1377
829
|
class LineItem extends Product {
|
|
1378
830
|
}
|
|
1379
831
|
|
|
@@ -1397,12 +849,12 @@ __decorate([
|
|
|
1397
849
|
__metadata("design:type", User)
|
|
1398
850
|
], Checkout.prototype, "user", void 0);
|
|
1399
851
|
__decorate([
|
|
1400
|
-
Type(() =>
|
|
1401
|
-
__metadata("design:type",
|
|
852
|
+
Type(() => Address),
|
|
853
|
+
__metadata("design:type", Address)
|
|
1402
854
|
], Checkout.prototype, "shippingAddress", void 0);
|
|
1403
855
|
__decorate([
|
|
1404
|
-
Type(() =>
|
|
1405
|
-
__metadata("design:type",
|
|
856
|
+
Type(() => Address),
|
|
857
|
+
__metadata("design:type", Address)
|
|
1406
858
|
], Checkout.prototype, "billingAddress", void 0);
|
|
1407
859
|
__decorate([
|
|
1408
860
|
Type(() => ShippingMethod),
|
|
@@ -1413,18 +865,6 @@ __decorate([
|
|
|
1413
865
|
__metadata("design:type", Coupon)
|
|
1414
866
|
], Checkout.prototype, "coupon", void 0);
|
|
1415
867
|
|
|
1416
|
-
var OrderStatus;
|
|
1417
|
-
(function (OrderStatus) {
|
|
1418
|
-
OrderStatus["AGUARDANDO_PAGAMENTO"] = "Aguardando pagamento";
|
|
1419
|
-
OrderStatus["EM_PREPARO"] = "Preparando pedido";
|
|
1420
|
-
OrderStatus["NF_EMITIDA"] = "Nota Fiscal Emitida";
|
|
1421
|
-
OrderStatus["AGUARDANDO_ENVIO"] = "Aguardando Transaportadora";
|
|
1422
|
-
OrderStatus["ENVIADO"] = "Enviado";
|
|
1423
|
-
OrderStatus["ENTREGUE"] = "Entregue";
|
|
1424
|
-
OrderStatus["CANCELADO"] = "Cancelado";
|
|
1425
|
-
OrderStatus["CREDIT_CARD"] = "credit_card";
|
|
1426
|
-
})(OrderStatus || (OrderStatus = {}));
|
|
1427
|
-
|
|
1428
868
|
class Order extends Checkout {
|
|
1429
869
|
}
|
|
1430
870
|
__decorate([
|
|
@@ -1438,12 +878,12 @@ class CheckoutSubscription extends BaseModel {
|
|
|
1438
878
|
}
|
|
1439
879
|
}
|
|
1440
880
|
__decorate([
|
|
1441
|
-
Type(() =>
|
|
1442
|
-
__metadata("design:type",
|
|
881
|
+
Type(() => Address),
|
|
882
|
+
__metadata("design:type", Address)
|
|
1443
883
|
], CheckoutSubscription.prototype, "shippingAddress", void 0);
|
|
1444
884
|
__decorate([
|
|
1445
|
-
Type(() =>
|
|
1446
|
-
__metadata("design:type",
|
|
885
|
+
Type(() => Address),
|
|
886
|
+
__metadata("design:type", Address)
|
|
1447
887
|
], CheckoutSubscription.prototype, "billingAddress", void 0);
|
|
1448
888
|
__decorate([
|
|
1449
889
|
Type(() => SubscriptionPlan),
|
|
@@ -1454,19 +894,15 @@ __decorate([
|
|
|
1454
894
|
__metadata("design:type", Coupon)
|
|
1455
895
|
], CheckoutSubscription.prototype, "coupon", void 0);
|
|
1456
896
|
|
|
1457
|
-
class
|
|
1458
|
-
static
|
|
1459
|
-
|
|
1460
|
-
product.price.fullPrice = Number(product.price.fullPrice.toFixed(2));
|
|
1461
|
-
if (product.price.subscriberPrice) {
|
|
1462
|
-
product.price.subscriberPrice = Number(product.price.subscriberPrice.toFixed(2));
|
|
1463
|
-
}
|
|
1464
|
-
if (product instanceof LineItem && product.pricePaid) {
|
|
1465
|
-
product.pricePaid = Number(product.pricePaid.toFixed(2));
|
|
1466
|
-
}
|
|
1467
|
-
return product;
|
|
897
|
+
class Buy2Win extends BaseModel {
|
|
898
|
+
static get identifiersFields() {
|
|
899
|
+
return ['id'];
|
|
1468
900
|
}
|
|
1469
901
|
}
|
|
902
|
+
__decorate([
|
|
903
|
+
Type(() => Category),
|
|
904
|
+
__metadata("design:type", Array)
|
|
905
|
+
], Buy2Win.prototype, "categories", void 0);
|
|
1470
906
|
|
|
1471
907
|
var FilterType;
|
|
1472
908
|
(function (FilterType) {
|
|
@@ -1510,27 +946,6 @@ var QuestionsFilters;
|
|
|
1510
946
|
QuestionsFilters["PRODUCT_SPENT"] = "Qual \u00E9 o seu nivel de gasto mensal em produtos de beleza e cuidados pessoais?";
|
|
1511
947
|
})(QuestionsFilters || (QuestionsFilters = {}));
|
|
1512
948
|
|
|
1513
|
-
var ShopPageName;
|
|
1514
|
-
(function (ShopPageName) {
|
|
1515
|
-
ShopPageName["LP_CLUB"] = "LP_CLUBE";
|
|
1516
|
-
ShopPageName["SUBSCRIBER_PANEL"] = "SUBSCRIBER_PANEL";
|
|
1517
|
-
ShopPageName["INVITE_FRIENDS"] = "INVITE_FRIENDS";
|
|
1518
|
-
ShopPageName["INVITE_AND_WIN"] = "INVITE_AND_WIN";
|
|
1519
|
-
ShopPageName["WIN_GLAMPOINTS"] = "WIN_GLAMPOINTS";
|
|
1520
|
-
ShopPageName["POSTS"] = "POSTS";
|
|
1521
|
-
ShopPageName["GLAMPOINTS_SHOWCASE"] = "GLAMPOINTS_SHOWCASE";
|
|
1522
|
-
ShopPageName["LP_EDITIONS"] = "LP_EDITIONS";
|
|
1523
|
-
ShopPageName["LP_GLAMBOX_EDITION"] = "LP_GLAMBOX_EDITION";
|
|
1524
|
-
ShopPageName["LP_GLAMBOX_PROMOTION"] = "LP_GLAMBOX_PROMOTION";
|
|
1525
|
-
ShopPageName["LP_GLAMBAG_PROMOTION"] = "LP_GLAMBAG_PROMOTION";
|
|
1526
|
-
ShopPageName["LP_GLAMPASS_PROMOTION"] = "LP_GLAMPASS_PROMOTION";
|
|
1527
|
-
ShopPageName["LP_SUBSCRIPTION_PROMOTION"] = "LP_SUBSCRIPTION_PROMOTION";
|
|
1528
|
-
ShopPageName["LP_GLAMPARTNER_PROMOTION"] = "LP_GLAMPARTNER_PROMOTION";
|
|
1529
|
-
ShopPageName["LP_GLAMQUEENS"] = "LP_GLAMQUEENS";
|
|
1530
|
-
ShopPageName["LP_INVITE"] = "LP_INVITE";
|
|
1531
|
-
ShopPageName["LP_LIVELO"] = "LP_LIVELO";
|
|
1532
|
-
})(ShopPageName || (ShopPageName = {}));
|
|
1533
|
-
|
|
1534
949
|
class BeautyQuestionsHelper {
|
|
1535
950
|
static getAnswers(filter) {
|
|
1536
951
|
switch (filter) {
|
|
@@ -1571,19 +986,8 @@ class BeautyQuestionsHelper {
|
|
|
1571
986
|
}
|
|
1572
987
|
}
|
|
1573
988
|
static getQuestions(filter) {
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
}
|
|
1577
|
-
|
|
1578
|
-
class Campaign extends BaseModel {
|
|
1579
|
-
static get identifiersFields() {
|
|
1580
|
-
return ['id'];
|
|
1581
|
-
}
|
|
1582
|
-
}
|
|
1583
|
-
|
|
1584
|
-
class CampaignBanner extends BaseModel {
|
|
1585
|
-
static get identifiersFields() {
|
|
1586
|
-
return ['id'];
|
|
989
|
+
const filterKey = Object.keys(FilterType)[Object.values(FilterType).indexOf(filter)];
|
|
990
|
+
return QuestionsFilters[filterKey];
|
|
1587
991
|
}
|
|
1588
992
|
}
|
|
1589
993
|
|
|
@@ -1599,16 +1003,9 @@ class ShopMenu extends BaseModel {
|
|
|
1599
1003
|
}
|
|
1600
1004
|
}
|
|
1601
1005
|
|
|
1602
|
-
class ShopSettings extends BaseModel {
|
|
1603
|
-
static get identifiersFields() {
|
|
1604
|
-
return ['id'];
|
|
1605
|
-
}
|
|
1606
|
-
}
|
|
1607
|
-
|
|
1608
1006
|
class InvalidArgumentError extends CustomError {
|
|
1609
1007
|
constructor(message) {
|
|
1610
1008
|
super(message);
|
|
1611
|
-
this.message = message;
|
|
1612
1009
|
}
|
|
1613
1010
|
}
|
|
1614
1011
|
|
|
@@ -1623,14 +1020,12 @@ class RequiredArgumentError extends CustomError {
|
|
|
1623
1020
|
class NotFoundError extends CustomError {
|
|
1624
1021
|
constructor(message) {
|
|
1625
1022
|
super(message);
|
|
1626
|
-
this.message = message;
|
|
1627
1023
|
}
|
|
1628
1024
|
}
|
|
1629
1025
|
|
|
1630
1026
|
class DuplicatedResultsError extends CustomError {
|
|
1631
1027
|
constructor(message) {
|
|
1632
1028
|
super(message);
|
|
1633
|
-
this.message = message;
|
|
1634
1029
|
}
|
|
1635
1030
|
}
|
|
1636
1031
|
|
|
@@ -1638,21 +1033,19 @@ class AxiosAdapter {
|
|
|
1638
1033
|
constructor(config) {
|
|
1639
1034
|
this.config = config;
|
|
1640
1035
|
}
|
|
1641
|
-
get(index
|
|
1036
|
+
get(index) {
|
|
1642
1037
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1643
1038
|
try {
|
|
1644
1039
|
const { data } = yield axios({
|
|
1645
|
-
url: `${this.config.url}/${index}
|
|
1040
|
+
url: `${this.config.url}/${index}`,
|
|
1646
1041
|
method: 'GET',
|
|
1647
|
-
|
|
1648
|
-
headers: {
|
|
1649
|
-
'Content-Type': 'application/json',
|
|
1650
|
-
Authorization: `ApiKey ${this.config.credential}`,
|
|
1651
|
-
},
|
|
1042
|
+
headers: { Authorization: `Basic ${this.config.credential}` },
|
|
1652
1043
|
});
|
|
1653
1044
|
return data._source;
|
|
1654
1045
|
}
|
|
1655
1046
|
catch (error) {
|
|
1047
|
+
if (!(error instanceof Error))
|
|
1048
|
+
throw error;
|
|
1656
1049
|
throw new NotFoundError(error.message);
|
|
1657
1050
|
}
|
|
1658
1051
|
});
|
|
@@ -1660,14 +1053,9 @@ class AxiosAdapter {
|
|
|
1660
1053
|
query(index, query) {
|
|
1661
1054
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1662
1055
|
const { data } = yield axios({
|
|
1663
|
-
url: `${this.config.url}/${index}
|
|
1056
|
+
url: `${this.config.url}/${index}`,
|
|
1664
1057
|
method: 'POST',
|
|
1665
|
-
|
|
1666
|
-
headers: {
|
|
1667
|
-
Accept: 'application/vnd.elasticsearch+json;compatible-with=7',
|
|
1668
|
-
'Content-Type': 'application/vnd.elasticsearch+json;compatible-with=7',
|
|
1669
|
-
Authorization: `ApiKey ${this.config.credential}`,
|
|
1670
|
-
},
|
|
1058
|
+
headers: { Authorization: `Basic ${this.config.credential}` },
|
|
1671
1059
|
data: query,
|
|
1672
1060
|
});
|
|
1673
1061
|
return {
|
|
@@ -1679,29 +1067,19 @@ class AxiosAdapter {
|
|
|
1679
1067
|
save(index, data) {
|
|
1680
1068
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1681
1069
|
yield axios({
|
|
1682
|
-
url: `${this.config.url}/${index}
|
|
1683
|
-
method: 'POST',
|
|
1684
|
-
headers: { Authorization: `ApiKey ${this.config.credential}` },
|
|
1685
|
-
data,
|
|
1686
|
-
});
|
|
1687
|
-
});
|
|
1688
|
-
}
|
|
1689
|
-
update(index, id, data) {
|
|
1690
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1691
|
-
yield axios({
|
|
1692
|
-
url: `${this.config.url}/${index}/_update/${id}`,
|
|
1070
|
+
url: `${this.config.url}/${index}`,
|
|
1693
1071
|
method: 'PUT',
|
|
1694
|
-
headers: { Authorization: `
|
|
1072
|
+
headers: { Authorization: `Basic ${this.config.credential}` },
|
|
1695
1073
|
data,
|
|
1696
1074
|
});
|
|
1697
1075
|
});
|
|
1698
1076
|
}
|
|
1699
|
-
delete(index
|
|
1077
|
+
delete(index) {
|
|
1700
1078
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1701
1079
|
yield axios({
|
|
1702
|
-
url: `${this.config.url}/${index}
|
|
1080
|
+
url: `${this.config.url}/${index}`,
|
|
1703
1081
|
method: 'DELETE',
|
|
1704
|
-
headers: { Authorization: `
|
|
1082
|
+
headers: { Authorization: `Basic ${this.config.credential}` },
|
|
1705
1083
|
});
|
|
1706
1084
|
});
|
|
1707
1085
|
}
|
|
@@ -1710,19 +1088,16 @@ class AxiosAdapter {
|
|
|
1710
1088
|
class ProductsIndex {
|
|
1711
1089
|
constructor(adapter) {
|
|
1712
1090
|
this.adapter = adapter;
|
|
1713
|
-
this.index = `products`;
|
|
1714
1091
|
}
|
|
1715
|
-
|
|
1092
|
+
get(id) {
|
|
1716
1093
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1717
|
-
const data = yield this.adapter.get(
|
|
1094
|
+
const data = yield this.adapter.get(`products/_doc/${id}`);
|
|
1718
1095
|
return Product.toInstance(data);
|
|
1719
1096
|
});
|
|
1720
1097
|
}
|
|
1721
|
-
|
|
1098
|
+
findById(ids, options) {
|
|
1722
1099
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1723
|
-
const size = total || 9;
|
|
1724
1100
|
const fields = [
|
|
1725
|
-
'EAN',
|
|
1726
1101
|
'brand',
|
|
1727
1102
|
'id',
|
|
1728
1103
|
'images',
|
|
@@ -1733,88 +1108,73 @@ class ProductsIndex {
|
|
|
1733
1108
|
'stock',
|
|
1734
1109
|
'slug',
|
|
1735
1110
|
'reviews',
|
|
1111
|
+
'pricePaid',
|
|
1112
|
+
'isGift',
|
|
1113
|
+
'stock',
|
|
1114
|
+
'weight',
|
|
1115
|
+
'tags',
|
|
1736
1116
|
'hasVariants',
|
|
1737
|
-
'
|
|
1117
|
+
'type',
|
|
1738
1118
|
];
|
|
1739
|
-
const
|
|
1740
|
-
if (size > 9) {
|
|
1741
|
-
fields.push(...['pricePaid', 'isGift', 'stock', 'weight', 'tags']);
|
|
1742
|
-
}
|
|
1743
|
-
else {
|
|
1744
|
-
filter.push({ term: { tags: shop == Shops.GLAMSHOP ? 'feminino' : 'masculino' } });
|
|
1745
|
-
}
|
|
1746
|
-
const search = yield this.adapter.query(this.index, {
|
|
1747
|
-
size,
|
|
1748
|
-
_source: fields,
|
|
1749
|
-
query: {
|
|
1119
|
+
const { hits } = yield this.adapter.query('products/_search', Object.assign({ _source: fields, query: {
|
|
1750
1120
|
bool: {
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
'name',
|
|
1757
|
-
'name.folded',
|
|
1758
|
-
'name.search',
|
|
1759
|
-
'description',
|
|
1760
|
-
'description.search',
|
|
1761
|
-
'description.folded',
|
|
1762
|
-
'brand',
|
|
1763
|
-
'brand.search',
|
|
1764
|
-
'brand.folded',
|
|
1765
|
-
],
|
|
1766
|
-
fuzziness: 2,
|
|
1121
|
+
filter: [
|
|
1122
|
+
{
|
|
1123
|
+
terms: {
|
|
1124
|
+
_id: ids,
|
|
1125
|
+
},
|
|
1767
1126
|
},
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
'name.search': {
|
|
1772
|
-
query: `${searchTerm}`,
|
|
1773
|
-
slop: 10,
|
|
1127
|
+
{
|
|
1128
|
+
term: {
|
|
1129
|
+
published: true,
|
|
1774
1130
|
},
|
|
1775
1131
|
},
|
|
1776
|
-
|
|
1777
|
-
|
|
1132
|
+
...((options === null || options === void 0 ? void 0 : options.hasStock)
|
|
1133
|
+
? [
|
|
1134
|
+
{
|
|
1135
|
+
range: {
|
|
1136
|
+
'stock.quantity': {
|
|
1137
|
+
gt: 0,
|
|
1138
|
+
},
|
|
1139
|
+
},
|
|
1140
|
+
},
|
|
1141
|
+
]
|
|
1142
|
+
: []),
|
|
1143
|
+
],
|
|
1778
1144
|
},
|
|
1779
|
-
},
|
|
1780
|
-
|
|
1781
|
-
search.hits = search.hits
|
|
1782
|
-
.filter((e) => e._source.name !== '')
|
|
1783
|
-
.map((hit) => {
|
|
1784
|
-
RoundProductPricesHelper.roundProductPrices(hit._source);
|
|
1785
|
-
return hit;
|
|
1786
|
-
});
|
|
1787
|
-
return search;
|
|
1145
|
+
} }, ((options === null || options === void 0 ? void 0 : options.size) ? { size: options === null || options === void 0 ? void 0 : options.size } : {})));
|
|
1146
|
+
return hits.map((hit) => Product.toInstance(hit._source));
|
|
1788
1147
|
});
|
|
1789
1148
|
}
|
|
1790
1149
|
save(product) {
|
|
1791
1150
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1151
|
+
delete product.createdAt;
|
|
1152
|
+
delete product.updatedAt;
|
|
1153
|
+
delete product.kitProducts;
|
|
1792
1154
|
try {
|
|
1793
|
-
|
|
1794
|
-
|
|
1155
|
+
if (!product.firestoreId)
|
|
1156
|
+
throw new Error('Is not a product from firestore');
|
|
1157
|
+
yield this.get(product.firestoreId);
|
|
1158
|
+
yield this.adapter.save(`products/_doc/${product.firestoreId}`, product.toPlain());
|
|
1795
1159
|
}
|
|
1796
1160
|
catch (error) {
|
|
1797
|
-
|
|
1161
|
+
if (!(error instanceof Error))
|
|
1162
|
+
throw error;
|
|
1163
|
+
console.error(error.message);
|
|
1164
|
+
yield this.adapter.save(`products/_doc/${product.id}`, product.toPlain());
|
|
1798
1165
|
}
|
|
1799
1166
|
});
|
|
1800
1167
|
}
|
|
1801
|
-
|
|
1802
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1803
|
-
try {
|
|
1804
|
-
yield this.adapter.update(this.index, product.id, product);
|
|
1805
|
-
}
|
|
1806
|
-
catch (error) {
|
|
1807
|
-
console.error(error);
|
|
1808
|
-
}
|
|
1809
|
-
});
|
|
1810
|
-
}
|
|
1811
|
-
delete(id) {
|
|
1168
|
+
delete(product) {
|
|
1812
1169
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1170
|
+
if (!product.firestoreId)
|
|
1171
|
+
return;
|
|
1813
1172
|
try {
|
|
1814
|
-
yield this.
|
|
1173
|
+
yield this.get(product.firestoreId);
|
|
1174
|
+
yield this.adapter.delete(`products/_doc/${product.firestoreId}`);
|
|
1815
1175
|
}
|
|
1816
1176
|
catch (error) {
|
|
1817
|
-
|
|
1177
|
+
yield this.adapter.delete(`products/_doc/${product.id}`);
|
|
1818
1178
|
}
|
|
1819
1179
|
});
|
|
1820
1180
|
}
|
|
@@ -1842,30 +1202,20 @@ const withFirestore = (MixinBase) => {
|
|
|
1842
1202
|
? data[key].map((element) => (isObjectsAndNoDate(element) ? bindAllDateFromObject(element) : element))
|
|
1843
1203
|
: bindDate(data[key], key) })), {});
|
|
1844
1204
|
};
|
|
1845
|
-
const omitByRecursivelyInPlace = (value, iteratee) => {
|
|
1846
|
-
each(value, (v, k) => {
|
|
1847
|
-
if (iteratee(v, k)) {
|
|
1848
|
-
unset(value, k);
|
|
1849
|
-
}
|
|
1850
|
-
else if (isObject(v)) {
|
|
1851
|
-
omitByRecursivelyInPlace(v, iteratee);
|
|
1852
|
-
}
|
|
1853
|
-
});
|
|
1854
|
-
return value;
|
|
1855
|
-
};
|
|
1856
1205
|
return class extends MixinBase {
|
|
1206
|
+
constructor() {
|
|
1207
|
+
super(...arguments);
|
|
1208
|
+
this.collectionName = '';
|
|
1209
|
+
}
|
|
1857
1210
|
collection(path) {
|
|
1858
|
-
return this.firestore
|
|
1211
|
+
return collection(this.firestore, path || this.collectionName).withConverter(this.buildModelInstance());
|
|
1859
1212
|
}
|
|
1860
1213
|
buildModelInstance() {
|
|
1861
1214
|
return {
|
|
1862
|
-
toFirestore: (data) =>
|
|
1863
|
-
const plain = (data === null || data === void 0 ? void 0 : data.toPlain) ? data.toPlain() : data;
|
|
1864
|
-
return omitByRecursivelyInPlace(plain, (value) => value === undefined);
|
|
1865
|
-
},
|
|
1215
|
+
toFirestore: (data) => ((data === null || data === void 0 ? void 0 : data.toPlain) ? data.toPlain() : data),
|
|
1866
1216
|
fromFirestore: (snap) => {
|
|
1867
1217
|
const data = snap.data();
|
|
1868
|
-
let bindedData;
|
|
1218
|
+
let bindedData = null;
|
|
1869
1219
|
try {
|
|
1870
1220
|
const ids = { id: snap.id };
|
|
1871
1221
|
bindedData = bindAllDateFromObject(data);
|
|
@@ -1903,10 +1253,8 @@ const withGetFirestore = (MixinBase) => {
|
|
|
1903
1253
|
return class GetFirestore extends MixinBase {
|
|
1904
1254
|
get(identifiers) {
|
|
1905
1255
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1906
|
-
const
|
|
1907
|
-
|
|
1908
|
-
.get();
|
|
1909
|
-
const data = doc.data();
|
|
1256
|
+
const docRef = yield getDoc(doc(yield this.collection(this.buildCollectionPathForGet(identifiers)), Object.values(identifiers).shift().toString()));
|
|
1257
|
+
const data = docRef.data();
|
|
1910
1258
|
if (isNil(data))
|
|
1911
1259
|
throw new NotFoundError(`Document ${JSON.stringify(identifiers)} not found`);
|
|
1912
1260
|
return data;
|
|
@@ -1941,10 +1289,13 @@ const withFindFirestore = (MixinBase) => {
|
|
|
1941
1289
|
return class FindFirestore extends MixinBase {
|
|
1942
1290
|
constructor() {
|
|
1943
1291
|
super(...arguments);
|
|
1944
|
-
this.makeFirestoreWhere = (
|
|
1945
|
-
|
|
1292
|
+
this.makeFirestoreWhere = (filter) => Object.keys(filter).reduce((queries, fieldName) => [
|
|
1293
|
+
...queries,
|
|
1294
|
+
...this.buildWhereSentence(fieldName, is(filter[fieldName])),
|
|
1295
|
+
], []);
|
|
1296
|
+
this.buildWhereSentence = (fieldName, options) => {
|
|
1946
1297
|
if (this.isSubCollection(this) && fieldName === this.parentIdField)
|
|
1947
|
-
|
|
1298
|
+
[];
|
|
1948
1299
|
const value = (options === null || options === void 0 ? void 0 : options.value) || options;
|
|
1949
1300
|
const object = {};
|
|
1950
1301
|
set(object, fieldName, value);
|
|
@@ -1954,41 +1305,49 @@ const withFindFirestore = (MixinBase) => {
|
|
|
1954
1305
|
: Object.keys(plainInstance).find((key) => plainInstance[key]);
|
|
1955
1306
|
if ((options === null || options === void 0 ? void 0 : options.operator) === Where.LIKE) {
|
|
1956
1307
|
if (Array.isArray(options === null || options === void 0 ? void 0 : options.value) &&
|
|
1957
|
-
(this.fields[firestoreFieldName] ===
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
return
|
|
1308
|
+
(this.fields[firestoreFieldName] ===
|
|
1309
|
+
FirestoreFieldType.Array ||
|
|
1310
|
+
!this.fields[firestoreFieldName]))
|
|
1311
|
+
return [where(firestoreFieldName, 'array-contains-any', options.value)];
|
|
1312
|
+
return [where(firestoreFieldName, '>=', options.value), where(firestoreFieldName, '<=', `${options.value}~`)];
|
|
1962
1313
|
}
|
|
1963
1314
|
if ((options === null || options === void 0 ? void 0 : options.operator) === Where.IN &&
|
|
1964
1315
|
Array.isArray(options === null || options === void 0 ? void 0 : options.value) &&
|
|
1965
|
-
(this.fields[firestoreFieldName] === FirestoreFieldType.Array ||
|
|
1966
|
-
|
|
1316
|
+
(this.fields[firestoreFieldName] === FirestoreFieldType.Array ||
|
|
1317
|
+
!this.fields[firestoreFieldName]))
|
|
1318
|
+
return [where(firestoreFieldName, 'array-contains', options.value)];
|
|
1967
1319
|
if (isObject(options) && isNil(options === null || options === void 0 ? void 0 : options.operator) && isNil(options === null || options === void 0 ? void 0 : options.value)) {
|
|
1968
|
-
return Object.keys(options).reduce((
|
|
1320
|
+
return Object.keys(options).reduce((queries, key) => [
|
|
1321
|
+
...queries,
|
|
1322
|
+
...this.buildWhereSentence(`${fieldName.toString()}.${key}`, is(options)[key]),
|
|
1323
|
+
], []);
|
|
1969
1324
|
}
|
|
1970
|
-
return
|
|
1325
|
+
return [where(firestoreFieldName, (options === null || options === void 0 ? void 0 : options.operator) || '==', (options === null || options === void 0 ? void 0 : options.value) || options)];
|
|
1326
|
+
};
|
|
1327
|
+
this.makeFirestoreOrderBy = (filters, fieldsToOrderBy) => {
|
|
1328
|
+
const orderByKeys = Object.keys(fieldsToOrderBy || {});
|
|
1329
|
+
if (!orderByKeys.length)
|
|
1330
|
+
return [];
|
|
1331
|
+
const filtersKeysWithUnordered = Object.keys(filters || {}).filter((filterKey) => !orderByKeys.includes(filterKey));
|
|
1332
|
+
if (filtersKeysWithUnordered.length)
|
|
1333
|
+
filtersKeysWithUnordered.forEach((filterKey) => (fieldsToOrderBy = Object.assign(Object.assign({}, (![Where.EQUALS].includes(is(filters[filterKey]).operator)
|
|
1334
|
+
? { [filterKey]: 'asc' }
|
|
1335
|
+
: {})), fieldsToOrderBy)));
|
|
1336
|
+
return Object.keys(fieldsToOrderBy).map((fieldName) => orderBy(fieldName, fieldsToOrderBy[fieldName]));
|
|
1971
1337
|
};
|
|
1972
1338
|
}
|
|
1973
|
-
find({ filters, limits, orderBy,
|
|
1974
|
-
var _a;
|
|
1339
|
+
find({ filters, limits, orderBy, } = {}) {
|
|
1975
1340
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1976
|
-
const
|
|
1977
|
-
const
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
if (filtersKeysWithUnordered.length)
|
|
1983
|
-
filtersKeysWithUnordered.forEach((filterKey) => (orderBy = Object.assign(Object.assign({}, (![Where.EQUALS].includes(filters[filterKey].operator) ? { [filterKey]: 'asc' } : {})), orderBy)));
|
|
1984
|
-
Object.keys(orderBy).forEach((fieldName) => (query = query.orderBy(fieldName, orderBy[fieldName])));
|
|
1985
|
-
}
|
|
1986
|
-
query = yield this.defineLimits(query, filters, limits);
|
|
1987
|
-
const docs = yield query.get();
|
|
1341
|
+
const collection = this.collection(this.buildCollectionPathForFind(filters));
|
|
1342
|
+
const queries = this.makeFirestoreWhere(filters || {});
|
|
1343
|
+
const ordination = this.makeFirestoreOrderBy(filters, orderBy);
|
|
1344
|
+
const offsets = yield this.defineLimits(filters, limits);
|
|
1345
|
+
const queryArgumments = [...queries, ...ordination, ...offsets];
|
|
1346
|
+
const docs = yield getDocs(query(collection, ...queryArgumments));
|
|
1988
1347
|
const data = docs.docs.map((doc) => doc.data());
|
|
1989
1348
|
return {
|
|
1990
1349
|
data,
|
|
1991
|
-
count:
|
|
1350
|
+
count: this.calculateCount(data, limits),
|
|
1992
1351
|
};
|
|
1993
1352
|
});
|
|
1994
1353
|
}
|
|
@@ -1999,19 +1358,19 @@ const withFindFirestore = (MixinBase) => {
|
|
|
1999
1358
|
const parentId = getValueFromFilter(filters === null || filters === void 0 ? void 0 : filters[parentIdField]);
|
|
2000
1359
|
return `${this.parentRepository.collectionName}/${parentId}/${this.collectionName}`;
|
|
2001
1360
|
}
|
|
2002
|
-
defineLimits(
|
|
1361
|
+
defineLimits(filters, limits) {
|
|
1362
|
+
var _a;
|
|
2003
1363
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1364
|
+
const queries = [];
|
|
2004
1365
|
if (limits === null || limits === void 0 ? void 0 : limits.offset) {
|
|
2005
1366
|
if (this.model.isModel(limits.offset))
|
|
2006
|
-
|
|
2007
|
-
.doc(limits.offset[limits.offset.identifiersFields.shift()])
|
|
2008
|
-
.get());
|
|
1367
|
+
queries.push(startAfter(yield getDoc(doc(this.collection(this.buildCollectionPathForFind(filters)), limits.offset.identifier[(_a = limits.offset.identifiersFields) === null || _a === void 0 ? void 0 : _a.shift()]))));
|
|
2009
1368
|
else if (isNumber(limits.offset) || isString(limits.offset))
|
|
2010
|
-
|
|
1369
|
+
queries.push(startAt(limits.offset));
|
|
2011
1370
|
}
|
|
2012
1371
|
if (limits === null || limits === void 0 ? void 0 : limits.limit)
|
|
2013
|
-
|
|
2014
|
-
return
|
|
1372
|
+
queries.push(limit(limits.limit));
|
|
1373
|
+
return queries;
|
|
2015
1374
|
});
|
|
2016
1375
|
}
|
|
2017
1376
|
calculateCount(data, limits) {
|
|
@@ -2029,19 +1388,20 @@ const withCreateFirestore = (MixinBase) => {
|
|
|
2029
1388
|
create(data) {
|
|
2030
1389
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2031
1390
|
const docRef = yield this.save(this.model.toInstance(data));
|
|
2032
|
-
const doc = yield docRef
|
|
1391
|
+
const doc = yield getDoc(docRef);
|
|
2033
1392
|
return doc.data();
|
|
2034
1393
|
});
|
|
2035
1394
|
}
|
|
2036
1395
|
save(data) {
|
|
2037
1396
|
var _a, _b;
|
|
2038
1397
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2039
|
-
const id = (_b = (_a =
|
|
1398
|
+
const id = (_b = data.identifier[(_a = data.identifiersFields) === null || _a === void 0 ? void 0 : _a.shift()]) === null || _b === void 0 ? void 0 : _b.toString();
|
|
2040
1399
|
const collectionPath = this.buildCollectionPathForAdd(data);
|
|
1400
|
+
const collection = this.collection(collectionPath);
|
|
2041
1401
|
if (isEmpty(id))
|
|
2042
|
-
return
|
|
2043
|
-
const docRef =
|
|
2044
|
-
yield docRef
|
|
1402
|
+
return addDoc(collection, data);
|
|
1403
|
+
const docRef = doc(collection, id);
|
|
1404
|
+
yield setDoc(docRef, data);
|
|
2045
1405
|
return docRef;
|
|
2046
1406
|
});
|
|
2047
1407
|
}
|
|
@@ -2054,30 +1414,36 @@ const withCreateFirestore = (MixinBase) => {
|
|
|
2054
1414
|
};
|
|
2055
1415
|
|
|
2056
1416
|
const withUpdateFirestore = (MixinBase) => {
|
|
2057
|
-
const getValueFromParams = (params, field) => {
|
|
1417
|
+
const getValueFromParams = (params, field) => {
|
|
1418
|
+
var _a;
|
|
1419
|
+
return (isNil((_a = is(params[field])) === null || _a === void 0 ? void 0 : _a.value)
|
|
1420
|
+
? is(params[field])
|
|
1421
|
+
: is(params[field]).value) || null;
|
|
1422
|
+
};
|
|
2058
1423
|
const getValueByAction = (options) => {
|
|
2059
|
-
|
|
2060
|
-
if (isNil(options.action))
|
|
1424
|
+
if (isNil(options === null || options === void 0 ? void 0 : options.action))
|
|
2061
1425
|
return options;
|
|
2062
|
-
if (options.action === UpdateOptionActions.REMOVE_FIELD)
|
|
2063
|
-
return
|
|
2064
|
-
if (
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
if (options.action === UpdateOptionActions.
|
|
2068
|
-
return
|
|
1426
|
+
if ((options === null || options === void 0 ? void 0 : options.action) === UpdateOptionActions.REMOVE_FIELD)
|
|
1427
|
+
return deleteField();
|
|
1428
|
+
if ((options === null || options === void 0 ? void 0 : options.action) === UpdateOptionActions.NULL)
|
|
1429
|
+
return null;
|
|
1430
|
+
if (Array.isArray(options === null || options === void 0 ? void 0 : options.value)) {
|
|
1431
|
+
if ((options === null || options === void 0 ? void 0 : options.action) === UpdateOptionActions.MERGE)
|
|
1432
|
+
return arrayUnion(...options.value);
|
|
1433
|
+
if ((options === null || options === void 0 ? void 0 : options.action) === UpdateOptionActions.REMOVE)
|
|
1434
|
+
return arrayRemove(...options.value);
|
|
2069
1435
|
}
|
|
2070
|
-
return options.value;
|
|
1436
|
+
return options === null || options === void 0 ? void 0 : options.value;
|
|
2071
1437
|
};
|
|
2072
1438
|
return class UpdateFirestore extends MixinBase {
|
|
2073
1439
|
update(data) {
|
|
2074
1440
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2075
1441
|
const model = new this.model();
|
|
2076
1442
|
const keyField = model.identifiersFields.shift();
|
|
2077
|
-
const docRef = this.collection(this.buildCollectionPathForUpdate(data))
|
|
2078
|
-
yield docRef
|
|
2079
|
-
const
|
|
2080
|
-
return
|
|
1443
|
+
const docRef = doc(this.collection(this.buildCollectionPathForUpdate(data)), getValueFromParams(data, keyField).toString());
|
|
1444
|
+
yield setDoc(docRef, this.paramsToPlain(data), { merge: true });
|
|
1445
|
+
const docData = yield getDoc(docRef);
|
|
1446
|
+
return docData.data();
|
|
2081
1447
|
});
|
|
2082
1448
|
}
|
|
2083
1449
|
buildCollectionPathForUpdate(identifiers) {
|
|
@@ -2089,7 +1455,7 @@ const withUpdateFirestore = (MixinBase) => {
|
|
|
2089
1455
|
const model = this.model;
|
|
2090
1456
|
if (model.isModel(params))
|
|
2091
1457
|
return params.toPlain();
|
|
2092
|
-
return Object.keys(params).reduce((data, currentKey) => (Object.assign(Object.assign({}, data), { [currentKey]: getValueByAction(params[currentKey])
|
|
1458
|
+
return Object.keys(params).reduce((data, currentKey) => (Object.assign(Object.assign({}, data), ((value) => (value === undefined ? {} : { [currentKey]: value }))(getValueByAction(params[currentKey])))), {});
|
|
2093
1459
|
}
|
|
2094
1460
|
};
|
|
2095
1461
|
};
|
|
@@ -2098,9 +1464,7 @@ const withDeleteFirestore = (MixinBase) => {
|
|
|
2098
1464
|
return class DeleteFirestore extends MixinBase {
|
|
2099
1465
|
delete(identifiers) {
|
|
2100
1466
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2101
|
-
yield this.collection(this.buildCollectionPathForRemove(identifiers))
|
|
2102
|
-
.doc(Object.values(identifiers).shift().toString())
|
|
2103
|
-
.delete();
|
|
1467
|
+
yield deleteDoc(doc(this.collection(this.buildCollectionPathForRemove(identifiers)), Object.values(identifiers).shift().toString()));
|
|
2104
1468
|
});
|
|
2105
1469
|
}
|
|
2106
1470
|
buildCollectionPathForRemove(identifiers) {
|
|
@@ -2226,22 +1590,13 @@ class UserFirestoreRepository extends withCrudFirestore(withHelpers(withFirestor
|
|
|
2226
1590
|
}
|
|
2227
1591
|
getBeautyProfile(userId) {
|
|
2228
1592
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2229
|
-
const beautyProfile = yield this.collection()
|
|
2230
|
-
.doc(userId)
|
|
2231
|
-
.collection('CX')
|
|
2232
|
-
.withConverter(this.buildBeautyProfileModelInstance())
|
|
2233
|
-
.doc('beautyProfile')
|
|
2234
|
-
.get();
|
|
1593
|
+
const beautyProfile = yield getDoc(doc(this.collection(`${this.collectionName}/${userId}/CX`).withConverter(this.buildBeautyProfileModelInstance()), 'beautyProfile'));
|
|
2235
1594
|
return beautyProfile.data();
|
|
2236
1595
|
});
|
|
2237
1596
|
}
|
|
2238
1597
|
checkIfIsSubscriber(userId) {
|
|
2239
1598
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2240
|
-
const docs = yield this.
|
|
2241
|
-
.collection('subscription')
|
|
2242
|
-
.where('user.id', '==', userId)
|
|
2243
|
-
.where('status', '==', 'active')
|
|
2244
|
-
.get();
|
|
1599
|
+
const docs = yield getDocs(query(this.collection('subscription'), where('user.id', '==', userId), where('status', '==', 'active')));
|
|
2245
1600
|
return !!docs && !!docs.size;
|
|
2246
1601
|
});
|
|
2247
1602
|
}
|
|
@@ -2272,33 +1627,25 @@ class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFire
|
|
|
2272
1627
|
this.model = Category;
|
|
2273
1628
|
}
|
|
2274
1629
|
getCategoryBySlug(slug, shop) {
|
|
2275
|
-
return this
|
|
2276
|
-
.where('slug', '==', slug)
|
|
2277
|
-
.
|
|
2278
|
-
.where('published', '==', true)
|
|
2279
|
-
.get()
|
|
2280
|
-
.then((snap) => {
|
|
2281
|
-
if (snap.size > 1)
|
|
1630
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1631
|
+
const categoryDocs = yield getDocs(query(this.collection(this.collectionName), where('slug', '==', slug), where('shop', '==', shop), where('published', '==', true)));
|
|
1632
|
+
if (categoryDocs.size > 1)
|
|
2282
1633
|
throw new DuplicatedResultsError('Query returned duplicated values');
|
|
2283
|
-
if (
|
|
1634
|
+
if (categoryDocs.empty)
|
|
2284
1635
|
throw new NotFoundError(`Document with slug ${slug} not found`);
|
|
2285
|
-
return
|
|
2286
|
-
})
|
|
2287
|
-
.catch((error) => error);
|
|
1636
|
+
return categoryDocs.docs[0].data();
|
|
1637
|
+
});
|
|
2288
1638
|
}
|
|
2289
|
-
getCategoriesForHome(categoryIds, limit = 4
|
|
1639
|
+
getCategoriesForHome(categoryIds, limit = 4) {
|
|
2290
1640
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2291
|
-
const categorySnap = yield this.collection(this.collectionName)
|
|
2292
|
-
.where('id', 'in', categoryIds.filter(Boolean))
|
|
2293
|
-
.where('published', '==', true)
|
|
2294
|
-
.get();
|
|
1641
|
+
const categorySnap = yield getDocs(query(this.collection(this.collectionName), where('id', 'in', categoryIds.filter(Boolean)), where('published', '==', true)));
|
|
2295
1642
|
if (categorySnap.empty)
|
|
2296
1643
|
throw new NotFoundError('Categories not found');
|
|
2297
1644
|
const categories = categorySnap.docs.map((doc) => doc.data());
|
|
2298
1645
|
const homeSections = yield Promise.all(categories.map((category) => __awaiter(this, void 0, void 0, function* () {
|
|
2299
1646
|
return ({
|
|
2300
1647
|
category,
|
|
2301
|
-
products: yield this.mountCategory(category, { limit, hasStock: true
|
|
1648
|
+
products: yield this.mountCategory(category, { limit, hasStock: true }),
|
|
2302
1649
|
});
|
|
2303
1650
|
})));
|
|
2304
1651
|
return homeSections;
|
|
@@ -2310,35 +1657,23 @@ class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFire
|
|
|
2310
1657
|
throw new RequiredArgumentError(['Category products is empty']);
|
|
2311
1658
|
const chunks = chunk(category.products, 10);
|
|
2312
1659
|
const products = [];
|
|
1660
|
+
const wheres = [];
|
|
2313
1661
|
for (const productIds of chunks) {
|
|
2314
1662
|
if ((options === null || options === void 0 ? void 0 : options.limit) && products.length >= (options === null || options === void 0 ? void 0 : options.limit))
|
|
2315
1663
|
break;
|
|
2316
|
-
|
|
2317
|
-
.where('published', '==', true)
|
|
2318
|
-
.where('id', 'in', productIds);
|
|
1664
|
+
wheres.push(where('published', '==', true), where('id', 'in', productIds));
|
|
2319
1665
|
if (options === null || options === void 0 ? void 0 : options.hasStock)
|
|
2320
|
-
|
|
2321
|
-
if (options === null || options === void 0 ? void 0 : options.gender)
|
|
2322
|
-
query = query.where('tags', 'array-contains', options === null || options === void 0 ? void 0 : options.gender);
|
|
1666
|
+
wheres.push(where('stock.quantity', '>', 0));
|
|
2323
1667
|
if (options === null || options === void 0 ? void 0 : options.limit)
|
|
2324
|
-
|
|
2325
|
-
const productSnap = yield query.
|
|
1668
|
+
wheres.push(limit(options === null || options === void 0 ? void 0 : options.limit));
|
|
1669
|
+
const productSnap = yield getDocs(query(this.collection('productsErpVitrine'), ...wheres));
|
|
2326
1670
|
if (productSnap.empty)
|
|
2327
1671
|
continue;
|
|
2328
|
-
products.push(...productSnap.docs
|
|
1672
|
+
products.push(...productSnap.docs);
|
|
2329
1673
|
}
|
|
2330
|
-
return products;
|
|
1674
|
+
return is(products);
|
|
2331
1675
|
});
|
|
2332
1676
|
}
|
|
2333
|
-
getCategoryByShop(shop) {
|
|
2334
|
-
return;
|
|
2335
|
-
}
|
|
2336
|
-
getChildren(parentId) {
|
|
2337
|
-
return;
|
|
2338
|
-
}
|
|
2339
|
-
isChild(id, parentId) {
|
|
2340
|
-
return;
|
|
2341
|
-
}
|
|
2342
1677
|
}
|
|
2343
1678
|
|
|
2344
1679
|
class ProductFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
@@ -2382,17 +1717,12 @@ class ProductFirestoreRepository extends withCrudFirestore(withHelpers(withFires
|
|
|
2382
1717
|
return this.reviews.rejected.push(Object.assign(Object.assign({}, review), productInfo));
|
|
2383
1718
|
if (!!review.status)
|
|
2384
1719
|
return this.reviews.approved.push(Object.assign(Object.assign({}, review), productInfo));
|
|
1720
|
+
return review;
|
|
2385
1721
|
});
|
|
2386
1722
|
});
|
|
2387
1723
|
return this.reviews[status];
|
|
2388
1724
|
});
|
|
2389
1725
|
}
|
|
2390
|
-
cleanShoppingCountFromIds(ids) {
|
|
2391
|
-
return;
|
|
2392
|
-
}
|
|
2393
|
-
findCatalog(params) {
|
|
2394
|
-
return this.find(params);
|
|
2395
|
-
}
|
|
2396
1726
|
}
|
|
2397
1727
|
|
|
2398
1728
|
class ProductVariantFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), Product) {
|
|
@@ -2415,33 +1745,6 @@ class SubscriptionProductFirestoreRepository extends withCrudFirestore(withHelpe
|
|
|
2415
1745
|
}
|
|
2416
1746
|
}
|
|
2417
1747
|
|
|
2418
|
-
class Buy2WinFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
2419
|
-
constructor(firestore) {
|
|
2420
|
-
super();
|
|
2421
|
-
this.firestore = firestore;
|
|
2422
|
-
this.collectionName = 'buy2win';
|
|
2423
|
-
this.model = Buy2Win;
|
|
2424
|
-
}
|
|
2425
|
-
}
|
|
2426
|
-
|
|
2427
|
-
class CampaignDashboardFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
2428
|
-
constructor(firestore) {
|
|
2429
|
-
super();
|
|
2430
|
-
this.firestore = firestore;
|
|
2431
|
-
this.collectionName = 'dashboardCampaignsAuto';
|
|
2432
|
-
this.model = CampaignDashboard;
|
|
2433
|
-
}
|
|
2434
|
-
}
|
|
2435
|
-
|
|
2436
|
-
class CampaignHashtagFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
2437
|
-
constructor(firestore) {
|
|
2438
|
-
super();
|
|
2439
|
-
this.firestore = firestore;
|
|
2440
|
-
this.collectionName = 'hashtagCampaignsAuto';
|
|
2441
|
-
this.model = CampaignHashtag;
|
|
2442
|
-
}
|
|
2443
|
-
}
|
|
2444
|
-
|
|
2445
1748
|
class CheckoutFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
2446
1749
|
constructor(firestore) {
|
|
2447
1750
|
super();
|
|
@@ -2451,15 +1754,6 @@ class CheckoutFirestoreRepository extends withCrudFirestore(withHelpers(withFire
|
|
|
2451
1754
|
}
|
|
2452
1755
|
}
|
|
2453
1756
|
|
|
2454
|
-
class CheckoutSubscriptionFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
2455
|
-
constructor(firestore) {
|
|
2456
|
-
super();
|
|
2457
|
-
this.firestore = firestore;
|
|
2458
|
-
this.collectionName = 'checkoutsSubscription';
|
|
2459
|
-
this.model = CheckoutSubscription;
|
|
2460
|
-
}
|
|
2461
|
-
}
|
|
2462
|
-
|
|
2463
1757
|
class CouponFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
2464
1758
|
constructor(firestore) {
|
|
2465
1759
|
super();
|
|
@@ -2494,11 +1788,10 @@ class OrderFirestoreRepository extends withCrudFirestore(withHelpers(withFiresto
|
|
|
2494
1788
|
var _a;
|
|
2495
1789
|
if (!!((_a = order === null || order === void 0 ? void 0 : order.lineItems) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
2496
1790
|
order.lineItems = order.lineItems.map((lineItem) => {
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
lineItem
|
|
2501
|
-
}
|
|
1791
|
+
const prices = !!lineItem.price;
|
|
1792
|
+
const shopPrice = prices[order.shop];
|
|
1793
|
+
if (!!shopPrice)
|
|
1794
|
+
lineItem.price = shopPrice;
|
|
2502
1795
|
return lineItem;
|
|
2503
1796
|
});
|
|
2504
1797
|
}
|
|
@@ -2522,20 +1815,21 @@ class OrderFirestoreRepository extends withCrudFirestore(withHelpers(withFiresto
|
|
|
2522
1815
|
}
|
|
2523
1816
|
}
|
|
2524
1817
|
|
|
2525
|
-
class
|
|
1818
|
+
class PaymentFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
2526
1819
|
constructor(firestore) {
|
|
2527
|
-
super(
|
|
1820
|
+
super();
|
|
2528
1821
|
this.firestore = firestore;
|
|
2529
|
-
this.collectionName = '
|
|
1822
|
+
this.collectionName = 'payments';
|
|
1823
|
+
this.model = Payment;
|
|
2530
1824
|
}
|
|
2531
1825
|
}
|
|
2532
1826
|
|
|
2533
|
-
class
|
|
1827
|
+
class CheckoutSubscriptionFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
2534
1828
|
constructor(firestore) {
|
|
2535
1829
|
super();
|
|
2536
1830
|
this.firestore = firestore;
|
|
2537
|
-
this.collectionName = '
|
|
2538
|
-
this.model =
|
|
1831
|
+
this.collectionName = 'checkoutsSubscription';
|
|
1832
|
+
this.model = CheckoutSubscription;
|
|
2539
1833
|
}
|
|
2540
1834
|
}
|
|
2541
1835
|
|
|
@@ -2548,21 +1842,20 @@ class SubscriptionPlanFirestoreRepository extends withCrudFirestore(withHelpers(
|
|
|
2548
1842
|
}
|
|
2549
1843
|
}
|
|
2550
1844
|
|
|
2551
|
-
class
|
|
1845
|
+
class Buy2WinFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
2552
1846
|
constructor(firestore) {
|
|
2553
1847
|
super();
|
|
2554
1848
|
this.firestore = firestore;
|
|
2555
|
-
this.collectionName = '
|
|
2556
|
-
this.model =
|
|
1849
|
+
this.collectionName = 'buy2win';
|
|
1850
|
+
this.model = Buy2Win;
|
|
2557
1851
|
}
|
|
2558
1852
|
}
|
|
2559
1853
|
|
|
2560
|
-
class
|
|
1854
|
+
class LegacyOrderFirestoreRepository extends OrderFirestoreRepository {
|
|
2561
1855
|
constructor(firestore) {
|
|
2562
|
-
super();
|
|
1856
|
+
super(firestore);
|
|
2563
1857
|
this.firestore = firestore;
|
|
2564
|
-
this.collectionName = '
|
|
2565
|
-
this.model = Campaign;
|
|
1858
|
+
this.collectionName = 'legacyOrders';
|
|
2566
1859
|
}
|
|
2567
1860
|
}
|
|
2568
1861
|
|
|
@@ -2590,9 +1883,9 @@ class HomeFirestoreRepository extends withCrudFirestore(withHelpers(withFirestor
|
|
|
2590
1883
|
home.data.data.featuredProducts = home.data.data.featuredProducts.map(this.plainToHomeCategoryGroup);
|
|
2591
1884
|
home.data.data.verticalProducts = home.data.data.verticalProducts.map(this.plainToHomeCategoryGroup);
|
|
2592
1885
|
home.data.createdAt =
|
|
2593
|
-
home.data.createdAt instanceof
|
|
1886
|
+
home.data.createdAt instanceof Timestamp ? home.data.createdAt.toDate() : home.data.createdAt;
|
|
2594
1887
|
home.data.expiresAt =
|
|
2595
|
-
home.data.expiresAt instanceof
|
|
1888
|
+
home.data.expiresAt instanceof Timestamp ? home.data.expiresAt.toDate() : home.data.expiresAt;
|
|
2596
1889
|
}
|
|
2597
1890
|
return home;
|
|
2598
1891
|
};
|
|
@@ -2614,25 +1907,16 @@ class HomeFirestoreRepository extends withCrudFirestore(withHelpers(withFirestor
|
|
|
2614
1907
|
const instance = fromFirestore(snap);
|
|
2615
1908
|
return this.homeFromFirestore(instance);
|
|
2616
1909
|
},
|
|
2617
|
-
};
|
|
2618
|
-
}
|
|
2619
|
-
}
|
|
2620
|
-
|
|
2621
|
-
class ShopMenuFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
2622
|
-
constructor(firestore) {
|
|
2623
|
-
super();
|
|
2624
|
-
this.firestore = firestore;
|
|
2625
|
-
this.collectionName = 'shopMenus';
|
|
2626
|
-
this.model = ShopMenu;
|
|
1910
|
+
};
|
|
2627
1911
|
}
|
|
2628
1912
|
}
|
|
2629
1913
|
|
|
2630
|
-
class
|
|
1914
|
+
class ShopMenuFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
2631
1915
|
constructor(firestore) {
|
|
2632
1916
|
super();
|
|
2633
1917
|
this.firestore = firestore;
|
|
2634
|
-
this.collectionName = '
|
|
2635
|
-
this.model =
|
|
1918
|
+
this.collectionName = 'shopMenus';
|
|
1919
|
+
this.model = ShopMenu;
|
|
2636
1920
|
}
|
|
2637
1921
|
}
|
|
2638
1922
|
|
|
@@ -2642,7 +1926,7 @@ class AuthenticationFirebaseAuthService {
|
|
|
2642
1926
|
}
|
|
2643
1927
|
signInWithEmailAndPassword(data) {
|
|
2644
1928
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2645
|
-
const credentials = yield this.firebaseAuth
|
|
1929
|
+
const credentials = yield signInWithEmailAndPassword(this.firebaseAuth, data.email, data.password);
|
|
2646
1930
|
const user = credentials.user;
|
|
2647
1931
|
return {
|
|
2648
1932
|
id: user.uid,
|
|
@@ -2655,7 +1939,7 @@ class AuthenticationFirebaseAuthService {
|
|
|
2655
1939
|
}
|
|
2656
1940
|
signInWithGoogle() {
|
|
2657
1941
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2658
|
-
const credentials = yield this.firebaseAuth
|
|
1942
|
+
const credentials = yield signInWithPopup(this.firebaseAuth, new GoogleAuthProvider());
|
|
2659
1943
|
const user = credentials.user;
|
|
2660
1944
|
return {
|
|
2661
1945
|
id: user.uid,
|
|
@@ -2673,7 +1957,7 @@ class AuthenticationFirebaseAuthService {
|
|
|
2673
1957
|
}
|
|
2674
1958
|
signInAnonymously() {
|
|
2675
1959
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2676
|
-
const auth = yield this.firebaseAuth
|
|
1960
|
+
const auth = yield signInAnonymously(this.firebaseAuth);
|
|
2677
1961
|
const user = auth.user;
|
|
2678
1962
|
user.id = auth.user.uid;
|
|
2679
1963
|
return user;
|
|
@@ -2681,7 +1965,7 @@ class AuthenticationFirebaseAuthService {
|
|
|
2681
1965
|
}
|
|
2682
1966
|
sendPasswordResetEmail(email) {
|
|
2683
1967
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2684
|
-
return this.firebaseAuth
|
|
1968
|
+
return sendPasswordResetEmail(this.firebaseAuth, email);
|
|
2685
1969
|
});
|
|
2686
1970
|
}
|
|
2687
1971
|
}
|
|
@@ -2692,17 +1976,24 @@ class RegisterFirebaseAuthService {
|
|
|
2692
1976
|
}
|
|
2693
1977
|
register(params) {
|
|
2694
1978
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1979
|
+
if (!params.email)
|
|
1980
|
+
throw new RequiredArgumentError(['email']);
|
|
2695
1981
|
try {
|
|
2696
|
-
const auth = yield this.firebaseAuth
|
|
2697
|
-
const user = auth.user;
|
|
2698
|
-
user
|
|
2699
|
-
|
|
1982
|
+
const auth = yield createUserWithEmailAndPassword(this.firebaseAuth, params.email, params.password);
|
|
1983
|
+
const user = is(auth.user);
|
|
1984
|
+
if (!user)
|
|
1985
|
+
throw new Error('User not created');
|
|
1986
|
+
yield sendEmailVerification(user);
|
|
1987
|
+
user.id = user.uid;
|
|
2700
1988
|
return user;
|
|
2701
1989
|
}
|
|
2702
1990
|
catch (error) {
|
|
2703
|
-
if (error
|
|
1991
|
+
if (!(error instanceof Error))
|
|
1992
|
+
throw error;
|
|
1993
|
+
const firebaseError = error;
|
|
1994
|
+
if (firebaseError.code === 'auth/email-already-in-use')
|
|
2704
1995
|
throw new UserAlreadyRegisteredError('Email already registered');
|
|
2705
|
-
if (
|
|
1996
|
+
if (firebaseError.code === 'auth/weak-password')
|
|
2706
1997
|
throw new WeakPasswordError();
|
|
2707
1998
|
throw error;
|
|
2708
1999
|
}
|
|
@@ -2713,27 +2004,28 @@ class RegisterFirebaseAuthService {
|
|
|
2713
2004
|
class AttributeOptionHelper {
|
|
2714
2005
|
}
|
|
2715
2006
|
AttributeOptionHelper.FindByAttribute = (attributeName, fields) => {
|
|
2007
|
+
var _a;
|
|
2716
2008
|
if (fields.includes(attributeName))
|
|
2717
|
-
return { columnName: attributeName.toString(), attributeName
|
|
2009
|
+
return { columnName: attributeName.toString(), attributeName };
|
|
2718
2010
|
const field = fields.find((columnOption) => isObject(columnOption) && Object.keys(columnOption).includes(attributeName.toString()));
|
|
2719
|
-
const fieldOption = field === null ||
|
|
2011
|
+
const fieldOption = (_a = is(field)) === null || _a === void 0 ? void 0 : _a[attributeName];
|
|
2720
2012
|
if (isNil(fieldOption))
|
|
2721
2013
|
return { columnName: attributeName.toString(), attributeName };
|
|
2722
2014
|
if (Array.isArray(fieldOption))
|
|
2723
2015
|
return { columnName: attributeName.toString(), attributeName, fields: fieldOption };
|
|
2724
2016
|
return Object.assign({ attributeName, columnName: attributeName.toString() }, fieldOption);
|
|
2725
2017
|
};
|
|
2726
|
-
AttributeOptionHelper.CheckIsColumnOption = (fieldValue) => !!
|
|
2018
|
+
AttributeOptionHelper.CheckIsColumnOption = (fieldValue) => !!fieldValue.columnName;
|
|
2727
2019
|
AttributeOptionHelper.FindColumnOptionFromList = (columnName, fields) => {
|
|
2728
2020
|
if (fields.includes(columnName))
|
|
2729
2021
|
return { columnName, attributeName: columnName };
|
|
2730
|
-
const field = fields.find((
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
|
|
2735
|
-
|
|
2736
|
-
|
|
2022
|
+
const field = is(fields.find((field) => {
|
|
2023
|
+
if (!isObject(field))
|
|
2024
|
+
return false;
|
|
2025
|
+
const columnOption = Object.values(field).find((option) => AttributeOptionHelper.CheckIsColumnOption(option) && option.columnName === columnName ? option : {});
|
|
2026
|
+
return AttributeOptionHelper.CheckIsColumnOption(columnOption) && (columnOption === null || columnOption === void 0 ? void 0 : columnOption.columnName) === columnName;
|
|
2027
|
+
}) || {});
|
|
2028
|
+
const attributeName = Object.keys(field).find((fieldOptionFromList) => AttributeOptionHelper.CheckIsColumnOption(field[fieldOptionFromList]) || Array.isArray(field[fieldOptionFromList]));
|
|
2737
2029
|
const fieldOption = field === null || field === void 0 ? void 0 : field[attributeName];
|
|
2738
2030
|
if (Array.isArray(fieldOption))
|
|
2739
2031
|
return { attributeName: attributeName, fields: fieldOption };
|
|
@@ -2753,6 +2045,8 @@ var HasuraGraphQLWhere;
|
|
|
2753
2045
|
HasuraGraphQLWhere["NOTLIKE"] = "_nlike";
|
|
2754
2046
|
HasuraGraphQLWhere["ISNULL"] = "_is_null";
|
|
2755
2047
|
HasuraGraphQLWhere["ISNOTNULL"] = "_is_null";
|
|
2048
|
+
HasuraGraphQLWhere["JSON_CONTAINS"] = "_contains";
|
|
2049
|
+
HasuraGraphQLWhere["JSON_HAS_KEYS_ANY"] = "_has_keys_any";
|
|
2756
2050
|
})(HasuraGraphQLWhere || (HasuraGraphQLWhere = {}));
|
|
2757
2051
|
|
|
2758
2052
|
var HasuraGraphQLColumnType;
|
|
@@ -2801,23 +2095,22 @@ BindFilterQueryHelper.MakeGraphQLWhere = (filter, fields) => Object.keys(filter)
|
|
|
2801
2095
|
}, {});
|
|
2802
2096
|
BindFilterQueryHelper.BuildWhereSentence = (field, options, fields) => {
|
|
2803
2097
|
const fieldSentenceOptions = AttributeOptionHelper.FindByAttribute(field, fields);
|
|
2804
|
-
|
|
2098
|
+
if (!Array.isArray(options) &&
|
|
2805
2099
|
isObject(options) &&
|
|
2806
2100
|
isNil(options === null || options === void 0 ? void 0 : options.operator) &&
|
|
2807
2101
|
isNil(options === null || options === void 0 ? void 0 : options.value) &&
|
|
2808
|
-
isNil(fieldSentenceOptions === null || fieldSentenceOptions === void 0 ? void 0 : fieldSentenceOptions.to)
|
|
2809
|
-
if (isNestedField)
|
|
2102
|
+
isNil(fieldSentenceOptions === null || fieldSentenceOptions === void 0 ? void 0 : fieldSentenceOptions.to))
|
|
2810
2103
|
return Object.keys(options).reduce((variables, key) => {
|
|
2811
2104
|
const fieldOptions = AttributeOptionHelper.FindByAttribute(key, (fieldSentenceOptions === null || fieldSentenceOptions === void 0 ? void 0 : fieldSentenceOptions.fields) || fields);
|
|
2812
2105
|
const columnName = fieldOptions.columnName;
|
|
2813
2106
|
const columnFields = fieldOptions.fields;
|
|
2814
|
-
return Object.assign(Object.assign({}, variables), { [columnName]: BindFilterQueryHelper.BuildWhereSentence(key, options[key],
|
|
2107
|
+
return Object.assign(Object.assign({}, variables), { [columnName]: BindFilterQueryHelper.BuildWhereSentence(key, is(is(options)[key]), columnFields || []) });
|
|
2815
2108
|
}, {});
|
|
2816
2109
|
if (!Array.isArray(options) && !isNil(fieldSentenceOptions.fields))
|
|
2817
2110
|
return {
|
|
2818
2111
|
[fieldSentenceOptions.fields[0]]: BindFilterQueryHelper.BuildOperatorSentence(options, fieldSentenceOptions),
|
|
2819
2112
|
};
|
|
2820
|
-
if (
|
|
2113
|
+
if (isObject(options) && !FilterOptionHelper.CheckIfIsFilterOption(options))
|
|
2821
2114
|
options = Object.values(options)[0];
|
|
2822
2115
|
return Array.isArray(options)
|
|
2823
2116
|
? options.reduce((whereSentence, option) => (Object.assign(Object.assign({}, whereSentence), BindFilterQueryHelper.BuildOperatorSentence(option, fieldSentenceOptions))), {})
|
|
@@ -2826,20 +2119,18 @@ BindFilterQueryHelper.BuildWhereSentence = (field, options, fields) => {
|
|
|
2826
2119
|
BindFilterQueryHelper.BuildOperatorSentence = (options, fieldOption) => ({
|
|
2827
2120
|
[BindFilterQueryHelper.GetHasuraOperator(options, fieldOption)]: FilterOptionHelper.GetValueFromFilter(options, fieldOption),
|
|
2828
2121
|
});
|
|
2829
|
-
BindFilterQueryHelper.GetHasuraOperator = (options, fieldOption) =>
|
|
2830
|
-
|
|
2831
|
-
|
|
2832
|
-
|
|
2833
|
-
|
|
2834
|
-
|
|
2835
|
-
|
|
2836
|
-
|
|
2837
|
-
|
|
2838
|
-
|
|
2839
|
-
|
|
2840
|
-
|
|
2841
|
-
return HasuraGraphQLWhere[Object.keys(HasuraGraphQLWhere).find((graphQLOperator) => graphQLOperator === Object.keys(Where).find((operator) => Where[operator] === (options === null || options === void 0 ? void 0 : options.operator)))];
|
|
2842
|
-
};
|
|
2122
|
+
BindFilterQueryHelper.GetHasuraOperator = (options, fieldOption) => FilterOptionHelper.CheckIfIsFilterOption(options)
|
|
2123
|
+
? fieldOption.type === HasuraGraphQLColumnType.Jsonb
|
|
2124
|
+
? BindFilterQueryHelper.GetHasuraJsonbOperator(options)
|
|
2125
|
+
: HasuraGraphQLWhere[Object.keys(HasuraGraphQLWhere).find((graphQLOperator) => graphQLOperator ===
|
|
2126
|
+
Object.keys(Where).find((operator) => Where[operator] === (options === null || options === void 0 ? void 0 : options.operator)))]
|
|
2127
|
+
: HasuraGraphQLWhere.EQUALS;
|
|
2128
|
+
BindFilterQueryHelper.GetHasuraJsonbOperator = (options) => options.operator === Where.IN
|
|
2129
|
+
? HasuraGraphQLWhere.JSON_CONTAINS
|
|
2130
|
+
: options.operator === Where.LIKE
|
|
2131
|
+
? HasuraGraphQLWhere.JSON_HAS_KEYS_ANY
|
|
2132
|
+
: HasuraGraphQLWhere[Object.keys(HasuraGraphQLWhere).find((graphQLOperator) => graphQLOperator ===
|
|
2133
|
+
Object.keys(Where).find((operator) => Where[operator] === (options === null || options === void 0 ? void 0 : options.operator)))];
|
|
2843
2134
|
|
|
2844
2135
|
class GraphQLFieldHelper {
|
|
2845
2136
|
}
|
|
@@ -2848,33 +2139,50 @@ GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields = (fields) => {
|
|
|
2848
2139
|
return fields === null || fields === void 0 ? void 0 : fields.map((field) => {
|
|
2849
2140
|
if (isString(field))
|
|
2850
2141
|
return field.toString();
|
|
2142
|
+
if (field === 'affected_rows')
|
|
2143
|
+
return field;
|
|
2851
2144
|
const fieldName = Object.keys(field).shift();
|
|
2852
2145
|
const fieldValue = field[fieldName];
|
|
2853
2146
|
if (Array.isArray(fieldValue))
|
|
2854
2147
|
return { [fieldName]: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(fieldValue) };
|
|
2855
2148
|
if (!AttributeOptionHelper.CheckIsColumnOption(fieldValue))
|
|
2856
|
-
return;
|
|
2857
|
-
|
|
2858
|
-
|
|
2859
|
-
|
|
2149
|
+
return null;
|
|
2150
|
+
if (fieldValue.fields)
|
|
2151
|
+
return !fieldValue.filters
|
|
2152
|
+
? {
|
|
2153
|
+
[fieldValue.columnName || fieldName]: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(fieldValue.fields),
|
|
2154
|
+
}
|
|
2155
|
+
: {
|
|
2156
|
+
operation: fieldValue.columnName || fieldName,
|
|
2157
|
+
fields: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(fieldValue.fields),
|
|
2158
|
+
variables: {
|
|
2159
|
+
[`${fieldValue.columnName}_where`]: {
|
|
2160
|
+
name: 'where',
|
|
2161
|
+
type: fieldValue.filters.filterType,
|
|
2162
|
+
value: BindFilterQueryHelper.MakeGraphQLWhere(fieldValue.filters.filters, fieldValue.fields),
|
|
2163
|
+
required: true,
|
|
2164
|
+
},
|
|
2165
|
+
},
|
|
2166
|
+
};
|
|
2860
2167
|
return fieldValue.columnName;
|
|
2861
2168
|
}).filter((field) => !!field);
|
|
2862
2169
|
};
|
|
2863
2170
|
GraphQLFieldHelper.ConvertFieldValueFrom = (data, fields) => Object.keys(data).reduce((result, columnName) => {
|
|
2171
|
+
var _a;
|
|
2864
2172
|
const { attributeName, fields: attributeFields, from, } = AttributeOptionHelper.FindColumnOptionFromList(columnName, fields);
|
|
2865
2173
|
if (!!attributeFields && Array.isArray(attributeFields)) {
|
|
2866
2174
|
if (Array.isArray(data[columnName]))
|
|
2867
2175
|
return Object.assign(Object.assign({}, result), { [attributeName]: from
|
|
2868
2176
|
? from(data[columnName], data)
|
|
2869
|
-
: data[columnName].map((value) => GraphQLFieldHelper.ConvertFieldValueFrom(value, attributeFields)) });
|
|
2177
|
+
: is(data[columnName]).map((value) => GraphQLFieldHelper.ConvertFieldValueFrom(is(value), attributeFields)) });
|
|
2870
2178
|
if (isObject(data[columnName]))
|
|
2871
2179
|
return Object.assign(Object.assign({}, result), { [attributeName]: !!from
|
|
2872
2180
|
? from(data[columnName])
|
|
2873
|
-
: GraphQLFieldHelper.ConvertFieldValueFrom(data[columnName], attributeFields) });
|
|
2181
|
+
: GraphQLFieldHelper.ConvertFieldValueFrom(is(data[columnName]), attributeFields) });
|
|
2874
2182
|
}
|
|
2875
2183
|
if (!!from)
|
|
2876
2184
|
return Object.assign(Object.assign({}, result), { [attributeName]: from(data[columnName], data) });
|
|
2877
|
-
return Object.assign(Object.assign({}, result), { [attributeName]: parseDateTime(data[columnName]) });
|
|
2185
|
+
return Object.assign(Object.assign({}, result), { [attributeName]: parseDateTime((_a = data[columnName]) === null || _a === void 0 ? void 0 : _a.toString()) });
|
|
2878
2186
|
}, {});
|
|
2879
2187
|
GraphQLFieldHelper.ConvertFieldValueTo = (instance, fields, update = false) => {
|
|
2880
2188
|
var _a;
|
|
@@ -2887,16 +2195,22 @@ GraphQLFieldHelper.ConvertFieldValueTo = (instance, fields, update = false) => {
|
|
|
2887
2195
|
return result;
|
|
2888
2196
|
if (!!foreignKeyColumn &&
|
|
2889
2197
|
!isEmpty(foreignKeyColumn) &&
|
|
2890
|
-
!Object.keys(foreignKeyColumn).filter((key) => { var _a; return !((_a = data[attributeName]) === null || _a === void 0 ? void 0 : _a[key]); }).length)
|
|
2198
|
+
!Object.keys(foreignKeyColumn).filter((key) => { var _a; return !((_a = is(data[attributeName])) === null || _a === void 0 ? void 0 : _a[key]); }).length)
|
|
2891
2199
|
return Object.keys(foreignKeyColumn).reduce((object, current) => {
|
|
2892
2200
|
var _a;
|
|
2893
|
-
|
|
2894
|
-
return Object.assign(Object.assign({}, object), { [foreignColumnName]: (_a = data[attributeName]) === null || _a === void 0 ? void 0 : _a[current] });
|
|
2201
|
+
return (Object.assign(Object.assign({}, object), { [foreignKeyColumn[current]]: (_a = data[attributeName]) === null || _a === void 0 ? void 0 : _a[current] }));
|
|
2895
2202
|
}, Object.assign({}, result));
|
|
2896
|
-
if (update &&
|
|
2203
|
+
if (update &&
|
|
2204
|
+
isObject(data[attributeName]) &&
|
|
2205
|
+
!isNil(attributeFields) &&
|
|
2206
|
+
!isDate(data[attributeName]))
|
|
2897
2207
|
return result;
|
|
2898
|
-
if (!!columnName &&
|
|
2899
|
-
|
|
2208
|
+
if (!!columnName &&
|
|
2209
|
+
Array.isArray(attributeFields) &&
|
|
2210
|
+
isObject(data[attributeName])) {
|
|
2211
|
+
const converted = !isNil(columnName) && to
|
|
2212
|
+
? to(instance[attributeName], instance)
|
|
2213
|
+
: data[attributeName];
|
|
2900
2214
|
return Object.assign(Object.assign({}, result), (converted !== undefined
|
|
2901
2215
|
? {
|
|
2902
2216
|
[columnName]: {
|
|
@@ -2912,25 +2226,6 @@ GraphQLFieldHelper.ConvertFieldValueTo = (instance, fields, update = false) => {
|
|
|
2912
2226
|
return Object.assign(Object.assign({}, result), { [columnName]: data[attributeName] });
|
|
2913
2227
|
}, {});
|
|
2914
2228
|
};
|
|
2915
|
-
GraphQLFieldHelper.ConvertNestedFieldsToGraphQLFields = (fieldName, fieldValue) => {
|
|
2916
|
-
const hasCustomFilters = !!fieldValue.filters;
|
|
2917
|
-
if (hasCustomFilters)
|
|
2918
|
-
return {
|
|
2919
|
-
operation: fieldValue.columnName || fieldName,
|
|
2920
|
-
fields: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(fieldValue.fields),
|
|
2921
|
-
variables: {
|
|
2922
|
-
[`${fieldValue.columnName}_where`]: {
|
|
2923
|
-
name: 'where',
|
|
2924
|
-
type: fieldValue.filters.filterType,
|
|
2925
|
-
value: BindFilterQueryHelper.MakeGraphQLWhere(fieldValue.filters.filters, fieldValue.fields),
|
|
2926
|
-
required: true,
|
|
2927
|
-
},
|
|
2928
|
-
},
|
|
2929
|
-
};
|
|
2930
|
-
return {
|
|
2931
|
-
[fieldValue.columnName || fieldName]: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(fieldValue.fields),
|
|
2932
|
-
};
|
|
2933
|
-
};
|
|
2934
2229
|
|
|
2935
2230
|
const withCreateHasuraGraphQL = (MixinBase) => {
|
|
2936
2231
|
return class CreateHasuraGraphQLMixin extends MixinBase {
|
|
@@ -2938,30 +2233,14 @@ const withCreateHasuraGraphQL = (MixinBase) => {
|
|
|
2938
2233
|
const options = params === null || params === void 0 ? void 0 : params[0];
|
|
2939
2234
|
super(...params);
|
|
2940
2235
|
this.insertGraphQLOperation = (options === null || options === void 0 ? void 0 : options.insertGraphQLOperation) || `insert_${this.tableName}_one`;
|
|
2941
|
-
this.insertAllGraphQLOperation = (options === null || options === void 0 ? void 0 : options.insertAllGraphQLOperation) || `insert_${this.tableName}`;
|
|
2942
2236
|
this.insertGraphQLObjectType = (options === null || options === void 0 ? void 0 : options.insertGraphQLObjectType) || `${this.tableName}_insert_input`;
|
|
2943
2237
|
}
|
|
2944
2238
|
create(data) {
|
|
2945
2239
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2946
|
-
this.logger = DebugHelper.from(this, 'create');
|
|
2947
2240
|
const newData = yield this.save(this.model.toInstance(data));
|
|
2948
2241
|
return this.model.toInstance(newData);
|
|
2949
2242
|
});
|
|
2950
2243
|
}
|
|
2951
|
-
createAll(data) {
|
|
2952
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
2953
|
-
this.logger = DebugHelper.from(this, 'createAll');
|
|
2954
|
-
const result = yield this.mutation(this.insertAllGraphQLOperation, [{ returning: this.model.identifiersFields }], {
|
|
2955
|
-
objects: {
|
|
2956
|
-
type: this.insertGraphQLObjectType,
|
|
2957
|
-
required: true,
|
|
2958
|
-
list: true,
|
|
2959
|
-
value: data.map((item) => this.convertDataToHasura(item)),
|
|
2960
|
-
},
|
|
2961
|
-
});
|
|
2962
|
-
return result[this.insertAllGraphQLOperation].returning.map((item, index) => this.model.toInstance(Object.assign(Object.assign({}, data[index]), item)));
|
|
2963
|
-
});
|
|
2964
|
-
}
|
|
2965
2244
|
save(data) {
|
|
2966
2245
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2967
2246
|
const primaryKeyColumns = this.model.identifiersFields.map((field) => AttributeOptionHelper.FindByAttribute(field, this.fields).columnName);
|
|
@@ -2970,11 +2249,12 @@ const withCreateHasuraGraphQL = (MixinBase) => {
|
|
|
2970
2249
|
const columnOptions = Object.values(field).shift();
|
|
2971
2250
|
return (AttributeOptionHelper.CheckIsColumnOption(columnOptions) &&
|
|
2972
2251
|
columnOptions.foreignKeyColumn && [
|
|
2973
|
-
...Object.values(columnOptions.foreignKeyColumn)
|
|
2252
|
+
...Object.values(columnOptions.foreignKeyColumn),
|
|
2974
2253
|
{
|
|
2975
2254
|
[columnOptions.columnName]: Object.keys(columnOptions.foreignKeyColumn).map((foreignKeyField) => {
|
|
2976
2255
|
var _a;
|
|
2977
|
-
return ((_a = AttributeOptionHelper.FindByAttribute(foreignKeyField, columnOptions === null || columnOptions === void 0 ? void 0 : columnOptions.fields)) === null || _a === void 0 ? void 0 : _a.columnName) ||
|
|
2256
|
+
return ((_a = AttributeOptionHelper.FindByAttribute(foreignKeyField, columnOptions === null || columnOptions === void 0 ? void 0 : columnOptions.fields)) === null || _a === void 0 ? void 0 : _a.columnName) ||
|
|
2257
|
+
foreignKeyField;
|
|
2978
2258
|
}),
|
|
2979
2259
|
},
|
|
2980
2260
|
]);
|
|
@@ -2999,14 +2279,12 @@ const withDeleteHasuraGraphQL = (MixinBase) => {
|
|
|
2999
2279
|
}
|
|
3000
2280
|
delete(identifiers) {
|
|
3001
2281
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3002
|
-
this.logger = DebugHelper.from(this, 'delete');
|
|
3003
2282
|
const instance = this.model.toInstance(identifiers);
|
|
3004
2283
|
yield this.mutation(this.deleteGraphQLOperation, this.model.identifiersFields.map((field) => AttributeOptionHelper.FindByAttribute(field, this.fields).columnName), this.model.identifiersFields.reduce((ids, identifier) => {
|
|
3005
|
-
|
|
3006
|
-
if (isNil(instance[identifierBinded]))
|
|
2284
|
+
if (isNil(instance[identifier]))
|
|
3007
2285
|
return ids;
|
|
3008
2286
|
const columnOption = AttributeOptionHelper.FindByAttribute(identifier, this.fields);
|
|
3009
|
-
const value = columnOption.to(identifiers[identifier
|
|
2287
|
+
const value = columnOption.to(identifiers[identifier], instance);
|
|
3010
2288
|
return Object.assign(Object.assign({}, ids), { [columnOption.columnName]: {
|
|
3011
2289
|
type: this.getAttributeGraphQLTypeOf(columnOption.type || value),
|
|
3012
2290
|
value,
|
|
@@ -3028,7 +2306,6 @@ const withHasuraGraphQL = (MixinBase) => {
|
|
|
3028
2306
|
this.authOptions = options.authOptions;
|
|
3029
2307
|
this.model = options.model;
|
|
3030
2308
|
this.fields = options.fields || this.model.identifiersFields;
|
|
3031
|
-
this.logger = DebugHelper.from(this);
|
|
3032
2309
|
}
|
|
3033
2310
|
get headers() {
|
|
3034
2311
|
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)
|
|
@@ -3046,34 +2323,24 @@ const withHasuraGraphQL = (MixinBase) => {
|
|
|
3046
2323
|
});
|
|
3047
2324
|
}
|
|
3048
2325
|
query(operation, fields, variables) {
|
|
2326
|
+
var _a, _b, _c, _d;
|
|
3049
2327
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3050
|
-
const
|
|
3051
|
-
|
|
3052
|
-
|
|
3053
|
-
|
|
3054
|
-
|
|
3055
|
-
})))
|
|
3056
|
-
: query({
|
|
3057
|
-
operation,
|
|
3058
|
-
variables,
|
|
3059
|
-
fields: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(fields),
|
|
3060
|
-
});
|
|
3061
|
-
return this.fetch(resultQuery);
|
|
2328
|
+
const builded = this.buildHasuraQueryFields({ operation, fields, variables });
|
|
2329
|
+
const interpected = (yield ((_b = (_a = this.interceptors) === null || _a === void 0 ? void 0 : _a.request) === null || _b === void 0 ? void 0 : _b.call(_a, builded))) || builded;
|
|
2330
|
+
const resultQuery = query$1(interpected);
|
|
2331
|
+
const result = yield this.fetch(resultQuery);
|
|
2332
|
+
return (yield ((_d = (_c = this.interceptors) === null || _c === void 0 ? void 0 : _c.response) === null || _d === void 0 ? void 0 : _d.call(_c, result, interpected))) || result;
|
|
3062
2333
|
});
|
|
3063
2334
|
}
|
|
3064
2335
|
fetch(params) {
|
|
3065
2336
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3066
|
-
this.logger.with('params').log(params);
|
|
3067
2337
|
const headers = this.headers;
|
|
3068
|
-
const
|
|
3069
|
-
url: `${this.endpoint}`,
|
|
3070
|
-
method: 'POST',
|
|
3071
|
-
data: params,
|
|
2338
|
+
const response = yield axios.post(`${this.endpoint}`, params, {
|
|
3072
2339
|
headers,
|
|
3073
2340
|
});
|
|
2341
|
+
const result = yield response.data;
|
|
3074
2342
|
if (!isNil(result.errors))
|
|
3075
2343
|
throw new Error(JSON.stringify(result.errors));
|
|
3076
|
-
this.logger.with('returns').log(result);
|
|
3077
2344
|
return result.data;
|
|
3078
2345
|
});
|
|
3079
2346
|
}
|
|
@@ -3100,13 +2367,26 @@ const withHasuraGraphQL = (MixinBase) => {
|
|
|
3100
2367
|
return value;
|
|
3101
2368
|
return date;
|
|
3102
2369
|
}
|
|
3103
|
-
convertDataFromHasura(data
|
|
3104
|
-
const plain = GraphQLFieldHelper.ConvertFieldValueFrom(data,
|
|
2370
|
+
convertDataFromHasura(data) {
|
|
2371
|
+
const plain = GraphQLFieldHelper.ConvertFieldValueFrom(data, this.fields);
|
|
3105
2372
|
return this.model.toInstance(plain);
|
|
3106
2373
|
}
|
|
3107
2374
|
convertDataToHasura(instance, update = false) {
|
|
3108
2375
|
return GraphQLFieldHelper.ConvertFieldValueTo(instance, this.fields, update);
|
|
3109
2376
|
}
|
|
2377
|
+
buildHasuraQueryFields({ operation, fields, variables, }) {
|
|
2378
|
+
return GraphQLFieldHelper.CheckIsGraphQLParams(operation)
|
|
2379
|
+
? operation.map((option) => ({
|
|
2380
|
+
operation: option.operation,
|
|
2381
|
+
variables: option.variables,
|
|
2382
|
+
fields: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(option.fields),
|
|
2383
|
+
}))
|
|
2384
|
+
: {
|
|
2385
|
+
operation,
|
|
2386
|
+
variables,
|
|
2387
|
+
fields: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(fields),
|
|
2388
|
+
};
|
|
2389
|
+
}
|
|
3110
2390
|
};
|
|
3111
2391
|
};
|
|
3112
2392
|
|
|
@@ -3130,7 +2410,6 @@ const withUpdateHasuraGraphQL = (MixinBase) => {
|
|
|
3130
2410
|
}
|
|
3131
2411
|
update(data) {
|
|
3132
2412
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3133
|
-
this.logger = DebugHelper.from(this, 'update');
|
|
3134
2413
|
const plainData = this.paramsToPlain(data);
|
|
3135
2414
|
yield this.mutation(this.updateGraphQLOperation, this.model.identifiersFields.map((field) => AttributeOptionHelper.FindByAttribute(field, this.fields).columnName), {
|
|
3136
2415
|
_set: {
|
|
@@ -3147,17 +2426,18 @@ const withUpdateHasuraGraphQL = (MixinBase) => {
|
|
|
3147
2426
|
const model = this.model;
|
|
3148
2427
|
if (model.isModel(params))
|
|
3149
2428
|
return params.toPlain();
|
|
3150
|
-
return Object.keys(params).reduce((data, currentKey) => (Object.assign(Object.assign({}, data), (params[currentKey] !== undefined && {
|
|
2429
|
+
return Object.keys(params).reduce((data, currentKey) => (Object.assign(Object.assign({}, data), (params[currentKey] !== undefined && {
|
|
2430
|
+
[currentKey]: getValueByAction(is(params[currentKey])),
|
|
2431
|
+
}))), {});
|
|
3151
2432
|
}
|
|
3152
2433
|
getUpdateModelKeys(data) {
|
|
3153
2434
|
const instance = this.model.toInstance(data);
|
|
3154
2435
|
return this.model.identifiersFields.reduce((ids, identifier) => {
|
|
3155
2436
|
var _a;
|
|
3156
|
-
|
|
3157
|
-
if (isNil(instance[identifierBinded]))
|
|
2437
|
+
if (isNil(instance[identifier]))
|
|
3158
2438
|
return ids;
|
|
3159
|
-
const columnOption = AttributeOptionHelper.FindByAttribute(
|
|
3160
|
-
const value = ((_a = columnOption === null || columnOption === void 0 ? void 0 : columnOption.to) === null || _a === void 0 ? void 0 : _a.call(columnOption, data[
|
|
2439
|
+
const columnOption = AttributeOptionHelper.FindByAttribute(identifier, this.fields);
|
|
2440
|
+
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];
|
|
3161
2441
|
return Object.assign(Object.assign({}, ids), { [columnOption.columnName]: value });
|
|
3162
2442
|
}, {});
|
|
3163
2443
|
}
|
|
@@ -3173,15 +2453,14 @@ const withGetHasuraGraphQL = (MixinBase) => {
|
|
|
3173
2453
|
}
|
|
3174
2454
|
get(identifiers) {
|
|
3175
2455
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3176
|
-
this.logger = DebugHelper.from(this, 'get');
|
|
3177
2456
|
const instance = this.model.toInstance(identifiers);
|
|
3178
2457
|
const result = yield this.query(this.getGraphQLOperation, this.fields, this.model.identifiersFields.reduce((ids, identifier) => {
|
|
3179
2458
|
var _a;
|
|
3180
|
-
|
|
3181
|
-
if (isNil(instance[identifierBinded]))
|
|
2459
|
+
if (isNil(instance[identifier]))
|
|
3182
2460
|
return ids;
|
|
3183
2461
|
const columnOption = AttributeOptionHelper.FindByAttribute(identifier, this.fields);
|
|
3184
|
-
const value = ((_a = columnOption === null || columnOption === void 0 ? void 0 : columnOption.to) === null || _a === void 0 ? void 0 : _a.call(columnOption, identifiers[identifier
|
|
2462
|
+
const value = ((_a = columnOption === null || columnOption === void 0 ? void 0 : columnOption.to) === null || _a === void 0 ? void 0 : _a.call(columnOption, identifiers[identifier], instance)) ||
|
|
2463
|
+
identifiers[identifier];
|
|
3185
2464
|
return Object.assign(Object.assign({}, ids), { [columnOption.columnName]: {
|
|
3186
2465
|
type: this.getAttributeGraphQLTypeOf(columnOption.type || value),
|
|
3187
2466
|
value,
|
|
@@ -3199,42 +2478,10 @@ const withGetHasuraGraphQL = (MixinBase) => {
|
|
|
3199
2478
|
|
|
3200
2479
|
const withFindHasuraGraphQL = (MixinBase) => {
|
|
3201
2480
|
return class FindHasuraGraphQLMixin extends MixinBase {
|
|
3202
|
-
|
|
3203
|
-
super(...arguments);
|
|
3204
|
-
this.bindOrderByAttributes = (orderBy, fields) => Object.keys(orderBy).reduce((acc, current) => (Object.assign(Object.assign({}, acc), { [AttributeOptionHelper.FindByAttribute(current, fields)
|
|
3205
|
-
.columnName]: orderBy[current] })), {});
|
|
3206
|
-
this.bindAggretageAttributes = (aggregates, fields) => {
|
|
3207
|
-
var _a, _b;
|
|
3208
|
-
return [
|
|
3209
|
-
...(((_a = aggregates === null || aggregates === void 0 ? void 0 : aggregates.minimal) === null || _a === void 0 ? void 0 : _a.length)
|
|
3210
|
-
? [
|
|
3211
|
-
{
|
|
3212
|
-
min: this.bindAttributesToColumns(aggregates === null || aggregates === void 0 ? void 0 : aggregates.minimal, fields),
|
|
3213
|
-
},
|
|
3214
|
-
]
|
|
3215
|
-
: []),
|
|
3216
|
-
...(((_b = aggregates === null || aggregates === void 0 ? void 0 : aggregates.maximum) === null || _b === void 0 ? void 0 : _b.length)
|
|
3217
|
-
? [
|
|
3218
|
-
{
|
|
3219
|
-
max: this.bindAttributesToColumns(aggregates === null || aggregates === void 0 ? void 0 : aggregates.maximum, fields),
|
|
3220
|
-
},
|
|
3221
|
-
]
|
|
3222
|
-
: []),
|
|
3223
|
-
];
|
|
3224
|
-
};
|
|
3225
|
-
this.bindDistinctAttributes = (distinct, fields) => this.bindAttributesToColumns(distinct, fields);
|
|
3226
|
-
this.bindAttributesToColumns = (attributes, fields) => attributes.map((attr) => {
|
|
3227
|
-
var _a;
|
|
3228
|
-
return ((_a = AttributeOptionHelper.FindByAttribute(attr.toString().split('.').pop(), fields)) === null || _a === void 0 ? void 0 : _a.columnName) || attr;
|
|
3229
|
-
});
|
|
3230
|
-
}
|
|
3231
|
-
find(params) {
|
|
3232
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
2481
|
+
find(options) {
|
|
3233
2482
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3234
|
-
|
|
3235
|
-
const
|
|
3236
|
-
const enableCount = (_a = options === null || options === void 0 ? void 0 : options.enableCount) !== null && _a !== void 0 ? _a : true;
|
|
3237
|
-
const variablesFilters = isNil(filters)
|
|
2483
|
+
const { filters, limits, orderBy } = options || {};
|
|
2484
|
+
const variablesCount = Object.assign(Object.assign({}, (isNil(orderBy) ? {} : { order_by: { type: `${this.tableName}_order_by!`, list: true, value: orderBy } })), (isNil(filters)
|
|
3238
2485
|
? {}
|
|
3239
2486
|
: {
|
|
3240
2487
|
where: {
|
|
@@ -3242,26 +2489,13 @@ const withFindHasuraGraphQL = (MixinBase) => {
|
|
|
3242
2489
|
type: `${this.tableName}_bool_exp`,
|
|
3243
2490
|
required: true,
|
|
3244
2491
|
},
|
|
3245
|
-
};
|
|
3246
|
-
const variablesCount = Object.assign(Object.assign({}, (isNil(orderBy)
|
|
3247
|
-
? {}
|
|
3248
|
-
: {
|
|
3249
|
-
order_by: {
|
|
3250
|
-
type: `${this.tableName}_order_by!`,
|
|
3251
|
-
list: true,
|
|
3252
|
-
value: this.bindOrderByAttributes(orderBy, this.fields),
|
|
3253
|
-
},
|
|
3254
|
-
})), variablesFilters);
|
|
2492
|
+
}));
|
|
3255
2493
|
const variables = Object.assign(Object.assign({}, (isNil(limits) ? {} : limits)), variablesCount);
|
|
3256
|
-
const aggregateFields = [
|
|
3257
|
-
...(enableCount ? ['count'] : []),
|
|
3258
|
-
...this.bindAggretageAttributes(params.options, this.fields),
|
|
3259
|
-
];
|
|
3260
2494
|
const result = yield this.query([
|
|
3261
2495
|
{
|
|
3262
2496
|
operation: this.tableName,
|
|
3263
|
-
fields:
|
|
3264
|
-
?
|
|
2497
|
+
fields: options.fields
|
|
2498
|
+
? options.fields
|
|
3265
2499
|
.map((fieldName) => {
|
|
3266
2500
|
var _a;
|
|
3267
2501
|
return (_a = this.fields.find((fieldOption) => fieldOption === fieldName)) !== null && _a !== void 0 ? _a : this.fields.find((fieldOption) => Object.keys(fieldOption).shift() === fieldName);
|
|
@@ -3270,64 +2504,15 @@ const withFindHasuraGraphQL = (MixinBase) => {
|
|
|
3270
2504
|
: this.fields,
|
|
3271
2505
|
variables,
|
|
3272
2506
|
},
|
|
3273
|
-
|
|
3274
|
-
|
|
3275
|
-
|
|
3276
|
-
|
|
3277
|
-
|
|
3278
|
-
{
|
|
3279
|
-
aggregate: aggregateFields,
|
|
3280
|
-
},
|
|
3281
|
-
],
|
|
3282
|
-
variables: variablesCount,
|
|
3283
|
-
},
|
|
3284
|
-
]
|
|
3285
|
-
: []),
|
|
3286
|
-
...((!((_b = params.limits) === null || _b === void 0 ? void 0 : _b.offset) &&
|
|
3287
|
-
((_d = (_c = params.options) === null || _c === void 0 ? void 0 : _c.distinct) === null || _d === void 0 ? void 0 : _d.map((distinct) => {
|
|
3288
|
-
var _a, _b;
|
|
3289
|
-
const distinctOption = (_a = this.fields.find((fieldOption) => fieldOption === distinct)) !== null && _a !== void 0 ? _a : this.fields.find((fieldOption) => Object.keys(fieldOption).shift() === distinct);
|
|
3290
|
-
const fieldName = ((_b = Object.values(distinctOption).shift()) === null || _b === void 0 ? void 0 : _b.columnName) || distinct;
|
|
3291
|
-
return {
|
|
3292
|
-
operation: {
|
|
3293
|
-
name: `${this.tableName}`,
|
|
3294
|
-
alias: `${this.tableName}_${distinct}_distinct`,
|
|
3295
|
-
},
|
|
3296
|
-
fields: [distinctOption],
|
|
3297
|
-
variables: Object.assign(Object.assign({}, variablesFilters), { [`${this.tableName}_${fieldName}_distinct`]: {
|
|
3298
|
-
type: `${this.tableName}_select_column!`,
|
|
3299
|
-
list: true,
|
|
3300
|
-
value: fieldName,
|
|
3301
|
-
name: 'distinct_on',
|
|
3302
|
-
} }),
|
|
3303
|
-
};
|
|
3304
|
-
}))) ||
|
|
3305
|
-
[]),
|
|
2507
|
+
{
|
|
2508
|
+
operation: `${this.tableName}_aggregate`,
|
|
2509
|
+
fields: [{ aggregate: ['count'] }],
|
|
2510
|
+
variables: variablesCount,
|
|
2511
|
+
},
|
|
3306
2512
|
]);
|
|
3307
2513
|
const data = result[this.tableName].map((row) => this.convertDataFromHasura(row));
|
|
3308
|
-
|
|
3309
|
-
|
|
3310
|
-
minimal: options.minimal.reduce((minimals, current) => {
|
|
3311
|
-
var _a;
|
|
3312
|
-
return (Object.assign(Object.assign({}, minimals), set(minimals, current, result[`${this.tableName}_aggregate`].aggregate.min[((_a = AttributeOptionHelper.FindByAttribute(current.toString().split('.').pop(), this.fields)) === null || _a === void 0 ? void 0 : _a.columnName) || current])));
|
|
3313
|
-
}, {}),
|
|
3314
|
-
}
|
|
3315
|
-
: {})), (((_f = options === null || options === void 0 ? void 0 : options.maximum) === null || _f === void 0 ? void 0 : _f.length)
|
|
3316
|
-
? {
|
|
3317
|
-
maximum: options.maximum.reduce((maximums, current) => {
|
|
3318
|
-
var _a;
|
|
3319
|
-
return (Object.assign(Object.assign({}, maximums), set(maximums, current, result[`${this.tableName}_aggregate`].aggregate.max[((_a = AttributeOptionHelper.FindByAttribute(current.toString().split('.').pop(), this.fields)) === null || _a === void 0 ? void 0 : _a.columnName) || current])));
|
|
3320
|
-
}, {}),
|
|
3321
|
-
}
|
|
3322
|
-
: {})), (!((_g = params.limits) === null || _g === void 0 ? void 0 : _g.offset) &&
|
|
3323
|
-
((_h = options === null || options === void 0 ? void 0 : options.distinct) === null || _h === void 0 ? void 0 : _h.length) && {
|
|
3324
|
-
distinct: options === null || options === void 0 ? void 0 : options.distinct.reduce((distinct, current) => {
|
|
3325
|
-
var _a, _b;
|
|
3326
|
-
const distinctOption = (_a = this.fields.find((fieldOption) => fieldOption === current)) !== null && _a !== void 0 ? _a : this.fields.find((fieldOption) => Object.keys(fieldOption).shift() === current);
|
|
3327
|
-
const fieldName = ((_b = Object.values(distinctOption).shift()) === null || _b === void 0 ? void 0 : _b.columnName) || current;
|
|
3328
|
-
return Object.assign(Object.assign({}, distinct), { [current.toString()]: result[`${this.tableName}_${current.toString()}_distinct`].map((obj) => obj[fieldName]) });
|
|
3329
|
-
}, {}),
|
|
3330
|
-
}));
|
|
2514
|
+
const count = result[`${this.tableName}_aggregate`].aggregate.count;
|
|
2515
|
+
return { count, data };
|
|
3331
2516
|
});
|
|
3332
2517
|
}
|
|
3333
2518
|
};
|
|
@@ -3367,151 +2552,14 @@ class VariantHasuraGraphQL extends Variant {
|
|
|
3367
2552
|
}
|
|
3368
2553
|
}
|
|
3369
2554
|
|
|
3370
|
-
class CategoryCollectionChildrenHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
3371
|
-
constructor(endpoint, authOptions) {
|
|
3372
|
-
super({
|
|
3373
|
-
tableName: 'category_collection_children',
|
|
3374
|
-
model: CategoryCollectionChildren,
|
|
3375
|
-
endpoint,
|
|
3376
|
-
authOptions,
|
|
3377
|
-
fields: [
|
|
3378
|
-
{ collectionId: { columnName: 'collection_id' } },
|
|
3379
|
-
{ categoryId: { columnName: 'category_id' } },
|
|
3380
|
-
'name',
|
|
3381
|
-
'slug',
|
|
3382
|
-
'reference',
|
|
3383
|
-
{ parentCollectionId: { columnName: 'parent_collection_id' } },
|
|
3384
|
-
{ parentCategoryId: { columnName: 'parent_category_id' } },
|
|
3385
|
-
{
|
|
3386
|
-
parent: {
|
|
3387
|
-
columnName: 'parent',
|
|
3388
|
-
foreignKeyColumn: { collectionId: 'parentCollectionId', categoryId: 'parentCategoryId' },
|
|
3389
|
-
fields: [
|
|
3390
|
-
{ collectionId: { columnName: 'collection_id' } },
|
|
3391
|
-
{ categoryId: { columnName: 'category_id' } },
|
|
3392
|
-
'name',
|
|
3393
|
-
'slug',
|
|
3394
|
-
'reference',
|
|
3395
|
-
{ parentCollectionId: { columnName: 'parent_collection_id' } },
|
|
3396
|
-
{ parentCategoryId: { columnName: 'parent_category_id' } },
|
|
3397
|
-
],
|
|
3398
|
-
},
|
|
3399
|
-
},
|
|
3400
|
-
],
|
|
3401
|
-
});
|
|
3402
|
-
}
|
|
3403
|
-
}
|
|
3404
|
-
|
|
3405
|
-
class CategoryFilterHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
3406
|
-
constructor(endpoint, authOptions) {
|
|
3407
|
-
super({
|
|
3408
|
-
tableName: 'category_filter',
|
|
3409
|
-
model: CategoryFilter,
|
|
3410
|
-
endpoint,
|
|
3411
|
-
authOptions,
|
|
3412
|
-
fields: [
|
|
3413
|
-
'id',
|
|
3414
|
-
{ filterId: { columnName: 'filter_id' } },
|
|
3415
|
-
{ categoryId: { columnName: 'category_id' } },
|
|
3416
|
-
{
|
|
3417
|
-
filter: {
|
|
3418
|
-
columnName: 'filter',
|
|
3419
|
-
foreignKeyColumn: { id: 'filterId' },
|
|
3420
|
-
fields: [
|
|
3421
|
-
'id',
|
|
3422
|
-
'description',
|
|
3423
|
-
'slug',
|
|
3424
|
-
'enabled',
|
|
3425
|
-
{ createdAt: { columnName: 'created_at' } },
|
|
3426
|
-
{ updatedAt: { columnName: 'updated_at' } },
|
|
3427
|
-
{
|
|
3428
|
-
options: {
|
|
3429
|
-
columnName: 'options',
|
|
3430
|
-
foreignKeyColumn: { filterId: 'id' },
|
|
3431
|
-
fields: [
|
|
3432
|
-
'id',
|
|
3433
|
-
{ filterId: { columnName: 'filter_id' } },
|
|
3434
|
-
'description',
|
|
3435
|
-
{ createdAt: { columnName: 'created_at' } },
|
|
3436
|
-
{ updatedAt: { columnName: 'updated_at' } },
|
|
3437
|
-
],
|
|
3438
|
-
},
|
|
3439
|
-
},
|
|
3440
|
-
],
|
|
3441
|
-
},
|
|
3442
|
-
},
|
|
3443
|
-
{
|
|
3444
|
-
category: {
|
|
3445
|
-
columnName: 'category',
|
|
3446
|
-
foreignKeyColumn: { id: 'categoryId' },
|
|
3447
|
-
fields: [
|
|
3448
|
-
'id',
|
|
3449
|
-
'description',
|
|
3450
|
-
{
|
|
3451
|
-
products: {
|
|
3452
|
-
columnName: 'products',
|
|
3453
|
-
fields: ['product_id'],
|
|
3454
|
-
from: (value) => value.map((product) => product.product_id.toString()),
|
|
3455
|
-
to: (productIds) => productIds.map((productId) => ({
|
|
3456
|
-
product_id: +productId,
|
|
3457
|
-
})),
|
|
3458
|
-
},
|
|
3459
|
-
},
|
|
3460
|
-
{
|
|
3461
|
-
childrenProducts: {
|
|
3462
|
-
columnName: 'children_products',
|
|
3463
|
-
foreignKeyColumn: { category_id: 'id' },
|
|
3464
|
-
fields: [
|
|
3465
|
-
'id',
|
|
3466
|
-
'name',
|
|
3467
|
-
'slug',
|
|
3468
|
-
{
|
|
3469
|
-
categories: {
|
|
3470
|
-
columnName: 'categories',
|
|
3471
|
-
fields: ['category_id'],
|
|
3472
|
-
bindPersistData: (value) => ({
|
|
3473
|
-
categories: { data: value.map((category) => ({ category_id: +category })) },
|
|
3474
|
-
}),
|
|
3475
|
-
to: (categories) => categories.map((categoryId) => +categoryId),
|
|
3476
|
-
from: (categories) => (categories === null || categories === void 0 ? void 0 : categories.map((category) => { var _a; return (_a = category === null || category === void 0 ? void 0 : category.category_id) === null || _a === void 0 ? void 0 : _a.toString(); })) || [],
|
|
3477
|
-
},
|
|
3478
|
-
},
|
|
3479
|
-
],
|
|
3480
|
-
},
|
|
3481
|
-
},
|
|
3482
|
-
],
|
|
3483
|
-
},
|
|
3484
|
-
},
|
|
3485
|
-
],
|
|
3486
|
-
});
|
|
3487
|
-
}
|
|
3488
|
-
deleteByCategory(categoryId) {
|
|
3489
|
-
return this.mutation('delete_category_filter', ['affected_rows'], {
|
|
3490
|
-
where: {
|
|
3491
|
-
type: 'category_filter_bool_exp',
|
|
3492
|
-
required: true,
|
|
3493
|
-
value: { category_id: { _eq: categoryId } },
|
|
3494
|
-
},
|
|
3495
|
-
});
|
|
3496
|
-
}
|
|
3497
|
-
deleteByCategoryAndFilter(categoryId, filterId) {
|
|
3498
|
-
return this.mutation('delete_category_filter', ['affected_rows'], {
|
|
3499
|
-
where: {
|
|
3500
|
-
type: 'category_filter_bool_exp',
|
|
3501
|
-
required: true,
|
|
3502
|
-
value: { category_id: { _eq: categoryId }, filter_id: { _eq: filterId } },
|
|
3503
|
-
},
|
|
3504
|
-
});
|
|
3505
|
-
}
|
|
3506
|
-
}
|
|
3507
|
-
|
|
3508
2555
|
class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
3509
|
-
constructor(endpoint, authOptions,
|
|
2556
|
+
constructor({ endpoint, authOptions, interceptors, }, productRepository) {
|
|
3510
2557
|
super({
|
|
3511
2558
|
tableName: 'category',
|
|
3512
2559
|
model: Category,
|
|
3513
2560
|
endpoint,
|
|
3514
2561
|
authOptions,
|
|
2562
|
+
interceptors,
|
|
3515
2563
|
fields: [
|
|
3516
2564
|
{ id: { columnName: 'id', to: (value) => +value, from: (value) => value.toString() } },
|
|
3517
2565
|
{ firestoreId: { columnName: 'firestore_id' } },
|
|
@@ -3520,7 +2568,6 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
3520
2568
|
'image',
|
|
3521
2569
|
'published',
|
|
3522
2570
|
'shop',
|
|
3523
|
-
{ shops: { columnName: 'shops', type: HasuraGraphQLColumnType.Jsonb } },
|
|
3524
2571
|
'slug',
|
|
3525
2572
|
{ brandCategory: { columnName: 'brand_category' } },
|
|
3526
2573
|
{ brandCategoryBanner: { columnName: 'brand_banner' } },
|
|
@@ -3531,7 +2578,10 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
3531
2578
|
conditions: {
|
|
3532
2579
|
columnName: 'tag_condition',
|
|
3533
2580
|
type: HasuraGraphQLColumnType.Jsonb,
|
|
3534
|
-
from: (tags, row) => ({
|
|
2581
|
+
from: (tags, row) => ({
|
|
2582
|
+
brand: row.brand_condition,
|
|
2583
|
+
tags: Array.isArray(tags) ? tags : [],
|
|
2584
|
+
}),
|
|
3535
2585
|
bindPersistData: (value) => {
|
|
3536
2586
|
return {
|
|
3537
2587
|
brand_condition: value.brand,
|
|
@@ -3543,17 +2593,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
3543
2593
|
},
|
|
3544
2594
|
},
|
|
3545
2595
|
},
|
|
3546
|
-
|
|
3547
|
-
filters: {
|
|
3548
|
-
columnName: 'filters',
|
|
3549
|
-
foreignKeyColumn: { filter_id: 'id' },
|
|
3550
|
-
fields: [{ filter: ['id', 'description', 'slug', 'enabled'] }],
|
|
3551
|
-
bindPersistData: (value) => ({
|
|
3552
|
-
filters: { data: value.map((filter) => ({ filter_id: filter.id })) },
|
|
3553
|
-
}),
|
|
3554
|
-
from: (filters) => (filters === null || filters === void 0 ? void 0 : filters.map((filter) => filter === null || filter === void 0 ? void 0 : filter.filter)) || [],
|
|
3555
|
-
},
|
|
3556
|
-
},
|
|
2596
|
+
'filters',
|
|
3557
2597
|
{ createdAt: { columnName: 'created_at' } },
|
|
3558
2598
|
{ updatedAt: { columnName: 'updated_at' } },
|
|
3559
2599
|
{
|
|
@@ -3575,21 +2615,9 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
3575
2615
|
}),
|
|
3576
2616
|
},
|
|
3577
2617
|
},
|
|
3578
|
-
{ isCollection: { columnName: 'is_collection' } },
|
|
3579
|
-
{ isWishlist: { columnName: 'is_wishlist' } },
|
|
3580
|
-
'reference',
|
|
3581
|
-
{ parentId: { columnName: 'parent_id' } },
|
|
3582
|
-
{
|
|
3583
|
-
parent: {
|
|
3584
|
-
columnName: 'parent',
|
|
3585
|
-
foreignKeyColumn: { id: 'parentId' },
|
|
3586
|
-
fields: ['id', 'name', 'reference', 'slug'],
|
|
3587
|
-
},
|
|
3588
|
-
},
|
|
3589
2618
|
],
|
|
3590
2619
|
});
|
|
3591
2620
|
this.productRepository = productRepository;
|
|
3592
|
-
this.categoryFilterRepository = categoryFilterRepository;
|
|
3593
2621
|
}
|
|
3594
2622
|
create(params) {
|
|
3595
2623
|
const _super = Object.create(null, {
|
|
@@ -3597,7 +2625,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
3597
2625
|
});
|
|
3598
2626
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3599
2627
|
const { metadata } = params, data = __rest(params, ["metadata"]);
|
|
3600
|
-
return _super.create.call(this, Object.assign(Object.assign({}, data), {
|
|
2628
|
+
return _super.create.call(this, Object.assign(Object.assign({}, data), { metadata: metadata || { description: null, title: null } }));
|
|
3601
2629
|
});
|
|
3602
2630
|
}
|
|
3603
2631
|
get(identifiers) {
|
|
@@ -3607,7 +2635,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
3607
2635
|
var _a;
|
|
3608
2636
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3609
2637
|
return Number.isNaN(+identifiers.id)
|
|
3610
|
-
? (_a = (yield this.find({ filters: { firestoreId: identifiers.id }
|
|
2638
|
+
? (_a = (yield this.find({ filters: { firestoreId: identifiers.id } })).data) === null || _a === void 0 ? void 0 : _a[0]
|
|
3611
2639
|
: _super.get.call(this, identifiers);
|
|
3612
2640
|
});
|
|
3613
2641
|
}
|
|
@@ -3616,56 +2644,28 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
3616
2644
|
update: { get: () => super.update }
|
|
3617
2645
|
});
|
|
3618
2646
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3619
|
-
const { products, id: checkId, metadata
|
|
2647
|
+
const { products, id: checkId, metadata } = params, data = __rest(params, ["products", "id", "metadata"]);
|
|
3620
2648
|
const plainData = this.paramsToPlain({ id: checkId });
|
|
3621
2649
|
const id = yield this.getId(plainData.id);
|
|
3622
|
-
const category = yield _super.update.call(this, Object.assign(
|
|
2650
|
+
const category = yield _super.update.call(this, Object.assign({ id }, data));
|
|
3623
2651
|
category.products = products && (yield this.updateProducts(+id, { products }));
|
|
3624
2652
|
category.metadata = metadata && (yield this.updateMetadata(+id, { metadata }));
|
|
3625
|
-
category.filters = filters && (yield this.updateFilters(+id, { filters }));
|
|
3626
2653
|
return category;
|
|
3627
2654
|
});
|
|
3628
2655
|
}
|
|
3629
2656
|
getCategoryBySlug(slug, shop) {
|
|
3630
2657
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3631
2658
|
if (!slug)
|
|
3632
|
-
return;
|
|
3633
|
-
const { data } = yield this.find({
|
|
3634
|
-
|
|
3635
|
-
slug,
|
|
3636
|
-
shops: { operator: Where.IN, value: [shop] },
|
|
3637
|
-
published: { operator: Where.EQUALS, value: true },
|
|
3638
|
-
isWishlist: { operator: Where.EQUALS, value: false },
|
|
3639
|
-
},
|
|
3640
|
-
options: {
|
|
3641
|
-
enableCount: false,
|
|
3642
|
-
},
|
|
3643
|
-
});
|
|
3644
|
-
if (!data.length)
|
|
3645
|
-
throw new NotFoundError(`Category with slug ${slug} not found`);
|
|
3646
|
-
if (data.length > 1)
|
|
2659
|
+
return null;
|
|
2660
|
+
const { data, count } = yield this.find({ filters: { slug, shop, published: true } });
|
|
2661
|
+
if (count > 1)
|
|
3647
2662
|
throw new DuplicatedResultsError('Query returned duplicated values');
|
|
2663
|
+
if (!count)
|
|
2664
|
+
throw new NotFoundError(`Category with slug ${slug} not found`);
|
|
3648
2665
|
return data.shift();
|
|
3649
2666
|
});
|
|
3650
2667
|
}
|
|
3651
|
-
|
|
3652
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
3653
|
-
if (!shop)
|
|
3654
|
-
return;
|
|
3655
|
-
const { data } = yield this.find({
|
|
3656
|
-
filters: {
|
|
3657
|
-
shops: { operator: Where.IN, value: [shop] },
|
|
3658
|
-
published: { operator: Where.EQUALS, value: true },
|
|
3659
|
-
isWishlist: { operator: Where.EQUALS, value: false },
|
|
3660
|
-
},
|
|
3661
|
-
options: {
|
|
3662
|
-
enableCount: false,
|
|
3663
|
-
},
|
|
3664
|
-
});
|
|
3665
|
-
return data;
|
|
3666
|
-
});
|
|
3667
|
-
}
|
|
3668
|
-
getCategoriesForHome(categoryIds, limit = 4, gender) {
|
|
2668
|
+
getCategoriesForHome(categoryIds, limit = 4) {
|
|
3669
2669
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3670
2670
|
if (!(categoryIds === null || categoryIds === void 0 ? void 0 : categoryIds.length))
|
|
3671
2671
|
return [];
|
|
@@ -3685,7 +2685,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
3685
2685
|
const homeSections = yield Promise.all(categories.map((category) => __awaiter(this, void 0, void 0, function* () {
|
|
3686
2686
|
return ({
|
|
3687
2687
|
category,
|
|
3688
|
-
products: yield this.mountCategory(category, { limit, hasStock: true
|
|
2688
|
+
products: yield this.mountCategory(category, { limit, hasStock: true }),
|
|
3689
2689
|
});
|
|
3690
2690
|
})));
|
|
3691
2691
|
return homeSections;
|
|
@@ -3697,7 +2697,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
3697
2697
|
if (!((_a = category === null || category === void 0 ? void 0 : category.products) === null || _a === void 0 ? void 0 : _a.length))
|
|
3698
2698
|
return [];
|
|
3699
2699
|
const products = [];
|
|
3700
|
-
const { data: productsData } = yield this.productRepository.find(Object.assign(
|
|
2700
|
+
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: [
|
|
3701
2701
|
'id',
|
|
3702
2702
|
'name',
|
|
3703
2703
|
'slug',
|
|
@@ -3721,9 +2721,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
3721
2721
|
'tags',
|
|
3722
2722
|
'type',
|
|
3723
2723
|
'shoppingCount',
|
|
3724
|
-
|
|
3725
|
-
'createdAt',
|
|
3726
|
-
] }, ((options === null || options === void 0 ? void 0 : options.limit) ? { limits: { limit: options === null || options === void 0 ? void 0 : options.limit } } : {})), { options: { enableCount: false } }));
|
|
2724
|
+
] }, ((options === null || options === void 0 ? void 0 : options.limit) ? { limits: { limit: options === null || options === void 0 ? void 0 : options.limit } } : {})));
|
|
3727
2725
|
products.push(...productsData);
|
|
3728
2726
|
return products;
|
|
3729
2727
|
});
|
|
@@ -3733,7 +2731,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
3733
2731
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3734
2732
|
if (!Number.isNaN(+id))
|
|
3735
2733
|
return id;
|
|
3736
|
-
const { data } = yield this.find({ filters: { firestoreId: id }
|
|
2734
|
+
const { data } = yield this.find({ filters: { firestoreId: id } });
|
|
3737
2735
|
if ((_a = data === null || data === void 0 ? void 0 : data[0]) === null || _a === void 0 ? void 0 : _a.id)
|
|
3738
2736
|
return (_b = data === null || data === void 0 ? void 0 : data[0]) === null || _b === void 0 ? void 0 : _b.id;
|
|
3739
2737
|
throw new NotFoundError(`Category with id ${id} not found`);
|
|
@@ -3746,270 +2744,65 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
3746
2744
|
where: {
|
|
3747
2745
|
type: 'category_product_bool_exp',
|
|
3748
2746
|
required: true,
|
|
3749
|
-
value: { category_id: { _eq: categoryId } },
|
|
3750
|
-
},
|
|
3751
|
-
});
|
|
3752
|
-
return [];
|
|
3753
|
-
}
|
|
3754
|
-
const plainData = this.paramsToPlain({ products });
|
|
3755
|
-
if (!plainData.products || plainData.products.length <= 0)
|
|
3756
|
-
return [];
|
|
3757
|
-
yield this.mutation('delete_category_product', ['affected_rows'], {
|
|
3758
|
-
where: {
|
|
3759
|
-
type: 'category_product_bool_exp',
|
|
3760
|
-
required: true,
|
|
3761
|
-
value: { category_id: { _eq: categoryId } },
|
|
3762
|
-
},
|
|
3763
|
-
});
|
|
3764
|
-
yield this.mutation('insert_category_product', ['affected_rows'], {
|
|
3765
|
-
objects: {
|
|
3766
|
-
type: '[category_product_insert_input!]',
|
|
3767
|
-
required: true,
|
|
3768
|
-
value: plainData.products.map((productId) => ({ category_id: categoryId, product_id: productId })),
|
|
3769
|
-
},
|
|
3770
|
-
});
|
|
3771
|
-
return plainData.products;
|
|
3772
|
-
});
|
|
3773
|
-
}
|
|
3774
|
-
updateMetadata(categoryId, { metadata }) {
|
|
3775
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
3776
|
-
const plainData = this.paramsToPlain({ metadata });
|
|
3777
|
-
if (!plainData.metadata)
|
|
3778
|
-
return;
|
|
3779
|
-
yield this.mutation('update_category_metadata_by_pk', ['category_id'], {
|
|
3780
|
-
pk_columns: {
|
|
3781
|
-
value: { category_id: categoryId },
|
|
3782
|
-
type: 'category_metadata_pk_columns_input',
|
|
3783
|
-
required: true,
|
|
3784
|
-
},
|
|
3785
|
-
_set: {
|
|
3786
|
-
value: omit(metadata, ['category_id']),
|
|
3787
|
-
type: 'category_metadata_set_input',
|
|
3788
|
-
required: true,
|
|
3789
|
-
},
|
|
3790
|
-
});
|
|
3791
|
-
return plainData.metadata;
|
|
3792
|
-
});
|
|
3793
|
-
}
|
|
3794
|
-
updateFilters(categoryId, { filters }) {
|
|
3795
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
3796
|
-
if ('action' in filters && filters.action === 'remove' && filters.value.length) {
|
|
3797
|
-
for (let i = 0; i < filters.value.length; i++) {
|
|
3798
|
-
yield this.categoryFilterRepository.deleteByCategoryAndFilter(categoryId, filters.value[i].id);
|
|
3799
|
-
}
|
|
3800
|
-
return [];
|
|
3801
|
-
}
|
|
3802
|
-
if ('action' in filters && filters.action === 'merge' && filters.value.length) {
|
|
3803
|
-
let filtersList = [];
|
|
3804
|
-
const currentFilters = yield this.categoryFilterRepository
|
|
3805
|
-
.find({
|
|
3806
|
-
filters: {
|
|
3807
|
-
categoryId,
|
|
3808
|
-
},
|
|
3809
|
-
})
|
|
3810
|
-
.then((res) => res.data);
|
|
3811
|
-
const currentFiltersId = currentFilters.map((f) => f.id);
|
|
3812
|
-
const filtersUpdatedId = filters.value.map((f) => f.id);
|
|
3813
|
-
const filterToBeDeleted = currentFiltersId.filter((c) => !filtersUpdatedId.includes(c));
|
|
3814
|
-
const filterToBeInserted = filtersUpdatedId.filter((c) => !currentFiltersId.includes(c));
|
|
3815
|
-
for (const filter of filterToBeDeleted) {
|
|
3816
|
-
const index = currentFilters.findIndex((f) => f.id == filter);
|
|
3817
|
-
if (index != -1) {
|
|
3818
|
-
currentFilters.splice(index, 1);
|
|
3819
|
-
}
|
|
3820
|
-
yield this.categoryFilterRepository.deleteByCategoryAndFilter(categoryId, filter);
|
|
3821
|
-
}
|
|
3822
|
-
for (const filter of filterToBeInserted) {
|
|
3823
|
-
const newCategoryFilter = yield this.categoryFilterRepository.create({
|
|
3824
|
-
filterId: filter,
|
|
3825
|
-
categoryId,
|
|
3826
|
-
});
|
|
3827
|
-
filtersList.push(newCategoryFilter);
|
|
3828
|
-
}
|
|
3829
|
-
return [...currentFilters, ...filtersList];
|
|
3830
|
-
}
|
|
3831
|
-
if (Array.isArray(filters) && filters.length) {
|
|
3832
|
-
yield this.categoryFilterRepository.deleteByCategory(categoryId);
|
|
3833
|
-
let filtersList = [];
|
|
3834
|
-
for (let i = 0; i < filters.length; i++) {
|
|
3835
|
-
const newCategoryFilter = yield this.categoryFilterRepository.create({
|
|
3836
|
-
filterId: filters[i].id,
|
|
3837
|
-
categoryId,
|
|
3838
|
-
});
|
|
3839
|
-
filtersList.push(newCategoryFilter);
|
|
3840
|
-
}
|
|
3841
|
-
return filtersList;
|
|
3842
|
-
}
|
|
3843
|
-
});
|
|
3844
|
-
}
|
|
3845
|
-
getChildren(parentId) {
|
|
3846
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
3847
|
-
const { category_tree } = yield this.query('category_tree', ['id', 'name', 'parent_id'], {
|
|
3848
|
-
args: {
|
|
3849
|
-
type: 'category_tree_args',
|
|
3850
|
-
value: { parentid: parentId },
|
|
3851
|
-
required: true,
|
|
3852
|
-
},
|
|
3853
|
-
});
|
|
3854
|
-
return category_tree.map((category) => Category.toInstance(category));
|
|
3855
|
-
});
|
|
3856
|
-
}
|
|
3857
|
-
isChild(id, parentId) {
|
|
3858
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
3859
|
-
const categoryTree = yield this.getChildren(parentId);
|
|
3860
|
-
return categoryTree.some((c) => c.id == id.toString());
|
|
3861
|
-
});
|
|
3862
|
-
}
|
|
3863
|
-
}
|
|
3864
|
-
|
|
3865
|
-
class FilterHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
3866
|
-
constructor(endpoint, authOptions, filterOptionRepository, categoryFilterRepository) {
|
|
3867
|
-
super({
|
|
3868
|
-
tableName: 'filter',
|
|
3869
|
-
model: Filter,
|
|
3870
|
-
endpoint,
|
|
3871
|
-
authOptions,
|
|
3872
|
-
fields: [
|
|
3873
|
-
'id',
|
|
3874
|
-
'description',
|
|
3875
|
-
'slug',
|
|
3876
|
-
'enabled',
|
|
3877
|
-
{ createdAt: { columnName: 'created_at' } },
|
|
3878
|
-
{ updatedAt: { columnName: 'updated_at' } },
|
|
3879
|
-
{
|
|
3880
|
-
options: {
|
|
3881
|
-
columnName: 'options',
|
|
3882
|
-
foreignKeyColumn: { filterId: 'id' },
|
|
3883
|
-
fields: [
|
|
3884
|
-
'id',
|
|
3885
|
-
{ filterId: { columnName: 'filter_id' } },
|
|
3886
|
-
'description',
|
|
3887
|
-
{ createdAt: { columnName: 'created_at' } },
|
|
3888
|
-
{ updatedAt: { columnName: 'updated_at' } },
|
|
3889
|
-
],
|
|
3890
|
-
},
|
|
3891
|
-
},
|
|
3892
|
-
],
|
|
3893
|
-
});
|
|
3894
|
-
this.filterOptionRepository = filterOptionRepository;
|
|
3895
|
-
this.categoryFilterRepository = categoryFilterRepository;
|
|
3896
|
-
}
|
|
3897
|
-
update(params) {
|
|
3898
|
-
const _super = Object.create(null, {
|
|
3899
|
-
update: { get: () => super.update }
|
|
3900
|
-
});
|
|
3901
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
3902
|
-
const { options } = params, data = __rest(params, ["options"]);
|
|
3903
|
-
const filter = yield _super.update.call(this, data);
|
|
3904
|
-
filter.options = yield this.updateOptions(+data.id, { options });
|
|
3905
|
-
return filter;
|
|
3906
|
-
});
|
|
3907
|
-
}
|
|
3908
|
-
updateOptions(filterId, { options }) {
|
|
3909
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
3910
|
-
if (!options)
|
|
3911
|
-
return [];
|
|
3912
|
-
if ('action' in options && options.action === 'remove' && options.value.length) {
|
|
3913
|
-
for (let i = 0; i < options.value.length; i++) {
|
|
3914
|
-
yield this.filterOptionRepository.delete({ id: options.value[i].id });
|
|
3915
|
-
}
|
|
3916
|
-
return [];
|
|
3917
|
-
}
|
|
3918
|
-
if ('action' in options && options.action === 'merge' && options.value.length) {
|
|
3919
|
-
let filterOptions = [];
|
|
3920
|
-
for (let i = 0; i < options.value.length; i++) {
|
|
3921
|
-
try {
|
|
3922
|
-
const hasFilter = yield this.filterOptionRepository.get({ id: options.value[i].id });
|
|
3923
|
-
if (hasFilter)
|
|
3924
|
-
filterOptions.push(hasFilter);
|
|
3925
|
-
}
|
|
3926
|
-
catch (error) {
|
|
3927
|
-
const newOption = yield this.filterOptionRepository.create(Object.assign(Object.assign({}, options.value[i]), { filterId }));
|
|
3928
|
-
filterOptions.push(newOption);
|
|
3929
|
-
}
|
|
3930
|
-
}
|
|
3931
|
-
return filterOptions;
|
|
3932
|
-
}
|
|
3933
|
-
if (Array.isArray(options) && options.length) {
|
|
3934
|
-
let filterOptions = [];
|
|
3935
|
-
for (let i = 0; i < options.length; i++) {
|
|
3936
|
-
try {
|
|
3937
|
-
const hasFilter = yield this.filterOptionRepository.get({ id: options[i].id });
|
|
3938
|
-
if (hasFilter)
|
|
3939
|
-
filterOptions.push(hasFilter);
|
|
3940
|
-
}
|
|
3941
|
-
catch (error) {
|
|
3942
|
-
const newOption = yield this.filterOptionRepository.create(Object.assign(Object.assign({}, options[i]), { filterId }));
|
|
3943
|
-
filterOptions.push(newOption);
|
|
3944
|
-
}
|
|
3945
|
-
}
|
|
3946
|
-
}
|
|
3947
|
-
return [];
|
|
3948
|
-
});
|
|
3949
|
-
}
|
|
3950
|
-
delete(params) {
|
|
3951
|
-
const _super = Object.create(null, {
|
|
3952
|
-
delete: { get: () => super.delete }
|
|
3953
|
-
});
|
|
3954
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
3955
|
-
const { options } = params, data = __rest(params, ["options"]);
|
|
3956
|
-
const categoryFilters = yield this.categoryFilterRepository
|
|
3957
|
-
.find({
|
|
3958
|
-
filters: {
|
|
3959
|
-
filterId: +data.id,
|
|
2747
|
+
value: { category_id: { _eq: categoryId } },
|
|
2748
|
+
},
|
|
2749
|
+
});
|
|
2750
|
+
return [];
|
|
2751
|
+
}
|
|
2752
|
+
const plainData = this.paramsToPlain({ products });
|
|
2753
|
+
if (!plainData.products || plainData.products.length <= 0)
|
|
2754
|
+
return [];
|
|
2755
|
+
yield this.mutation('delete_category_product', ['affected_rows'], {
|
|
2756
|
+
where: {
|
|
2757
|
+
type: 'category_product_bool_exp',
|
|
2758
|
+
required: true,
|
|
2759
|
+
value: { category_id: { _eq: categoryId } },
|
|
2760
|
+
},
|
|
2761
|
+
});
|
|
2762
|
+
yield this.mutation('insert_category_product', ['affected_rows'], {
|
|
2763
|
+
objects: {
|
|
2764
|
+
type: '[category_product_insert_input!]',
|
|
2765
|
+
required: true,
|
|
2766
|
+
value: plainData.products.map((productId) => ({ category_id: categoryId, product_id: productId })),
|
|
3960
2767
|
},
|
|
3961
|
-
})
|
|
3962
|
-
|
|
3963
|
-
if (categoryFilters.length)
|
|
3964
|
-
throw new Error('Erro: o filtro está associado a uma ou mais categoria(s)');
|
|
3965
|
-
yield this.deleteOptions(options);
|
|
3966
|
-
yield _super.delete.call(this, { id: +data.id });
|
|
3967
|
-
return;
|
|
2768
|
+
});
|
|
2769
|
+
return plainData.products;
|
|
3968
2770
|
});
|
|
3969
2771
|
}
|
|
3970
|
-
|
|
2772
|
+
updateMetadata(categoryId, { metadata }) {
|
|
3971
2773
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3972
|
-
|
|
3973
|
-
|
|
3974
|
-
|
|
3975
|
-
|
|
3976
|
-
|
|
3977
|
-
|
|
3978
|
-
|
|
3979
|
-
|
|
3980
|
-
|
|
3981
|
-
|
|
3982
|
-
|
|
3983
|
-
|
|
3984
|
-
|
|
3985
|
-
|
|
3986
|
-
|
|
3987
|
-
|
|
3988
|
-
model: FilterOption,
|
|
3989
|
-
endpoint,
|
|
3990
|
-
authOptions,
|
|
3991
|
-
fields: [
|
|
3992
|
-
'id',
|
|
3993
|
-
'description',
|
|
3994
|
-
{ filterId: { columnName: 'filter_id' } },
|
|
3995
|
-
{ createdAt: { columnName: 'created_at' } },
|
|
3996
|
-
{ updatedAt: { columnName: 'updated_at' } },
|
|
3997
|
-
],
|
|
2774
|
+
const plainData = this.paramsToPlain({ metadata });
|
|
2775
|
+
if (!plainData.metadata)
|
|
2776
|
+
return null;
|
|
2777
|
+
yield this.mutation('update_category_metadata_by_pk', ['category_id'], {
|
|
2778
|
+
pk_columns: {
|
|
2779
|
+
value: { category_id: categoryId },
|
|
2780
|
+
type: 'category_metadata_pk_columns_input',
|
|
2781
|
+
required: true,
|
|
2782
|
+
},
|
|
2783
|
+
_set: {
|
|
2784
|
+
value: omit(metadata, ['category_id']),
|
|
2785
|
+
type: 'category_metadata_set_input',
|
|
2786
|
+
required: true,
|
|
2787
|
+
},
|
|
2788
|
+
});
|
|
2789
|
+
return plainData.metadata;
|
|
3998
2790
|
});
|
|
3999
2791
|
}
|
|
4000
2792
|
}
|
|
4001
2793
|
|
|
4002
2794
|
class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
4003
|
-
constructor(endpoint, authOptions) {
|
|
2795
|
+
constructor({ endpoint, authOptions, interceptors, }) {
|
|
4004
2796
|
super({
|
|
4005
2797
|
tableName: 'product',
|
|
4006
2798
|
model: ProductHasuraGraphQL,
|
|
4007
2799
|
endpoint,
|
|
4008
2800
|
authOptions,
|
|
2801
|
+
interceptors,
|
|
4009
2802
|
fields: [],
|
|
4010
2803
|
});
|
|
4011
|
-
this.bindReviewToModel = (plain) => (Object.assign(Object.assign({}, 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 }));
|
|
4012
|
-
this.bindReviewToHasura = (review) => (Object.assign(Object.assign({}, omit(review, ['productId', 'createdAt', 'updatedAt', 'personId', 'orderId'])), { person_id: review.personId, order_id: review.orderId }));
|
|
2804
|
+
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 }));
|
|
2805
|
+
this.bindReviewToHasura = (review) => (Object.assign(Object.assign({}, is(omit(review, ['productId', 'createdAt', 'updatedAt', 'personId', 'orderId']))), { person_id: review.personId, order_id: review.orderId }));
|
|
4013
2806
|
const commonFields = [
|
|
4014
2807
|
{ id: { columnName: 'id', to: (value) => +value, from: (value) => value.toString() } },
|
|
4015
2808
|
{ firestoreId: { columnName: 'firestore_id' } },
|
|
@@ -4028,29 +2821,26 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
4028
2821
|
whoMustUse: data.who_must_use,
|
|
4029
2822
|
howToUse: data.how_to_use,
|
|
4030
2823
|
brand: data.brand_description,
|
|
4031
|
-
ingredients: data.ingredients,
|
|
4032
2824
|
}),
|
|
4033
|
-
bindFindFilter: (
|
|
4034
|
-
|
|
2825
|
+
bindFindFilter: (sentence) => {
|
|
2826
|
+
const filters = Object.values(sentence).shift();
|
|
2827
|
+
return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, ((filters === null || filters === void 0 ? void 0 : filters.description) && { description: filters.description })), (filters.differentials && { differentials: filters.differentials })), (filters.whoMustUse && {
|
|
4035
2828
|
who_must_use: filters.whoMustUse,
|
|
4036
2829
|
})), (filters.howToUse && {
|
|
4037
2830
|
how_to_use: filters.howToUse,
|
|
4038
2831
|
})), (filters.brand && {
|
|
4039
2832
|
brand_description: filters.brand,
|
|
4040
|
-
})), (filters.ingredients && {
|
|
4041
|
-
ingredients: filters.ingredients,
|
|
4042
2833
|
}));
|
|
4043
2834
|
},
|
|
4044
|
-
bindPersistData: (descriptionData) => (Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(
|
|
2835
|
+
bindPersistData: (descriptionData) => (Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, ((descriptionData === null || descriptionData === void 0 ? void 0 : descriptionData.description) && { description: descriptionData.description })), (descriptionData.differentials && { differentials: descriptionData.differentials })), (descriptionData.whoMustUse && {
|
|
4045
2836
|
who_must_use: descriptionData.whoMustUse,
|
|
4046
|
-
})), (descriptionData.howToUse && { how_to_use: descriptionData.howToUse })), (descriptionData.brand && { brand_description: descriptionData.brand }))
|
|
2837
|
+
})), (descriptionData.howToUse && { how_to_use: descriptionData.howToUse })), (descriptionData.brand && { brand_description: descriptionData.brand }))),
|
|
4047
2838
|
},
|
|
4048
2839
|
},
|
|
4049
2840
|
{ differentials: { columnName: 'differentials' } },
|
|
4050
2841
|
{ whoMustUse: { columnName: 'who_must_use' } },
|
|
4051
2842
|
{ howToUse: { columnName: 'how_to_use' } },
|
|
4052
2843
|
{ brandDescription: { columnName: 'brand_description' } },
|
|
4053
|
-
{ ingredients: { columnName: 'ingredients' } },
|
|
4054
2844
|
{ hasVariants: { columnName: 'has_variants' } },
|
|
4055
2845
|
{
|
|
4056
2846
|
images: {
|
|
@@ -4074,7 +2864,8 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
4074
2864
|
subscriberDiscountPercentage: data.subscriber_discount_percentage,
|
|
4075
2865
|
subscriberPrice: data.subscriber_price,
|
|
4076
2866
|
}),
|
|
4077
|
-
bindFindFilter: (
|
|
2867
|
+
bindFindFilter: (sentence) => {
|
|
2868
|
+
const filters = Object.values(sentence).shift();
|
|
4078
2869
|
return Object.assign(Object.assign(Object.assign(Object.assign({}, (((filters === null || filters === void 0 ? void 0 : filters.price) || (filters === null || filters === void 0 ? void 0 : filters.price) === 0) && { price: filters.price })), ((filters.fullPrice || filters.fullPrice === 0) && { full_price: filters.fullPrice })), ((filters.subscriberDiscountPercentage || filters.subscriberDiscountPercentage === 0) && {
|
|
4079
2870
|
subscriber_discount_percentage: filters.subscriberDiscountPercentage,
|
|
4080
2871
|
})), ((filters.subscriberPrice || filters.subscriberPrice === 0) && {
|
|
@@ -4098,29 +2889,27 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
4098
2889
|
to: (value) => (isNil(value === null || value === void 0 ? void 0 : value.quantity) ? value : value === null || value === void 0 ? void 0 : value.quantity),
|
|
4099
2890
|
},
|
|
4100
2891
|
},
|
|
4101
|
-
{ hasStock: { columnName: 'has_stock' } },
|
|
4102
2892
|
'slug',
|
|
4103
2893
|
'type',
|
|
4104
2894
|
'video',
|
|
4105
2895
|
'weight',
|
|
4106
2896
|
'gender',
|
|
4107
|
-
{ intGender: { columnName: 'int_gender' } },
|
|
4108
2897
|
{ tags: { columnName: 'tags', type: HasuraGraphQLColumnType.Jsonb } },
|
|
4109
|
-
{ filters: { columnName: 'filters', type: HasuraGraphQLColumnType.Jsonb } },
|
|
4110
2898
|
{ isKit: { columnName: 'is_kit' } },
|
|
4111
2899
|
{ createdAt: { columnName: 'created_at' } },
|
|
4112
2900
|
{ updatedAt: { columnName: 'updated_at' } },
|
|
4113
|
-
{ rate: { columnName: 'rating' } },
|
|
4114
|
-
{ reviewsTotal: { columnName: 'reviews_total' } },
|
|
4115
|
-
{ shoppingCount: { columnName: 'shopping_count' } },
|
|
4116
|
-
{ categoryId: { columnName: 'category_id' } },
|
|
4117
2901
|
{
|
|
4118
|
-
|
|
4119
|
-
columnName: '
|
|
4120
|
-
|
|
4121
|
-
|
|
2902
|
+
rate: {
|
|
2903
|
+
columnName: 'reviews_aggregate',
|
|
2904
|
+
filters: {
|
|
2905
|
+
filters: { status: true },
|
|
2906
|
+
filterType: 'product_review_bool_exp',
|
|
2907
|
+
},
|
|
2908
|
+
fields: [{ aggregate: [{ avg: ['rate'] }] }],
|
|
2909
|
+
from: (value) => value.aggregate.avg.rate,
|
|
4122
2910
|
},
|
|
4123
2911
|
},
|
|
2912
|
+
{ shoppingCount: { columnName: 'shopping_count' } },
|
|
4124
2913
|
];
|
|
4125
2914
|
this.fields = [
|
|
4126
2915
|
...commonFields,
|
|
@@ -4207,7 +2996,7 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
4207
2996
|
var _a;
|
|
4208
2997
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4209
2998
|
const product = Number.isNaN(+identifiers.id)
|
|
4210
|
-
? (_a = (yield this.find({ filters: { firestoreId: identifiers.id }
|
|
2999
|
+
? (_a = (yield this.find({ filters: { firestoreId: identifiers.id } })).data) === null || _a === void 0 ? void 0 : _a[0]
|
|
4211
3000
|
: yield _super.get.call(this, identifiers);
|
|
4212
3001
|
if (product.productId)
|
|
4213
3002
|
throw new NotFoundError('Product not found, it is a variant');
|
|
@@ -4219,29 +3008,13 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
4219
3008
|
const _super = Object.create(null, {
|
|
4220
3009
|
find: { get: () => super.find }
|
|
4221
3010
|
});
|
|
4222
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
4223
3011
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4224
|
-
const
|
|
3012
|
+
const _a = params || {}, { filters, fields } = _a, options = __rest(_a, ["filters", "fields"]);
|
|
4225
3013
|
const bindFields = fields ||
|
|
4226
3014
|
this.fields
|
|
4227
3015
|
.map((field) => (typeof field === 'string' ? field : Object.keys(field).shift()))
|
|
4228
3016
|
.filter((field) => field !== 'reviews');
|
|
4229
|
-
|
|
4230
|
-
(_c = options.options) === null || _c === void 0 ? void 0 : _c.minimal.push('price.price', 'price.fullPrice', 'price.subscriberPrice');
|
|
4231
|
-
if ((_e = (_d = options.options) === null || _d === void 0 ? void 0 : _d.maximum) === null || _e === void 0 ? void 0 : _e.includes('price'))
|
|
4232
|
-
(_f = options.options) === null || _f === void 0 ? void 0 : _f.maximum.push('price.price', 'price.fullPrice', 'price.subscriberPrice');
|
|
4233
|
-
(_h = (_g = options.options) === null || _g === void 0 ? void 0 : _g.minimal) === null || _h === void 0 ? void 0 : _h.splice((_j = options.options) === null || _j === void 0 ? void 0 : _j.minimal.indexOf('price'), 1);
|
|
4234
|
-
(_l = (_k = options.options) === null || _k === void 0 ? void 0 : _k.maximum) === null || _l === void 0 ? void 0 : _l.splice((_m = options.options) === null || _m === void 0 ? void 0 : _m.maximum.indexOf('price'), 1);
|
|
4235
|
-
return _super.find.call(this, Object.assign(Object.assign({}, options), { filters: Object.assign(Object.assign({}, filters), { productId: { operator: Where.ISNULL } }), fields: [
|
|
4236
|
-
...bindFields,
|
|
4237
|
-
...(bindFields.includes('price')
|
|
4238
|
-
? [
|
|
4239
|
-
'subscriberPrice',
|
|
4240
|
-
'subscriberDiscountPercentage',
|
|
4241
|
-
'fullPrice',
|
|
4242
|
-
]
|
|
4243
|
-
: []),
|
|
4244
|
-
] }));
|
|
3017
|
+
return _super.find.call(this, Object.assign(Object.assign({}, options), { filters: Object.assign(Object.assign({}, filters), { productId: { operator: Where.ISNULL } }), fields: bindFields }));
|
|
4245
3018
|
});
|
|
4246
3019
|
}
|
|
4247
3020
|
getBySlug(slug) {
|
|
@@ -4251,13 +3024,9 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
4251
3024
|
filters: {
|
|
4252
3025
|
slug,
|
|
4253
3026
|
},
|
|
4254
|
-
fields: this.fields.map((field) => typeof field === 'string' ? field : Object.keys(field).shift()),
|
|
4255
|
-
options: {
|
|
4256
|
-
enableCount: false,
|
|
4257
|
-
},
|
|
4258
3027
|
});
|
|
4259
3028
|
const product = (_a = result === null || result === void 0 ? void 0 : result.data) === null || _a === void 0 ? void 0 : _a.shift();
|
|
4260
|
-
|
|
3029
|
+
product.reviews = yield this.findReviewsByProduct(+product.id);
|
|
4261
3030
|
return product;
|
|
4262
3031
|
});
|
|
4263
3032
|
}
|
|
@@ -4297,11 +3066,6 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
4297
3066
|
], []);
|
|
4298
3067
|
});
|
|
4299
3068
|
}
|
|
4300
|
-
findCatalog(params, mainGender) {
|
|
4301
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
4302
|
-
return this.find(Object.assign(Object.assign({}, params), { filters: Object.assign(Object.assign({}, params.filters), { published: true }), orderBy: Object.assign(Object.assign({ hasStock: 'desc' }, (!mainGender ? {} : { intGender: mainGender === 'female' ? 'desc' : 'asc' })), omit(params.orderBy, ['hasStock', 'intGender'])) }));
|
|
4303
|
-
});
|
|
4304
|
-
}
|
|
4305
3069
|
updateCategories(productId, { categories }) {
|
|
4306
3070
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4307
3071
|
if ('action' in categories && categories.action === 'remove') {
|
|
@@ -4404,7 +3168,7 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
4404
3168
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4405
3169
|
const plainData = this.paramsToPlain({ metadata });
|
|
4406
3170
|
if (!plainData.metadata)
|
|
4407
|
-
return;
|
|
3171
|
+
return null;
|
|
4408
3172
|
yield this.mutation('update_product_metadata_by_pk', ['product_id'], {
|
|
4409
3173
|
pk_columns: {
|
|
4410
3174
|
value: { product_id: productId },
|
|
@@ -4425,7 +3189,7 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
4425
3189
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4426
3190
|
if (!Number.isNaN(+id))
|
|
4427
3191
|
return id;
|
|
4428
|
-
const { data } = yield this.find({ filters: { firestoreId: id }
|
|
3192
|
+
const { data } = yield this.find({ filters: { firestoreId: id } });
|
|
4429
3193
|
if ((_a = data === null || data === void 0 ? void 0 : data[0]) === null || _a === void 0 ? void 0 : _a.id)
|
|
4430
3194
|
return (_b = data === null || data === void 0 ? void 0 : data[0]) === null || _b === void 0 ? void 0 : _b.id;
|
|
4431
3195
|
throw new NotFoundError(`Product with id ${id} not found`);
|
|
@@ -4481,34 +3245,26 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
4481
3245
|
return data && data[0] && this.bindReviewToModel(data[0]);
|
|
4482
3246
|
});
|
|
4483
3247
|
}
|
|
4484
|
-
cleanShoppingCountFromIds(ids) {
|
|
4485
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
4486
|
-
return yield this.mutation('update_product', ['affected_rows'], {
|
|
4487
|
-
where: {
|
|
4488
|
-
value: { id: { _nin: ids } },
|
|
4489
|
-
type: 'product_bool_exp',
|
|
4490
|
-
required: true,
|
|
4491
|
-
},
|
|
4492
|
-
_set: {
|
|
4493
|
-
value: { shopping_count: 0 },
|
|
4494
|
-
type: 'product_set_input',
|
|
4495
|
-
},
|
|
4496
|
-
});
|
|
4497
|
-
});
|
|
4498
|
-
}
|
|
4499
3248
|
}
|
|
4500
3249
|
|
|
4501
3250
|
class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
4502
|
-
constructor(endpoint, authOptions) {
|
|
3251
|
+
constructor({ endpoint, authOptions, interceptors, }) {
|
|
4503
3252
|
super({
|
|
4504
3253
|
tableName: 'product',
|
|
4505
3254
|
model: VariantHasuraGraphQL,
|
|
4506
3255
|
endpoint,
|
|
4507
3256
|
authOptions,
|
|
3257
|
+
interceptors,
|
|
4508
3258
|
fields: [
|
|
4509
3259
|
{ id: { columnName: 'id', to: (value) => +value, from: (value) => value.toString() } },
|
|
4510
3260
|
{ firestoreId: { columnName: 'firestore_id' } },
|
|
4511
|
-
{
|
|
3261
|
+
{
|
|
3262
|
+
productId: {
|
|
3263
|
+
columnName: 'main_product_id',
|
|
3264
|
+
to: (value) => +value,
|
|
3265
|
+
from: (value) => value === null || value === void 0 ? void 0 : value.toString(),
|
|
3266
|
+
},
|
|
3267
|
+
},
|
|
4512
3268
|
{ EAN: { columnName: 'ean' } },
|
|
4513
3269
|
{ costPrice: { columnName: 'cost_price' } },
|
|
4514
3270
|
{
|
|
@@ -4521,16 +3277,16 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
4521
3277
|
subscriberPrice: data.subscriber_price,
|
|
4522
3278
|
}),
|
|
4523
3279
|
bindFindFilter: (sentence) => {
|
|
4524
|
-
const filters = Object.values(sentence).shift();
|
|
3280
|
+
const filters = Object.values(sentence || {}).shift();
|
|
4525
3281
|
return Object.assign(Object.assign(Object.assign(Object.assign({}, (((filters === null || filters === void 0 ? void 0 : filters.price) || (filters === null || filters === void 0 ? void 0 : filters.price) === 0) && { price: filters.price })), ((filters.fullPrice || filters.fullPrice === 0) && { full_price: filters.fullPrice })), ((filters.subscriberDiscountPercentage || filters.subscriberDiscountPercentage === 0) && {
|
|
4526
3282
|
subscriber_discount_percentage: filters.subscriberDiscountPercentage,
|
|
4527
3283
|
})), ((filters.subscriberPrice || filters.subscriberPrice === 0) && {
|
|
4528
3284
|
subscriber_price: filters.subscriberPrice,
|
|
4529
3285
|
}));
|
|
4530
3286
|
},
|
|
4531
|
-
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 && {
|
|
3287
|
+
bindPersistData: (priceData) => (Object.assign(Object.assign(Object.assign(Object.assign({}, (((priceData === null || priceData === void 0 ? void 0 : priceData.price) || 0) >= 0 && { price: priceData.price })), (((priceData === null || priceData === void 0 ? void 0 : priceData.fullPrice) || 0) >= 0 && { full_price: priceData.fullPrice })), (((priceData === null || priceData === void 0 ? void 0 : priceData.subscriberDiscountPercentage) || 0) >= 0 && {
|
|
4532
3288
|
subscriber_discount_percentage: priceData.subscriberDiscountPercentage,
|
|
4533
|
-
})), (priceData.subscriberPrice >= 0 && { subscriber_price: priceData.subscriberPrice }))),
|
|
3289
|
+
})), (((priceData === null || priceData === void 0 ? void 0 : priceData.subscriberPrice) || 0) >= 0 && { subscriber_price: priceData.subscriberPrice }))),
|
|
4534
3290
|
},
|
|
4535
3291
|
},
|
|
4536
3292
|
{ fullPrice: { columnName: 'full_price' } },
|
|
@@ -4544,7 +3300,6 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
4544
3300
|
to: (value) => (isNil(value === null || value === void 0 ? void 0 : value.quantity) ? value : value === null || value === void 0 ? void 0 : value.quantity),
|
|
4545
3301
|
},
|
|
4546
3302
|
},
|
|
4547
|
-
{ hasStock: { columnName: 'has_stock' } },
|
|
4548
3303
|
'weight',
|
|
4549
3304
|
{ name: { to: () => '', from: () => undefined } },
|
|
4550
3305
|
{ hasVariants: { columnName: 'has_variants', to: () => false, from: () => undefined } },
|
|
@@ -4600,7 +3355,7 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
4600
3355
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4601
3356
|
if (!Number.isNaN(+id))
|
|
4602
3357
|
return id;
|
|
4603
|
-
const { data } = yield this.find({ filters: { firestoreId: id }
|
|
3358
|
+
const { data } = yield this.find({ filters: { firestoreId: id } });
|
|
4604
3359
|
if ((_a = data === null || data === void 0 ? void 0 : data[0]) === null || _a === void 0 ? void 0 : _a.id)
|
|
4605
3360
|
return (_b = data === null || data === void 0 ? void 0 : data[0]) === null || _b === void 0 ? void 0 : _b.id;
|
|
4606
3361
|
throw new NotFoundError(`Product with id ${id} not found`);
|
|
@@ -4608,255 +3363,9 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
4608
3363
|
}
|
|
4609
3364
|
}
|
|
4610
3365
|
|
|
4611
|
-
class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
4612
|
-
constructor(endpoint, authOptions, categoryFilterRepository) {
|
|
4613
|
-
super({
|
|
4614
|
-
tableName: 'category',
|
|
4615
|
-
model: Wishlist,
|
|
4616
|
-
endpoint,
|
|
4617
|
-
authOptions,
|
|
4618
|
-
fields: [
|
|
4619
|
-
{ id: { columnName: 'id', to: (value) => +value, from: (value) => value.toString() } },
|
|
4620
|
-
{ firestoreId: { columnName: 'firestore_id' } },
|
|
4621
|
-
'name',
|
|
4622
|
-
'description',
|
|
4623
|
-
'image',
|
|
4624
|
-
'published',
|
|
4625
|
-
'shop',
|
|
4626
|
-
{ shops: { columnName: 'shops', type: HasuraGraphQLColumnType.Jsonb } },
|
|
4627
|
-
'slug',
|
|
4628
|
-
{ brandCategory: { columnName: 'brand_category' } },
|
|
4629
|
-
{ brandCategoryBanner: { columnName: 'brand_banner' } },
|
|
4630
|
-
{ brandCategoryBannerMobile: { columnName: 'brand_banner_mobile' } },
|
|
4631
|
-
{ brandLogo: { columnName: 'brand_logo' } },
|
|
4632
|
-
{ brandCondition: { columnName: 'brand_condition' } },
|
|
4633
|
-
{
|
|
4634
|
-
conditions: {
|
|
4635
|
-
columnName: 'tag_condition',
|
|
4636
|
-
type: HasuraGraphQLColumnType.Jsonb,
|
|
4637
|
-
from: (tags, row) => ({ brand: row.brand_condition, tags: Array.isArray(tags) ? tags : [] }),
|
|
4638
|
-
bindPersistData: (value) => {
|
|
4639
|
-
return {
|
|
4640
|
-
brand_condition: value.brand,
|
|
4641
|
-
tag_condition: (value === null || value === void 0 ? void 0 : value.tags) || [],
|
|
4642
|
-
};
|
|
4643
|
-
},
|
|
4644
|
-
bindFindFilter: (sentence) => {
|
|
4645
|
-
return Object.assign(Object.assign({}, (sentence.brand ? { brand_condition: sentence.brand } : {})), (sentence.tags ? { tag_condition: sentence.tags } : {}));
|
|
4646
|
-
},
|
|
4647
|
-
},
|
|
4648
|
-
},
|
|
4649
|
-
{
|
|
4650
|
-
filters: {
|
|
4651
|
-
columnName: 'filters',
|
|
4652
|
-
foreignKeyColumn: { filter_id: 'id' },
|
|
4653
|
-
fields: [{ filter: ['id', 'description', 'slug', 'enabled'] }],
|
|
4654
|
-
bindPersistData: (value) => ({
|
|
4655
|
-
filters: { data: value.map((filter) => ({ filter_id: filter.id })) },
|
|
4656
|
-
}),
|
|
4657
|
-
from: (filters) => (filters === null || filters === void 0 ? void 0 : filters.map((filter) => filter === null || filter === void 0 ? void 0 : filter.filter)) || [],
|
|
4658
|
-
},
|
|
4659
|
-
},
|
|
4660
|
-
{ createdAt: { columnName: 'created_at' } },
|
|
4661
|
-
{ updatedAt: { columnName: 'updated_at' } },
|
|
4662
|
-
{
|
|
4663
|
-
products: {
|
|
4664
|
-
columnName: 'products',
|
|
4665
|
-
fields: ['product_id'],
|
|
4666
|
-
from: (value) => value.map((product) => product.product_id.toString()),
|
|
4667
|
-
to: (productIds) => productIds.map((productId) => ({
|
|
4668
|
-
product_id: +productId,
|
|
4669
|
-
})),
|
|
4670
|
-
},
|
|
4671
|
-
},
|
|
4672
|
-
{
|
|
4673
|
-
metadata: {
|
|
4674
|
-
columnName: 'metadata',
|
|
4675
|
-
fields: ['title', 'description'],
|
|
4676
|
-
bindPersistData: (value) => ({
|
|
4677
|
-
metadata: { data: value },
|
|
4678
|
-
}),
|
|
4679
|
-
},
|
|
4680
|
-
},
|
|
4681
|
-
{ isCollection: { columnName: 'is_collection' } },
|
|
4682
|
-
{ isWishlist: { columnName: 'is_wishlist' } },
|
|
4683
|
-
'reference',
|
|
4684
|
-
{ parentId: { columnName: 'parent_id' } },
|
|
4685
|
-
{
|
|
4686
|
-
parent: {
|
|
4687
|
-
columnName: 'parent',
|
|
4688
|
-
foreignKeyColumn: { id: 'parentId' },
|
|
4689
|
-
fields: ['id', 'name', 'reference', 'slug'],
|
|
4690
|
-
},
|
|
4691
|
-
},
|
|
4692
|
-
{ personId: { columnName: 'person_id' } },
|
|
4693
|
-
],
|
|
4694
|
-
});
|
|
4695
|
-
this.categoryFilterRepository = categoryFilterRepository;
|
|
4696
|
-
}
|
|
4697
|
-
create(params) {
|
|
4698
|
-
const _super = Object.create(null, {
|
|
4699
|
-
create: { get: () => super.create }
|
|
4700
|
-
});
|
|
4701
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
4702
|
-
const { metadata } = params, data = __rest(params, ["metadata"]);
|
|
4703
|
-
return _super.create.call(this, Object.assign(Object.assign({}, data), { isWishlist: true, isCollection: true, brandCategory: false, metadata: metadata || { description: data.description, title: data.name } }));
|
|
4704
|
-
});
|
|
4705
|
-
}
|
|
4706
|
-
get(identifiers) {
|
|
4707
|
-
const _super = Object.create(null, {
|
|
4708
|
-
get: { get: () => super.get }
|
|
4709
|
-
});
|
|
4710
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
4711
|
-
const data = yield _super.get.call(this, identifiers);
|
|
4712
|
-
if (!data.isWishlist)
|
|
4713
|
-
throw new NotFoundError(`Category with id ${identifiers.id} is not a wishlist`);
|
|
4714
|
-
return data;
|
|
4715
|
-
});
|
|
4716
|
-
}
|
|
4717
|
-
update(params) {
|
|
4718
|
-
const _super = Object.create(null, {
|
|
4719
|
-
update: { get: () => super.update }
|
|
4720
|
-
});
|
|
4721
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
4722
|
-
const { products, id: checkId, metadata, filters } = params, data = __rest(params, ["products", "id", "metadata", "filters"]);
|
|
4723
|
-
const plainData = this.paramsToPlain({ id: checkId });
|
|
4724
|
-
const id = plainData.id;
|
|
4725
|
-
const category = yield _super.update.call(this, Object.assign(Object.assign({ id }, data), { isWishlist: true, isCollection: true, brandCategory: false }));
|
|
4726
|
-
category.products = products && (yield this.updateProducts(+id, { products }));
|
|
4727
|
-
category.metadata = metadata && (yield this.updateMetadata(+id, { metadata }));
|
|
4728
|
-
return category;
|
|
4729
|
-
});
|
|
4730
|
-
}
|
|
4731
|
-
getWishlistBySlug(slug) {
|
|
4732
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
4733
|
-
if (!slug)
|
|
4734
|
-
return;
|
|
4735
|
-
const { data } = yield this.find({
|
|
4736
|
-
filters: {
|
|
4737
|
-
slug,
|
|
4738
|
-
isWishlist: { operator: Where.EQUALS, value: true },
|
|
4739
|
-
},
|
|
4740
|
-
options: {
|
|
4741
|
-
enableCount: false,
|
|
4742
|
-
},
|
|
4743
|
-
});
|
|
4744
|
-
if (!data.length)
|
|
4745
|
-
throw new NotFoundError(`Wishlist with slug ${slug} not found`);
|
|
4746
|
-
if (data.length > 1)
|
|
4747
|
-
throw new DuplicatedResultsError('Query returned duplicated values');
|
|
4748
|
-
return data.shift();
|
|
4749
|
-
});
|
|
4750
|
-
}
|
|
4751
|
-
getWishlistByPerson(personId) {
|
|
4752
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
4753
|
-
if (!personId)
|
|
4754
|
-
return;
|
|
4755
|
-
const { data } = yield this.find({
|
|
4756
|
-
filters: {
|
|
4757
|
-
personId: { operator: Where.EQUALS, value: personId },
|
|
4758
|
-
isWishlist: { operator: Where.EQUALS, value: true },
|
|
4759
|
-
},
|
|
4760
|
-
options: {
|
|
4761
|
-
enableCount: false,
|
|
4762
|
-
},
|
|
4763
|
-
});
|
|
4764
|
-
if (!data.length)
|
|
4765
|
-
throw new NotFoundError(`Wishlists from person ${personId} not found`);
|
|
4766
|
-
return data;
|
|
4767
|
-
});
|
|
4768
|
-
}
|
|
4769
|
-
updateProducts(categoryId, { products }) {
|
|
4770
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
4771
|
-
if ('action' in products && products.action === 'remove') {
|
|
4772
|
-
yield this.mutation('delete_category_product', ['affected_rows'], {
|
|
4773
|
-
where: {
|
|
4774
|
-
type: 'category_product_bool_exp',
|
|
4775
|
-
required: true,
|
|
4776
|
-
value: { category_id: { _eq: categoryId } },
|
|
4777
|
-
},
|
|
4778
|
-
});
|
|
4779
|
-
yield this.categoryFilterRepository.deleteByCategory(categoryId);
|
|
4780
|
-
return [];
|
|
4781
|
-
}
|
|
4782
|
-
const plainData = this.paramsToPlain({ products });
|
|
4783
|
-
if (!plainData.products || plainData.products.length <= 0)
|
|
4784
|
-
return [];
|
|
4785
|
-
yield this.mutation('delete_category_product', ['affected_rows'], {
|
|
4786
|
-
where: {
|
|
4787
|
-
type: 'category_product_bool_exp',
|
|
4788
|
-
required: true,
|
|
4789
|
-
value: { category_id: { _eq: categoryId } },
|
|
4790
|
-
},
|
|
4791
|
-
});
|
|
4792
|
-
yield this.categoryFilterRepository.deleteByCategory(categoryId);
|
|
4793
|
-
yield this.mutation('insert_category_product', ['affected_rows'], {
|
|
4794
|
-
objects: {
|
|
4795
|
-
type: '[category_product_insert_input!]',
|
|
4796
|
-
required: true,
|
|
4797
|
-
value: plainData.products.map((productId) => ({ category_id: categoryId, product_id: productId })),
|
|
4798
|
-
},
|
|
4799
|
-
});
|
|
4800
|
-
return plainData.products;
|
|
4801
|
-
});
|
|
4802
|
-
}
|
|
4803
|
-
updateMetadata(categoryId, { metadata }) {
|
|
4804
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
4805
|
-
const plainData = this.paramsToPlain({ metadata });
|
|
4806
|
-
if (!plainData.metadata)
|
|
4807
|
-
return;
|
|
4808
|
-
yield this.mutation('update_category_metadata_by_pk', ['category_id'], {
|
|
4809
|
-
pk_columns: {
|
|
4810
|
-
value: { category_id: categoryId },
|
|
4811
|
-
type: 'category_metadata_pk_columns_input',
|
|
4812
|
-
required: true,
|
|
4813
|
-
},
|
|
4814
|
-
_set: {
|
|
4815
|
-
value: omit(metadata, ['category_id']),
|
|
4816
|
-
type: 'category_metadata_set_input',
|
|
4817
|
-
required: true,
|
|
4818
|
-
},
|
|
4819
|
-
});
|
|
4820
|
-
return plainData.metadata;
|
|
4821
|
-
});
|
|
4822
|
-
}
|
|
4823
|
-
getCategoryBySlug(slug, _shop) {
|
|
4824
|
-
return this.getWishlistBySlug(slug);
|
|
4825
|
-
}
|
|
4826
|
-
getCategoryByShop(shop) {
|
|
4827
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
4828
|
-
if (!shop)
|
|
4829
|
-
return;
|
|
4830
|
-
const { data } = yield this.find({
|
|
4831
|
-
filters: {
|
|
4832
|
-
shops: { operator: Where.IN, value: [shop] },
|
|
4833
|
-
published: { operator: Where.EQUALS, value: true },
|
|
4834
|
-
isWishlist: { operator: Where.EQUALS, value: true },
|
|
4835
|
-
},
|
|
4836
|
-
options: {
|
|
4837
|
-
enableCount: false,
|
|
4838
|
-
},
|
|
4839
|
-
});
|
|
4840
|
-
return data;
|
|
4841
|
-
});
|
|
4842
|
-
}
|
|
4843
|
-
getCategoriesForHome(categoryIds, limit, gender) {
|
|
4844
|
-
return;
|
|
4845
|
-
}
|
|
4846
|
-
mountCategory(category, options) {
|
|
4847
|
-
return;
|
|
4848
|
-
}
|
|
4849
|
-
getChildren(parentId) {
|
|
4850
|
-
return;
|
|
4851
|
-
}
|
|
4852
|
-
isChild(id, parentId) {
|
|
4853
|
-
return;
|
|
4854
|
-
}
|
|
4855
|
-
}
|
|
4856
|
-
|
|
4857
3366
|
/**
|
|
4858
3367
|
* Generated bundle index. Do not edit.
|
|
4859
3368
|
*/
|
|
4860
3369
|
|
|
4861
|
-
export { AccessoryImportances, Address, Area, Authentication, AuthenticationFirebaseAuthService, AxiosAdapter, Base, BaseModel, BeardProblems, BeardSizes, BeautyProductImportances, BeautyProfile, BeautyQuestionsHelper, BillingStatus, BodyProblems, BodyShapes, BodyTattoos, Buy2Win, Buy2WinFirestoreRepository,
|
|
4862
|
-
//# sourceMappingURL=infrab4a-connect.
|
|
3370
|
+
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, get, is, isUUID, parseDateTime, withCreateFirestore, withCreateHasuraGraphQL, withCrudFirestore, withCrudHasuraGraphQL, withDeleteFirestore, withDeleteHasuraGraphQL, withFindFirestore, withFindHasuraGraphQL, withFirestore, withGetFirestore, withGetHasuraGraphQL, withHasuraGraphQL, withHelpers, withSubCollection, withUpdateFirestore, withUpdateHasuraGraphQL };
|
|
3371
|
+
//# sourceMappingURL=infrab4a-connect.mjs.map
|