@infrab4a/connect 3.16.0-beta.1 → 4.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/domain/catalog/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/{esm2015/domain/users/models/subscription/payment.js → esm2020/domain/users/models/subscription/payment.mjs} +1 -1
- 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.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/{esm2015/infra/firebase/firestore/repositories/shopping/coupon-firestore.repository.js → esm2020/infra/firebase/firestore/repositories/shopping/coupon-firestore.repository.mjs} +2 -2
- 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 +92 -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 +222 -0
- package/esm2020/infra/hasura-graphql/repositories/catalog/index.mjs +4 -0
- package/esm2020/infra/hasura-graphql/repositories/catalog/product-hasura-graphql.repository.mjs +466 -0
- package/esm2020/infra/hasura-graphql/repositories/catalog/variant-hasura-graphql.repository.mjs +112 -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/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} +471 -1971
- package/fesm2015/infrab4a-connect.mjs.map +1 -0
- package/fesm2020/infrab4a-connect.mjs +3313 -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 +2 -2
- 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 +2 -9
- package/infra/hasura-graphql/repositories/catalog/index.d.ts +0 -5
- package/infra/hasura-graphql/repositories/catalog/product-hasura-graphql.repository.d.ts +1 -3
- 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/index.d.ts +46 -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/subscription.js +0 -43
- 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/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/edition.js → esm2020/domain/users/models/subscription/edition.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/models/user-payment-method.js → esm2020/domain/users/models/user-payment-method.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,19 @@ import { plainToInstance, instanceToPlain, Expose, Type } from 'class-transforme
|
|
|
3
3
|
import { __decorate, __metadata, __awaiter, __rest } from 'tslib';
|
|
4
4
|
import { parseISO } from 'date-fns';
|
|
5
5
|
export { add, addBusinessDays, addDays, addMonths, addYears, endOfDay, format, formatISO9075, parseISO, startOfDay, sub } from 'date-fns';
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
import { Subject } from 'rxjs';
|
|
9
|
-
import { debug } from 'debug';
|
|
6
|
+
import * as lodash from 'lodash';
|
|
7
|
+
import { isString as isString$1 } 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';
|
|
13
|
+
import fetch from 'node-fetch';
|
|
14
14
|
|
|
15
15
|
class BaseModel {
|
|
16
16
|
get identifier() {
|
|
17
17
|
const fields = this.constructor.identifiersFields.filter((field) => field !== 'identifier');
|
|
18
|
-
|
|
19
|
-
return fields.reduce((object, field) => (Object.assign(Object.assign({}, object), { [field]: data[field] })), {});
|
|
18
|
+
return fields.reduce((object, field) => (Object.assign(Object.assign({}, object), { [field]: this[field] })), {});
|
|
20
19
|
}
|
|
21
20
|
get identifiersFields() {
|
|
22
21
|
return this.constructor.identifiersFields;
|
|
@@ -462,439 +461,17 @@ __decorate([
|
|
|
462
461
|
__metadata("design:type", Payment)
|
|
463
462
|
], SubscriptionPayment.prototype, "payment", void 0);
|
|
464
463
|
|
|
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
|
-
});
|
|
649
|
-
}
|
|
650
|
-
}
|
|
651
|
-
DebugDecoratorHelper.DebugNamingMetadataKey = 'model:naming:decorator';
|
|
652
|
-
|
|
653
|
-
class ClassNameHelper {
|
|
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
|
-
}
|
|
666
|
-
|
|
667
|
-
const isDebuggable = (object) => {
|
|
668
|
-
return 'debug' in object;
|
|
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(' ');
|
|
464
|
+
class Address extends BaseModel {
|
|
465
|
+
static get identifiersFields() {
|
|
466
|
+
return ['id'];
|
|
805
467
|
}
|
|
806
468
|
}
|
|
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
|
-
};
|
|
816
|
-
}
|
|
817
469
|
|
|
818
|
-
|
|
819
|
-
|
|
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
|
-
};
|
|
470
|
+
function is(value) {
|
|
471
|
+
return value;
|
|
836
472
|
}
|
|
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
473
|
|
|
897
|
-
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);
|
|
474
|
+
const isUUID = (value) => isString$1(value) && /[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}/.test(value);
|
|
898
475
|
|
|
899
476
|
class Base {
|
|
900
477
|
constructor(...args) {
|
|
@@ -903,7 +480,7 @@ class Base {
|
|
|
903
480
|
}
|
|
904
481
|
|
|
905
482
|
const parseDateTime = (value) => {
|
|
906
|
-
if (!isString(value))
|
|
483
|
+
if (!isString$1(value))
|
|
907
484
|
return value;
|
|
908
485
|
if (!/^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])$/.test(value) &&
|
|
909
486
|
!/^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])T\d{2}:\d{2}:\d{2}/.test(value))
|
|
@@ -914,6 +491,8 @@ const parseDateTime = (value) => {
|
|
|
914
491
|
return date;
|
|
915
492
|
};
|
|
916
493
|
|
|
494
|
+
const { chunk, get, isBoolean, isDate, isEmpty, isInteger, isNaN: isNaN$1, isNil, isNumber, isObject, isString, now, omit, pick, set, } = lodash;
|
|
495
|
+
|
|
917
496
|
var CheckoutTypes;
|
|
918
497
|
(function (CheckoutTypes) {
|
|
919
498
|
CheckoutTypes[CheckoutTypes["ECOMMERCE"] = 1] = "ECOMMERCE";
|
|
@@ -958,28 +537,26 @@ class Coupon extends BaseModel {
|
|
|
958
537
|
static createCoupon(userId) {
|
|
959
538
|
return this.toInstance({
|
|
960
539
|
nickname: `${Date.now()}`,
|
|
540
|
+
type: CouponTypes.ABSOLUTE,
|
|
961
541
|
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
|
-
},
|
|
542
|
+
discount: 30,
|
|
976
543
|
user: userId,
|
|
544
|
+
useLimit: 1,
|
|
545
|
+
useLimitPerUser: true,
|
|
977
546
|
createdAt: new Date(Date.now()),
|
|
978
547
|
beginAt: new Date(Date.now()),
|
|
979
548
|
expiresIn: new Date(Date.now() + COUPON_EXPIRATION),
|
|
980
549
|
});
|
|
981
550
|
}
|
|
982
551
|
}
|
|
552
|
+
__decorate([
|
|
553
|
+
Expose({ name: 'checkout_type' }),
|
|
554
|
+
__metadata("design:type", Number)
|
|
555
|
+
], Coupon.prototype, "checkoutType", void 0);
|
|
556
|
+
__decorate([
|
|
557
|
+
Expose({ name: 'exclusivity_type' }),
|
|
558
|
+
__metadata("design:type", Number)
|
|
559
|
+
], Coupon.prototype, "exclusivityType", void 0);
|
|
983
560
|
|
|
984
561
|
class SubscriptionPlan extends BaseModel {
|
|
985
562
|
static get identifiersFields() {
|
|
@@ -1019,18 +596,6 @@ __decorate([
|
|
|
1019
596
|
__metadata("design:type", BeautyProfile)
|
|
1020
597
|
], User.prototype, "beautyProfile", void 0);
|
|
1021
598
|
|
|
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
599
|
class Subscription extends BaseModel {
|
|
1035
600
|
static get identifiersFields() {
|
|
1036
601
|
return ['id'];
|
|
@@ -1045,12 +610,12 @@ __decorate([
|
|
|
1045
610
|
__metadata("design:type", SubscriptionPlan)
|
|
1046
611
|
], Subscription.prototype, "subscriptionPlan", void 0);
|
|
1047
612
|
__decorate([
|
|
1048
|
-
Type(() =>
|
|
1049
|
-
__metadata("design:type",
|
|
613
|
+
Type(() => Address),
|
|
614
|
+
__metadata("design:type", Address)
|
|
1050
615
|
], Subscription.prototype, "shippingAddress", void 0);
|
|
1051
616
|
__decorate([
|
|
1052
|
-
Type(() =>
|
|
1053
|
-
__metadata("design:type",
|
|
617
|
+
Type(() => Address),
|
|
618
|
+
__metadata("design:type", Address)
|
|
1054
619
|
], Subscription.prototype, "billingAddress", void 0);
|
|
1055
620
|
__decorate([
|
|
1056
621
|
Type(() => Coupon),
|
|
@@ -1065,6 +630,12 @@ __decorate([
|
|
|
1065
630
|
__metadata("design:type", Array)
|
|
1066
631
|
], Subscription.prototype, "payment", void 0);
|
|
1067
632
|
|
|
633
|
+
class UserAddress extends Address {
|
|
634
|
+
static get identifiersFields() {
|
|
635
|
+
return ['id', 'userId'];
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
|
|
1068
639
|
class UserPaymentMethod extends BaseModel {
|
|
1069
640
|
static get identifiersFields() {
|
|
1070
641
|
return ['id', 'userId'];
|
|
@@ -1080,7 +651,6 @@ class Lead extends BaseModel {
|
|
|
1080
651
|
class UnauthorizedError extends CustomError {
|
|
1081
652
|
constructor(message) {
|
|
1082
653
|
super(message);
|
|
1083
|
-
this.message = message;
|
|
1084
654
|
}
|
|
1085
655
|
}
|
|
1086
656
|
|
|
@@ -1123,14 +693,12 @@ class Authentication {
|
|
|
1123
693
|
class UserAlreadyRegisteredError extends CustomError {
|
|
1124
694
|
constructor(message) {
|
|
1125
695
|
super(message);
|
|
1126
|
-
this.message = message;
|
|
1127
696
|
}
|
|
1128
697
|
}
|
|
1129
698
|
|
|
1130
699
|
class WeakPasswordError extends CustomError {
|
|
1131
700
|
constructor(message = 'Weak password') {
|
|
1132
701
|
super(message);
|
|
1133
|
-
this.message = message;
|
|
1134
702
|
}
|
|
1135
703
|
}
|
|
1136
704
|
|
|
@@ -1187,123 +755,14 @@ class RecoveryPassword {
|
|
|
1187
755
|
}
|
|
1188
756
|
}
|
|
1189
757
|
|
|
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() {
|
|
1236
|
-
return ['id'];
|
|
1237
|
-
}
|
|
1238
|
-
}
|
|
1239
|
-
|
|
1240
|
-
class ProductForKit extends ProductBase {
|
|
1241
|
-
static get identifiersFields() {
|
|
1242
|
-
return ['id'];
|
|
1243
|
-
}
|
|
1244
|
-
}
|
|
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() {
|
|
758
|
+
class Category extends BaseModel {
|
|
759
|
+
identifierFields() {
|
|
1276
760
|
return ['id'];
|
|
1277
761
|
}
|
|
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
762
|
static get identifiersFields() {
|
|
1296
763
|
return ['id'];
|
|
1297
764
|
}
|
|
1298
765
|
}
|
|
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
766
|
|
|
1308
767
|
var GenderDestination;
|
|
1309
768
|
(function (GenderDestination) {
|
|
@@ -1320,60 +779,54 @@ var Shops;
|
|
|
1320
779
|
Shops["ALL"] = "ALL";
|
|
1321
780
|
})(Shops || (Shops = {}));
|
|
1322
781
|
|
|
1323
|
-
class
|
|
1324
|
-
|
|
782
|
+
class Product extends BaseModel {
|
|
783
|
+
identifierFields() {
|
|
1325
784
|
return ['id'];
|
|
1326
785
|
}
|
|
1327
|
-
}
|
|
1328
|
-
|
|
1329
|
-
class Product extends ProductBase {
|
|
1330
786
|
static get identifiersFields() {
|
|
1331
787
|
return ['id'];
|
|
1332
788
|
}
|
|
1333
789
|
}
|
|
1334
|
-
__decorate([
|
|
1335
|
-
Type(() => CategoryForProduct),
|
|
1336
|
-
__metadata("design:type", CategoryForProduct)
|
|
1337
|
-
], Product.prototype, "category", void 0);
|
|
1338
790
|
__decorate([
|
|
1339
791
|
Type(() => KitProduct),
|
|
1340
792
|
__metadata("design:type", Array)
|
|
1341
793
|
], Product.prototype, "kitProducts", void 0);
|
|
1342
794
|
|
|
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 {
|
|
795
|
+
class KitProduct extends BaseModel {
|
|
1356
796
|
static get identifiersFields() {
|
|
1357
|
-
return ['
|
|
797
|
+
return ['productId', 'kitProducId'];
|
|
1358
798
|
}
|
|
1359
799
|
}
|
|
1360
800
|
__decorate([
|
|
1361
|
-
Type(() =>
|
|
1362
|
-
__metadata("design:type",
|
|
1363
|
-
],
|
|
801
|
+
Type(() => Product),
|
|
802
|
+
__metadata("design:type", Product)
|
|
803
|
+
], KitProduct.prototype, "kit", void 0);
|
|
804
|
+
__decorate([
|
|
805
|
+
Type(() => Product),
|
|
806
|
+
__metadata("design:type", Product)
|
|
807
|
+
], KitProduct.prototype, "product", void 0);
|
|
1364
808
|
|
|
1365
|
-
class
|
|
1366
|
-
|
|
809
|
+
class Variant extends BaseModel {
|
|
810
|
+
identifierFields() {
|
|
1367
811
|
return ['id'];
|
|
1368
812
|
}
|
|
1369
|
-
}
|
|
1370
|
-
|
|
1371
|
-
class CampaignHashtag extends BaseModel {
|
|
1372
813
|
static get identifiersFields() {
|
|
1373
|
-
return ['id'];
|
|
814
|
+
return ['id', 'productId'];
|
|
1374
815
|
}
|
|
1375
816
|
}
|
|
1376
817
|
|
|
818
|
+
var OrderStatus;
|
|
819
|
+
(function (OrderStatus) {
|
|
820
|
+
OrderStatus["AGUARDANDO_PAGAMENTO"] = "Aguardando pagamento";
|
|
821
|
+
OrderStatus["EM_PREPARO"] = "Preparando pedido";
|
|
822
|
+
OrderStatus["NF_EMITIDA"] = "Nota Fiscal Emitida";
|
|
823
|
+
OrderStatus["AGUARDANDO_ENVIO"] = "Aguardando Transaportadora";
|
|
824
|
+
OrderStatus["ENVIADO"] = "Enviado";
|
|
825
|
+
OrderStatus["ENTREGUE"] = "Entregue";
|
|
826
|
+
OrderStatus["CANCELADO"] = "Cancelado";
|
|
827
|
+
OrderStatus["CREDIT_CARD"] = "credit_card";
|
|
828
|
+
})(OrderStatus || (OrderStatus = {}));
|
|
829
|
+
|
|
1377
830
|
class LineItem extends Product {
|
|
1378
831
|
}
|
|
1379
832
|
|
|
@@ -1397,12 +850,12 @@ __decorate([
|
|
|
1397
850
|
__metadata("design:type", User)
|
|
1398
851
|
], Checkout.prototype, "user", void 0);
|
|
1399
852
|
__decorate([
|
|
1400
|
-
Type(() =>
|
|
1401
|
-
__metadata("design:type",
|
|
853
|
+
Type(() => Address),
|
|
854
|
+
__metadata("design:type", Address)
|
|
1402
855
|
], Checkout.prototype, "shippingAddress", void 0);
|
|
1403
856
|
__decorate([
|
|
1404
|
-
Type(() =>
|
|
1405
|
-
__metadata("design:type",
|
|
857
|
+
Type(() => Address),
|
|
858
|
+
__metadata("design:type", Address)
|
|
1406
859
|
], Checkout.prototype, "billingAddress", void 0);
|
|
1407
860
|
__decorate([
|
|
1408
861
|
Type(() => ShippingMethod),
|
|
@@ -1413,18 +866,6 @@ __decorate([
|
|
|
1413
866
|
__metadata("design:type", Coupon)
|
|
1414
867
|
], Checkout.prototype, "coupon", void 0);
|
|
1415
868
|
|
|
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
869
|
class Order extends Checkout {
|
|
1429
870
|
}
|
|
1430
871
|
__decorate([
|
|
@@ -1438,12 +879,12 @@ class CheckoutSubscription extends BaseModel {
|
|
|
1438
879
|
}
|
|
1439
880
|
}
|
|
1440
881
|
__decorate([
|
|
1441
|
-
Type(() =>
|
|
1442
|
-
__metadata("design:type",
|
|
882
|
+
Type(() => Address),
|
|
883
|
+
__metadata("design:type", Address)
|
|
1443
884
|
], CheckoutSubscription.prototype, "shippingAddress", void 0);
|
|
1444
885
|
__decorate([
|
|
1445
|
-
Type(() =>
|
|
1446
|
-
__metadata("design:type",
|
|
886
|
+
Type(() => Address),
|
|
887
|
+
__metadata("design:type", Address)
|
|
1447
888
|
], CheckoutSubscription.prototype, "billingAddress", void 0);
|
|
1448
889
|
__decorate([
|
|
1449
890
|
Type(() => SubscriptionPlan),
|
|
@@ -1454,19 +895,15 @@ __decorate([
|
|
|
1454
895
|
__metadata("design:type", Coupon)
|
|
1455
896
|
], CheckoutSubscription.prototype, "coupon", void 0);
|
|
1456
897
|
|
|
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;
|
|
898
|
+
class Buy2Win extends BaseModel {
|
|
899
|
+
static get identifiersFields() {
|
|
900
|
+
return ['id'];
|
|
1468
901
|
}
|
|
1469
902
|
}
|
|
903
|
+
__decorate([
|
|
904
|
+
Type(() => Category),
|
|
905
|
+
__metadata("design:type", Array)
|
|
906
|
+
], Buy2Win.prototype, "categories", void 0);
|
|
1470
907
|
|
|
1471
908
|
var FilterType;
|
|
1472
909
|
(function (FilterType) {
|
|
@@ -1510,27 +947,6 @@ var QuestionsFilters;
|
|
|
1510
947
|
QuestionsFilters["PRODUCT_SPENT"] = "Qual \u00E9 o seu nivel de gasto mensal em produtos de beleza e cuidados pessoais?";
|
|
1511
948
|
})(QuestionsFilters || (QuestionsFilters = {}));
|
|
1512
949
|
|
|
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
950
|
class BeautyQuestionsHelper {
|
|
1535
951
|
static getAnswers(filter) {
|
|
1536
952
|
switch (filter) {
|
|
@@ -1571,19 +987,8 @@ class BeautyQuestionsHelper {
|
|
|
1571
987
|
}
|
|
1572
988
|
}
|
|
1573
989
|
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'];
|
|
990
|
+
const filterKey = Object.keys(FilterType)[Object.values(FilterType).indexOf(filter)];
|
|
991
|
+
return QuestionsFilters[filterKey];
|
|
1587
992
|
}
|
|
1588
993
|
}
|
|
1589
994
|
|
|
@@ -1599,16 +1004,9 @@ class ShopMenu extends BaseModel {
|
|
|
1599
1004
|
}
|
|
1600
1005
|
}
|
|
1601
1006
|
|
|
1602
|
-
class ShopSettings extends BaseModel {
|
|
1603
|
-
static get identifiersFields() {
|
|
1604
|
-
return ['id'];
|
|
1605
|
-
}
|
|
1606
|
-
}
|
|
1607
|
-
|
|
1608
1007
|
class InvalidArgumentError extends CustomError {
|
|
1609
1008
|
constructor(message) {
|
|
1610
1009
|
super(message);
|
|
1611
|
-
this.message = message;
|
|
1612
1010
|
}
|
|
1613
1011
|
}
|
|
1614
1012
|
|
|
@@ -1623,14 +1021,12 @@ class RequiredArgumentError extends CustomError {
|
|
|
1623
1021
|
class NotFoundError extends CustomError {
|
|
1624
1022
|
constructor(message) {
|
|
1625
1023
|
super(message);
|
|
1626
|
-
this.message = message;
|
|
1627
1024
|
}
|
|
1628
1025
|
}
|
|
1629
1026
|
|
|
1630
1027
|
class DuplicatedResultsError extends CustomError {
|
|
1631
1028
|
constructor(message) {
|
|
1632
1029
|
super(message);
|
|
1633
|
-
this.message = message;
|
|
1634
1030
|
}
|
|
1635
1031
|
}
|
|
1636
1032
|
|
|
@@ -1638,21 +1034,19 @@ class AxiosAdapter {
|
|
|
1638
1034
|
constructor(config) {
|
|
1639
1035
|
this.config = config;
|
|
1640
1036
|
}
|
|
1641
|
-
get(index
|
|
1037
|
+
get(index) {
|
|
1642
1038
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1643
1039
|
try {
|
|
1644
1040
|
const { data } = yield axios({
|
|
1645
|
-
url: `${this.config.url}/${index}
|
|
1041
|
+
url: `${this.config.url}/${index}`,
|
|
1646
1042
|
method: 'GET',
|
|
1647
|
-
|
|
1648
|
-
headers: {
|
|
1649
|
-
'Content-Type': 'application/json',
|
|
1650
|
-
Authorization: `ApiKey ${this.config.credential}`,
|
|
1651
|
-
},
|
|
1043
|
+
headers: { Authorization: `Basic ${this.config.credential}` },
|
|
1652
1044
|
});
|
|
1653
1045
|
return data._source;
|
|
1654
1046
|
}
|
|
1655
1047
|
catch (error) {
|
|
1048
|
+
if (!(error instanceof Error))
|
|
1049
|
+
throw error;
|
|
1656
1050
|
throw new NotFoundError(error.message);
|
|
1657
1051
|
}
|
|
1658
1052
|
});
|
|
@@ -1660,14 +1054,9 @@ class AxiosAdapter {
|
|
|
1660
1054
|
query(index, query) {
|
|
1661
1055
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1662
1056
|
const { data } = yield axios({
|
|
1663
|
-
url: `${this.config.url}/${index}
|
|
1057
|
+
url: `${this.config.url}/${index}`,
|
|
1664
1058
|
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
|
-
},
|
|
1059
|
+
headers: { Authorization: `Basic ${this.config.credential}` },
|
|
1671
1060
|
data: query,
|
|
1672
1061
|
});
|
|
1673
1062
|
return {
|
|
@@ -1679,29 +1068,19 @@ class AxiosAdapter {
|
|
|
1679
1068
|
save(index, data) {
|
|
1680
1069
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1681
1070
|
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}`,
|
|
1071
|
+
url: `${this.config.url}/${index}`,
|
|
1693
1072
|
method: 'PUT',
|
|
1694
|
-
headers: { Authorization: `
|
|
1073
|
+
headers: { Authorization: `Basic ${this.config.credential}` },
|
|
1695
1074
|
data,
|
|
1696
1075
|
});
|
|
1697
1076
|
});
|
|
1698
1077
|
}
|
|
1699
|
-
delete(index
|
|
1078
|
+
delete(index) {
|
|
1700
1079
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1701
1080
|
yield axios({
|
|
1702
|
-
url: `${this.config.url}/${index}
|
|
1081
|
+
url: `${this.config.url}/${index}`,
|
|
1703
1082
|
method: 'DELETE',
|
|
1704
|
-
headers: { Authorization: `
|
|
1083
|
+
headers: { Authorization: `Basic ${this.config.credential}` },
|
|
1705
1084
|
});
|
|
1706
1085
|
});
|
|
1707
1086
|
}
|
|
@@ -1710,19 +1089,16 @@ class AxiosAdapter {
|
|
|
1710
1089
|
class ProductsIndex {
|
|
1711
1090
|
constructor(adapter) {
|
|
1712
1091
|
this.adapter = adapter;
|
|
1713
|
-
this.index = `products`;
|
|
1714
1092
|
}
|
|
1715
|
-
|
|
1093
|
+
get(id) {
|
|
1716
1094
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1717
|
-
const data = yield this.adapter.get(
|
|
1095
|
+
const data = yield this.adapter.get(`products/_doc/${id}`);
|
|
1718
1096
|
return Product.toInstance(data);
|
|
1719
1097
|
});
|
|
1720
1098
|
}
|
|
1721
|
-
|
|
1099
|
+
findById(ids, options) {
|
|
1722
1100
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1723
|
-
const size = total || 9;
|
|
1724
1101
|
const fields = [
|
|
1725
|
-
'EAN',
|
|
1726
1102
|
'brand',
|
|
1727
1103
|
'id',
|
|
1728
1104
|
'images',
|
|
@@ -1733,88 +1109,73 @@ class ProductsIndex {
|
|
|
1733
1109
|
'stock',
|
|
1734
1110
|
'slug',
|
|
1735
1111
|
'reviews',
|
|
1112
|
+
'pricePaid',
|
|
1113
|
+
'isGift',
|
|
1114
|
+
'stock',
|
|
1115
|
+
'weight',
|
|
1116
|
+
'tags',
|
|
1736
1117
|
'hasVariants',
|
|
1737
|
-
'
|
|
1118
|
+
'type',
|
|
1738
1119
|
];
|
|
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: {
|
|
1120
|
+
const { hits } = yield this.adapter.query('products/_search', Object.assign({ _source: fields, query: {
|
|
1750
1121
|
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,
|
|
1122
|
+
filter: [
|
|
1123
|
+
{
|
|
1124
|
+
terms: {
|
|
1125
|
+
_id: ids,
|
|
1126
|
+
},
|
|
1767
1127
|
},
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
'name.search': {
|
|
1772
|
-
query: `${searchTerm}`,
|
|
1773
|
-
slop: 10,
|
|
1128
|
+
{
|
|
1129
|
+
term: {
|
|
1130
|
+
published: true,
|
|
1774
1131
|
},
|
|
1775
1132
|
},
|
|
1776
|
-
|
|
1777
|
-
|
|
1133
|
+
...((options === null || options === void 0 ? void 0 : options.hasStock)
|
|
1134
|
+
? [
|
|
1135
|
+
{
|
|
1136
|
+
range: {
|
|
1137
|
+
'stock.quantity': {
|
|
1138
|
+
gt: 0,
|
|
1139
|
+
},
|
|
1140
|
+
},
|
|
1141
|
+
},
|
|
1142
|
+
]
|
|
1143
|
+
: []),
|
|
1144
|
+
],
|
|
1778
1145
|
},
|
|
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;
|
|
1146
|
+
} }, ((options === null || options === void 0 ? void 0 : options.size) ? { size: options === null || options === void 0 ? void 0 : options.size } : {})));
|
|
1147
|
+
return hits.map((hit) => Product.toInstance(hit._source));
|
|
1788
1148
|
});
|
|
1789
1149
|
}
|
|
1790
1150
|
save(product) {
|
|
1791
1151
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1152
|
+
delete product.createdAt;
|
|
1153
|
+
delete product.updatedAt;
|
|
1154
|
+
delete product.kitProducts;
|
|
1792
1155
|
try {
|
|
1793
|
-
|
|
1794
|
-
|
|
1156
|
+
if (!product.firestoreId)
|
|
1157
|
+
throw new Error('Is not a product from firestore');
|
|
1158
|
+
yield this.get(product.firestoreId);
|
|
1159
|
+
yield this.adapter.save(`products/_doc/${product.firestoreId}`, product.toPlain());
|
|
1795
1160
|
}
|
|
1796
1161
|
catch (error) {
|
|
1797
|
-
|
|
1162
|
+
if (!(error instanceof Error))
|
|
1163
|
+
throw error;
|
|
1164
|
+
console.error(error.message);
|
|
1165
|
+
yield this.adapter.save(`products/_doc/${product.id}`, product.toPlain());
|
|
1798
1166
|
}
|
|
1799
1167
|
});
|
|
1800
1168
|
}
|
|
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) {
|
|
1169
|
+
delete(product) {
|
|
1812
1170
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1171
|
+
if (!product.firestoreId)
|
|
1172
|
+
return;
|
|
1813
1173
|
try {
|
|
1814
|
-
yield this.
|
|
1174
|
+
yield this.get(product.firestoreId);
|
|
1175
|
+
yield this.adapter.delete(`products/_doc/${product.firestoreId}`);
|
|
1815
1176
|
}
|
|
1816
1177
|
catch (error) {
|
|
1817
|
-
|
|
1178
|
+
yield this.adapter.delete(`products/_doc/${product.id}`);
|
|
1818
1179
|
}
|
|
1819
1180
|
});
|
|
1820
1181
|
}
|
|
@@ -1842,30 +1203,20 @@ const withFirestore = (MixinBase) => {
|
|
|
1842
1203
|
? data[key].map((element) => (isObjectsAndNoDate(element) ? bindAllDateFromObject(element) : element))
|
|
1843
1204
|
: bindDate(data[key], key) })), {});
|
|
1844
1205
|
};
|
|
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
1206
|
return class extends MixinBase {
|
|
1207
|
+
constructor() {
|
|
1208
|
+
super(...arguments);
|
|
1209
|
+
this.collectionName = '';
|
|
1210
|
+
}
|
|
1857
1211
|
collection(path) {
|
|
1858
|
-
return this.firestore
|
|
1212
|
+
return collection(this.firestore, path || this.collectionName).withConverter(this.buildModelInstance());
|
|
1859
1213
|
}
|
|
1860
1214
|
buildModelInstance() {
|
|
1861
1215
|
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
|
-
},
|
|
1216
|
+
toFirestore: (data) => ((data === null || data === void 0 ? void 0 : data.toPlain) ? data.toPlain() : data),
|
|
1866
1217
|
fromFirestore: (snap) => {
|
|
1867
1218
|
const data = snap.data();
|
|
1868
|
-
let bindedData;
|
|
1219
|
+
let bindedData = null;
|
|
1869
1220
|
try {
|
|
1870
1221
|
const ids = { id: snap.id };
|
|
1871
1222
|
bindedData = bindAllDateFromObject(data);
|
|
@@ -1903,10 +1254,8 @@ const withGetFirestore = (MixinBase) => {
|
|
|
1903
1254
|
return class GetFirestore extends MixinBase {
|
|
1904
1255
|
get(identifiers) {
|
|
1905
1256
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1906
|
-
const
|
|
1907
|
-
|
|
1908
|
-
.get();
|
|
1909
|
-
const data = doc.data();
|
|
1257
|
+
const docRef = yield getDoc(doc(yield this.collection(this.buildCollectionPathForGet(identifiers)), Object.values(identifiers).shift().toString()));
|
|
1258
|
+
const data = docRef.data();
|
|
1910
1259
|
if (isNil(data))
|
|
1911
1260
|
throw new NotFoundError(`Document ${JSON.stringify(identifiers)} not found`);
|
|
1912
1261
|
return data;
|
|
@@ -1941,10 +1290,13 @@ const withFindFirestore = (MixinBase) => {
|
|
|
1941
1290
|
return class FindFirestore extends MixinBase {
|
|
1942
1291
|
constructor() {
|
|
1943
1292
|
super(...arguments);
|
|
1944
|
-
this.makeFirestoreWhere = (
|
|
1945
|
-
|
|
1293
|
+
this.makeFirestoreWhere = (filter) => Object.keys(filter).reduce((queries, fieldName) => [
|
|
1294
|
+
...queries,
|
|
1295
|
+
...this.buildWhereSentence(fieldName, is(filter[fieldName])),
|
|
1296
|
+
], []);
|
|
1297
|
+
this.buildWhereSentence = (fieldName, options) => {
|
|
1946
1298
|
if (this.isSubCollection(this) && fieldName === this.parentIdField)
|
|
1947
|
-
|
|
1299
|
+
[];
|
|
1948
1300
|
const value = (options === null || options === void 0 ? void 0 : options.value) || options;
|
|
1949
1301
|
const object = {};
|
|
1950
1302
|
set(object, fieldName, value);
|
|
@@ -1954,41 +1306,49 @@ const withFindFirestore = (MixinBase) => {
|
|
|
1954
1306
|
: Object.keys(plainInstance).find((key) => plainInstance[key]);
|
|
1955
1307
|
if ((options === null || options === void 0 ? void 0 : options.operator) === Where.LIKE) {
|
|
1956
1308
|
if (Array.isArray(options === null || options === void 0 ? void 0 : options.value) &&
|
|
1957
|
-
(this.fields[firestoreFieldName] ===
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
return
|
|
1309
|
+
(this.fields[firestoreFieldName] ===
|
|
1310
|
+
FirestoreFieldType.Array ||
|
|
1311
|
+
!this.fields[firestoreFieldName]))
|
|
1312
|
+
return [where(firestoreFieldName, 'array-contains-any', options.value)];
|
|
1313
|
+
return [where(firestoreFieldName, '>=', options.value), where(firestoreFieldName, '<=', `${options.value}~`)];
|
|
1962
1314
|
}
|
|
1963
1315
|
if ((options === null || options === void 0 ? void 0 : options.operator) === Where.IN &&
|
|
1964
1316
|
Array.isArray(options === null || options === void 0 ? void 0 : options.value) &&
|
|
1965
|
-
(this.fields[firestoreFieldName] === FirestoreFieldType.Array ||
|
|
1966
|
-
|
|
1317
|
+
(this.fields[firestoreFieldName] === FirestoreFieldType.Array ||
|
|
1318
|
+
!this.fields[firestoreFieldName]))
|
|
1319
|
+
return [where(firestoreFieldName, 'array-contains', options.value)];
|
|
1967
1320
|
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((
|
|
1321
|
+
return Object.keys(options).reduce((queries, key) => [
|
|
1322
|
+
...queries,
|
|
1323
|
+
...this.buildWhereSentence(`${fieldName.toString()}.${key}`, is(options)[key]),
|
|
1324
|
+
], []);
|
|
1969
1325
|
}
|
|
1970
|
-
return
|
|
1326
|
+
return [where(firestoreFieldName, (options === null || options === void 0 ? void 0 : options.operator) || '==', (options === null || options === void 0 ? void 0 : options.value) || options)];
|
|
1327
|
+
};
|
|
1328
|
+
this.makeFirestoreOrderBy = (filters, fieldsToOrderBy) => {
|
|
1329
|
+
const orderByKeys = Object.keys(fieldsToOrderBy || {});
|
|
1330
|
+
if (!orderByKeys.length)
|
|
1331
|
+
return [];
|
|
1332
|
+
const filtersKeysWithUnordered = Object.keys(filters || {}).filter((filterKey) => !orderByKeys.includes(filterKey));
|
|
1333
|
+
if (filtersKeysWithUnordered.length)
|
|
1334
|
+
filtersKeysWithUnordered.forEach((filterKey) => (fieldsToOrderBy = Object.assign(Object.assign({}, (![Where.EQUALS].includes(is(filters[filterKey]).operator)
|
|
1335
|
+
? { [filterKey]: 'asc' }
|
|
1336
|
+
: {})), fieldsToOrderBy)));
|
|
1337
|
+
return Object.keys(fieldsToOrderBy).map((fieldName) => orderBy(fieldName, fieldsToOrderBy[fieldName]));
|
|
1971
1338
|
};
|
|
1972
1339
|
}
|
|
1973
|
-
find({ filters, limits, orderBy,
|
|
1974
|
-
var _a;
|
|
1340
|
+
find({ filters, limits, orderBy, } = {}) {
|
|
1975
1341
|
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();
|
|
1342
|
+
const collection = this.collection(this.buildCollectionPathForFind(filters));
|
|
1343
|
+
const queries = this.makeFirestoreWhere(filters || {});
|
|
1344
|
+
const ordination = this.makeFirestoreOrderBy(filters, orderBy);
|
|
1345
|
+
const offsets = yield this.defineLimits(filters, limits);
|
|
1346
|
+
const queryArgumments = [...queries, ...ordination, ...offsets];
|
|
1347
|
+
const docs = yield getDocs(query(collection, ...queryArgumments));
|
|
1988
1348
|
const data = docs.docs.map((doc) => doc.data());
|
|
1989
1349
|
return {
|
|
1990
1350
|
data,
|
|
1991
|
-
count:
|
|
1351
|
+
count: this.calculateCount(data, limits),
|
|
1992
1352
|
};
|
|
1993
1353
|
});
|
|
1994
1354
|
}
|
|
@@ -1999,19 +1359,18 @@ const withFindFirestore = (MixinBase) => {
|
|
|
1999
1359
|
const parentId = getValueFromFilter(filters === null || filters === void 0 ? void 0 : filters[parentIdField]);
|
|
2000
1360
|
return `${this.parentRepository.collectionName}/${parentId}/${this.collectionName}`;
|
|
2001
1361
|
}
|
|
2002
|
-
defineLimits(
|
|
1362
|
+
defineLimits(filters, limits) {
|
|
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.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
|
};
|
|
@@ -2627,22 +1920,13 @@ class ShopMenuFirestoreRepository extends withCrudFirestore(withHelpers(withFire
|
|
|
2627
1920
|
}
|
|
2628
1921
|
}
|
|
2629
1922
|
|
|
2630
|
-
class ShopSettingsFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
2631
|
-
constructor(firestore) {
|
|
2632
|
-
super();
|
|
2633
|
-
this.firestore = firestore;
|
|
2634
|
-
this.collectionName = 'shopSettings';
|
|
2635
|
-
this.model = ShopSettings;
|
|
2636
|
-
}
|
|
2637
|
-
}
|
|
2638
|
-
|
|
2639
1923
|
class AuthenticationFirebaseAuthService {
|
|
2640
1924
|
constructor(firebaseAuth) {
|
|
2641
1925
|
this.firebaseAuth = firebaseAuth;
|
|
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,15 +2139,31 @@ 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
|
};
|
|
@@ -2866,15 +2173,15 @@ GraphQLFieldHelper.ConvertFieldValueFrom = (data, fields) => Object.keys(data).r
|
|
|
2866
2173
|
if (Array.isArray(data[columnName]))
|
|
2867
2174
|
return Object.assign(Object.assign({}, result), { [attributeName]: from
|
|
2868
2175
|
? from(data[columnName], data)
|
|
2869
|
-
: data[columnName].map((value) => GraphQLFieldHelper.ConvertFieldValueFrom(value, attributeFields)) });
|
|
2176
|
+
: is(data[columnName]).map((value) => GraphQLFieldHelper.ConvertFieldValueFrom(is(value), attributeFields)) });
|
|
2870
2177
|
if (isObject(data[columnName]))
|
|
2871
2178
|
return Object.assign(Object.assign({}, result), { [attributeName]: !!from
|
|
2872
2179
|
? from(data[columnName])
|
|
2873
|
-
: GraphQLFieldHelper.ConvertFieldValueFrom(data[columnName], attributeFields) });
|
|
2180
|
+
: GraphQLFieldHelper.ConvertFieldValueFrom(is(data[columnName]), attributeFields) });
|
|
2874
2181
|
}
|
|
2875
2182
|
if (!!from)
|
|
2876
2183
|
return Object.assign(Object.assign({}, result), { [attributeName]: from(data[columnName], data) });
|
|
2877
|
-
return Object.assign(Object.assign({}, result), { [attributeName]: parseDateTime(data[columnName]) });
|
|
2184
|
+
return Object.assign(Object.assign({}, result), { [attributeName]: parseDateTime(data[columnName].toString()) });
|
|
2878
2185
|
}, {});
|
|
2879
2186
|
GraphQLFieldHelper.ConvertFieldValueTo = (instance, fields, update = false) => {
|
|
2880
2187
|
var _a;
|
|
@@ -2887,16 +2194,22 @@ GraphQLFieldHelper.ConvertFieldValueTo = (instance, fields, update = false) => {
|
|
|
2887
2194
|
return result;
|
|
2888
2195
|
if (!!foreignKeyColumn &&
|
|
2889
2196
|
!isEmpty(foreignKeyColumn) &&
|
|
2890
|
-
!Object.keys(foreignKeyColumn).filter((key) => { var _a; return !((_a = data[attributeName]) === null || _a === void 0 ? void 0 : _a[key]); }).length)
|
|
2197
|
+
!Object.keys(foreignKeyColumn).filter((key) => { var _a; return !((_a = is(data[attributeName])) === null || _a === void 0 ? void 0 : _a[key]); }).length)
|
|
2891
2198
|
return Object.keys(foreignKeyColumn).reduce((object, current) => {
|
|
2892
2199
|
var _a;
|
|
2893
|
-
|
|
2894
|
-
return Object.assign(Object.assign({}, object), { [foreignColumnName]: (_a = data[attributeName]) === null || _a === void 0 ? void 0 : _a[current] });
|
|
2200
|
+
return (Object.assign(Object.assign({}, object), { [foreignKeyColumn[current]]: (_a = data[attributeName]) === null || _a === void 0 ? void 0 : _a[current] }));
|
|
2895
2201
|
}, Object.assign({}, result));
|
|
2896
|
-
if (update &&
|
|
2202
|
+
if (update &&
|
|
2203
|
+
isObject(data[attributeName]) &&
|
|
2204
|
+
!isNil(attributeFields) &&
|
|
2205
|
+
!isDate(data[attributeName]))
|
|
2897
2206
|
return result;
|
|
2898
|
-
if (!!columnName &&
|
|
2899
|
-
|
|
2207
|
+
if (!!columnName &&
|
|
2208
|
+
Array.isArray(attributeFields) &&
|
|
2209
|
+
isObject(data[attributeName])) {
|
|
2210
|
+
const converted = !isNil(columnName) && to
|
|
2211
|
+
? to(instance[attributeName], instance)
|
|
2212
|
+
: data[attributeName];
|
|
2900
2213
|
return Object.assign(Object.assign({}, result), (converted !== undefined
|
|
2901
2214
|
? {
|
|
2902
2215
|
[columnName]: {
|
|
@@ -2912,25 +2225,6 @@ GraphQLFieldHelper.ConvertFieldValueTo = (instance, fields, update = false) => {
|
|
|
2912
2225
|
return Object.assign(Object.assign({}, result), { [columnName]: data[attributeName] });
|
|
2913
2226
|
}, {});
|
|
2914
2227
|
};
|
|
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
2228
|
|
|
2935
2229
|
const withCreateHasuraGraphQL = (MixinBase) => {
|
|
2936
2230
|
return class CreateHasuraGraphQLMixin extends MixinBase {
|
|
@@ -2938,30 +2232,14 @@ const withCreateHasuraGraphQL = (MixinBase) => {
|
|
|
2938
2232
|
const options = params === null || params === void 0 ? void 0 : params[0];
|
|
2939
2233
|
super(...params);
|
|
2940
2234
|
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
2235
|
this.insertGraphQLObjectType = (options === null || options === void 0 ? void 0 : options.insertGraphQLObjectType) || `${this.tableName}_insert_input`;
|
|
2943
2236
|
}
|
|
2944
2237
|
create(data) {
|
|
2945
2238
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2946
|
-
this.logger = DebugHelper.from(this, 'create');
|
|
2947
2239
|
const newData = yield this.save(this.model.toInstance(data));
|
|
2948
2240
|
return this.model.toInstance(newData);
|
|
2949
2241
|
});
|
|
2950
2242
|
}
|
|
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
2243
|
save(data) {
|
|
2966
2244
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2967
2245
|
const primaryKeyColumns = this.model.identifiersFields.map((field) => AttributeOptionHelper.FindByAttribute(field, this.fields).columnName);
|
|
@@ -2970,11 +2248,12 @@ const withCreateHasuraGraphQL = (MixinBase) => {
|
|
|
2970
2248
|
const columnOptions = Object.values(field).shift();
|
|
2971
2249
|
return (AttributeOptionHelper.CheckIsColumnOption(columnOptions) &&
|
|
2972
2250
|
columnOptions.foreignKeyColumn && [
|
|
2973
|
-
...Object.values(columnOptions.foreignKeyColumn)
|
|
2251
|
+
...Object.values(columnOptions.foreignKeyColumn),
|
|
2974
2252
|
{
|
|
2975
2253
|
[columnOptions.columnName]: Object.keys(columnOptions.foreignKeyColumn).map((foreignKeyField) => {
|
|
2976
2254
|
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) ||
|
|
2255
|
+
return ((_a = AttributeOptionHelper.FindByAttribute(foreignKeyField, columnOptions === null || columnOptions === void 0 ? void 0 : columnOptions.fields)) === null || _a === void 0 ? void 0 : _a.columnName) ||
|
|
2256
|
+
foreignKeyField;
|
|
2978
2257
|
}),
|
|
2979
2258
|
},
|
|
2980
2259
|
]);
|
|
@@ -2999,14 +2278,12 @@ const withDeleteHasuraGraphQL = (MixinBase) => {
|
|
|
2999
2278
|
}
|
|
3000
2279
|
delete(identifiers) {
|
|
3001
2280
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3002
|
-
this.logger = DebugHelper.from(this, 'delete');
|
|
3003
2281
|
const instance = this.model.toInstance(identifiers);
|
|
3004
2282
|
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]))
|
|
2283
|
+
if (isNil(instance[identifier]))
|
|
3007
2284
|
return ids;
|
|
3008
2285
|
const columnOption = AttributeOptionHelper.FindByAttribute(identifier, this.fields);
|
|
3009
|
-
const value = columnOption.to(identifiers[identifier
|
|
2286
|
+
const value = columnOption.to(identifiers[identifier], instance);
|
|
3010
2287
|
return Object.assign(Object.assign({}, ids), { [columnOption.columnName]: {
|
|
3011
2288
|
type: this.getAttributeGraphQLTypeOf(columnOption.type || value),
|
|
3012
2289
|
value,
|
|
@@ -3028,7 +2305,6 @@ const withHasuraGraphQL = (MixinBase) => {
|
|
|
3028
2305
|
this.authOptions = options.authOptions;
|
|
3029
2306
|
this.model = options.model;
|
|
3030
2307
|
this.fields = options.fields || this.model.identifiersFields;
|
|
3031
|
-
this.logger = DebugHelper.from(this);
|
|
3032
2308
|
}
|
|
3033
2309
|
get headers() {
|
|
3034
2310
|
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)
|
|
@@ -3048,12 +2324,12 @@ const withHasuraGraphQL = (MixinBase) => {
|
|
|
3048
2324
|
query(operation, fields, variables) {
|
|
3049
2325
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3050
2326
|
const resultQuery = GraphQLFieldHelper.CheckIsGraphQLParams(operation)
|
|
3051
|
-
? query(operation.map((option) => ({
|
|
2327
|
+
? query$1(operation.map((option) => ({
|
|
3052
2328
|
operation: option.operation,
|
|
3053
2329
|
variables: option.variables,
|
|
3054
2330
|
fields: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(option.fields),
|
|
3055
2331
|
})))
|
|
3056
|
-
: query({
|
|
2332
|
+
: query$1({
|
|
3057
2333
|
operation,
|
|
3058
2334
|
variables,
|
|
3059
2335
|
fields: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(fields),
|
|
@@ -3063,17 +2339,15 @@ const withHasuraGraphQL = (MixinBase) => {
|
|
|
3063
2339
|
}
|
|
3064
2340
|
fetch(params) {
|
|
3065
2341
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3066
|
-
this.logger.with('params').log(params);
|
|
3067
2342
|
const headers = this.headers;
|
|
3068
|
-
const
|
|
3069
|
-
url: `${this.endpoint}`,
|
|
2343
|
+
const response = yield fetch(`${this.endpoint}`, {
|
|
3070
2344
|
method: 'POST',
|
|
3071
|
-
|
|
2345
|
+
body: JSON.stringify(params),
|
|
3072
2346
|
headers,
|
|
3073
2347
|
});
|
|
2348
|
+
const result = yield response.json();
|
|
3074
2349
|
if (!isNil(result.errors))
|
|
3075
2350
|
throw new Error(JSON.stringify(result.errors));
|
|
3076
|
-
this.logger.with('returns').log(result);
|
|
3077
2351
|
return result.data;
|
|
3078
2352
|
});
|
|
3079
2353
|
}
|
|
@@ -3100,8 +2374,8 @@ const withHasuraGraphQL = (MixinBase) => {
|
|
|
3100
2374
|
return value;
|
|
3101
2375
|
return date;
|
|
3102
2376
|
}
|
|
3103
|
-
convertDataFromHasura(data
|
|
3104
|
-
const plain = GraphQLFieldHelper.ConvertFieldValueFrom(data,
|
|
2377
|
+
convertDataFromHasura(data) {
|
|
2378
|
+
const plain = GraphQLFieldHelper.ConvertFieldValueFrom(data, this.fields);
|
|
3105
2379
|
return this.model.toInstance(plain);
|
|
3106
2380
|
}
|
|
3107
2381
|
convertDataToHasura(instance, update = false) {
|
|
@@ -3130,7 +2404,6 @@ const withUpdateHasuraGraphQL = (MixinBase) => {
|
|
|
3130
2404
|
}
|
|
3131
2405
|
update(data) {
|
|
3132
2406
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3133
|
-
this.logger = DebugHelper.from(this, 'update');
|
|
3134
2407
|
const plainData = this.paramsToPlain(data);
|
|
3135
2408
|
yield this.mutation(this.updateGraphQLOperation, this.model.identifiersFields.map((field) => AttributeOptionHelper.FindByAttribute(field, this.fields).columnName), {
|
|
3136
2409
|
_set: {
|
|
@@ -3147,17 +2420,18 @@ const withUpdateHasuraGraphQL = (MixinBase) => {
|
|
|
3147
2420
|
const model = this.model;
|
|
3148
2421
|
if (model.isModel(params))
|
|
3149
2422
|
return params.toPlain();
|
|
3150
|
-
return Object.keys(params).reduce((data, currentKey) => (Object.assign(Object.assign({}, data), (params[currentKey] !== undefined && {
|
|
2423
|
+
return Object.keys(params).reduce((data, currentKey) => (Object.assign(Object.assign({}, data), (params[currentKey] !== undefined && {
|
|
2424
|
+
[currentKey]: getValueByAction(is(params[currentKey])),
|
|
2425
|
+
}))), {});
|
|
3151
2426
|
}
|
|
3152
2427
|
getUpdateModelKeys(data) {
|
|
3153
2428
|
const instance = this.model.toInstance(data);
|
|
3154
2429
|
return this.model.identifiersFields.reduce((ids, identifier) => {
|
|
3155
2430
|
var _a;
|
|
3156
|
-
|
|
3157
|
-
if (isNil(instance[identifierBinded]))
|
|
2431
|
+
if (isNil(instance[identifier]))
|
|
3158
2432
|
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[
|
|
2433
|
+
const columnOption = AttributeOptionHelper.FindByAttribute(identifier, this.fields);
|
|
2434
|
+
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
2435
|
return Object.assign(Object.assign({}, ids), { [columnOption.columnName]: value });
|
|
3162
2436
|
}, {});
|
|
3163
2437
|
}
|
|
@@ -3173,15 +2447,14 @@ const withGetHasuraGraphQL = (MixinBase) => {
|
|
|
3173
2447
|
}
|
|
3174
2448
|
get(identifiers) {
|
|
3175
2449
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3176
|
-
this.logger = DebugHelper.from(this, 'get');
|
|
3177
2450
|
const instance = this.model.toInstance(identifiers);
|
|
3178
2451
|
const result = yield this.query(this.getGraphQLOperation, this.fields, this.model.identifiersFields.reduce((ids, identifier) => {
|
|
3179
2452
|
var _a;
|
|
3180
|
-
|
|
3181
|
-
if (isNil(instance[identifierBinded]))
|
|
2453
|
+
if (isNil(instance[identifier]))
|
|
3182
2454
|
return ids;
|
|
3183
2455
|
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
|
|
2456
|
+
const value = ((_a = columnOption === null || columnOption === void 0 ? void 0 : columnOption.to) === null || _a === void 0 ? void 0 : _a.call(columnOption, identifiers[identifier], instance)) ||
|
|
2457
|
+
identifiers[identifier];
|
|
3185
2458
|
return Object.assign(Object.assign({}, ids), { [columnOption.columnName]: {
|
|
3186
2459
|
type: this.getAttributeGraphQLTypeOf(columnOption.type || value),
|
|
3187
2460
|
value,
|
|
@@ -3199,42 +2472,10 @@ const withGetHasuraGraphQL = (MixinBase) => {
|
|
|
3199
2472
|
|
|
3200
2473
|
const withFindHasuraGraphQL = (MixinBase) => {
|
|
3201
2474
|
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;
|
|
2475
|
+
find(options) {
|
|
3233
2476
|
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)
|
|
2477
|
+
const { filters, limits, orderBy } = options || {};
|
|
2478
|
+
const variablesCount = Object.assign(Object.assign({}, (isNil(orderBy) ? {} : { order_by: { type: `${this.tableName}_order_by!`, list: true, value: orderBy } })), (isNil(filters)
|
|
3238
2479
|
? {}
|
|
3239
2480
|
: {
|
|
3240
2481
|
where: {
|
|
@@ -3242,26 +2483,13 @@ const withFindHasuraGraphQL = (MixinBase) => {
|
|
|
3242
2483
|
type: `${this.tableName}_bool_exp`,
|
|
3243
2484
|
required: true,
|
|
3244
2485
|
},
|
|
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);
|
|
2486
|
+
}));
|
|
3255
2487
|
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
2488
|
const result = yield this.query([
|
|
3261
2489
|
{
|
|
3262
2490
|
operation: this.tableName,
|
|
3263
|
-
fields:
|
|
3264
|
-
?
|
|
2491
|
+
fields: options.fields
|
|
2492
|
+
? options.fields
|
|
3265
2493
|
.map((fieldName) => {
|
|
3266
2494
|
var _a;
|
|
3267
2495
|
return (_a = this.fields.find((fieldOption) => fieldOption === fieldName)) !== null && _a !== void 0 ? _a : this.fields.find((fieldOption) => Object.keys(fieldOption).shift() === fieldName);
|
|
@@ -3270,64 +2498,15 @@ const withFindHasuraGraphQL = (MixinBase) => {
|
|
|
3270
2498
|
: this.fields,
|
|
3271
2499
|
variables,
|
|
3272
2500
|
},
|
|
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
|
-
[]),
|
|
2501
|
+
{
|
|
2502
|
+
operation: `${this.tableName}_aggregate`,
|
|
2503
|
+
fields: [{ aggregate: ['count'] }],
|
|
2504
|
+
variables: variablesCount,
|
|
2505
|
+
},
|
|
3306
2506
|
]);
|
|
3307
2507
|
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
|
-
}));
|
|
2508
|
+
const count = result[`${this.tableName}_aggregate`].aggregate.count;
|
|
2509
|
+
return { count, data };
|
|
3331
2510
|
});
|
|
3332
2511
|
}
|
|
3333
2512
|
};
|
|
@@ -3367,146 +2546,8 @@ class VariantHasuraGraphQL extends Variant {
|
|
|
3367
2546
|
}
|
|
3368
2547
|
}
|
|
3369
2548
|
|
|
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
2549
|
class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
3509
|
-
constructor(endpoint, authOptions, productRepository
|
|
2550
|
+
constructor(endpoint, authOptions, productRepository) {
|
|
3510
2551
|
super({
|
|
3511
2552
|
tableName: 'category',
|
|
3512
2553
|
model: Category,
|
|
@@ -3520,7 +2561,6 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
3520
2561
|
'image',
|
|
3521
2562
|
'published',
|
|
3522
2563
|
'shop',
|
|
3523
|
-
{ shops: { columnName: 'shops', type: HasuraGraphQLColumnType.Jsonb } },
|
|
3524
2564
|
'slug',
|
|
3525
2565
|
{ brandCategory: { columnName: 'brand_category' } },
|
|
3526
2566
|
{ brandCategoryBanner: { columnName: 'brand_banner' } },
|
|
@@ -3531,7 +2571,10 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
3531
2571
|
conditions: {
|
|
3532
2572
|
columnName: 'tag_condition',
|
|
3533
2573
|
type: HasuraGraphQLColumnType.Jsonb,
|
|
3534
|
-
from: (tags, row) => ({
|
|
2574
|
+
from: (tags, row) => ({
|
|
2575
|
+
brand: row.brand_condition,
|
|
2576
|
+
tags: Array.isArray(tags) ? tags : [],
|
|
2577
|
+
}),
|
|
3535
2578
|
bindPersistData: (value) => {
|
|
3536
2579
|
return {
|
|
3537
2580
|
brand_condition: value.brand,
|
|
@@ -3543,17 +2586,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
3543
2586
|
},
|
|
3544
2587
|
},
|
|
3545
2588
|
},
|
|
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
|
-
},
|
|
2589
|
+
'filters',
|
|
3557
2590
|
{ createdAt: { columnName: 'created_at' } },
|
|
3558
2591
|
{ updatedAt: { columnName: 'updated_at' } },
|
|
3559
2592
|
{
|
|
@@ -3575,21 +2608,9 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
3575
2608
|
}),
|
|
3576
2609
|
},
|
|
3577
2610
|
},
|
|
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
2611
|
],
|
|
3590
2612
|
});
|
|
3591
2613
|
this.productRepository = productRepository;
|
|
3592
|
-
this.categoryFilterRepository = categoryFilterRepository;
|
|
3593
2614
|
}
|
|
3594
2615
|
create(params) {
|
|
3595
2616
|
const _super = Object.create(null, {
|
|
@@ -3597,7 +2618,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
3597
2618
|
});
|
|
3598
2619
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3599
2620
|
const { metadata } = params, data = __rest(params, ["metadata"]);
|
|
3600
|
-
return _super.create.call(this, Object.assign(Object.assign({}, data), {
|
|
2621
|
+
return _super.create.call(this, Object.assign(Object.assign({}, data), { metadata: metadata || { description: null, title: null } }));
|
|
3601
2622
|
});
|
|
3602
2623
|
}
|
|
3603
2624
|
get(identifiers) {
|
|
@@ -3607,7 +2628,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
3607
2628
|
var _a;
|
|
3608
2629
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3609
2630
|
return Number.isNaN(+identifiers.id)
|
|
3610
|
-
? (_a = (yield this.find({ filters: { firestoreId: identifiers.id }
|
|
2631
|
+
? (_a = (yield this.find({ filters: { firestoreId: identifiers.id } })).data) === null || _a === void 0 ? void 0 : _a[0]
|
|
3611
2632
|
: _super.get.call(this, identifiers);
|
|
3612
2633
|
});
|
|
3613
2634
|
}
|
|
@@ -3616,56 +2637,28 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
3616
2637
|
update: { get: () => super.update }
|
|
3617
2638
|
});
|
|
3618
2639
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3619
|
-
const { products, id: checkId, metadata
|
|
2640
|
+
const { products, id: checkId, metadata } = params, data = __rest(params, ["products", "id", "metadata"]);
|
|
3620
2641
|
const plainData = this.paramsToPlain({ id: checkId });
|
|
3621
2642
|
const id = yield this.getId(plainData.id);
|
|
3622
|
-
const category = yield _super.update.call(this, Object.assign(
|
|
2643
|
+
const category = yield _super.update.call(this, Object.assign({ id }, data));
|
|
3623
2644
|
category.products = products && (yield this.updateProducts(+id, { products }));
|
|
3624
2645
|
category.metadata = metadata && (yield this.updateMetadata(+id, { metadata }));
|
|
3625
|
-
category.filters = filters && (yield this.updateFilters(+id, { filters }));
|
|
3626
2646
|
return category;
|
|
3627
2647
|
});
|
|
3628
2648
|
}
|
|
3629
2649
|
getCategoryBySlug(slug, shop) {
|
|
3630
2650
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3631
2651
|
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)
|
|
2652
|
+
return null;
|
|
2653
|
+
const { data, count } = yield this.find({ filters: { slug, shop, published: true } });
|
|
2654
|
+
if (count > 1)
|
|
3647
2655
|
throw new DuplicatedResultsError('Query returned duplicated values');
|
|
2656
|
+
if (!count)
|
|
2657
|
+
throw new NotFoundError(`Category with slug ${slug} not found`);
|
|
3648
2658
|
return data.shift();
|
|
3649
2659
|
});
|
|
3650
2660
|
}
|
|
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) {
|
|
2661
|
+
getCategoriesForHome(categoryIds, limit = 4) {
|
|
3669
2662
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3670
2663
|
if (!(categoryIds === null || categoryIds === void 0 ? void 0 : categoryIds.length))
|
|
3671
2664
|
return [];
|
|
@@ -3685,7 +2678,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
3685
2678
|
const homeSections = yield Promise.all(categories.map((category) => __awaiter(this, void 0, void 0, function* () {
|
|
3686
2679
|
return ({
|
|
3687
2680
|
category,
|
|
3688
|
-
products: yield this.mountCategory(category, { limit, hasStock: true
|
|
2681
|
+
products: yield this.mountCategory(category, { limit, hasStock: true }),
|
|
3689
2682
|
});
|
|
3690
2683
|
})));
|
|
3691
2684
|
return homeSections;
|
|
@@ -3697,7 +2690,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
3697
2690
|
if (!((_a = category === null || category === void 0 ? void 0 : category.products) === null || _a === void 0 ? void 0 : _a.length))
|
|
3698
2691
|
return [];
|
|
3699
2692
|
const products = [];
|
|
3700
|
-
const { data: productsData } = yield this.productRepository.find(Object.assign(
|
|
2693
|
+
const { data: productsData } = yield this.productRepository.find(Object.assign({ filters: Object.assign({ id: { operator: Where.IN, value: category.products }, published: true }, ((options === null || options === void 0 ? void 0 : options.hasStock) ? { stock: { quantity: { operator: Where.GT, value: 0 } } } : {})), fields: [
|
|
3701
2694
|
'id',
|
|
3702
2695
|
'name',
|
|
3703
2696
|
'slug',
|
|
@@ -3721,9 +2714,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
3721
2714
|
'tags',
|
|
3722
2715
|
'type',
|
|
3723
2716
|
'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 } }));
|
|
2717
|
+
] }, ((options === null || options === void 0 ? void 0 : options.limit) ? { limits: { limit: options === null || options === void 0 ? void 0 : options.limit } } : {})));
|
|
3727
2718
|
products.push(...productsData);
|
|
3728
2719
|
return products;
|
|
3729
2720
|
});
|
|
@@ -3733,7 +2724,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
3733
2724
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3734
2725
|
if (!Number.isNaN(+id))
|
|
3735
2726
|
return id;
|
|
3736
|
-
const { data } = yield this.find({ filters: { firestoreId: id }
|
|
2727
|
+
const { data } = yield this.find({ filters: { firestoreId: id } });
|
|
3737
2728
|
if ((_a = data === null || data === void 0 ? void 0 : data[0]) === null || _a === void 0 ? void 0 : _a.id)
|
|
3738
2729
|
return (_b = data === null || data === void 0 ? void 0 : data[0]) === null || _b === void 0 ? void 0 : _b.id;
|
|
3739
2730
|
throw new NotFoundError(`Category with id ${id} not found`);
|
|
@@ -3747,254 +2738,48 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
3747
2738
|
type: 'category_product_bool_exp',
|
|
3748
2739
|
required: true,
|
|
3749
2740
|
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,
|
|
2741
|
+
},
|
|
2742
|
+
});
|
|
2743
|
+
return [];
|
|
2744
|
+
}
|
|
2745
|
+
const plainData = this.paramsToPlain({ products });
|
|
2746
|
+
if (!plainData.products || plainData.products.length <= 0)
|
|
2747
|
+
return [];
|
|
2748
|
+
yield this.mutation('delete_category_product', ['affected_rows'], {
|
|
2749
|
+
where: {
|
|
2750
|
+
type: 'category_product_bool_exp',
|
|
2751
|
+
required: true,
|
|
2752
|
+
value: { category_id: { _eq: categoryId } },
|
|
2753
|
+
},
|
|
2754
|
+
});
|
|
2755
|
+
yield this.mutation('insert_category_product', ['affected_rows'], {
|
|
2756
|
+
objects: {
|
|
2757
|
+
type: '[category_product_insert_input!]',
|
|
2758
|
+
required: true,
|
|
2759
|
+
value: plainData.products.map((productId) => ({ category_id: categoryId, product_id: productId })),
|
|
3960
2760
|
},
|
|
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;
|
|
2761
|
+
});
|
|
2762
|
+
return plainData.products;
|
|
3968
2763
|
});
|
|
3969
2764
|
}
|
|
3970
|
-
|
|
2765
|
+
updateMetadata(categoryId, { metadata }) {
|
|
3971
2766
|
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
|
-
],
|
|
2767
|
+
const plainData = this.paramsToPlain({ metadata });
|
|
2768
|
+
if (!plainData.metadata)
|
|
2769
|
+
return null;
|
|
2770
|
+
yield this.mutation('update_category_metadata_by_pk', ['category_id'], {
|
|
2771
|
+
pk_columns: {
|
|
2772
|
+
value: { category_id: categoryId },
|
|
2773
|
+
type: 'category_metadata_pk_columns_input',
|
|
2774
|
+
required: true,
|
|
2775
|
+
},
|
|
2776
|
+
_set: {
|
|
2777
|
+
value: omit(metadata, ['category_id']),
|
|
2778
|
+
type: 'category_metadata_set_input',
|
|
2779
|
+
required: true,
|
|
2780
|
+
},
|
|
2781
|
+
});
|
|
2782
|
+
return plainData.metadata;
|
|
3998
2783
|
});
|
|
3999
2784
|
}
|
|
4000
2785
|
}
|
|
@@ -4008,8 +2793,8 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
4008
2793
|
authOptions,
|
|
4009
2794
|
fields: [],
|
|
4010
2795
|
});
|
|
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 }));
|
|
2796
|
+
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 }));
|
|
2797
|
+
this.bindReviewToHasura = (review) => (Object.assign(Object.assign({}, is(omit(review, ['productId', 'createdAt', 'updatedAt', 'personId', 'orderId']))), { person_id: review.personId, order_id: review.orderId }));
|
|
4013
2798
|
const commonFields = [
|
|
4014
2799
|
{ id: { columnName: 'id', to: (value) => +value, from: (value) => value.toString() } },
|
|
4015
2800
|
{ firestoreId: { columnName: 'firestore_id' } },
|
|
@@ -4028,29 +2813,26 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
4028
2813
|
whoMustUse: data.who_must_use,
|
|
4029
2814
|
howToUse: data.how_to_use,
|
|
4030
2815
|
brand: data.brand_description,
|
|
4031
|
-
ingredients: data.ingredients,
|
|
4032
2816
|
}),
|
|
4033
|
-
bindFindFilter: (
|
|
4034
|
-
|
|
2817
|
+
bindFindFilter: (sentence) => {
|
|
2818
|
+
const filters = Object.values(sentence).shift();
|
|
2819
|
+
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
2820
|
who_must_use: filters.whoMustUse,
|
|
4036
2821
|
})), (filters.howToUse && {
|
|
4037
2822
|
how_to_use: filters.howToUse,
|
|
4038
2823
|
})), (filters.brand && {
|
|
4039
2824
|
brand_description: filters.brand,
|
|
4040
|
-
})), (filters.ingredients && {
|
|
4041
|
-
ingredients: filters.ingredients,
|
|
4042
2825
|
}));
|
|
4043
2826
|
},
|
|
4044
|
-
bindPersistData: (descriptionData) => (Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(
|
|
2827
|
+
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
2828
|
who_must_use: descriptionData.whoMustUse,
|
|
4046
|
-
})), (descriptionData.howToUse && { how_to_use: descriptionData.howToUse })), (descriptionData.brand && { brand_description: descriptionData.brand }))
|
|
2829
|
+
})), (descriptionData.howToUse && { how_to_use: descriptionData.howToUse })), (descriptionData.brand && { brand_description: descriptionData.brand }))),
|
|
4047
2830
|
},
|
|
4048
2831
|
},
|
|
4049
2832
|
{ differentials: { columnName: 'differentials' } },
|
|
4050
2833
|
{ whoMustUse: { columnName: 'who_must_use' } },
|
|
4051
2834
|
{ howToUse: { columnName: 'how_to_use' } },
|
|
4052
2835
|
{ brandDescription: { columnName: 'brand_description' } },
|
|
4053
|
-
{ ingredients: { columnName: 'ingredients' } },
|
|
4054
2836
|
{ hasVariants: { columnName: 'has_variants' } },
|
|
4055
2837
|
{
|
|
4056
2838
|
images: {
|
|
@@ -4074,7 +2856,8 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
4074
2856
|
subscriberDiscountPercentage: data.subscriber_discount_percentage,
|
|
4075
2857
|
subscriberPrice: data.subscriber_price,
|
|
4076
2858
|
}),
|
|
4077
|
-
bindFindFilter: (
|
|
2859
|
+
bindFindFilter: (sentence) => {
|
|
2860
|
+
const filters = Object.values(sentence).shift();
|
|
4078
2861
|
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
2862
|
subscriber_discount_percentage: filters.subscriberDiscountPercentage,
|
|
4080
2863
|
})), ((filters.subscriberPrice || filters.subscriberPrice === 0) && {
|
|
@@ -4098,29 +2881,27 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
4098
2881
|
to: (value) => (isNil(value === null || value === void 0 ? void 0 : value.quantity) ? value : value === null || value === void 0 ? void 0 : value.quantity),
|
|
4099
2882
|
},
|
|
4100
2883
|
},
|
|
4101
|
-
{ hasStock: { columnName: 'has_stock' } },
|
|
4102
2884
|
'slug',
|
|
4103
2885
|
'type',
|
|
4104
2886
|
'video',
|
|
4105
2887
|
'weight',
|
|
4106
2888
|
'gender',
|
|
4107
|
-
{ intGender: { columnName: 'int_gender' } },
|
|
4108
2889
|
{ tags: { columnName: 'tags', type: HasuraGraphQLColumnType.Jsonb } },
|
|
4109
|
-
{ filters: { columnName: 'filters', type: HasuraGraphQLColumnType.Jsonb } },
|
|
4110
2890
|
{ isKit: { columnName: 'is_kit' } },
|
|
4111
2891
|
{ createdAt: { columnName: 'created_at' } },
|
|
4112
2892
|
{ updatedAt: { columnName: 'updated_at' } },
|
|
4113
|
-
{ rate: { columnName: 'rating' } },
|
|
4114
|
-
{ reviewsTotal: { columnName: 'reviews_total' } },
|
|
4115
|
-
{ shoppingCount: { columnName: 'shopping_count' } },
|
|
4116
|
-
{ categoryId: { columnName: 'category_id' } },
|
|
4117
2893
|
{
|
|
4118
|
-
|
|
4119
|
-
columnName: '
|
|
4120
|
-
|
|
4121
|
-
|
|
2894
|
+
rate: {
|
|
2895
|
+
columnName: 'reviews_aggregate',
|
|
2896
|
+
filters: {
|
|
2897
|
+
filters: { status: true },
|
|
2898
|
+
filterType: 'product_review_bool_exp',
|
|
2899
|
+
},
|
|
2900
|
+
fields: [{ aggregate: [{ avg: ['rate'] }] }],
|
|
2901
|
+
from: (value) => value.aggregate.avg.rate,
|
|
4122
2902
|
},
|
|
4123
2903
|
},
|
|
2904
|
+
{ shoppingCount: { columnName: 'shopping_count' } },
|
|
4124
2905
|
];
|
|
4125
2906
|
this.fields = [
|
|
4126
2907
|
...commonFields,
|
|
@@ -4207,7 +2988,7 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
4207
2988
|
var _a;
|
|
4208
2989
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4209
2990
|
const product = Number.isNaN(+identifiers.id)
|
|
4210
|
-
? (_a = (yield this.find({ filters: { firestoreId: identifiers.id }
|
|
2991
|
+
? (_a = (yield this.find({ filters: { firestoreId: identifiers.id } })).data) === null || _a === void 0 ? void 0 : _a[0]
|
|
4211
2992
|
: yield _super.get.call(this, identifiers);
|
|
4212
2993
|
if (product.productId)
|
|
4213
2994
|
throw new NotFoundError('Product not found, it is a variant');
|
|
@@ -4219,29 +3000,13 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
4219
3000
|
const _super = Object.create(null, {
|
|
4220
3001
|
find: { get: () => super.find }
|
|
4221
3002
|
});
|
|
4222
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
4223
3003
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4224
|
-
const
|
|
3004
|
+
const _a = params || {}, { filters, fields } = _a, options = __rest(_a, ["filters", "fields"]);
|
|
4225
3005
|
const bindFields = fields ||
|
|
4226
3006
|
this.fields
|
|
4227
3007
|
.map((field) => (typeof field === 'string' ? field : Object.keys(field).shift()))
|
|
4228
3008
|
.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
|
-
] }));
|
|
3009
|
+
return _super.find.call(this, Object.assign(Object.assign({}, options), { filters: Object.assign(Object.assign({}, filters), { productId: { operator: Where.ISNULL } }), fields: bindFields }));
|
|
4245
3010
|
});
|
|
4246
3011
|
}
|
|
4247
3012
|
getBySlug(slug) {
|
|
@@ -4251,13 +3016,9 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
4251
3016
|
filters: {
|
|
4252
3017
|
slug,
|
|
4253
3018
|
},
|
|
4254
|
-
fields: this.fields.map((field) => typeof field === 'string' ? field : Object.keys(field).shift()),
|
|
4255
|
-
options: {
|
|
4256
|
-
enableCount: false,
|
|
4257
|
-
},
|
|
4258
3019
|
});
|
|
4259
3020
|
const product = (_a = result === null || result === void 0 ? void 0 : result.data) === null || _a === void 0 ? void 0 : _a.shift();
|
|
4260
|
-
|
|
3021
|
+
product.reviews = yield this.findReviewsByProduct(+product.id);
|
|
4261
3022
|
return product;
|
|
4262
3023
|
});
|
|
4263
3024
|
}
|
|
@@ -4297,11 +3058,6 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
4297
3058
|
], []);
|
|
4298
3059
|
});
|
|
4299
3060
|
}
|
|
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
3061
|
updateCategories(productId, { categories }) {
|
|
4306
3062
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4307
3063
|
if ('action' in categories && categories.action === 'remove') {
|
|
@@ -4404,7 +3160,7 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
4404
3160
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4405
3161
|
const plainData = this.paramsToPlain({ metadata });
|
|
4406
3162
|
if (!plainData.metadata)
|
|
4407
|
-
return;
|
|
3163
|
+
return null;
|
|
4408
3164
|
yield this.mutation('update_product_metadata_by_pk', ['product_id'], {
|
|
4409
3165
|
pk_columns: {
|
|
4410
3166
|
value: { product_id: productId },
|
|
@@ -4425,7 +3181,7 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
4425
3181
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4426
3182
|
if (!Number.isNaN(+id))
|
|
4427
3183
|
return id;
|
|
4428
|
-
const { data } = yield this.find({ filters: { firestoreId: id }
|
|
3184
|
+
const { data } = yield this.find({ filters: { firestoreId: id } });
|
|
4429
3185
|
if ((_a = data === null || data === void 0 ? void 0 : data[0]) === null || _a === void 0 ? void 0 : _a.id)
|
|
4430
3186
|
return (_b = data === null || data === void 0 ? void 0 : data[0]) === null || _b === void 0 ? void 0 : _b.id;
|
|
4431
3187
|
throw new NotFoundError(`Product with id ${id} not found`);
|
|
@@ -4481,21 +3237,6 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
4481
3237
|
return data && data[0] && this.bindReviewToModel(data[0]);
|
|
4482
3238
|
});
|
|
4483
3239
|
}
|
|
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
3240
|
}
|
|
4500
3241
|
|
|
4501
3242
|
class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
@@ -4508,7 +3249,13 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
4508
3249
|
fields: [
|
|
4509
3250
|
{ id: { columnName: 'id', to: (value) => +value, from: (value) => value.toString() } },
|
|
4510
3251
|
{ firestoreId: { columnName: 'firestore_id' } },
|
|
4511
|
-
{
|
|
3252
|
+
{
|
|
3253
|
+
productId: {
|
|
3254
|
+
columnName: 'main_product_id',
|
|
3255
|
+
to: (value) => +value,
|
|
3256
|
+
from: (value) => value === null || value === void 0 ? void 0 : value.toString(),
|
|
3257
|
+
},
|
|
3258
|
+
},
|
|
4512
3259
|
{ EAN: { columnName: 'ean' } },
|
|
4513
3260
|
{ costPrice: { columnName: 'cost_price' } },
|
|
4514
3261
|
{
|
|
@@ -4544,7 +3291,6 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
4544
3291
|
to: (value) => (isNil(value === null || value === void 0 ? void 0 : value.quantity) ? value : value === null || value === void 0 ? void 0 : value.quantity),
|
|
4545
3292
|
},
|
|
4546
3293
|
},
|
|
4547
|
-
{ hasStock: { columnName: 'has_stock' } },
|
|
4548
3294
|
'weight',
|
|
4549
3295
|
{ name: { to: () => '', from: () => undefined } },
|
|
4550
3296
|
{ hasVariants: { columnName: 'has_variants', to: () => false, from: () => undefined } },
|
|
@@ -4600,7 +3346,7 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
4600
3346
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4601
3347
|
if (!Number.isNaN(+id))
|
|
4602
3348
|
return id;
|
|
4603
|
-
const { data } = yield this.find({ filters: { firestoreId: id }
|
|
3349
|
+
const { data } = yield this.find({ filters: { firestoreId: id } });
|
|
4604
3350
|
if ((_a = data === null || data === void 0 ? void 0 : data[0]) === null || _a === void 0 ? void 0 : _a.id)
|
|
4605
3351
|
return (_b = data === null || data === void 0 ? void 0 : data[0]) === null || _b === void 0 ? void 0 : _b.id;
|
|
4606
3352
|
throw new NotFoundError(`Product with id ${id} not found`);
|
|
@@ -4608,255 +3354,9 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
4608
3354
|
}
|
|
4609
3355
|
}
|
|
4610
3356
|
|
|
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
3357
|
/**
|
|
4858
3358
|
* Generated bundle index. Do not edit.
|
|
4859
3359
|
*/
|
|
4860
3360
|
|
|
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.
|
|
3361
|
+
export { AccessoryImportances, Address, Area, Authentication, AuthenticationFirebaseAuthService, AxiosAdapter, Base, BaseModel, BeardProblems, BeardSizes, BeautyProductImportances, BeautyProfile, BeautyQuestionsHelper, BillingStatus, BodyProblems, BodyShapes, BodyTattoos, Buy2Win, Buy2WinFirestoreRepository, Category, CategoryFirestoreRepository, CategoryHasuraGraphQL, CategoryHasuraGraphQLRepository, Checkout, CheckoutFirestoreRepository, CheckoutSubscription, CheckoutSubscriptionFirestoreRepository, CheckoutTypes, Coupon, CouponFirestoreRepository, CouponSubtypes, CouponTypes, DuplicatedResultsError, Edition, EditionStatus, Exclusivities, FaceSkinOilinesses, FaceSkinProblems, FaceSkinTones, FamilyIncomes, FilterType, FragranceImportances, GenderDestination, HairColors, HairProblems, HairStrands, HairTypes, Home, HomeFirestoreRepository, InvalidArgumentError, KitProduct, KitProductHasuraGraphQL, Lead, LeadFirestoreRepository, LegacyOrderFirestoreRepository, LineItem, NotFoundError, OfficePosition, Order, OrderFirestoreRepository, OrderStatus, Payment, PaymentFirestoreRepository, PaymentType, Product, ProductFirestoreRepository, ProductHasuraGraphQL, ProductHasuraGraphQLRepository, ProductSpents, ProductVariantFirestoreRepository, ProductsIndex, QuestionsFilters, RecoveryPassword, Register, RegisterFirebaseAuthService, RequiredArgumentError, ShippingMethod, ShopMenu, ShopMenuFirestoreRepository, Shops, SignInMethods, SignOut, Status, Subscription, SubscriptionEditionFirestoreRepository, SubscriptionFirestoreRepository, SubscriptionPayment, SubscriptionPaymentFirestoreRepository, SubscriptionPlan, SubscriptionPlanFirestoreRepository, SubscriptionProductFirestoreRepository, UnauthorizedError, UpdateOptionActions, User, UserAddress, UserAddressFirestoreRepository, UserAlreadyRegisteredError, UserBeautyProfileFirestoreRepository, UserFirestoreRepository, UserPaymentMethod, UserPaymentMethodFirestoreRepository, UserType, Variant, VariantHasuraGraphQL, VariantHasuraGraphQLRepository, WeakPasswordError, Where, chunk, get, is, isBoolean, isDate, isEmpty, isInteger, isNaN$1 as isNaN, isNil, isNumber, isObject, isString, isUUID, now, omit, parseDateTime, pick, set, withCreateFirestore, withCreateHasuraGraphQL, withCrudFirestore, withCrudHasuraGraphQL, withDeleteFirestore, withDeleteHasuraGraphQL, withFindFirestore, withFindHasuraGraphQL, withFirestore, withGetFirestore, withGetHasuraGraphQL, withHasuraGraphQL, withHelpers, withSubCollection, withUpdateFirestore, withUpdateHasuraGraphQL };
|
|
3362
|
+
//# sourceMappingURL=infrab4a-connect.mjs.map
|