@infrab4a/connect 0.4.9 → 0.5.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/README.md +24 -24
- package/bundles/infrab4a-connect.umd.js +1645 -1610
- package/bundles/infrab4a-connect.umd.js.map +1 -1
- package/esm2015/infrab4a-connect.js +4 -4
- package/esm2015/lib/domain/catalog/index.js +3 -3
- package/esm2015/lib/domain/catalog/models/category.js +7 -7
- package/esm2015/lib/domain/catalog/models/enums/index.js +2 -2
- package/esm2015/lib/domain/catalog/models/enums/shops.enum.js +6 -6
- package/esm2015/lib/domain/catalog/models/index.js +6 -6
- package/esm2015/lib/domain/catalog/models/product.js +10 -7
- package/esm2015/lib/domain/catalog/models/types/category-condition.type.js +2 -2
- package/esm2015/lib/domain/catalog/models/types/category-filter.type.js +2 -2
- package/esm2015/lib/domain/catalog/models/types/index.js +8 -8
- package/esm2015/lib/domain/catalog/models/types/product-review.type.js +2 -2
- package/esm2015/lib/domain/catalog/models/types/shops-description.type.js +2 -2
- package/esm2015/lib/domain/catalog/models/types/shops-price.type.js +2 -2
- package/esm2015/lib/domain/catalog/models/types/stock.type.js +2 -2
- package/esm2015/lib/domain/catalog/models/types/variant-grade.type.js +2 -2
- package/esm2015/lib/domain/catalog/models/variant.js +7 -7
- package/esm2015/lib/domain/catalog/repositories/category.repository.js +2 -2
- package/esm2015/lib/domain/catalog/repositories/index.js +4 -4
- package/esm2015/lib/domain/catalog/repositories/product.repository.js +2 -2
- package/esm2015/lib/domain/catalog/repositories/variant.repository.js +2 -2
- package/esm2015/lib/domain/general/index.js +3 -3
- package/esm2015/lib/domain/general/model/base-model-with-identifier-fields.js +2 -2
- package/esm2015/lib/domain/general/model/base.model.js +13 -13
- package/esm2015/lib/domain/general/model/identifier-fields.js +2 -2
- package/esm2015/lib/domain/general/model/index.js +5 -5
- package/esm2015/lib/domain/general/model/types/base-model-builder.type.js +2 -2
- package/esm2015/lib/domain/general/model/types/index.js +4 -4
- package/esm2015/lib/domain/general/model/types/non-function-properties.type.js +2 -2
- package/esm2015/lib/domain/general/model/types/non-function-property-name.type.js +2 -2
- package/esm2015/lib/domain/general/repository/create.repository.js +2 -2
- package/esm2015/lib/domain/general/repository/crud.repository.js +2 -2
- package/esm2015/lib/domain/general/repository/delete.repository.js +2 -2
- package/esm2015/lib/domain/general/repository/enums/index.js +3 -3
- package/esm2015/lib/domain/general/repository/enums/update-option-actions.enum.js +9 -9
- package/esm2015/lib/domain/general/repository/enums/where.enum.js +11 -11
- package/esm2015/lib/domain/general/repository/find.repository.js +2 -2
- package/esm2015/lib/domain/general/repository/get.repository.js +2 -2
- package/esm2015/lib/domain/general/repository/index.js +10 -10
- package/esm2015/lib/domain/general/repository/read.repository.js +2 -2
- package/esm2015/lib/domain/general/repository/types/index.js +6 -6
- package/esm2015/lib/domain/general/repository/types/repository-find-filters.type.js +2 -2
- package/esm2015/lib/domain/general/repository/types/repository-find-result.type.js +2 -2
- package/esm2015/lib/domain/general/repository/types/repository-limit-options.type.js +2 -2
- package/esm2015/lib/domain/general/repository/types/repository-order-by-list.type.js +2 -2
- package/esm2015/lib/domain/general/repository/types/repository-update-params.type.js +2 -2
- package/esm2015/lib/domain/general/repository/update.repository.js +2 -2
- package/esm2015/lib/domain/index.js +7 -7
- package/esm2015/lib/domain/location/index.js +2 -2
- package/esm2015/lib/domain/location/models/address.js +4 -4
- package/esm2015/lib/domain/location/models/index.js +3 -3
- package/esm2015/lib/domain/location/models/types/index.js +4 -4
- package/esm2015/lib/domain/location/models/types/location-bound.type.js +2 -2
- package/esm2015/lib/domain/location/models/types/location-geometry.type.js +2 -2
- package/esm2015/lib/domain/location/models/types/location-lat-lng.type.js +2 -2
- package/esm2015/lib/domain/shop-settings/index.js +3 -3
- package/esm2015/lib/domain/shop-settings/models/home.js +7 -7
- package/esm2015/lib/domain/shop-settings/models/index.js +4 -4
- package/esm2015/lib/domain/shop-settings/models/shop-menu.js +7 -7
- package/esm2015/lib/domain/shop-settings/models/types/banner.type.js +2 -2
- package/esm2015/lib/domain/shop-settings/models/types/benefit.type.js +2 -2
- package/esm2015/lib/domain/shop-settings/models/types/index.js +5 -5
- package/esm2015/lib/domain/shop-settings/models/types/menu-nav.type.js +2 -2
- package/esm2015/lib/domain/shop-settings/models/types/sub-menu.type.js +2 -2
- package/esm2015/lib/domain/shop-settings/repositories/home.repository.js +2 -2
- package/esm2015/lib/domain/shop-settings/repositories/index.js +3 -3
- package/esm2015/lib/domain/shop-settings/repositories/shop-menu.repository.js +2 -2
- package/esm2015/lib/domain/shopping/index.js +3 -3
- package/esm2015/lib/domain/shopping/models/buy-2-win.js +7 -7
- package/esm2015/lib/domain/shopping/models/checkout.js +7 -7
- package/esm2015/lib/domain/shopping/models/coupons/coupon.js +15 -15
- package/esm2015/lib/domain/shopping/models/coupons/enums/coupon-subtypes.enum.js +6 -6
- package/esm2015/lib/domain/shopping/models/coupons/enums/coupon-types.enum.js +8 -8
- package/esm2015/lib/domain/shopping/models/coupons/enums/exclusivities.enum.js +7 -7
- package/esm2015/lib/domain/shopping/models/coupons/enums/index.js +4 -4
- package/esm2015/lib/domain/shopping/models/coupons/financial-coupon.js +28 -28
- package/esm2015/lib/domain/shopping/models/coupons/index.js +4 -4
- package/esm2015/lib/domain/shopping/models/enums/checkout-types.enum.js +6 -6
- package/esm2015/lib/domain/shopping/models/enums/index.js +3 -3
- package/esm2015/lib/domain/shopping/models/enums/order-status.enum.js +12 -12
- package/esm2015/lib/domain/shopping/models/index.js +12 -12
- package/esm2015/lib/domain/shopping/models/line-item.js +4 -4
- package/esm2015/lib/domain/shopping/models/order.js +4 -4
- package/esm2015/lib/domain/shopping/models/payment.js +129 -129
- package/esm2015/lib/domain/shopping/models/shipping-method.js +7 -7
- package/esm2015/lib/domain/shopping/models/subscription/checkout.js +7 -7
- package/esm2015/lib/domain/shopping/models/subscription/index.js +3 -3
- package/esm2015/lib/domain/shopping/models/subscription/plan.js +7 -7
- package/esm2015/lib/domain/shopping/models/types/index.js +8 -8
- package/esm2015/lib/domain/shopping/models/types/payment-address.type.js +2 -2
- package/esm2015/lib/domain/shopping/models/types/payment-billing.type.js +2 -2
- package/esm2015/lib/domain/shopping/models/types/payment-card.type.js +2 -2
- package/esm2015/lib/domain/shopping/models/types/payment-customer.type.js +2 -2
- package/esm2015/lib/domain/shopping/models/types/payment-document.type.js +2 -2
- package/esm2015/lib/domain/shopping/models/types/payment-item.type.js +2 -2
- package/esm2015/lib/domain/shopping/models/types/payment-shipping.type.js +2 -2
- package/esm2015/lib/domain/shopping/repositories/buy-2-win.repository.js +2 -2
- package/esm2015/lib/domain/shopping/repositories/checkout.repository.js +2 -2
- package/esm2015/lib/domain/shopping/repositories/coupon.repository.js +2 -2
- package/esm2015/lib/domain/shopping/repositories/index.js +7 -7
- package/esm2015/lib/domain/shopping/repositories/order.repository.js +2 -2
- package/esm2015/lib/domain/shopping/repositories/payment.repository.js +2 -2
- package/esm2015/lib/domain/shopping/repositories/subscription/checkout.repository.js +2 -2
- package/esm2015/lib/domain/shopping/repositories/subscription/index.js +3 -3
- package/esm2015/lib/domain/shopping/repositories/subscription/plan.repository.js +2 -2
- package/esm2015/lib/domain/users/errors/index.js +2 -2
- package/esm2015/lib/domain/users/errors/unauthorized.error.js +7 -7
- package/esm2015/lib/domain/users/index.js +6 -6
- package/esm2015/lib/domain/users/models/beauty-profile.js +12 -12
- package/esm2015/lib/domain/users/models/enums/area.enum.js +13 -13
- package/esm2015/lib/domain/users/models/enums/beard-sizes.enum.js +9 -9
- package/esm2015/lib/domain/users/models/enums/hair-types.enum.js +9 -9
- package/esm2015/lib/domain/users/models/enums/index.js +7 -7
- package/esm2015/lib/domain/users/models/enums/office-position.enum.js +8 -8
- package/esm2015/lib/domain/users/models/enums/user-type.enum.js +10 -10
- package/esm2015/lib/domain/users/models/index.js +6 -6
- package/esm2015/lib/domain/users/models/subscription/edition.js +7 -7
- package/esm2015/lib/domain/users/models/subscription/enums/billing-status.enum.js +5 -5
- package/esm2015/lib/domain/users/models/subscription/enums/edition-status.enum.js +5 -5
- package/esm2015/lib/domain/users/models/subscription/enums/index.js +5 -5
- package/esm2015/lib/domain/users/models/subscription/enums/payment-type.enum.js +7 -7
- package/esm2015/lib/domain/users/models/subscription/enums/status.enum.js +5 -5
- package/esm2015/lib/domain/users/models/subscription/index.js +5 -5
- package/esm2015/lib/domain/users/models/subscription/payment.js +7 -7
- package/esm2015/lib/domain/users/models/subscription/subscription.js +7 -7
- package/esm2015/lib/domain/users/models/user-address.js +7 -7
- package/esm2015/lib/domain/users/models/user.js +17 -17
- package/esm2015/lib/domain/users/repositories/beauty-profile.repository.js +2 -2
- package/esm2015/lib/domain/users/repositories/edition.repository.js +2 -2
- package/esm2015/lib/domain/users/repositories/index.js +7 -7
- package/esm2015/lib/domain/users/repositories/subscription-payment.repository.js +2 -2
- package/esm2015/lib/domain/users/repositories/subscription.repository.js +2 -2
- package/esm2015/lib/domain/users/repositories/user-address.repository.js +2 -2
- package/esm2015/lib/domain/users/repositories/user.repository.js +2 -2
- package/esm2015/lib/domain/users/services/authentication.service.js +2 -2
- package/esm2015/lib/domain/users/services/index.js +2 -2
- package/esm2015/lib/domain/users/use-cases/authentication.js +40 -40
- package/esm2015/lib/domain/users/use-cases/index.js +3 -3
- package/esm2015/lib/domain/users/use-cases/signout.js +12 -12
- package/esm2015/lib/errors/duplicated-results.error.js +7 -7
- package/esm2015/lib/errors/index.js +5 -5
- package/esm2015/lib/errors/invalid-argument.error.js +7 -7
- package/esm2015/lib/errors/not-found.error.js +7 -7
- package/esm2015/lib/errors/required-argument.error.js +8 -8
- package/esm2015/lib/index.js +5 -5
- package/esm2015/lib/infra/firebase/auth/authentication-firebase-auth.service.js +27 -27
- package/esm2015/lib/infra/firebase/auth/index.js +2 -2
- package/esm2015/lib/infra/firebase/firestore/index.js +4 -4
- package/esm2015/lib/infra/firebase/firestore/mixins/index.js +10 -10
- package/esm2015/lib/infra/firebase/firestore/mixins/with-create-firestore.mixin.js +30 -30
- package/esm2015/lib/infra/firebase/firestore/mixins/with-crud-firestore.mixin.js +10 -10
- package/esm2015/lib/infra/firebase/firestore/mixins/with-delete-firestore.mixin.js +18 -18
- package/esm2015/lib/infra/firebase/firestore/mixins/with-find-firestore.mixin.js +64 -64
- package/esm2015/lib/infra/firebase/firestore/mixins/with-firestore.mixin.js +26 -26
- package/esm2015/lib/infra/firebase/firestore/mixins/with-get-firestore.mixin.js +24 -24
- package/esm2015/lib/infra/firebase/firestore/mixins/with-helpers.mixin.js +17 -17
- package/esm2015/lib/infra/firebase/firestore/mixins/with-sub-collection.mixin.js +11 -11
- package/esm2015/lib/infra/firebase/firestore/mixins/with-update-firestore.mixin.js +45 -45
- package/esm2015/lib/infra/firebase/firestore/repositories/catalog/category-firestore.repository.js +74 -74
- package/esm2015/lib/infra/firebase/firestore/repositories/catalog/index.js +4 -4
- package/esm2015/lib/infra/firebase/firestore/repositories/catalog/product-firestore.repository.js +23 -23
- package/esm2015/lib/infra/firebase/firestore/repositories/catalog/product-variant-firestore.repository.js +14 -14
- package/esm2015/lib/infra/firebase/firestore/repositories/index.js +5 -5
- package/esm2015/lib/infra/firebase/firestore/repositories/shop-settings/home-firestore.repository.js +12 -12
- package/esm2015/lib/infra/firebase/firestore/repositories/shop-settings/index.js +3 -3
- package/esm2015/lib/infra/firebase/firestore/repositories/shop-settings/shop-menu-firestore.repository.js +12 -12
- package/esm2015/lib/infra/firebase/firestore/repositories/shopping/buy-2-win-firestore.repository.js +12 -12
- package/esm2015/lib/infra/firebase/firestore/repositories/shopping/checkout-firestore.repository.js +12 -12
- package/esm2015/lib/infra/firebase/firestore/repositories/shopping/checkout-subscription-firestore.repository.js +12 -12
- package/esm2015/lib/infra/firebase/firestore/repositories/shopping/coupon-firestore.repository.js +12 -12
- package/esm2015/lib/infra/firebase/firestore/repositories/shopping/index.js +8 -8
- package/esm2015/lib/infra/firebase/firestore/repositories/shopping/order-firestore.repository.js +12 -12
- package/esm2015/lib/infra/firebase/firestore/repositories/shopping/payment-firestore.repository.js +12 -12
- package/esm2015/lib/infra/firebase/firestore/repositories/shopping/subscription-plan-firestore.repository.js +12 -12
- package/esm2015/lib/infra/firebase/firestore/repositories/users/index.js +7 -7
- package/esm2015/lib/infra/firebase/firestore/repositories/users/subscription-edition-firestore.repository.js +14 -14
- package/esm2015/lib/infra/firebase/firestore/repositories/users/subscription-firestore.repository.js +12 -12
- package/esm2015/lib/infra/firebase/firestore/repositories/users/subscription-payment-firestore.repository.js +14 -14
- package/esm2015/lib/infra/firebase/firestore/repositories/users/user-address-firestore.repository.js +14 -14
- package/esm2015/lib/infra/firebase/firestore/repositories/users/user-beauty-profile-firestore.repository.js +14 -14
- package/esm2015/lib/infra/firebase/firestore/repositories/users/user-firestore.repository.js +62 -40
- package/esm2015/lib/infra/firebase/firestore/types/firestore-sub.repository.type.js +2 -2
- package/esm2015/lib/infra/firebase/firestore/types/firestore.helpers.type.js +2 -2
- package/esm2015/lib/infra/firebase/firestore/types/firestore.repository.type.js +2 -2
- package/esm2015/lib/infra/firebase/firestore/types/index.js +4 -4
- package/esm2015/lib/infra/firebase/index.js +3 -3
- package/esm2015/lib/infra/index.js +2 -2
- package/esm2015/lib/utils/index.js +5 -5
- package/esm2015/lib/utils/mixins/base.mixin.js +6 -6
- package/esm2015/lib/utils/mixins/index.js +3 -3
- package/esm2015/lib/utils/mixins/mixin-ctor.type.js +2 -2
- package/esm2015/lib/utils/types/index.js +2 -2
- package/esm2015/lib/utils/types/prop.type.js +2 -2
- package/esm2015/public-api.js +2 -2
- package/fesm2015/infrab4a-connect.js +913 -888
- package/fesm2015/infrab4a-connect.js.map +1 -1
- package/infrab4a-connect.d.ts +5 -5
- package/lib/domain/catalog/index.d.ts +2 -2
- package/lib/domain/catalog/models/category.d.ts +20 -20
- package/lib/domain/catalog/models/enums/index.d.ts +1 -1
- package/lib/domain/catalog/models/enums/shops.enum.d.ts +4 -4
- package/lib/domain/catalog/models/index.d.ts +5 -5
- package/lib/domain/catalog/models/product.d.ts +33 -32
- package/lib/domain/catalog/models/types/category-condition.type.d.ts +4 -4
- package/lib/domain/catalog/models/types/category-filter.type.d.ts +4 -4
- package/lib/domain/catalog/models/types/index.d.ts +7 -7
- package/lib/domain/catalog/models/types/product-review.type.d.ts +12 -12
- package/lib/domain/catalog/models/types/shops-description.type.d.ts +7 -7
- package/lib/domain/catalog/models/types/shops-price.type.d.ts +10 -10
- package/lib/domain/catalog/models/types/stock.type.d.ts +3 -3
- package/lib/domain/catalog/models/types/variant-grade.type.d.ts +4 -4
- package/lib/domain/catalog/models/variant.d.ts +12 -12
- package/lib/domain/catalog/repositories/category.repository.d.ts +12 -12
- package/lib/domain/catalog/repositories/index.d.ts +3 -3
- package/lib/domain/catalog/repositories/product.repository.d.ts +5 -5
- package/lib/domain/catalog/repositories/variant.repository.d.ts +4 -4
- package/lib/domain/general/index.d.ts +2 -2
- package/lib/domain/general/model/base-model-with-identifier-fields.d.ts +3 -3
- package/lib/domain/general/model/base.model.d.ts +6 -6
- package/lib/domain/general/model/identifier-fields.d.ts +4 -4
- package/lib/domain/general/model/index.d.ts +4 -4
- package/lib/domain/general/model/types/base-model-builder.type.d.ts +5 -5
- package/lib/domain/general/model/types/index.d.ts +3 -3
- package/lib/domain/general/model/types/non-function-properties.type.d.ts +2 -2
- package/lib/domain/general/model/types/non-function-property-name.type.d.ts +3 -3
- package/lib/domain/general/repository/create.repository.d.ts +5 -5
- package/lib/domain/general/repository/crud.repository.d.ts +7 -7
- package/lib/domain/general/repository/delete.repository.d.ts +5 -5
- package/lib/domain/general/repository/enums/index.d.ts +2 -2
- package/lib/domain/general/repository/enums/update-option-actions.enum.d.ts +7 -7
- package/lib/domain/general/repository/enums/where.enum.d.ts +9 -9
- package/lib/domain/general/repository/find.repository.d.ts +5 -5
- package/lib/domain/general/repository/get.repository.d.ts +5 -5
- package/lib/domain/general/repository/index.d.ts +9 -9
- package/lib/domain/general/repository/read.repository.d.ts +5 -5
- package/lib/domain/general/repository/types/index.d.ts +5 -5
- package/lib/domain/general/repository/types/repository-find-filters.type.d.ts +10 -10
- package/lib/domain/general/repository/types/repository-find-result.type.d.ts +4 -4
- package/lib/domain/general/repository/types/repository-limit-options.type.d.ts +4 -4
- package/lib/domain/general/repository/types/repository-order-by-list.type.d.ts +5 -5
- package/lib/domain/general/repository/types/repository-update-params.type.d.ts +11 -11
- package/lib/domain/general/repository/update.repository.d.ts +5 -5
- package/lib/domain/index.d.ts +6 -6
- package/lib/domain/location/index.d.ts +1 -1
- package/lib/domain/location/models/address.d.ts +21 -21
- package/lib/domain/location/models/index.d.ts +2 -2
- package/lib/domain/location/models/types/index.d.ts +3 -3
- package/lib/domain/location/models/types/location-bound.type.d.ts +6 -6
- package/lib/domain/location/models/types/location-geometry.type.d.ts +7 -7
- package/lib/domain/location/models/types/location-lat-lng.type.d.ts +4 -4
- package/lib/domain/shop-settings/index.d.ts +2 -2
- package/lib/domain/shop-settings/models/home.d.ts +17 -17
- package/lib/domain/shop-settings/models/index.d.ts +3 -3
- package/lib/domain/shop-settings/models/shop-menu.d.ts +7 -7
- package/lib/domain/shop-settings/models/types/banner.type.d.ts +6 -6
- package/lib/domain/shop-settings/models/types/benefit.type.d.ts +5 -5
- package/lib/domain/shop-settings/models/types/index.d.ts +4 -4
- package/lib/domain/shop-settings/models/types/menu-nav.type.d.ts +8 -8
- package/lib/domain/shop-settings/models/types/sub-menu.type.d.ts +8 -8
- package/lib/domain/shop-settings/repositories/home.repository.d.ts +4 -4
- package/lib/domain/shop-settings/repositories/index.d.ts +2 -2
- package/lib/domain/shop-settings/repositories/shop-menu.repository.d.ts +4 -4
- package/lib/domain/shopping/index.d.ts +2 -2
- package/lib/domain/shopping/models/buy-2-win.d.ts +18 -18
- package/lib/domain/shopping/models/checkout.d.ts +28 -28
- package/lib/domain/shopping/models/coupons/coupon.d.ts +25 -25
- package/lib/domain/shopping/models/coupons/enums/coupon-subtypes.enum.d.ts +4 -4
- package/lib/domain/shopping/models/coupons/enums/coupon-types.enum.d.ts +6 -6
- package/lib/domain/shopping/models/coupons/enums/exclusivities.enum.d.ts +5 -5
- package/lib/domain/shopping/models/coupons/enums/index.d.ts +3 -3
- package/lib/domain/shopping/models/coupons/financial-coupon.d.ts +8 -8
- package/lib/domain/shopping/models/coupons/index.d.ts +3 -3
- package/lib/domain/shopping/models/enums/checkout-types.enum.d.ts +4 -4
- package/lib/domain/shopping/models/enums/index.d.ts +2 -2
- package/lib/domain/shopping/models/enums/order-status.enum.d.ts +10 -10
- package/lib/domain/shopping/models/index.d.ts +11 -11
- package/lib/domain/shopping/models/line-item.d.ts +8 -7
- package/lib/domain/shopping/models/order.d.ts +7 -7
- package/lib/domain/shopping/models/payment.d.ts +69 -69
- package/lib/domain/shopping/models/shipping-method.d.ts +18 -18
- package/lib/domain/shopping/models/subscription/checkout.d.ts +23 -23
- package/lib/domain/shopping/models/subscription/index.d.ts +2 -2
- package/lib/domain/shopping/models/subscription/plan.d.ts +12 -12
- package/lib/domain/shopping/models/types/index.d.ts +7 -7
- package/lib/domain/shopping/models/types/payment-address.type.d.ts +12 -12
- package/lib/domain/shopping/models/types/payment-billing.type.d.ts +7 -7
- package/lib/domain/shopping/models/types/payment-card.type.d.ts +14 -14
- package/lib/domain/shopping/models/types/payment-customer.type.d.ts +18 -18
- package/lib/domain/shopping/models/types/payment-document.type.d.ts +6 -6
- package/lib/domain/shopping/models/types/payment-item.type.d.ts +11 -11
- package/lib/domain/shopping/models/types/payment-shipping.type.d.ts +10 -10
- package/lib/domain/shopping/repositories/buy-2-win.repository.d.ts +4 -4
- package/lib/domain/shopping/repositories/checkout.repository.d.ts +4 -4
- package/lib/domain/shopping/repositories/coupon.repository.d.ts +4 -4
- package/lib/domain/shopping/repositories/index.d.ts +6 -6
- package/lib/domain/shopping/repositories/order.repository.d.ts +4 -4
- package/lib/domain/shopping/repositories/payment.repository.d.ts +4 -4
- package/lib/domain/shopping/repositories/subscription/checkout.repository.d.ts +4 -4
- package/lib/domain/shopping/repositories/subscription/index.d.ts +2 -2
- package/lib/domain/shopping/repositories/subscription/plan.repository.d.ts +4 -4
- package/lib/domain/users/errors/index.d.ts +1 -1
- package/lib/domain/users/errors/unauthorized.error.d.ts +4 -4
- package/lib/domain/users/index.d.ts +5 -5
- package/lib/domain/users/models/beauty-profile.d.ts +12 -12
- package/lib/domain/users/models/enums/area.enum.d.ts +11 -11
- package/lib/domain/users/models/enums/beard-sizes.enum.d.ts +7 -7
- package/lib/domain/users/models/enums/hair-types.enum.d.ts +7 -7
- package/lib/domain/users/models/enums/index.d.ts +6 -6
- package/lib/domain/users/models/enums/office-position.enum.d.ts +6 -6
- package/lib/domain/users/models/enums/user-type.enum.d.ts +8 -8
- package/lib/domain/users/models/index.d.ts +5 -5
- package/lib/domain/users/models/subscription/edition.d.ts +15 -15
- package/lib/domain/users/models/subscription/enums/billing-status.enum.d.ts +3 -3
- package/lib/domain/users/models/subscription/enums/edition-status.enum.d.ts +3 -3
- package/lib/domain/users/models/subscription/enums/index.d.ts +4 -4
- package/lib/domain/users/models/subscription/enums/payment-type.enum.d.ts +5 -5
- package/lib/domain/users/models/subscription/enums/status.enum.d.ts +3 -3
- package/lib/domain/users/models/subscription/index.d.ts +4 -4
- package/lib/domain/users/models/subscription/payment.d.ts +14 -14
- package/lib/domain/users/models/subscription/subscription.d.ts +30 -30
- package/lib/domain/users/models/user-address.d.ts +7 -7
- package/lib/domain/users/models/user.d.ts +24 -23
- package/lib/domain/users/repositories/beauty-profile.repository.d.ts +4 -4
- package/lib/domain/users/repositories/edition.repository.d.ts +4 -4
- package/lib/domain/users/repositories/index.d.ts +6 -6
- package/lib/domain/users/repositories/subscription-payment.repository.d.ts +4 -4
- package/lib/domain/users/repositories/subscription.repository.d.ts +4 -4
- package/lib/domain/users/repositories/user-address.repository.d.ts +4 -4
- package/lib/domain/users/repositories/user.repository.d.ts +4 -4
- package/lib/domain/users/services/authentication.service.d.ts +10 -10
- package/lib/domain/users/services/index.d.ts +1 -1
- package/lib/domain/users/use-cases/authentication.d.ts +21 -21
- package/lib/domain/users/use-cases/index.d.ts +2 -2
- package/lib/domain/users/use-cases/signout.d.ts +6 -6
- package/lib/errors/duplicated-results.error.d.ts +4 -4
- package/lib/errors/index.d.ts +4 -4
- package/lib/errors/invalid-argument.error.d.ts +4 -4
- package/lib/errors/not-found.error.d.ts +4 -4
- package/lib/errors/required-argument.error.d.ts +5 -5
- package/lib/index.d.ts +4 -4
- package/lib/infra/firebase/auth/authentication-firebase-auth.service.d.ts +9 -9
- package/lib/infra/firebase/auth/index.d.ts +1 -1
- package/lib/infra/firebase/firestore/index.d.ts +3 -3
- package/lib/infra/firebase/firestore/mixins/index.d.ts +9 -9
- package/lib/infra/firebase/firestore/mixins/with-create-firestore.mixin.d.ts +17 -17
- package/lib/infra/firebase/firestore/mixins/with-crud-firestore.mixin.d.ts +29 -29
- package/lib/infra/firebase/firestore/mixins/with-delete-firestore.mixin.d.ts +15 -15
- package/lib/infra/firebase/firestore/mixins/with-find-firestore.mixin.d.ts +20 -20
- package/lib/infra/firebase/firestore/mixins/with-firestore.mixin.d.ts +15 -15
- package/lib/infra/firebase/firestore/mixins/with-get-firestore.mixin.d.ts +15 -15
- package/lib/infra/firebase/firestore/mixins/with-helpers.mixin.d.ts +10 -10
- package/lib/infra/firebase/firestore/mixins/with-sub-collection.mixin.d.ts +14 -14
- package/lib/infra/firebase/firestore/mixins/with-update-firestore.mixin.d.ts +16 -16
- package/lib/infra/firebase/firestore/repositories/catalog/category-firestore.repository.d.ts +55 -55
- package/lib/infra/firebase/firestore/repositories/catalog/index.d.ts +3 -3
- package/lib/infra/firebase/firestore/repositories/catalog/product-firestore.repository.d.ts +50 -50
- package/lib/infra/firebase/firestore/repositories/catalog/product-variant-firestore.repository.d.ts +60 -60
- package/lib/infra/firebase/firestore/repositories/index.d.ts +4 -4
- package/lib/infra/firebase/firestore/repositories/shop-settings/home-firestore.repository.d.ts +49 -49
- package/lib/infra/firebase/firestore/repositories/shop-settings/index.d.ts +2 -2
- package/lib/infra/firebase/firestore/repositories/shop-settings/shop-menu-firestore.repository.d.ts +49 -49
- package/lib/infra/firebase/firestore/repositories/shopping/buy-2-win-firestore.repository.d.ts +49 -49
- package/lib/infra/firebase/firestore/repositories/shopping/checkout-firestore.repository.d.ts +49 -49
- package/lib/infra/firebase/firestore/repositories/shopping/checkout-subscription-firestore.repository.d.ts +49 -49
- package/lib/infra/firebase/firestore/repositories/shopping/coupon-firestore.repository.d.ts +49 -49
- package/lib/infra/firebase/firestore/repositories/shopping/index.d.ts +7 -7
- package/lib/infra/firebase/firestore/repositories/shopping/order-firestore.repository.d.ts +49 -49
- package/lib/infra/firebase/firestore/repositories/shopping/payment-firestore.repository.d.ts +49 -49
- package/lib/infra/firebase/firestore/repositories/shopping/subscription-plan-firestore.repository.d.ts +49 -49
- package/lib/infra/firebase/firestore/repositories/users/index.d.ts +6 -6
- package/lib/infra/firebase/firestore/repositories/users/subscription-edition-firestore.repository.d.ts +60 -60
- package/lib/infra/firebase/firestore/repositories/users/subscription-firestore.repository.d.ts +49 -49
- package/lib/infra/firebase/firestore/repositories/users/subscription-payment-firestore.repository.d.ts +60 -60
- package/lib/infra/firebase/firestore/repositories/users/user-address-firestore.repository.d.ts +60 -60
- package/lib/infra/firebase/firestore/repositories/users/user-beauty-profile-firestore.repository.d.ts +60 -60
- package/lib/infra/firebase/firestore/repositories/users/user-firestore.repository.d.ts +57 -52
- package/lib/infra/firebase/firestore/types/firestore-sub.repository.type.d.ts +6 -6
- package/lib/infra/firebase/firestore/types/firestore.helpers.type.d.ts +8 -8
- package/lib/infra/firebase/firestore/types/firestore.repository.type.d.ts +8 -8
- package/lib/infra/firebase/firestore/types/index.d.ts +3 -3
- package/lib/infra/firebase/index.d.ts +2 -2
- package/lib/infra/index.d.ts +1 -1
- package/lib/utils/index.d.ts +4 -4
- package/lib/utils/mixins/base.mixin.d.ts +3 -3
- package/lib/utils/mixins/index.d.ts +2 -2
- package/lib/utils/mixins/mixin-ctor.type.d.ts +1 -1
- package/lib/utils/types/index.d.ts +1 -1
- package/lib/utils/types/prop.type.d.ts +1 -1
- package/package.json +1 -1
- package/public-api.d.ts +1 -1
|
@@ -6,1046 +6,1071 @@ import { Md5 } from 'ts-md5';
|
|
|
6
6
|
import firebase from 'firebase';
|
|
7
7
|
import firebase$1 from 'firebase/app';
|
|
8
8
|
|
|
9
|
-
class BaseModel {
|
|
10
|
-
constructor(args) {
|
|
11
|
-
Object.assign(this, args);
|
|
12
|
-
}
|
|
13
|
-
static toInstance(data) {
|
|
14
|
-
return plainToClass(this, data);
|
|
15
|
-
}
|
|
16
|
-
toPlain() {
|
|
17
|
-
return classToPlain(this, { exposeUnsetFields: false });
|
|
18
|
-
}
|
|
9
|
+
class BaseModel {
|
|
10
|
+
constructor(args) {
|
|
11
|
+
Object.assign(this, args);
|
|
12
|
+
}
|
|
13
|
+
static toInstance(data) {
|
|
14
|
+
return plainToClass(this, data);
|
|
15
|
+
}
|
|
16
|
+
toPlain() {
|
|
17
|
+
return classToPlain(this, { exposeUnsetFields: false });
|
|
18
|
+
}
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
var Where;
|
|
22
|
-
(function (Where) {
|
|
23
|
-
Where["EQUALS"] = "==";
|
|
24
|
-
Where["GT"] = ">";
|
|
25
|
-
Where["GTE"] = ">=";
|
|
26
|
-
Where["IN"] = "in";
|
|
27
|
-
Where["LT"] = "<";
|
|
28
|
-
Where["LTE"] = "<=";
|
|
29
|
-
Where["LIKE"] = "like";
|
|
21
|
+
var Where;
|
|
22
|
+
(function (Where) {
|
|
23
|
+
Where["EQUALS"] = "==";
|
|
24
|
+
Where["GT"] = ">";
|
|
25
|
+
Where["GTE"] = ">=";
|
|
26
|
+
Where["IN"] = "in";
|
|
27
|
+
Where["LT"] = "<";
|
|
28
|
+
Where["LTE"] = "<=";
|
|
29
|
+
Where["LIKE"] = "like";
|
|
30
30
|
})(Where || (Where = {}));
|
|
31
31
|
|
|
32
|
-
var UpdateOptionActions;
|
|
33
|
-
(function (UpdateOptionActions) {
|
|
34
|
-
UpdateOptionActions["UPDATE"] = "update";
|
|
35
|
-
UpdateOptionActions["MERGE"] = "merge";
|
|
36
|
-
UpdateOptionActions["REMOVE"] = "remove";
|
|
37
|
-
UpdateOptionActions["REMOVE_FIELD"] = "removeField";
|
|
38
|
-
UpdateOptionActions["NULL"] = "null";
|
|
32
|
+
var UpdateOptionActions;
|
|
33
|
+
(function (UpdateOptionActions) {
|
|
34
|
+
UpdateOptionActions["UPDATE"] = "update";
|
|
35
|
+
UpdateOptionActions["MERGE"] = "merge";
|
|
36
|
+
UpdateOptionActions["REMOVE"] = "remove";
|
|
37
|
+
UpdateOptionActions["REMOVE_FIELD"] = "removeField";
|
|
38
|
+
UpdateOptionActions["NULL"] = "null";
|
|
39
39
|
})(UpdateOptionActions || (UpdateOptionActions = {}));
|
|
40
40
|
|
|
41
|
-
var UserType;
|
|
42
|
-
(function (UserType) {
|
|
43
|
-
UserType["B2C"] = "Cliente Transacional";
|
|
44
|
-
UserType["GlamGirl"] = "Glamgirl";
|
|
45
|
-
UserType["MensBoy"] = "Mensboy";
|
|
46
|
-
UserType["B2B"] = "Company";
|
|
47
|
-
UserType["Collaborator"] = "Funcion\u00E1rio";
|
|
48
|
-
UserType["Influencer"] = "Influencer";
|
|
41
|
+
var UserType;
|
|
42
|
+
(function (UserType) {
|
|
43
|
+
UserType["B2C"] = "Cliente Transacional";
|
|
44
|
+
UserType["GlamGirl"] = "Glamgirl";
|
|
45
|
+
UserType["MensBoy"] = "Mensboy";
|
|
46
|
+
UserType["B2B"] = "Company";
|
|
47
|
+
UserType["Collaborator"] = "Funcion\u00E1rio";
|
|
48
|
+
UserType["Influencer"] = "Influencer";
|
|
49
49
|
})(UserType || (UserType = {}));
|
|
50
50
|
|
|
51
|
-
var BeardSizes;
|
|
52
|
-
(function (BeardSizes) {
|
|
53
|
-
BeardSizes["BIG"] = "Grande";
|
|
54
|
-
BeardSizes["MEDIUM"] = "M\u00E9dia";
|
|
55
|
-
BeardSizes["SHORT"] = "Curta";
|
|
56
|
-
BeardSizes["MUSTACHE"] = "Bigode";
|
|
57
|
-
BeardSizes["NOTHING"] = "Sem Barba";
|
|
51
|
+
var BeardSizes;
|
|
52
|
+
(function (BeardSizes) {
|
|
53
|
+
BeardSizes["BIG"] = "Grande";
|
|
54
|
+
BeardSizes["MEDIUM"] = "M\u00E9dia";
|
|
55
|
+
BeardSizes["SHORT"] = "Curta";
|
|
56
|
+
BeardSizes["MUSTACHE"] = "Bigode";
|
|
57
|
+
BeardSizes["NOTHING"] = "Sem Barba";
|
|
58
58
|
})(BeardSizes || (BeardSizes = {}));
|
|
59
59
|
|
|
60
|
-
var HairTypes;
|
|
61
|
-
(function (HairTypes) {
|
|
62
|
-
HairTypes["Smooth"] = "Liso";
|
|
63
|
-
HairTypes["WAVY"] = "Ondulado";
|
|
64
|
-
HairTypes["CURLY"] = "Cacheado";
|
|
65
|
-
HairTypes["FRIZZY"] = "Crespo";
|
|
66
|
-
HairTypes["BALD"] = "Sou careca";
|
|
60
|
+
var HairTypes;
|
|
61
|
+
(function (HairTypes) {
|
|
62
|
+
HairTypes["Smooth"] = "Liso";
|
|
63
|
+
HairTypes["WAVY"] = "Ondulado";
|
|
64
|
+
HairTypes["CURLY"] = "Cacheado";
|
|
65
|
+
HairTypes["FRIZZY"] = "Crespo";
|
|
66
|
+
HairTypes["BALD"] = "Sou careca";
|
|
67
67
|
})(HairTypes || (HairTypes = {}));
|
|
68
68
|
|
|
69
|
-
var Area;
|
|
70
|
-
(function (Area) {
|
|
71
|
-
Area["GP"] = "Geral";
|
|
72
|
-
Area["CRM"] = "CRM";
|
|
73
|
-
Area["MediaProd"] = "Media Production";
|
|
74
|
-
Area["Tech"] = "Tecnologia";
|
|
75
|
-
Area["Transactional"] = "Transacional";
|
|
76
|
-
Area["Operations"] = "Opera\u00E7\u00F5es";
|
|
77
|
-
Area["Sales"] = "Comercial";
|
|
78
|
-
Area["Finantial"] = "Financeiro";
|
|
79
|
-
Area["HR"] = "RH";
|
|
69
|
+
var Area;
|
|
70
|
+
(function (Area) {
|
|
71
|
+
Area["GP"] = "Geral";
|
|
72
|
+
Area["CRM"] = "CRM";
|
|
73
|
+
Area["MediaProd"] = "Media Production";
|
|
74
|
+
Area["Tech"] = "Tecnologia";
|
|
75
|
+
Area["Transactional"] = "Transacional";
|
|
76
|
+
Area["Operations"] = "Opera\u00E7\u00F5es";
|
|
77
|
+
Area["Sales"] = "Comercial";
|
|
78
|
+
Area["Finantial"] = "Financeiro";
|
|
79
|
+
Area["HR"] = "RH";
|
|
80
80
|
})(Area || (Area = {}));
|
|
81
81
|
|
|
82
|
-
var OfficePosition;
|
|
83
|
-
(function (OfficePosition) {
|
|
84
|
-
OfficePosition["Intern"] = "Estagi\u00E1rio";
|
|
85
|
-
OfficePosition["Analyst"] = "Analista";
|
|
86
|
-
OfficePosition["Manager"] = "Gerente";
|
|
87
|
-
OfficePosition["Director"] = "Diretor";
|
|
82
|
+
var OfficePosition;
|
|
83
|
+
(function (OfficePosition) {
|
|
84
|
+
OfficePosition["Intern"] = "Estagi\u00E1rio";
|
|
85
|
+
OfficePosition["Analyst"] = "Analista";
|
|
86
|
+
OfficePosition["Manager"] = "Gerente";
|
|
87
|
+
OfficePosition["Director"] = "Diretor";
|
|
88
88
|
})(OfficePosition || (OfficePosition = {}));
|
|
89
89
|
|
|
90
|
-
var BillingStatus;
|
|
91
|
-
(function (BillingStatus) {
|
|
92
|
-
BillingStatus["PAYED"] = "PAGO";
|
|
90
|
+
var BillingStatus;
|
|
91
|
+
(function (BillingStatus) {
|
|
92
|
+
BillingStatus["PAYED"] = "PAGO";
|
|
93
93
|
})(BillingStatus || (BillingStatus = {}));
|
|
94
94
|
|
|
95
|
-
var EditionStatus;
|
|
96
|
-
(function (EditionStatus) {
|
|
97
|
-
EditionStatus["ALLOCATION_WAITING"] = "Aguardando aloca\u00E7\u00E3o";
|
|
95
|
+
var EditionStatus;
|
|
96
|
+
(function (EditionStatus) {
|
|
97
|
+
EditionStatus["ALLOCATION_WAITING"] = "Aguardando aloca\u00E7\u00E3o";
|
|
98
98
|
})(EditionStatus || (EditionStatus = {}));
|
|
99
99
|
|
|
100
|
-
var PaymentType;
|
|
101
|
-
(function (PaymentType) {
|
|
102
|
-
PaymentType["AQUISITION"] = "Aquisi\u00E7\u00E3o";
|
|
103
|
-
PaymentType["RENEWAL"] = "Renova\u00E7\u00E3o";
|
|
104
|
-
PaymentType["FREIGHT"] = "mudan\u00E7a de endere\u00E7o, Frete";
|
|
100
|
+
var PaymentType;
|
|
101
|
+
(function (PaymentType) {
|
|
102
|
+
PaymentType["AQUISITION"] = "Aquisi\u00E7\u00E3o";
|
|
103
|
+
PaymentType["RENEWAL"] = "Renova\u00E7\u00E3o";
|
|
104
|
+
PaymentType["FREIGHT"] = "mudan\u00E7a de endere\u00E7o, Frete";
|
|
105
105
|
})(PaymentType || (PaymentType = {}));
|
|
106
106
|
|
|
107
|
-
var Status;
|
|
108
|
-
(function (Status) {
|
|
109
|
-
Status["ACTIVE"] = "active";
|
|
107
|
+
var Status;
|
|
108
|
+
(function (Status) {
|
|
109
|
+
Status["ACTIVE"] = "active";
|
|
110
110
|
})(Status || (Status = {}));
|
|
111
111
|
|
|
112
|
-
class Edition extends BaseModel {
|
|
113
|
-
identifierFields() {
|
|
114
|
-
return ['id'];
|
|
115
|
-
}
|
|
112
|
+
class Edition extends BaseModel {
|
|
113
|
+
identifierFields() {
|
|
114
|
+
return ['id'];
|
|
115
|
+
}
|
|
116
116
|
}
|
|
117
117
|
|
|
118
|
-
class SubscriptionPayment extends BaseModel {
|
|
119
|
-
identifierFields() {
|
|
120
|
-
return ['id'];
|
|
121
|
-
}
|
|
118
|
+
class SubscriptionPayment extends BaseModel {
|
|
119
|
+
identifierFields() {
|
|
120
|
+
return ['id'];
|
|
121
|
+
}
|
|
122
122
|
}
|
|
123
123
|
|
|
124
|
-
class Subscription extends BaseModel {
|
|
125
|
-
identifierFields() {
|
|
126
|
-
return ['id'];
|
|
127
|
-
}
|
|
124
|
+
class Subscription extends BaseModel {
|
|
125
|
+
identifierFields() {
|
|
126
|
+
return ['id'];
|
|
127
|
+
}
|
|
128
128
|
}
|
|
129
129
|
|
|
130
|
-
class User extends BaseModel {
|
|
131
|
-
static toInstance(data) {
|
|
132
|
-
const instance = super.toInstance(data);
|
|
133
|
-
instance.displayName = `${data.firstName} ${data.lastName}`;
|
|
134
|
-
return instance;
|
|
135
|
-
}
|
|
136
|
-
identifierFields() {
|
|
137
|
-
return ['id'];
|
|
138
|
-
}
|
|
139
|
-
toPlain() {
|
|
140
|
-
const plain = super.toPlain();
|
|
141
|
-
delete plain.beautyProfile;
|
|
142
|
-
return plain;
|
|
143
|
-
}
|
|
130
|
+
class User extends BaseModel {
|
|
131
|
+
static toInstance(data) {
|
|
132
|
+
const instance = super.toInstance(data);
|
|
133
|
+
instance.displayName = `${data.firstName} ${data.lastName}`;
|
|
134
|
+
return instance;
|
|
135
|
+
}
|
|
136
|
+
identifierFields() {
|
|
137
|
+
return ['id'];
|
|
138
|
+
}
|
|
139
|
+
toPlain() {
|
|
140
|
+
const plain = super.toPlain();
|
|
141
|
+
delete plain.beautyProfile;
|
|
142
|
+
return plain;
|
|
143
|
+
}
|
|
144
144
|
}
|
|
145
145
|
|
|
146
|
-
class BeautyProfile extends BaseModel {
|
|
147
|
-
toPlain() {
|
|
148
|
-
const plain = super.toPlain();
|
|
149
|
-
delete plain.id;
|
|
150
|
-
return plain;
|
|
151
|
-
}
|
|
152
|
-
identifierFields() {
|
|
153
|
-
return ['id'];
|
|
154
|
-
}
|
|
146
|
+
class BeautyProfile extends BaseModel {
|
|
147
|
+
toPlain() {
|
|
148
|
+
const plain = super.toPlain();
|
|
149
|
+
delete plain.id;
|
|
150
|
+
return plain;
|
|
151
|
+
}
|
|
152
|
+
identifierFields() {
|
|
153
|
+
return ['id'];
|
|
154
|
+
}
|
|
155
155
|
}
|
|
156
156
|
|
|
157
|
-
class Address extends BaseModel {
|
|
157
|
+
class Address extends BaseModel {
|
|
158
158
|
}
|
|
159
159
|
|
|
160
|
-
class UserAddress extends Address {
|
|
161
|
-
identifierFields() {
|
|
162
|
-
return ['id'];
|
|
163
|
-
}
|
|
160
|
+
class UserAddress extends Address {
|
|
161
|
+
identifierFields() {
|
|
162
|
+
return ['id'];
|
|
163
|
+
}
|
|
164
164
|
}
|
|
165
165
|
|
|
166
|
-
class Base {
|
|
167
|
-
constructor(...args) {
|
|
168
|
-
Object.assign(this, ...args);
|
|
169
|
-
}
|
|
166
|
+
class Base {
|
|
167
|
+
constructor(...args) {
|
|
168
|
+
Object.assign(this, ...args);
|
|
169
|
+
}
|
|
170
170
|
}
|
|
171
171
|
|
|
172
|
-
class UnauthorizedError extends Error {
|
|
173
|
-
constructor(message) {
|
|
174
|
-
super(message);
|
|
175
|
-
this.message = message;
|
|
176
|
-
}
|
|
172
|
+
class UnauthorizedError extends Error {
|
|
173
|
+
constructor(message) {
|
|
174
|
+
super(message);
|
|
175
|
+
this.message = message;
|
|
176
|
+
}
|
|
177
177
|
}
|
|
178
178
|
|
|
179
|
-
var SignInMethods;
|
|
180
|
-
(function (SignInMethods) {
|
|
181
|
-
SignInMethods["EMAIL_PASSWORD"] = "email_password";
|
|
182
|
-
SignInMethods["GOOGLE"] = "google";
|
|
183
|
-
})(SignInMethods || (SignInMethods = {}));
|
|
184
|
-
class Authentication {
|
|
185
|
-
constructor(authService, userRepository) {
|
|
186
|
-
this.authService = authService;
|
|
187
|
-
this.userRepository = userRepository;
|
|
188
|
-
}
|
|
189
|
-
signIn({ email, password }, signInMethod) {
|
|
190
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
191
|
-
const method = this.getServiceByMethod(signInMethod);
|
|
192
|
-
const userAuth = yield this.authService[method]({ email, password });
|
|
193
|
-
const user = this.userRepository.get(userAuth);
|
|
194
|
-
if (!isNil(user))
|
|
195
|
-
return user;
|
|
196
|
-
if (/^.+@b4a.com.br$/.test(userAuth.email))
|
|
197
|
-
return this.createsUserByCredential(userAuth);
|
|
198
|
-
throw new UnauthorizedError('Invalid credentials');
|
|
199
|
-
});
|
|
200
|
-
}
|
|
201
|
-
getServiceByMethod(signInMethod) {
|
|
202
|
-
return signInMethod === SignInMethods.EMAIL_PASSWORD ? 'signInWithEmailAndPassword' : 'signInWithGoogle';
|
|
203
|
-
}
|
|
204
|
-
createsUserByCredential(user) {
|
|
205
|
-
var _a;
|
|
206
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
207
|
-
const [firstName, lastName] = (_a = user.displayName) === null || _a === void 0 ? void 0 : _a.split(/\s/);
|
|
208
|
-
const person = User.toInstance(Object.assign(Object.assign({}, user), { cpf: '', birthday: new Date(), firstName,
|
|
209
|
-
lastName, acceptsNewsletter: false, area: Area.Transactional, officePosition: OfficePosition.Intern, type: UserType.Collaborator }));
|
|
210
|
-
return this.userRepository.create(person);
|
|
211
|
-
});
|
|
212
|
-
}
|
|
179
|
+
var SignInMethods;
|
|
180
|
+
(function (SignInMethods) {
|
|
181
|
+
SignInMethods["EMAIL_PASSWORD"] = "email_password";
|
|
182
|
+
SignInMethods["GOOGLE"] = "google";
|
|
183
|
+
})(SignInMethods || (SignInMethods = {}));
|
|
184
|
+
class Authentication {
|
|
185
|
+
constructor(authService, userRepository) {
|
|
186
|
+
this.authService = authService;
|
|
187
|
+
this.userRepository = userRepository;
|
|
188
|
+
}
|
|
189
|
+
signIn({ email, password }, signInMethod) {
|
|
190
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
191
|
+
const method = this.getServiceByMethod(signInMethod);
|
|
192
|
+
const userAuth = yield this.authService[method]({ email, password });
|
|
193
|
+
const user = this.userRepository.get(userAuth);
|
|
194
|
+
if (!isNil(user))
|
|
195
|
+
return user;
|
|
196
|
+
if (/^.+@b4a.com.br$/.test(userAuth.email))
|
|
197
|
+
return this.createsUserByCredential(userAuth);
|
|
198
|
+
throw new UnauthorizedError('Invalid credentials');
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
getServiceByMethod(signInMethod) {
|
|
202
|
+
return signInMethod === SignInMethods.EMAIL_PASSWORD ? 'signInWithEmailAndPassword' : 'signInWithGoogle';
|
|
203
|
+
}
|
|
204
|
+
createsUserByCredential(user) {
|
|
205
|
+
var _a;
|
|
206
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
207
|
+
const [firstName, lastName] = (_a = user.displayName) === null || _a === void 0 ? void 0 : _a.split(/\s/);
|
|
208
|
+
const person = User.toInstance(Object.assign(Object.assign({}, user), { cpf: '', birthday: new Date(), firstName,
|
|
209
|
+
lastName, acceptsNewsletter: false, area: Area.Transactional, officePosition: OfficePosition.Intern, type: UserType.Collaborator }));
|
|
210
|
+
return this.userRepository.create(person);
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
213
|
}
|
|
214
214
|
|
|
215
|
-
class SignOut {
|
|
216
|
-
constructor(authService) {
|
|
217
|
-
this.authService = authService;
|
|
218
|
-
}
|
|
219
|
-
signOut() {
|
|
220
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
221
|
-
yield this.authService.signOut();
|
|
222
|
-
});
|
|
223
|
-
}
|
|
215
|
+
class SignOut {
|
|
216
|
+
constructor(authService) {
|
|
217
|
+
this.authService = authService;
|
|
218
|
+
}
|
|
219
|
+
signOut() {
|
|
220
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
221
|
+
yield this.authService.signOut();
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
224
|
}
|
|
225
225
|
|
|
226
|
-
var Shops;
|
|
227
|
-
(function (Shops) {
|
|
228
|
-
Shops["MENSMARKET"] = "Men's Market";
|
|
229
|
-
Shops["GLAMSHOP"] = "Glamshop";
|
|
226
|
+
var Shops;
|
|
227
|
+
(function (Shops) {
|
|
228
|
+
Shops["MENSMARKET"] = "Men's Market";
|
|
229
|
+
Shops["GLAMSHOP"] = "Glamshop";
|
|
230
230
|
})(Shops || (Shops = {}));
|
|
231
231
|
|
|
232
|
-
class Category extends BaseModel {
|
|
233
|
-
identifierFields() {
|
|
234
|
-
return ['id'];
|
|
235
|
-
}
|
|
232
|
+
class Category extends BaseModel {
|
|
233
|
+
identifierFields() {
|
|
234
|
+
return ['id'];
|
|
235
|
+
}
|
|
236
236
|
}
|
|
237
237
|
|
|
238
|
-
class Product extends BaseModel {
|
|
239
|
-
identifierFields() {
|
|
240
|
-
return ['id'];
|
|
241
|
-
}
|
|
238
|
+
class Product extends BaseModel {
|
|
239
|
+
identifierFields() {
|
|
240
|
+
return ['id'];
|
|
241
|
+
}
|
|
242
|
+
getInfoByShop(shop) {
|
|
243
|
+
return Object.assign(Object.assign({ description: this.description[shop].description }, this.price[shop]), this.stock[shop]);
|
|
244
|
+
}
|
|
242
245
|
}
|
|
243
246
|
|
|
244
|
-
class Variant extends BaseModel {
|
|
245
|
-
identifierFields() {
|
|
246
|
-
return ['id'];
|
|
247
|
-
}
|
|
247
|
+
class Variant extends BaseModel {
|
|
248
|
+
identifierFields() {
|
|
249
|
+
return ['id'];
|
|
250
|
+
}
|
|
248
251
|
}
|
|
249
252
|
|
|
250
|
-
var CouponTypes;
|
|
251
|
-
(function (CouponTypes) {
|
|
252
|
-
CouponTypes[CouponTypes["FINANCIAL"] = 1] = "FINANCIAL";
|
|
253
|
-
CouponTypes[CouponTypes["PRODUCT"] = 2] = "PRODUCT";
|
|
254
|
-
CouponTypes[CouponTypes["GIFTCARD"] = 3] = "GIFTCARD";
|
|
255
|
-
CouponTypes[CouponTypes["VOUCHER"] = 4] = "VOUCHER";
|
|
253
|
+
var CouponTypes;
|
|
254
|
+
(function (CouponTypes) {
|
|
255
|
+
CouponTypes[CouponTypes["FINANCIAL"] = 1] = "FINANCIAL";
|
|
256
|
+
CouponTypes[CouponTypes["PRODUCT"] = 2] = "PRODUCT";
|
|
257
|
+
CouponTypes[CouponTypes["GIFTCARD"] = 3] = "GIFTCARD";
|
|
258
|
+
CouponTypes[CouponTypes["VOUCHER"] = 4] = "VOUCHER";
|
|
256
259
|
})(CouponTypes || (CouponTypes = {}));
|
|
257
260
|
|
|
258
|
-
var CouponSubtypes;
|
|
259
|
-
(function (CouponSubtypes) {
|
|
260
|
-
CouponSubtypes[CouponSubtypes["ABSOLUTE"] = 1] = "ABSOLUTE";
|
|
261
|
-
CouponSubtypes[CouponSubtypes["PERCENTAGE"] = 2] = "PERCENTAGE";
|
|
261
|
+
var CouponSubtypes;
|
|
262
|
+
(function (CouponSubtypes) {
|
|
263
|
+
CouponSubtypes[CouponSubtypes["ABSOLUTE"] = 1] = "ABSOLUTE";
|
|
264
|
+
CouponSubtypes[CouponSubtypes["PERCENTAGE"] = 2] = "PERCENTAGE";
|
|
262
265
|
})(CouponSubtypes || (CouponSubtypes = {}));
|
|
263
266
|
|
|
264
|
-
var Exclusivities;
|
|
265
|
-
(function (Exclusivities) {
|
|
266
|
-
Exclusivities[Exclusivities["ALL_USERS"] = 1] = "ALL_USERS";
|
|
267
|
-
Exclusivities[Exclusivities["SPECIFIC_USER"] = 2] = "SPECIFIC_USER";
|
|
268
|
-
Exclusivities[Exclusivities["COLLABORATORS"] = 3] = "COLLABORATORS";
|
|
267
|
+
var Exclusivities;
|
|
268
|
+
(function (Exclusivities) {
|
|
269
|
+
Exclusivities[Exclusivities["ALL_USERS"] = 1] = "ALL_USERS";
|
|
270
|
+
Exclusivities[Exclusivities["SPECIFIC_USER"] = 2] = "SPECIFIC_USER";
|
|
271
|
+
Exclusivities[Exclusivities["COLLABORATORS"] = 3] = "COLLABORATORS";
|
|
269
272
|
})(Exclusivities || (Exclusivities = {}));
|
|
270
273
|
|
|
271
|
-
class Coupon extends BaseModel {
|
|
272
|
-
identifierFields() {
|
|
273
|
-
return ['id'];
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
__decorate([
|
|
277
|
-
Expose({ name: 'checkout_type' })
|
|
278
|
-
], Coupon.prototype, "checkoutType", void 0);
|
|
279
|
-
__decorate([
|
|
280
|
-
Expose({ name: 'exclusivity_type' })
|
|
274
|
+
class Coupon extends BaseModel {
|
|
275
|
+
identifierFields() {
|
|
276
|
+
return ['id'];
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
__decorate([
|
|
280
|
+
Expose({ name: 'checkout_type' })
|
|
281
|
+
], Coupon.prototype, "checkoutType", void 0);
|
|
282
|
+
__decorate([
|
|
283
|
+
Expose({ name: 'exclusivity_type' })
|
|
281
284
|
], Coupon.prototype, "exclusivityType", void 0);
|
|
282
285
|
|
|
283
|
-
var CheckoutTypes;
|
|
284
|
-
(function (CheckoutTypes) {
|
|
285
|
-
CheckoutTypes[CheckoutTypes["ECOMMERCE"] = 1] = "ECOMMERCE";
|
|
286
|
-
CheckoutTypes[CheckoutTypes["SUBSCRIPTION"] = 2] = "SUBSCRIPTION";
|
|
286
|
+
var CheckoutTypes;
|
|
287
|
+
(function (CheckoutTypes) {
|
|
288
|
+
CheckoutTypes[CheckoutTypes["ECOMMERCE"] = 1] = "ECOMMERCE";
|
|
289
|
+
CheckoutTypes[CheckoutTypes["SUBSCRIPTION"] = 2] = "SUBSCRIPTION";
|
|
287
290
|
})(CheckoutTypes || (CheckoutTypes = {}));
|
|
288
291
|
|
|
289
|
-
const COUPON_EXPIRATION = 60 * 60 * 24 * 30;
|
|
290
|
-
class FinancialCoupon extends Coupon {
|
|
291
|
-
constructor() {
|
|
292
|
-
super(...arguments);
|
|
293
|
-
this.type = CouponTypes.FINANCIAL;
|
|
294
|
-
}
|
|
295
|
-
static isFinancialCoupon(coupon) {
|
|
296
|
-
return coupon.type === CouponTypes.FINANCIAL && !!coupon.subtype;
|
|
297
|
-
}
|
|
298
|
-
static createCoupon(userId) {
|
|
299
|
-
return this.toInstance({
|
|
300
|
-
name: Md5.hashStr(`${userId}_${Date.now}`).toString(),
|
|
301
|
-
nickname: `${Date.now()}`,
|
|
302
|
-
type: CouponTypes.FINANCIAL,
|
|
303
|
-
subtype: CouponSubtypes.PERCENTAGE,
|
|
304
|
-
checkoutType: CheckoutTypes.ECOMMERCE,
|
|
305
|
-
discount: 30,
|
|
306
|
-
user: userId,
|
|
307
|
-
createdAt: new Date(Date.now()),
|
|
308
|
-
expiresIn: new Date(Date.now() + COUPON_EXPIRATION),
|
|
309
|
-
});
|
|
310
|
-
}
|
|
292
|
+
const COUPON_EXPIRATION = 60 * 60 * 24 * 30;
|
|
293
|
+
class FinancialCoupon extends Coupon {
|
|
294
|
+
constructor() {
|
|
295
|
+
super(...arguments);
|
|
296
|
+
this.type = CouponTypes.FINANCIAL;
|
|
297
|
+
}
|
|
298
|
+
static isFinancialCoupon(coupon) {
|
|
299
|
+
return coupon.type === CouponTypes.FINANCIAL && !!coupon.subtype;
|
|
300
|
+
}
|
|
301
|
+
static createCoupon(userId) {
|
|
302
|
+
return this.toInstance({
|
|
303
|
+
name: Md5.hashStr(`${userId}_${Date.now}`).toString(),
|
|
304
|
+
nickname: `${Date.now()}`,
|
|
305
|
+
type: CouponTypes.FINANCIAL,
|
|
306
|
+
subtype: CouponSubtypes.PERCENTAGE,
|
|
307
|
+
checkoutType: CheckoutTypes.ECOMMERCE,
|
|
308
|
+
discount: 30,
|
|
309
|
+
user: userId,
|
|
310
|
+
createdAt: new Date(Date.now()),
|
|
311
|
+
expiresIn: new Date(Date.now() + COUPON_EXPIRATION),
|
|
312
|
+
});
|
|
313
|
+
}
|
|
311
314
|
}
|
|
312
315
|
|
|
313
|
-
var OrderStatus;
|
|
314
|
-
(function (OrderStatus) {
|
|
315
|
-
OrderStatus["AGUARDANDO_PAGAMENTO"] = "Aguardando pagamento";
|
|
316
|
-
OrderStatus["EM_PREPARO"] = "Preparando pedido";
|
|
317
|
-
OrderStatus["NF_EMITIDA"] = "Nota Fiscal Emitida";
|
|
318
|
-
OrderStatus["AGUARDANDO_ENVIO"] = "Aguardando Transaportadora";
|
|
319
|
-
OrderStatus["ENVIADO"] = "Pedido Enviado";
|
|
320
|
-
OrderStatus["ENTREGUE"] = "Pedido entregue";
|
|
321
|
-
OrderStatus["CANCELADO"] = "Cancelado";
|
|
322
|
-
OrderStatus["CREDIT_CARD"] = "credit_card";
|
|
316
|
+
var OrderStatus;
|
|
317
|
+
(function (OrderStatus) {
|
|
318
|
+
OrderStatus["AGUARDANDO_PAGAMENTO"] = "Aguardando pagamento";
|
|
319
|
+
OrderStatus["EM_PREPARO"] = "Preparando pedido";
|
|
320
|
+
OrderStatus["NF_EMITIDA"] = "Nota Fiscal Emitida";
|
|
321
|
+
OrderStatus["AGUARDANDO_ENVIO"] = "Aguardando Transaportadora";
|
|
322
|
+
OrderStatus["ENVIADO"] = "Pedido Enviado";
|
|
323
|
+
OrderStatus["ENTREGUE"] = "Pedido entregue";
|
|
324
|
+
OrderStatus["CANCELADO"] = "Cancelado";
|
|
325
|
+
OrderStatus["CREDIT_CARD"] = "credit_card";
|
|
323
326
|
})(OrderStatus || (OrderStatus = {}));
|
|
324
327
|
|
|
325
|
-
class Checkout extends BaseModel {
|
|
326
|
-
identifierFields() {
|
|
327
|
-
return ['id'];
|
|
328
|
-
}
|
|
328
|
+
class Checkout extends BaseModel {
|
|
329
|
+
identifierFields() {
|
|
330
|
+
return ['id'];
|
|
331
|
+
}
|
|
329
332
|
}
|
|
330
333
|
|
|
331
|
-
class LineItem extends Product {
|
|
334
|
+
class LineItem extends Product {
|
|
332
335
|
}
|
|
333
336
|
|
|
334
|
-
class Order extends Checkout {
|
|
337
|
+
class Order extends Checkout {
|
|
335
338
|
}
|
|
336
339
|
|
|
337
|
-
class Payment extends BaseModel {
|
|
338
|
-
identifierFields() {
|
|
339
|
-
return ['id'];
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
__decorate([
|
|
343
|
-
Expose({ name: 'refuse_reason' })
|
|
344
|
-
], Payment.prototype, "refuseReason", void 0);
|
|
345
|
-
__decorate([
|
|
346
|
-
Expose({ name: 'status_reason' })
|
|
347
|
-
], Payment.prototype, "statusReason", void 0);
|
|
348
|
-
__decorate([
|
|
349
|
-
Expose({ name: 'acquirer_response_code' })
|
|
350
|
-
], Payment.prototype, "acquirerResponseCode", void 0);
|
|
351
|
-
__decorate([
|
|
352
|
-
Expose({ name: 'acquirer_name' })
|
|
353
|
-
], Payment.prototype, "acquirerName", void 0);
|
|
354
|
-
__decorate([
|
|
355
|
-
Expose({ name: 'acquirer_id' })
|
|
356
|
-
], Payment.prototype, "acquirerId", void 0);
|
|
357
|
-
__decorate([
|
|
358
|
-
Expose({ name: 'authorization_code' })
|
|
359
|
-
], Payment.prototype, "authorizationCode", void 0);
|
|
360
|
-
__decorate([
|
|
361
|
-
Expose({ name: 'soft_descriptor' })
|
|
362
|
-
], Payment.prototype, "softDescriptor", void 0);
|
|
363
|
-
__decorate([
|
|
364
|
-
Expose({ name: 'date_created' })
|
|
365
|
-
], Payment.prototype, "dateCreated", void 0);
|
|
366
|
-
__decorate([
|
|
367
|
-
Expose({ name: 'date_updated' })
|
|
368
|
-
], Payment.prototype, "dateUpdated", void 0);
|
|
369
|
-
__decorate([
|
|
370
|
-
Expose({ name: 'authorized_amount' })
|
|
371
|
-
], Payment.prototype, "authorizedAmount", void 0);
|
|
372
|
-
__decorate([
|
|
373
|
-
Expose({ name: 'paid_amount' })
|
|
374
|
-
], Payment.prototype, "paidAmount", void 0);
|
|
375
|
-
__decorate([
|
|
376
|
-
Expose({ name: 'refunded_amount' })
|
|
377
|
-
], Payment.prototype, "refundedAmount", void 0);
|
|
378
|
-
__decorate([
|
|
379
|
-
Expose({ name: 'card_holder_name' })
|
|
380
|
-
], Payment.prototype, "cardHolderName", void 0);
|
|
381
|
-
__decorate([
|
|
382
|
-
Expose({ name: 'card_last_digits' })
|
|
383
|
-
], Payment.prototype, "cardLastDigits", void 0);
|
|
384
|
-
__decorate([
|
|
385
|
-
Expose({ name: 'card_first_digits' })
|
|
386
|
-
], Payment.prototype, "cardFirstDigits", void 0);
|
|
387
|
-
__decorate([
|
|
388
|
-
Expose({ name: 'card_brand' })
|
|
389
|
-
], Payment.prototype, "cardBrand", void 0);
|
|
390
|
-
__decorate([
|
|
391
|
-
Expose({ name: 'card_pin_mode' })
|
|
392
|
-
], Payment.prototype, "cardPinMode", void 0);
|
|
393
|
-
__decorate([
|
|
394
|
-
Expose({ name: 'card_magstripe_fallback' })
|
|
395
|
-
], Payment.prototype, "cardMagstripeFallback", void 0);
|
|
396
|
-
__decorate([
|
|
397
|
-
Expose({ name: 'cvm_pin' })
|
|
398
|
-
], Payment.prototype, "cvmPin", void 0);
|
|
399
|
-
__decorate([
|
|
400
|
-
Expose({ name: 'postback_url' })
|
|
401
|
-
], Payment.prototype, "postbackUrl", void 0);
|
|
402
|
-
__decorate([
|
|
403
|
-
Expose({ name: 'payment_method' })
|
|
404
|
-
], Payment.prototype, "paymentMethod", void 0);
|
|
405
|
-
__decorate([
|
|
406
|
-
Expose({ name: 'capture_method' })
|
|
407
|
-
], Payment.prototype, "captureMethod", void 0);
|
|
408
|
-
__decorate([
|
|
409
|
-
Expose({ name: 'antifraud_score' })
|
|
410
|
-
], Payment.prototype, "antifraudScore", void 0);
|
|
411
|
-
__decorate([
|
|
412
|
-
Expose({ name: 'boleto_url' })
|
|
413
|
-
], Payment.prototype, "boletoUrl", void 0);
|
|
414
|
-
__decorate([
|
|
415
|
-
Expose({ name: 'boleto_barcode' })
|
|
416
|
-
], Payment.prototype, "boletoBarcode", void 0);
|
|
417
|
-
__decorate([
|
|
418
|
-
Expose({ name: 'boleto_expiration_date' })
|
|
419
|
-
], Payment.prototype, "boletoExpirationDate", void 0);
|
|
420
|
-
__decorate([
|
|
421
|
-
Expose({ name: 'subscription_id' })
|
|
422
|
-
], Payment.prototype, "subscriptionId", void 0);
|
|
423
|
-
__decorate([
|
|
424
|
-
Expose({ name: 'split_rules' })
|
|
425
|
-
], Payment.prototype, "splitRules", void 0);
|
|
426
|
-
__decorate([
|
|
427
|
-
Expose({ name: 'antifraud_metadata' })
|
|
428
|
-
], Payment.prototype, "antifraudMetadata", void 0);
|
|
429
|
-
__decorate([
|
|
430
|
-
Expose({ name: 'reference_key' })
|
|
431
|
-
], Payment.prototype, "referenceKey", void 0);
|
|
432
|
-
__decorate([
|
|
433
|
-
Expose({ name: 'local_transaction_id' })
|
|
434
|
-
], Payment.prototype, "localTransactionId", void 0);
|
|
435
|
-
__decorate([
|
|
436
|
-
Expose({ name: 'local_time' })
|
|
437
|
-
], Payment.prototype, "localTime", void 0);
|
|
438
|
-
__decorate([
|
|
439
|
-
Expose({ name: 'fraud_covered' })
|
|
440
|
-
], Payment.prototype, "fraudCovered", void 0);
|
|
441
|
-
__decorate([
|
|
442
|
-
Expose({ name: 'fraud_reimbursed' })
|
|
443
|
-
], Payment.prototype, "fraudReimbursed", void 0);
|
|
444
|
-
__decorate([
|
|
445
|
-
Expose({ name: 'order_id' })
|
|
446
|
-
], Payment.prototype, "orderId", void 0);
|
|
447
|
-
__decorate([
|
|
448
|
-
Expose({ name: 'risk_level' })
|
|
449
|
-
], Payment.prototype, "riskLevel", void 0);
|
|
450
|
-
__decorate([
|
|
451
|
-
Expose({ name: 'receipt_url' })
|
|
452
|
-
], Payment.prototype, "receiptUrl", void 0);
|
|
453
|
-
__decorate([
|
|
454
|
-
Expose({ name: 'private_label' })
|
|
455
|
-
], Payment.prototype, "privateLabel", void 0);
|
|
456
|
-
__decorate([
|
|
457
|
-
Expose({ name: 'pix_qr_code' })
|
|
458
|
-
], Payment.prototype, "pixQrCode", void 0);
|
|
459
|
-
__decorate([
|
|
460
|
-
Expose({ name: 'pix_expiration_date' })
|
|
340
|
+
class Payment extends BaseModel {
|
|
341
|
+
identifierFields() {
|
|
342
|
+
return ['id'];
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
__decorate([
|
|
346
|
+
Expose({ name: 'refuse_reason' })
|
|
347
|
+
], Payment.prototype, "refuseReason", void 0);
|
|
348
|
+
__decorate([
|
|
349
|
+
Expose({ name: 'status_reason' })
|
|
350
|
+
], Payment.prototype, "statusReason", void 0);
|
|
351
|
+
__decorate([
|
|
352
|
+
Expose({ name: 'acquirer_response_code' })
|
|
353
|
+
], Payment.prototype, "acquirerResponseCode", void 0);
|
|
354
|
+
__decorate([
|
|
355
|
+
Expose({ name: 'acquirer_name' })
|
|
356
|
+
], Payment.prototype, "acquirerName", void 0);
|
|
357
|
+
__decorate([
|
|
358
|
+
Expose({ name: 'acquirer_id' })
|
|
359
|
+
], Payment.prototype, "acquirerId", void 0);
|
|
360
|
+
__decorate([
|
|
361
|
+
Expose({ name: 'authorization_code' })
|
|
362
|
+
], Payment.prototype, "authorizationCode", void 0);
|
|
363
|
+
__decorate([
|
|
364
|
+
Expose({ name: 'soft_descriptor' })
|
|
365
|
+
], Payment.prototype, "softDescriptor", void 0);
|
|
366
|
+
__decorate([
|
|
367
|
+
Expose({ name: 'date_created' })
|
|
368
|
+
], Payment.prototype, "dateCreated", void 0);
|
|
369
|
+
__decorate([
|
|
370
|
+
Expose({ name: 'date_updated' })
|
|
371
|
+
], Payment.prototype, "dateUpdated", void 0);
|
|
372
|
+
__decorate([
|
|
373
|
+
Expose({ name: 'authorized_amount' })
|
|
374
|
+
], Payment.prototype, "authorizedAmount", void 0);
|
|
375
|
+
__decorate([
|
|
376
|
+
Expose({ name: 'paid_amount' })
|
|
377
|
+
], Payment.prototype, "paidAmount", void 0);
|
|
378
|
+
__decorate([
|
|
379
|
+
Expose({ name: 'refunded_amount' })
|
|
380
|
+
], Payment.prototype, "refundedAmount", void 0);
|
|
381
|
+
__decorate([
|
|
382
|
+
Expose({ name: 'card_holder_name' })
|
|
383
|
+
], Payment.prototype, "cardHolderName", void 0);
|
|
384
|
+
__decorate([
|
|
385
|
+
Expose({ name: 'card_last_digits' })
|
|
386
|
+
], Payment.prototype, "cardLastDigits", void 0);
|
|
387
|
+
__decorate([
|
|
388
|
+
Expose({ name: 'card_first_digits' })
|
|
389
|
+
], Payment.prototype, "cardFirstDigits", void 0);
|
|
390
|
+
__decorate([
|
|
391
|
+
Expose({ name: 'card_brand' })
|
|
392
|
+
], Payment.prototype, "cardBrand", void 0);
|
|
393
|
+
__decorate([
|
|
394
|
+
Expose({ name: 'card_pin_mode' })
|
|
395
|
+
], Payment.prototype, "cardPinMode", void 0);
|
|
396
|
+
__decorate([
|
|
397
|
+
Expose({ name: 'card_magstripe_fallback' })
|
|
398
|
+
], Payment.prototype, "cardMagstripeFallback", void 0);
|
|
399
|
+
__decorate([
|
|
400
|
+
Expose({ name: 'cvm_pin' })
|
|
401
|
+
], Payment.prototype, "cvmPin", void 0);
|
|
402
|
+
__decorate([
|
|
403
|
+
Expose({ name: 'postback_url' })
|
|
404
|
+
], Payment.prototype, "postbackUrl", void 0);
|
|
405
|
+
__decorate([
|
|
406
|
+
Expose({ name: 'payment_method' })
|
|
407
|
+
], Payment.prototype, "paymentMethod", void 0);
|
|
408
|
+
__decorate([
|
|
409
|
+
Expose({ name: 'capture_method' })
|
|
410
|
+
], Payment.prototype, "captureMethod", void 0);
|
|
411
|
+
__decorate([
|
|
412
|
+
Expose({ name: 'antifraud_score' })
|
|
413
|
+
], Payment.prototype, "antifraudScore", void 0);
|
|
414
|
+
__decorate([
|
|
415
|
+
Expose({ name: 'boleto_url' })
|
|
416
|
+
], Payment.prototype, "boletoUrl", void 0);
|
|
417
|
+
__decorate([
|
|
418
|
+
Expose({ name: 'boleto_barcode' })
|
|
419
|
+
], Payment.prototype, "boletoBarcode", void 0);
|
|
420
|
+
__decorate([
|
|
421
|
+
Expose({ name: 'boleto_expiration_date' })
|
|
422
|
+
], Payment.prototype, "boletoExpirationDate", void 0);
|
|
423
|
+
__decorate([
|
|
424
|
+
Expose({ name: 'subscription_id' })
|
|
425
|
+
], Payment.prototype, "subscriptionId", void 0);
|
|
426
|
+
__decorate([
|
|
427
|
+
Expose({ name: 'split_rules' })
|
|
428
|
+
], Payment.prototype, "splitRules", void 0);
|
|
429
|
+
__decorate([
|
|
430
|
+
Expose({ name: 'antifraud_metadata' })
|
|
431
|
+
], Payment.prototype, "antifraudMetadata", void 0);
|
|
432
|
+
__decorate([
|
|
433
|
+
Expose({ name: 'reference_key' })
|
|
434
|
+
], Payment.prototype, "referenceKey", void 0);
|
|
435
|
+
__decorate([
|
|
436
|
+
Expose({ name: 'local_transaction_id' })
|
|
437
|
+
], Payment.prototype, "localTransactionId", void 0);
|
|
438
|
+
__decorate([
|
|
439
|
+
Expose({ name: 'local_time' })
|
|
440
|
+
], Payment.prototype, "localTime", void 0);
|
|
441
|
+
__decorate([
|
|
442
|
+
Expose({ name: 'fraud_covered' })
|
|
443
|
+
], Payment.prototype, "fraudCovered", void 0);
|
|
444
|
+
__decorate([
|
|
445
|
+
Expose({ name: 'fraud_reimbursed' })
|
|
446
|
+
], Payment.prototype, "fraudReimbursed", void 0);
|
|
447
|
+
__decorate([
|
|
448
|
+
Expose({ name: 'order_id' })
|
|
449
|
+
], Payment.prototype, "orderId", void 0);
|
|
450
|
+
__decorate([
|
|
451
|
+
Expose({ name: 'risk_level' })
|
|
452
|
+
], Payment.prototype, "riskLevel", void 0);
|
|
453
|
+
__decorate([
|
|
454
|
+
Expose({ name: 'receipt_url' })
|
|
455
|
+
], Payment.prototype, "receiptUrl", void 0);
|
|
456
|
+
__decorate([
|
|
457
|
+
Expose({ name: 'private_label' })
|
|
458
|
+
], Payment.prototype, "privateLabel", void 0);
|
|
459
|
+
__decorate([
|
|
460
|
+
Expose({ name: 'pix_qr_code' })
|
|
461
|
+
], Payment.prototype, "pixQrCode", void 0);
|
|
462
|
+
__decorate([
|
|
463
|
+
Expose({ name: 'pix_expiration_date' })
|
|
461
464
|
], Payment.prototype, "pixExpirationDate", void 0);
|
|
462
465
|
|
|
463
|
-
class ShippingMethod extends BaseModel {
|
|
464
|
-
identifierFields() {
|
|
465
|
-
return ['id'];
|
|
466
|
-
}
|
|
466
|
+
class ShippingMethod extends BaseModel {
|
|
467
|
+
identifierFields() {
|
|
468
|
+
return ['id'];
|
|
469
|
+
}
|
|
467
470
|
}
|
|
468
471
|
|
|
469
|
-
class CheckoutSubscription extends BaseModel {
|
|
470
|
-
identifierFields() {
|
|
471
|
-
return ['id'];
|
|
472
|
-
}
|
|
472
|
+
class CheckoutSubscription extends BaseModel {
|
|
473
|
+
identifierFields() {
|
|
474
|
+
return ['id'];
|
|
475
|
+
}
|
|
473
476
|
}
|
|
474
477
|
|
|
475
|
-
class SubscriptionPlan extends BaseModel {
|
|
476
|
-
identifierFields() {
|
|
477
|
-
return ['id'];
|
|
478
|
-
}
|
|
478
|
+
class SubscriptionPlan extends BaseModel {
|
|
479
|
+
identifierFields() {
|
|
480
|
+
return ['id'];
|
|
481
|
+
}
|
|
479
482
|
}
|
|
480
483
|
|
|
481
|
-
class Buy2Win extends BaseModel {
|
|
482
|
-
identifierFields() {
|
|
483
|
-
return ['id'];
|
|
484
|
-
}
|
|
484
|
+
class Buy2Win extends BaseModel {
|
|
485
|
+
identifierFields() {
|
|
486
|
+
return ['id'];
|
|
487
|
+
}
|
|
485
488
|
}
|
|
486
489
|
|
|
487
|
-
class Home extends BaseModel {
|
|
488
|
-
identifierFields() {
|
|
489
|
-
return ['id'];
|
|
490
|
-
}
|
|
490
|
+
class Home extends BaseModel {
|
|
491
|
+
identifierFields() {
|
|
492
|
+
return ['id'];
|
|
493
|
+
}
|
|
491
494
|
}
|
|
492
495
|
|
|
493
|
-
class ShopMenu extends BaseModel {
|
|
494
|
-
identifierFields() {
|
|
495
|
-
return ['id'];
|
|
496
|
-
}
|
|
496
|
+
class ShopMenu extends BaseModel {
|
|
497
|
+
identifierFields() {
|
|
498
|
+
return ['id'];
|
|
499
|
+
}
|
|
497
500
|
}
|
|
498
501
|
|
|
499
|
-
class InvalidArgumentError extends Error {
|
|
500
|
-
constructor(message) {
|
|
501
|
-
super(message);
|
|
502
|
-
this.message = message;
|
|
503
|
-
}
|
|
502
|
+
class InvalidArgumentError extends Error {
|
|
503
|
+
constructor(message) {
|
|
504
|
+
super(message);
|
|
505
|
+
this.message = message;
|
|
506
|
+
}
|
|
504
507
|
}
|
|
505
508
|
|
|
506
|
-
class RequiredArgumentError extends Error {
|
|
507
|
-
constructor(args) {
|
|
508
|
-
super(`Required arguments: ${args.join(', ')}`);
|
|
509
|
-
this.args = args;
|
|
510
|
-
this.arguments = args;
|
|
511
|
-
}
|
|
509
|
+
class RequiredArgumentError extends Error {
|
|
510
|
+
constructor(args) {
|
|
511
|
+
super(`Required arguments: ${args.join(', ')}`);
|
|
512
|
+
this.args = args;
|
|
513
|
+
this.arguments = args;
|
|
514
|
+
}
|
|
512
515
|
}
|
|
513
516
|
|
|
514
|
-
class NotFoundError extends Error {
|
|
515
|
-
constructor(message) {
|
|
516
|
-
super(message);
|
|
517
|
-
this.message = message;
|
|
518
|
-
}
|
|
517
|
+
class NotFoundError extends Error {
|
|
518
|
+
constructor(message) {
|
|
519
|
+
super(message);
|
|
520
|
+
this.message = message;
|
|
521
|
+
}
|
|
519
522
|
}
|
|
520
523
|
|
|
521
|
-
class DuplicatedResultsError extends Error {
|
|
522
|
-
constructor(message) {
|
|
523
|
-
super(message);
|
|
524
|
-
this.message = message;
|
|
525
|
-
}
|
|
524
|
+
class DuplicatedResultsError extends Error {
|
|
525
|
+
constructor(message) {
|
|
526
|
+
super(message);
|
|
527
|
+
this.message = message;
|
|
528
|
+
}
|
|
526
529
|
}
|
|
527
530
|
|
|
528
|
-
const withFirestore = (MixinBase) => {
|
|
529
|
-
return class extends MixinBase {
|
|
530
|
-
constructor(...args) {
|
|
531
|
-
super(args);
|
|
532
|
-
}
|
|
533
|
-
collection(path) {
|
|
534
|
-
return this.firestore.collection(path || this.collectionName).withConverter(this.buildModelInstance());
|
|
535
|
-
}
|
|
536
|
-
buildModelInstance() {
|
|
537
|
-
return {
|
|
538
|
-
toFirestore: (data) => data.toPlain(),
|
|
539
|
-
fromFirestore: (snap) => {
|
|
540
|
-
const data = snap.data();
|
|
541
|
-
Object.keys(data).forEach((key) => {
|
|
542
|
-
if (data[key] instanceof firebase.firestore.Timestamp) {
|
|
543
|
-
data[key] = data[key].toDate();
|
|
544
|
-
}
|
|
545
|
-
});
|
|
546
|
-
return this.model.toInstance(Object.assign({ id: snap.id }, data));
|
|
547
|
-
},
|
|
548
|
-
};
|
|
549
|
-
}
|
|
550
|
-
};
|
|
531
|
+
const withFirestore = (MixinBase) => {
|
|
532
|
+
return class extends MixinBase {
|
|
533
|
+
constructor(...args) {
|
|
534
|
+
super(args);
|
|
535
|
+
}
|
|
536
|
+
collection(path) {
|
|
537
|
+
return this.firestore.collection(path || this.collectionName).withConverter(this.buildModelInstance());
|
|
538
|
+
}
|
|
539
|
+
buildModelInstance() {
|
|
540
|
+
return {
|
|
541
|
+
toFirestore: (data) => data.toPlain(),
|
|
542
|
+
fromFirestore: (snap) => {
|
|
543
|
+
const data = snap.data();
|
|
544
|
+
Object.keys(data).forEach((key) => {
|
|
545
|
+
if (data[key] instanceof firebase.firestore.Timestamp) {
|
|
546
|
+
data[key] = data[key].toDate();
|
|
547
|
+
}
|
|
548
|
+
});
|
|
549
|
+
return this.model.toInstance(Object.assign({ id: snap.id }, data));
|
|
550
|
+
},
|
|
551
|
+
};
|
|
552
|
+
}
|
|
553
|
+
};
|
|
551
554
|
};
|
|
552
555
|
|
|
553
|
-
const withHelpers = (MixinBase) => {
|
|
554
|
-
return class extends MixinBase {
|
|
555
|
-
toArray(snapShot) {
|
|
556
|
-
if (Array.isArray(snapShot)) {
|
|
557
|
-
return snapShot.map((doc) => doc.data());
|
|
558
|
-
}
|
|
559
|
-
else {
|
|
560
|
-
return snapShot.docs.map((doc) => doc.data());
|
|
561
|
-
}
|
|
562
|
-
}
|
|
563
|
-
isSubCollection(repository) {
|
|
564
|
-
return !isNil(Object.keys(this).find((key) => key === 'parentRepository'));
|
|
565
|
-
}
|
|
566
|
-
};
|
|
556
|
+
const withHelpers = (MixinBase) => {
|
|
557
|
+
return class extends MixinBase {
|
|
558
|
+
toArray(snapShot) {
|
|
559
|
+
if (Array.isArray(snapShot)) {
|
|
560
|
+
return snapShot.map((doc) => doc.data());
|
|
561
|
+
}
|
|
562
|
+
else {
|
|
563
|
+
return snapShot.docs.map((doc) => doc.data());
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
isSubCollection(repository) {
|
|
567
|
+
return !isNil(Object.keys(this).find((key) => key === 'parentRepository'));
|
|
568
|
+
}
|
|
569
|
+
};
|
|
567
570
|
};
|
|
568
571
|
|
|
569
|
-
const withGetFirestore = (MixinBase) => {
|
|
570
|
-
return class GetFirestore extends MixinBase {
|
|
571
|
-
get(identifiers) {
|
|
572
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
573
|
-
const doc = yield this.collection(this.buildCollectionPathForGet(identifiers))
|
|
574
|
-
.doc(Object.values(identifiers).shift().toString())
|
|
575
|
-
.get();
|
|
576
|
-
const data = doc.data();
|
|
577
|
-
if (isNil(data))
|
|
578
|
-
throw new NotFoundError(`Document ${JSON.stringify(identifiers)} not found`);
|
|
579
|
-
return data;
|
|
580
|
-
});
|
|
581
|
-
}
|
|
582
|
-
buildCollectionPathForGet(identifiers) {
|
|
583
|
-
return this.isSubCollection(this)
|
|
584
|
-
? `${this.parentRepository.collectionName}/${identifiers[this.parentIdField]}/${this.collectionName}`
|
|
585
|
-
: this.collectionName;
|
|
586
|
-
}
|
|
587
|
-
};
|
|
572
|
+
const withGetFirestore = (MixinBase) => {
|
|
573
|
+
return class GetFirestore extends MixinBase {
|
|
574
|
+
get(identifiers) {
|
|
575
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
576
|
+
const doc = yield this.collection(this.buildCollectionPathForGet(identifiers))
|
|
577
|
+
.doc(Object.values(identifiers).shift().toString())
|
|
578
|
+
.get();
|
|
579
|
+
const data = doc.data();
|
|
580
|
+
if (isNil(data))
|
|
581
|
+
throw new NotFoundError(`Document ${JSON.stringify(identifiers)} not found`);
|
|
582
|
+
return data;
|
|
583
|
+
});
|
|
584
|
+
}
|
|
585
|
+
buildCollectionPathForGet(identifiers) {
|
|
586
|
+
return this.isSubCollection(this)
|
|
587
|
+
? `${this.parentRepository.collectionName}/${identifiers[this.parentIdField]}/${this.collectionName}`
|
|
588
|
+
: this.collectionName;
|
|
589
|
+
}
|
|
590
|
+
};
|
|
588
591
|
};
|
|
589
592
|
|
|
590
|
-
const withFindFirestore = (MixinBase) => {
|
|
591
|
-
return class FindFirestore extends MixinBase {
|
|
592
|
-
constructor() {
|
|
593
|
-
super(...arguments);
|
|
594
|
-
this.makeFirestoreWhere = (queryReference, filter) => Object.keys(filter).reduce((query, fieldName) => this.buildWhereSentence(query, fieldName, filter[fieldName]), queryReference);
|
|
595
|
-
this.buildWhereSentence = (queryReference, fieldName, options) => {
|
|
596
|
-
if (this.isSubCollection(this) && fieldName === this.parentIdField)
|
|
597
|
-
return queryReference;
|
|
598
|
-
if ((options === null || options === void 0 ? void 0 : options.operator) === Where.LIKE) {
|
|
599
|
-
queryReference = queryReference.where(fieldName.toString(), '>=', options.value);
|
|
600
|
-
queryReference = queryReference.where(fieldName.toString(), '<=', `${options.value}~`);
|
|
601
|
-
return queryReference;
|
|
602
|
-
}
|
|
603
|
-
if ((options === null || options === void 0 ? void 0 : options.operator) === Where.IN && Array.isArray(options === null || options === void 0 ? void 0 : options.value))
|
|
604
|
-
return queryReference.where(fieldName.toString(), 'array-contains-any', options.value);
|
|
605
|
-
return queryReference.where(fieldName.toString(), options.operator, options.value);
|
|
606
|
-
};
|
|
607
|
-
}
|
|
608
|
-
find(filters, limits, orderBy) {
|
|
609
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
610
|
-
let query = this.collection(this.buildCollectionPathForFind(filters));
|
|
611
|
-
filters === null || filters === void 0 ? void 0 : filters.forEach((filterer) => (query = this.makeFirestoreWhere(query, filterer)));
|
|
612
|
-
orderBy === null || orderBy === void 0 ? void 0 : orderBy.forEach((orderer) => Object.keys(orderer).forEach((fieldName) => (query = query.orderBy(fieldName, orderer[fieldName]))));
|
|
613
|
-
query = this.defineLimits(query, filters, limits);
|
|
614
|
-
const docs = yield query.get();
|
|
615
|
-
const data = docs.docs.map((doc) => doc.data());
|
|
616
|
-
return {
|
|
617
|
-
data,
|
|
618
|
-
count: this.calculateCount(data, limits),
|
|
619
|
-
};
|
|
620
|
-
});
|
|
621
|
-
}
|
|
622
|
-
buildCollectionPathForFind(filters) {
|
|
623
|
-
var _a;
|
|
624
|
-
if (!this.isSubCollection(this))
|
|
625
|
-
return this.collectionName;
|
|
626
|
-
const parentIdField = this.parentIdField;
|
|
627
|
-
const parentId = (_a = filters.find((groupFilter) => { var _a; return Boolean((_a = groupFilter[parentIdField]) === null || _a === void 0 ? void 0 : _a.value); })) === null || _a === void 0 ? void 0 : _a[parentIdField].value;
|
|
628
|
-
return `${this.parentRepository.collectionName}/${parentId}/${this.collectionName}`;
|
|
629
|
-
}
|
|
630
|
-
defineLimits(query, filters, limits) {
|
|
631
|
-
if (limits === null || limits === void 0 ? void 0 : limits.offset) {
|
|
632
|
-
if (limits.offset instanceof this.model)
|
|
633
|
-
query = query.startAfter(this.collection(this.buildCollectionPathForFind(filters)).doc(limits.offset[limits.offset.identifierFields().shift()]));
|
|
634
|
-
if (isNumber(limits.offset) || isString(limits.offset))
|
|
635
|
-
query = query.startAt(limits.offset);
|
|
636
|
-
}
|
|
637
|
-
if (limits === null || limits === void 0 ? void 0 : limits.limit)
|
|
638
|
-
query = query.limit(limits.limit);
|
|
639
|
-
return query;
|
|
640
|
-
}
|
|
641
|
-
calculateCount(data, limits) {
|
|
642
|
-
if (data.length <= 0)
|
|
643
|
-
return 0;
|
|
644
|
-
if (data.length < (limits === null || limits === void 0 ? void 0 : limits.limit))
|
|
645
|
-
return data.length;
|
|
646
|
-
return Infinity;
|
|
647
|
-
}
|
|
648
|
-
};
|
|
593
|
+
const withFindFirestore = (MixinBase) => {
|
|
594
|
+
return class FindFirestore extends MixinBase {
|
|
595
|
+
constructor() {
|
|
596
|
+
super(...arguments);
|
|
597
|
+
this.makeFirestoreWhere = (queryReference, filter) => Object.keys(filter).reduce((query, fieldName) => this.buildWhereSentence(query, fieldName, filter[fieldName]), queryReference);
|
|
598
|
+
this.buildWhereSentence = (queryReference, fieldName, options) => {
|
|
599
|
+
if (this.isSubCollection(this) && fieldName === this.parentIdField)
|
|
600
|
+
return queryReference;
|
|
601
|
+
if ((options === null || options === void 0 ? void 0 : options.operator) === Where.LIKE) {
|
|
602
|
+
queryReference = queryReference.where(fieldName.toString(), '>=', options.value);
|
|
603
|
+
queryReference = queryReference.where(fieldName.toString(), '<=', `${options.value}~`);
|
|
604
|
+
return queryReference;
|
|
605
|
+
}
|
|
606
|
+
if ((options === null || options === void 0 ? void 0 : options.operator) === Where.IN && Array.isArray(options === null || options === void 0 ? void 0 : options.value))
|
|
607
|
+
return queryReference.where(fieldName.toString(), 'array-contains-any', options.value);
|
|
608
|
+
return queryReference.where(fieldName.toString(), options.operator, options.value);
|
|
609
|
+
};
|
|
610
|
+
}
|
|
611
|
+
find(filters, limits, orderBy) {
|
|
612
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
613
|
+
let query = this.collection(this.buildCollectionPathForFind(filters));
|
|
614
|
+
filters === null || filters === void 0 ? void 0 : filters.forEach((filterer) => (query = this.makeFirestoreWhere(query, filterer)));
|
|
615
|
+
orderBy === null || orderBy === void 0 ? void 0 : orderBy.forEach((orderer) => Object.keys(orderer).forEach((fieldName) => (query = query.orderBy(fieldName, orderer[fieldName]))));
|
|
616
|
+
query = this.defineLimits(query, filters, limits);
|
|
617
|
+
const docs = yield query.get();
|
|
618
|
+
const data = docs.docs.map((doc) => doc.data());
|
|
619
|
+
return {
|
|
620
|
+
data,
|
|
621
|
+
count: this.calculateCount(data, limits),
|
|
622
|
+
};
|
|
623
|
+
});
|
|
624
|
+
}
|
|
625
|
+
buildCollectionPathForFind(filters) {
|
|
626
|
+
var _a;
|
|
627
|
+
if (!this.isSubCollection(this))
|
|
628
|
+
return this.collectionName;
|
|
629
|
+
const parentIdField = this.parentIdField;
|
|
630
|
+
const parentId = (_a = filters.find((groupFilter) => { var _a; return Boolean((_a = groupFilter[parentIdField]) === null || _a === void 0 ? void 0 : _a.value); })) === null || _a === void 0 ? void 0 : _a[parentIdField].value;
|
|
631
|
+
return `${this.parentRepository.collectionName}/${parentId}/${this.collectionName}`;
|
|
632
|
+
}
|
|
633
|
+
defineLimits(query, filters, limits) {
|
|
634
|
+
if (limits === null || limits === void 0 ? void 0 : limits.offset) {
|
|
635
|
+
if (limits.offset instanceof this.model)
|
|
636
|
+
query = query.startAfter(this.collection(this.buildCollectionPathForFind(filters)).doc(limits.offset[limits.offset.identifierFields().shift()]));
|
|
637
|
+
if (isNumber(limits.offset) || isString(limits.offset))
|
|
638
|
+
query = query.startAt(limits.offset);
|
|
639
|
+
}
|
|
640
|
+
if (limits === null || limits === void 0 ? void 0 : limits.limit)
|
|
641
|
+
query = query.limit(limits.limit);
|
|
642
|
+
return query;
|
|
643
|
+
}
|
|
644
|
+
calculateCount(data, limits) {
|
|
645
|
+
if (data.length <= 0)
|
|
646
|
+
return 0;
|
|
647
|
+
if (data.length < (limits === null || limits === void 0 ? void 0 : limits.limit))
|
|
648
|
+
return data.length;
|
|
649
|
+
return Infinity;
|
|
650
|
+
}
|
|
651
|
+
};
|
|
649
652
|
};
|
|
650
653
|
|
|
651
|
-
const withCreateFirestore = (MixinBase) => {
|
|
652
|
-
return class CreateFirestore extends MixinBase {
|
|
653
|
-
create(data) {
|
|
654
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
655
|
-
const docRef = yield this.save(this.model.toInstance(data));
|
|
656
|
-
const doc = yield docRef.get();
|
|
657
|
-
return doc.data();
|
|
658
|
-
});
|
|
659
|
-
}
|
|
660
|
-
save(data) {
|
|
661
|
-
var _a;
|
|
662
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
663
|
-
const id = (_a = data[data.identifierFields().shift()]) === null || _a === void 0 ? void 0 : _a.toString();
|
|
664
|
-
if (isEmpty(id))
|
|
665
|
-
return this.collection(this.buildCollectionPathForAdd(data)).add(data);
|
|
666
|
-
const docRef = this.collection().doc(id);
|
|
667
|
-
yield docRef.set(data);
|
|
668
|
-
return docRef;
|
|
669
|
-
});
|
|
670
|
-
}
|
|
671
|
-
buildCollectionPathForAdd(identifiers) {
|
|
672
|
-
return this.isSubCollection(this)
|
|
673
|
-
? `${this.parentRepository.collectionName}/${identifiers[this.parentIdField]}/${this.collectionName}`
|
|
674
|
-
: this.collectionName;
|
|
675
|
-
}
|
|
676
|
-
};
|
|
654
|
+
const withCreateFirestore = (MixinBase) => {
|
|
655
|
+
return class CreateFirestore extends MixinBase {
|
|
656
|
+
create(data) {
|
|
657
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
658
|
+
const docRef = yield this.save(this.model.toInstance(data));
|
|
659
|
+
const doc = yield docRef.get();
|
|
660
|
+
return doc.data();
|
|
661
|
+
});
|
|
662
|
+
}
|
|
663
|
+
save(data) {
|
|
664
|
+
var _a;
|
|
665
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
666
|
+
const id = (_a = data[data.identifierFields().shift()]) === null || _a === void 0 ? void 0 : _a.toString();
|
|
667
|
+
if (isEmpty(id))
|
|
668
|
+
return this.collection(this.buildCollectionPathForAdd(data)).add(data);
|
|
669
|
+
const docRef = this.collection().doc(id);
|
|
670
|
+
yield docRef.set(data);
|
|
671
|
+
return docRef;
|
|
672
|
+
});
|
|
673
|
+
}
|
|
674
|
+
buildCollectionPathForAdd(identifiers) {
|
|
675
|
+
return this.isSubCollection(this)
|
|
676
|
+
? `${this.parentRepository.collectionName}/${identifiers[this.parentIdField]}/${this.collectionName}`
|
|
677
|
+
: this.collectionName;
|
|
678
|
+
}
|
|
679
|
+
};
|
|
677
680
|
};
|
|
678
681
|
|
|
679
|
-
const withUpdateFirestore = (MixinBase) => {
|
|
680
|
-
const getValueFromParams = (params, field) => { var _a; return (isNil((_a = params[field]) === null || _a === void 0 ? void 0 : _a.value) ? params[field] : params[field].value) || null; };
|
|
681
|
-
const getValueByAction = (options) => {
|
|
682
|
-
const fieldValues = firebase.firestore.FieldValue;
|
|
683
|
-
if (isNil(options.action))
|
|
684
|
-
return options;
|
|
685
|
-
if (options.action === UpdateOptionActions.REMOVE_FIELD)
|
|
686
|
-
return fieldValues.delete();
|
|
687
|
-
if (Array.isArray(options.value)) {
|
|
688
|
-
if (options.action === UpdateOptionActions.MERGE)
|
|
689
|
-
return fieldValues.arrayUnion(...options.value);
|
|
690
|
-
if (options.action === UpdateOptionActions.REMOVE)
|
|
691
|
-
return fieldValues.arrayRemove(...options.value);
|
|
692
|
-
}
|
|
693
|
-
return options.value;
|
|
694
|
-
};
|
|
695
|
-
return class UpdateFirestore extends MixinBase {
|
|
696
|
-
update(data) {
|
|
697
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
698
|
-
const model = new this.model();
|
|
699
|
-
const keyField = model.identifierFields().shift();
|
|
700
|
-
const docRef = this.collection(this.buildCollectionPathForUpdate(data)).doc(getValueFromParams(data, keyField).toString());
|
|
701
|
-
yield docRef.update(this.paramsToPlain(data));
|
|
702
|
-
const doc = yield docRef.get();
|
|
703
|
-
return doc.data();
|
|
704
|
-
});
|
|
705
|
-
}
|
|
706
|
-
buildCollectionPathForUpdate(identifiers) {
|
|
707
|
-
return this.isSubCollection(this)
|
|
708
|
-
? `${this.parentRepository.collectionName}/${getValueFromParams(identifiers, this.parentIdField)}/${this.collectionName}`
|
|
709
|
-
: this.collectionName;
|
|
710
|
-
}
|
|
711
|
-
paramsToPlain(params) {
|
|
712
|
-
const model = this.model;
|
|
713
|
-
if (params instanceof model)
|
|
714
|
-
return params.toPlain();
|
|
715
|
-
return Object.keys(params).reduce((data, currentKey) => (Object.assign(Object.assign({}, data), { [currentKey]: getValueByAction(params[currentKey]) })), {});
|
|
716
|
-
}
|
|
717
|
-
};
|
|
682
|
+
const withUpdateFirestore = (MixinBase) => {
|
|
683
|
+
const getValueFromParams = (params, field) => { var _a; return (isNil((_a = params[field]) === null || _a === void 0 ? void 0 : _a.value) ? params[field] : params[field].value) || null; };
|
|
684
|
+
const getValueByAction = (options) => {
|
|
685
|
+
const fieldValues = firebase.firestore.FieldValue;
|
|
686
|
+
if (isNil(options.action))
|
|
687
|
+
return options;
|
|
688
|
+
if (options.action === UpdateOptionActions.REMOVE_FIELD)
|
|
689
|
+
return fieldValues.delete();
|
|
690
|
+
if (Array.isArray(options.value)) {
|
|
691
|
+
if (options.action === UpdateOptionActions.MERGE)
|
|
692
|
+
return fieldValues.arrayUnion(...options.value);
|
|
693
|
+
if (options.action === UpdateOptionActions.REMOVE)
|
|
694
|
+
return fieldValues.arrayRemove(...options.value);
|
|
695
|
+
}
|
|
696
|
+
return options.value;
|
|
697
|
+
};
|
|
698
|
+
return class UpdateFirestore extends MixinBase {
|
|
699
|
+
update(data) {
|
|
700
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
701
|
+
const model = new this.model();
|
|
702
|
+
const keyField = model.identifierFields().shift();
|
|
703
|
+
const docRef = this.collection(this.buildCollectionPathForUpdate(data)).doc(getValueFromParams(data, keyField).toString());
|
|
704
|
+
yield docRef.update(this.paramsToPlain(data));
|
|
705
|
+
const doc = yield docRef.get();
|
|
706
|
+
return doc.data();
|
|
707
|
+
});
|
|
708
|
+
}
|
|
709
|
+
buildCollectionPathForUpdate(identifiers) {
|
|
710
|
+
return this.isSubCollection(this)
|
|
711
|
+
? `${this.parentRepository.collectionName}/${getValueFromParams(identifiers, this.parentIdField)}/${this.collectionName}`
|
|
712
|
+
: this.collectionName;
|
|
713
|
+
}
|
|
714
|
+
paramsToPlain(params) {
|
|
715
|
+
const model = this.model;
|
|
716
|
+
if (params instanceof model)
|
|
717
|
+
return params.toPlain();
|
|
718
|
+
return Object.keys(params).reduce((data, currentKey) => (Object.assign(Object.assign({}, data), { [currentKey]: getValueByAction(params[currentKey]) })), {});
|
|
719
|
+
}
|
|
720
|
+
};
|
|
718
721
|
};
|
|
719
722
|
|
|
720
|
-
const withDeleteFirestore = (MixinBase) => {
|
|
721
|
-
return class DeleteFirestore extends MixinBase {
|
|
722
|
-
delete(identifiers) {
|
|
723
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
724
|
-
yield this.collection(this.buildCollectionPathForRemove(identifiers))
|
|
725
|
-
.doc(Object.values(identifiers).shift().toString())
|
|
726
|
-
.delete();
|
|
727
|
-
});
|
|
728
|
-
}
|
|
729
|
-
buildCollectionPathForRemove(identifiers) {
|
|
730
|
-
return this.isSubCollection(this)
|
|
731
|
-
? `${this.parentRepository.collectionName}/${identifiers[this.parentIdField]}/${this.collectionName}`
|
|
732
|
-
: this.collectionName;
|
|
733
|
-
}
|
|
734
|
-
};
|
|
723
|
+
const withDeleteFirestore = (MixinBase) => {
|
|
724
|
+
return class DeleteFirestore extends MixinBase {
|
|
725
|
+
delete(identifiers) {
|
|
726
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
727
|
+
yield this.collection(this.buildCollectionPathForRemove(identifiers))
|
|
728
|
+
.doc(Object.values(identifiers).shift().toString())
|
|
729
|
+
.delete();
|
|
730
|
+
});
|
|
731
|
+
}
|
|
732
|
+
buildCollectionPathForRemove(identifiers) {
|
|
733
|
+
return this.isSubCollection(this)
|
|
734
|
+
? `${this.parentRepository.collectionName}/${identifiers[this.parentIdField]}/${this.collectionName}`
|
|
735
|
+
: this.collectionName;
|
|
736
|
+
}
|
|
737
|
+
};
|
|
735
738
|
};
|
|
736
739
|
|
|
737
|
-
const withSubCollection = (MixinBase, ParentModel) => {
|
|
738
|
-
return class SubCollectionMix extends MixinBase {
|
|
739
|
-
constructor(...args) {
|
|
740
|
-
super(args);
|
|
741
|
-
}
|
|
742
|
-
collection(path) {
|
|
743
|
-
return super.collection(path);
|
|
744
|
-
}
|
|
745
|
-
};
|
|
740
|
+
const withSubCollection = (MixinBase, ParentModel) => {
|
|
741
|
+
return class SubCollectionMix extends MixinBase {
|
|
742
|
+
constructor(...args) {
|
|
743
|
+
super(args);
|
|
744
|
+
}
|
|
745
|
+
collection(path) {
|
|
746
|
+
return super.collection(path);
|
|
747
|
+
}
|
|
748
|
+
};
|
|
746
749
|
};
|
|
747
750
|
|
|
748
|
-
const withCrudFirestore = (MixinBase) => {
|
|
749
|
-
return class CrudFirestore extends withUpdateFirestore(withGetFirestore(withFindFirestore(withDeleteFirestore(withCreateFirestore(MixinBase))))) {
|
|
750
|
-
};
|
|
751
|
+
const withCrudFirestore = (MixinBase) => {
|
|
752
|
+
return class CrudFirestore extends withUpdateFirestore(withGetFirestore(withFindFirestore(withDeleteFirestore(withCreateFirestore(MixinBase))))) {
|
|
753
|
+
};
|
|
751
754
|
};
|
|
752
755
|
|
|
753
|
-
class SubscriptionFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
754
|
-
constructor(firestore) {
|
|
755
|
-
super();
|
|
756
|
-
this.firestore = firestore;
|
|
757
|
-
this.collectionName = 'subscription';
|
|
758
|
-
this.model = Subscription;
|
|
759
|
-
}
|
|
756
|
+
class SubscriptionFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
757
|
+
constructor(firestore) {
|
|
758
|
+
super();
|
|
759
|
+
this.firestore = firestore;
|
|
760
|
+
this.collectionName = 'subscription';
|
|
761
|
+
this.model = Subscription;
|
|
762
|
+
}
|
|
760
763
|
}
|
|
761
764
|
|
|
762
|
-
class UserFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
763
|
-
constructor(firestore) {
|
|
764
|
-
super();
|
|
765
|
-
this.firestore = firestore;
|
|
766
|
-
this.collectionName = 'users';
|
|
767
|
-
this.model = User;
|
|
768
|
-
}
|
|
769
|
-
get(identifiers) {
|
|
770
|
-
const _super = Object.create(null, {
|
|
771
|
-
get: { get: () => super.get }
|
|
772
|
-
});
|
|
773
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
774
|
-
const user = yield _super.get.call(this, { id: identifiers.id });
|
|
775
|
-
user.beautyProfile = yield this.getBeautyProfile(user.id);
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
.
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
765
|
+
class UserFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
766
|
+
constructor(firestore) {
|
|
767
|
+
super();
|
|
768
|
+
this.firestore = firestore;
|
|
769
|
+
this.collectionName = 'users';
|
|
770
|
+
this.model = User;
|
|
771
|
+
}
|
|
772
|
+
get(identifiers) {
|
|
773
|
+
const _super = Object.create(null, {
|
|
774
|
+
get: { get: () => super.get }
|
|
775
|
+
});
|
|
776
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
777
|
+
const user = yield _super.get.call(this, { id: identifiers.id });
|
|
778
|
+
user.beautyProfile = yield this.getBeautyProfile(user.id);
|
|
779
|
+
user.isSubscriber = yield this.checkIfIsSubscriber(user.id);
|
|
780
|
+
return user;
|
|
781
|
+
});
|
|
782
|
+
}
|
|
783
|
+
buildModelInstance() {
|
|
784
|
+
const { fromFirestore, toFirestore } = super.buildModelInstance();
|
|
785
|
+
return {
|
|
786
|
+
toFirestore: (data) => {
|
|
787
|
+
const plain = toFirestore(data);
|
|
788
|
+
delete plain.isSubscriber;
|
|
789
|
+
return plain;
|
|
790
|
+
},
|
|
791
|
+
fromFirestore,
|
|
792
|
+
};
|
|
793
|
+
}
|
|
794
|
+
getBeautyProfile(userId) {
|
|
795
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
796
|
+
const beautyProfile = yield this.collection()
|
|
797
|
+
.doc(userId)
|
|
798
|
+
.collection('CX')
|
|
799
|
+
.withConverter(this.buildBeautyProfileModelInstance())
|
|
800
|
+
.doc('beautyProfile')
|
|
801
|
+
.get();
|
|
802
|
+
return beautyProfile.data();
|
|
803
|
+
});
|
|
804
|
+
}
|
|
805
|
+
checkIfIsSubscriber(userId) {
|
|
806
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
807
|
+
const docs = yield this.firestore
|
|
808
|
+
.collection('subscription')
|
|
809
|
+
.where('user.id', '==', userId)
|
|
810
|
+
.where('status', '==', 'active')
|
|
811
|
+
.get();
|
|
812
|
+
return !!docs && !!docs.size;
|
|
813
|
+
});
|
|
814
|
+
}
|
|
815
|
+
buildBeautyProfileModelInstance() {
|
|
816
|
+
return {
|
|
817
|
+
toFirestore: (data) => data.toPlain(),
|
|
818
|
+
fromFirestore: (snap) => BeautyProfile.toInstance(snap.data()),
|
|
819
|
+
};
|
|
820
|
+
}
|
|
796
821
|
}
|
|
797
822
|
|
|
798
|
-
class SubscriptionEditionFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), Subscription) {
|
|
799
|
-
constructor(firestore, parentRepository) {
|
|
800
|
-
super();
|
|
801
|
-
this.firestore = firestore;
|
|
802
|
-
this.parentRepository = parentRepository;
|
|
803
|
-
this.collectionName = 'editions';
|
|
804
|
-
this.parentIdField = 'subscriptionId';
|
|
805
|
-
this.model = Edition;
|
|
806
|
-
}
|
|
823
|
+
class SubscriptionEditionFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), Subscription) {
|
|
824
|
+
constructor(firestore, parentRepository) {
|
|
825
|
+
super();
|
|
826
|
+
this.firestore = firestore;
|
|
827
|
+
this.parentRepository = parentRepository;
|
|
828
|
+
this.collectionName = 'editions';
|
|
829
|
+
this.parentIdField = 'subscriptionId';
|
|
830
|
+
this.model = Edition;
|
|
831
|
+
}
|
|
807
832
|
}
|
|
808
833
|
|
|
809
|
-
class UserBeautyProfileFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), User) {
|
|
810
|
-
constructor(firestore, parentRepository) {
|
|
811
|
-
super();
|
|
812
|
-
this.firestore = firestore;
|
|
813
|
-
this.parentRepository = parentRepository;
|
|
814
|
-
this.collectionName = 'CX';
|
|
815
|
-
this.parentIdField = 'userId';
|
|
816
|
-
this.model = BeautyProfile;
|
|
817
|
-
}
|
|
834
|
+
class UserBeautyProfileFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), User) {
|
|
835
|
+
constructor(firestore, parentRepository) {
|
|
836
|
+
super();
|
|
837
|
+
this.firestore = firestore;
|
|
838
|
+
this.parentRepository = parentRepository;
|
|
839
|
+
this.collectionName = 'CX';
|
|
840
|
+
this.parentIdField = 'userId';
|
|
841
|
+
this.model = BeautyProfile;
|
|
842
|
+
}
|
|
818
843
|
}
|
|
819
844
|
|
|
820
|
-
class UserAddressFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), User) {
|
|
821
|
-
constructor(firestore, parentRepository) {
|
|
822
|
-
super();
|
|
823
|
-
this.firestore = firestore;
|
|
824
|
-
this.parentRepository = parentRepository;
|
|
825
|
-
this.collectionName = 'address';
|
|
826
|
-
this.parentIdField = 'userId';
|
|
827
|
-
this.model = UserAddress;
|
|
828
|
-
}
|
|
845
|
+
class UserAddressFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), User) {
|
|
846
|
+
constructor(firestore, parentRepository) {
|
|
847
|
+
super();
|
|
848
|
+
this.firestore = firestore;
|
|
849
|
+
this.parentRepository = parentRepository;
|
|
850
|
+
this.collectionName = 'address';
|
|
851
|
+
this.parentIdField = 'userId';
|
|
852
|
+
this.model = UserAddress;
|
|
853
|
+
}
|
|
829
854
|
}
|
|
830
855
|
|
|
831
|
-
class SubscriptionPaymentFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), Subscription) {
|
|
832
|
-
constructor(firestore, parentRepository) {
|
|
833
|
-
super();
|
|
834
|
-
this.firestore = firestore;
|
|
835
|
-
this.parentRepository = parentRepository;
|
|
836
|
-
this.collectionName = 'Payments';
|
|
837
|
-
this.parentIdField = 'subscriptionId';
|
|
838
|
-
this.model = SubscriptionPayment;
|
|
839
|
-
}
|
|
856
|
+
class SubscriptionPaymentFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), Subscription) {
|
|
857
|
+
constructor(firestore, parentRepository) {
|
|
858
|
+
super();
|
|
859
|
+
this.firestore = firestore;
|
|
860
|
+
this.parentRepository = parentRepository;
|
|
861
|
+
this.collectionName = 'Payments';
|
|
862
|
+
this.parentIdField = 'subscriptionId';
|
|
863
|
+
this.model = SubscriptionPayment;
|
|
864
|
+
}
|
|
840
865
|
}
|
|
841
866
|
|
|
842
|
-
class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
843
|
-
constructor(firestore) {
|
|
844
|
-
super();
|
|
845
|
-
this.firestore = firestore;
|
|
846
|
-
this.collectionName = 'categories';
|
|
847
|
-
this.model = Category;
|
|
848
|
-
}
|
|
849
|
-
getCategoryBySlug(slug, shop) {
|
|
850
|
-
return this.collection(this.collectionName)
|
|
851
|
-
.where("slug", "==", slug)
|
|
852
|
-
.where("shop", "==", shop)
|
|
853
|
-
.where("published", "==", true)
|
|
854
|
-
.get().then(snap => {
|
|
855
|
-
if (snap.size > 1)
|
|
856
|
-
throw new DuplicatedResultsError("Query returned duplicated values");
|
|
857
|
-
if (snap.empty)
|
|
858
|
-
throw new NotFoundError(`Document with slug ${slug} not found`);
|
|
859
|
-
return snap.docs[0].data();
|
|
860
|
-
}).catch(error => error);
|
|
861
|
-
}
|
|
862
|
-
getCategoriesForHome(categoryIds) {
|
|
863
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
864
|
-
const categorySnap = yield this.collection(this.collectionName)
|
|
865
|
-
.where("id", "in", categoryIds)
|
|
866
|
-
.where("published", "==", true)
|
|
867
|
-
.get();
|
|
868
|
-
if (categorySnap.empty)
|
|
869
|
-
throw new NotFoundError("Categories not found");
|
|
870
|
-
const categories = categorySnap.docs.map(doc => doc.data());
|
|
871
|
-
const homeSections = [];
|
|
872
|
-
for (const category of categories) {
|
|
873
|
-
const productSnap = yield this.collection("products")
|
|
874
|
-
.where("categories", "array-contains", category.id)
|
|
875
|
-
// .where("published", "==", true)
|
|
876
|
-
.where("stock.quantity", ">", 1)
|
|
877
|
-
.limit(4)
|
|
878
|
-
.get();
|
|
879
|
-
const products = productSnap.docs.map(doc => doc.data());
|
|
880
|
-
homeSections.push({ title: category.name, products });
|
|
881
|
-
}
|
|
882
|
-
return homeSections;
|
|
883
|
-
});
|
|
884
|
-
}
|
|
885
|
-
mountCategory(category) {
|
|
886
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
887
|
-
if (!category.products)
|
|
888
|
-
throw new RequiredArgumentError(["Category products is empty"]);
|
|
889
|
-
const chunks = category.products.reduce((resultArray, item, index) => {
|
|
890
|
-
const chunkIndex = Math.floor(index / 10);
|
|
891
|
-
if (!resultArray[chunkIndex])
|
|
892
|
-
resultArray[chunkIndex] = [];
|
|
893
|
-
resultArray[chunkIndex].push(item);
|
|
894
|
-
return resultArray;
|
|
895
|
-
}, []);
|
|
896
|
-
const products = [];
|
|
897
|
-
for (const productIds of chunks) {
|
|
898
|
-
const productSnap = yield this.collection("products")
|
|
899
|
-
.where("id", "in", productIds)
|
|
900
|
-
// .where("published", "==", true)
|
|
901
|
-
.get();
|
|
902
|
-
if (productSnap.empty)
|
|
903
|
-
continue;
|
|
904
|
-
products.push(...productSnap.docs.map(doc => doc.data()));
|
|
905
|
-
}
|
|
906
|
-
return products;
|
|
907
|
-
});
|
|
908
|
-
}
|
|
867
|
+
class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
868
|
+
constructor(firestore) {
|
|
869
|
+
super();
|
|
870
|
+
this.firestore = firestore;
|
|
871
|
+
this.collectionName = 'categories';
|
|
872
|
+
this.model = Category;
|
|
873
|
+
}
|
|
874
|
+
getCategoryBySlug(slug, shop) {
|
|
875
|
+
return this.collection(this.collectionName)
|
|
876
|
+
.where("slug", "==", slug)
|
|
877
|
+
.where("shop", "==", shop)
|
|
878
|
+
.where("published", "==", true)
|
|
879
|
+
.get().then(snap => {
|
|
880
|
+
if (snap.size > 1)
|
|
881
|
+
throw new DuplicatedResultsError("Query returned duplicated values");
|
|
882
|
+
if (snap.empty)
|
|
883
|
+
throw new NotFoundError(`Document with slug ${slug} not found`);
|
|
884
|
+
return snap.docs[0].data();
|
|
885
|
+
}).catch(error => error);
|
|
886
|
+
}
|
|
887
|
+
getCategoriesForHome(categoryIds) {
|
|
888
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
889
|
+
const categorySnap = yield this.collection(this.collectionName)
|
|
890
|
+
.where("id", "in", categoryIds)
|
|
891
|
+
.where("published", "==", true)
|
|
892
|
+
.get();
|
|
893
|
+
if (categorySnap.empty)
|
|
894
|
+
throw new NotFoundError("Categories not found");
|
|
895
|
+
const categories = categorySnap.docs.map(doc => doc.data());
|
|
896
|
+
const homeSections = [];
|
|
897
|
+
for (const category of categories) {
|
|
898
|
+
const productSnap = yield this.collection("products")
|
|
899
|
+
.where("categories", "array-contains", category.id)
|
|
900
|
+
// .where("published", "==", true)
|
|
901
|
+
.where("stock.quantity", ">", 1)
|
|
902
|
+
.limit(4)
|
|
903
|
+
.get();
|
|
904
|
+
const products = productSnap.docs.map(doc => doc.data());
|
|
905
|
+
homeSections.push({ title: category.name, products });
|
|
906
|
+
}
|
|
907
|
+
return homeSections;
|
|
908
|
+
});
|
|
909
|
+
}
|
|
910
|
+
mountCategory(category) {
|
|
911
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
912
|
+
if (!category.products)
|
|
913
|
+
throw new RequiredArgumentError(["Category products is empty"]);
|
|
914
|
+
const chunks = category.products.reduce((resultArray, item, index) => {
|
|
915
|
+
const chunkIndex = Math.floor(index / 10);
|
|
916
|
+
if (!resultArray[chunkIndex])
|
|
917
|
+
resultArray[chunkIndex] = [];
|
|
918
|
+
resultArray[chunkIndex].push(item);
|
|
919
|
+
return resultArray;
|
|
920
|
+
}, []);
|
|
921
|
+
const products = [];
|
|
922
|
+
for (const productIds of chunks) {
|
|
923
|
+
const productSnap = yield this.collection("products")
|
|
924
|
+
.where("id", "in", productIds)
|
|
925
|
+
// .where("published", "==", true)
|
|
926
|
+
.get();
|
|
927
|
+
if (productSnap.empty)
|
|
928
|
+
continue;
|
|
929
|
+
products.push(...productSnap.docs.map(doc => doc.data()));
|
|
930
|
+
}
|
|
931
|
+
return products;
|
|
932
|
+
});
|
|
933
|
+
}
|
|
909
934
|
}
|
|
910
935
|
|
|
911
|
-
class ProductFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
912
|
-
constructor(firestore) {
|
|
913
|
-
super();
|
|
914
|
-
this.firestore = firestore;
|
|
915
|
-
this.collectionName = 'products';
|
|
916
|
-
this.model = Product;
|
|
917
|
-
}
|
|
918
|
-
getBySlug(slug, shop) {
|
|
919
|
-
var _a;
|
|
920
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
921
|
-
const result = yield this.find([
|
|
922
|
-
{ slug: { operator: Where.EQUALS, value: slug } },
|
|
923
|
-
{ shopAvailability: { operator: Where.IN, value: [shop] } },
|
|
924
|
-
]);
|
|
925
|
-
return (_a = result === null || result === void 0 ? void 0 : result.data) === null || _a === void 0 ? void 0 : _a.shift();
|
|
926
|
-
});
|
|
927
|
-
}
|
|
936
|
+
class ProductFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
937
|
+
constructor(firestore) {
|
|
938
|
+
super();
|
|
939
|
+
this.firestore = firestore;
|
|
940
|
+
this.collectionName = 'products';
|
|
941
|
+
this.model = Product;
|
|
942
|
+
}
|
|
943
|
+
getBySlug(slug, shop) {
|
|
944
|
+
var _a;
|
|
945
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
946
|
+
const result = yield this.find([
|
|
947
|
+
{ slug: { operator: Where.EQUALS, value: slug } },
|
|
948
|
+
{ shopAvailability: { operator: Where.IN, value: [shop] } },
|
|
949
|
+
]);
|
|
950
|
+
return (_a = result === null || result === void 0 ? void 0 : result.data) === null || _a === void 0 ? void 0 : _a.shift();
|
|
951
|
+
});
|
|
952
|
+
}
|
|
928
953
|
}
|
|
929
954
|
|
|
930
|
-
class ProductVariantFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), Product) {
|
|
931
|
-
constructor(firestore, parentRepository) {
|
|
932
|
-
super();
|
|
933
|
-
this.firestore = firestore;
|
|
934
|
-
this.parentRepository = parentRepository;
|
|
935
|
-
this.collectionName = 'variants';
|
|
936
|
-
this.parentIdField = 'productId';
|
|
937
|
-
this.model = Variant;
|
|
938
|
-
}
|
|
955
|
+
class ProductVariantFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), Product) {
|
|
956
|
+
constructor(firestore, parentRepository) {
|
|
957
|
+
super();
|
|
958
|
+
this.firestore = firestore;
|
|
959
|
+
this.parentRepository = parentRepository;
|
|
960
|
+
this.collectionName = 'variants';
|
|
961
|
+
this.parentIdField = 'productId';
|
|
962
|
+
this.model = Variant;
|
|
963
|
+
}
|
|
939
964
|
}
|
|
940
965
|
|
|
941
|
-
class CheckoutFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
942
|
-
constructor(firestore) {
|
|
943
|
-
super();
|
|
944
|
-
this.firestore = firestore;
|
|
945
|
-
this.collectionName = 'checkouts';
|
|
946
|
-
this.model = Checkout;
|
|
947
|
-
}
|
|
966
|
+
class CheckoutFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
967
|
+
constructor(firestore) {
|
|
968
|
+
super();
|
|
969
|
+
this.firestore = firestore;
|
|
970
|
+
this.collectionName = 'checkouts';
|
|
971
|
+
this.model = Checkout;
|
|
972
|
+
}
|
|
948
973
|
}
|
|
949
974
|
|
|
950
|
-
class CouponFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
951
|
-
constructor(firestore) {
|
|
952
|
-
super();
|
|
953
|
-
this.firestore = firestore;
|
|
954
|
-
this.collectionName = 'coupons';
|
|
955
|
-
this.model = Coupon;
|
|
956
|
-
}
|
|
975
|
+
class CouponFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
976
|
+
constructor(firestore) {
|
|
977
|
+
super();
|
|
978
|
+
this.firestore = firestore;
|
|
979
|
+
this.collectionName = 'coupons';
|
|
980
|
+
this.model = Coupon;
|
|
981
|
+
}
|
|
957
982
|
}
|
|
958
983
|
|
|
959
|
-
class OrderFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
960
|
-
constructor(firestore) {
|
|
961
|
-
super();
|
|
962
|
-
this.firestore = firestore;
|
|
963
|
-
this.collectionName = 'orders';
|
|
964
|
-
this.model = Order;
|
|
965
|
-
}
|
|
984
|
+
class OrderFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
985
|
+
constructor(firestore) {
|
|
986
|
+
super();
|
|
987
|
+
this.firestore = firestore;
|
|
988
|
+
this.collectionName = 'orders';
|
|
989
|
+
this.model = Order;
|
|
990
|
+
}
|
|
966
991
|
}
|
|
967
992
|
|
|
968
|
-
class PaymentFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
969
|
-
constructor(firestore) {
|
|
970
|
-
super();
|
|
971
|
-
this.firestore = firestore;
|
|
972
|
-
this.collectionName = 'payments';
|
|
973
|
-
this.model = Payment;
|
|
974
|
-
}
|
|
993
|
+
class PaymentFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
994
|
+
constructor(firestore) {
|
|
995
|
+
super();
|
|
996
|
+
this.firestore = firestore;
|
|
997
|
+
this.collectionName = 'payments';
|
|
998
|
+
this.model = Payment;
|
|
999
|
+
}
|
|
975
1000
|
}
|
|
976
1001
|
|
|
977
|
-
class CheckoutSubscriptionFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
978
|
-
constructor(firestore) {
|
|
979
|
-
super();
|
|
980
|
-
this.firestore = firestore;
|
|
981
|
-
this.collectionName = 'checkoutsSubscription';
|
|
982
|
-
this.model = CheckoutSubscription;
|
|
983
|
-
}
|
|
1002
|
+
class CheckoutSubscriptionFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1003
|
+
constructor(firestore) {
|
|
1004
|
+
super();
|
|
1005
|
+
this.firestore = firestore;
|
|
1006
|
+
this.collectionName = 'checkoutsSubscription';
|
|
1007
|
+
this.model = CheckoutSubscription;
|
|
1008
|
+
}
|
|
984
1009
|
}
|
|
985
1010
|
|
|
986
|
-
class SubscriptionPlanFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
987
|
-
constructor(firestore) {
|
|
988
|
-
super();
|
|
989
|
-
this.firestore = firestore;
|
|
990
|
-
this.collectionName = 'subscriptionPlans';
|
|
991
|
-
this.model = SubscriptionPlan;
|
|
992
|
-
}
|
|
1011
|
+
class SubscriptionPlanFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1012
|
+
constructor(firestore) {
|
|
1013
|
+
super();
|
|
1014
|
+
this.firestore = firestore;
|
|
1015
|
+
this.collectionName = 'subscriptionPlans';
|
|
1016
|
+
this.model = SubscriptionPlan;
|
|
1017
|
+
}
|
|
993
1018
|
}
|
|
994
1019
|
|
|
995
|
-
class Buy2WinFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
996
|
-
constructor(firestore) {
|
|
997
|
-
super();
|
|
998
|
-
this.firestore = firestore;
|
|
999
|
-
this.collectionName = 'buy2win';
|
|
1000
|
-
this.model = Buy2Win;
|
|
1001
|
-
}
|
|
1020
|
+
class Buy2WinFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1021
|
+
constructor(firestore) {
|
|
1022
|
+
super();
|
|
1023
|
+
this.firestore = firestore;
|
|
1024
|
+
this.collectionName = 'buy2win';
|
|
1025
|
+
this.model = Buy2Win;
|
|
1026
|
+
}
|
|
1002
1027
|
}
|
|
1003
1028
|
|
|
1004
|
-
class HomeFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1005
|
-
constructor(firestore) {
|
|
1006
|
-
super();
|
|
1007
|
-
this.firestore = firestore;
|
|
1008
|
-
this.collectionName = 'dms';
|
|
1009
|
-
this.model = Home;
|
|
1010
|
-
}
|
|
1029
|
+
class HomeFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1030
|
+
constructor(firestore) {
|
|
1031
|
+
super();
|
|
1032
|
+
this.firestore = firestore;
|
|
1033
|
+
this.collectionName = 'dms';
|
|
1034
|
+
this.model = Home;
|
|
1035
|
+
}
|
|
1011
1036
|
}
|
|
1012
1037
|
|
|
1013
|
-
class ShopMenuFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1014
|
-
constructor(firestore) {
|
|
1015
|
-
super();
|
|
1016
|
-
this.firestore = firestore;
|
|
1017
|
-
this.collectionName = 'shopMenus';
|
|
1018
|
-
this.model = ShopMenu;
|
|
1019
|
-
}
|
|
1038
|
+
class ShopMenuFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1039
|
+
constructor(firestore) {
|
|
1040
|
+
super();
|
|
1041
|
+
this.firestore = firestore;
|
|
1042
|
+
this.collectionName = 'shopMenus';
|
|
1043
|
+
this.model = ShopMenu;
|
|
1044
|
+
}
|
|
1020
1045
|
}
|
|
1021
1046
|
|
|
1022
|
-
class AuthenticationFirebaseAuthService {
|
|
1023
|
-
constructor(firebaseAuth) {
|
|
1024
|
-
this.firebaseAuth = firebaseAuth;
|
|
1025
|
-
}
|
|
1026
|
-
signInWithEmailAndPassword(data) {
|
|
1027
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1028
|
-
const credentials = yield this.firebaseAuth.signInWithEmailAndPassword(data.email, data.password);
|
|
1029
|
-
const user = credentials.user;
|
|
1030
|
-
return { id: user.uid, displayName: user.displayName, email: user.email, phone: user.phoneNumber };
|
|
1031
|
-
});
|
|
1032
|
-
}
|
|
1033
|
-
signInWithGoogle() {
|
|
1034
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1035
|
-
const credentials = yield this.firebaseAuth.signInWithPopup(new firebase$1.auth.GoogleAuthProvider());
|
|
1036
|
-
const user = credentials.user;
|
|
1037
|
-
return { id: user.uid, displayName: user.displayName, email: user.email, phone: user.phoneNumber };
|
|
1038
|
-
});
|
|
1039
|
-
}
|
|
1040
|
-
signOut() {
|
|
1041
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1042
|
-
this.firebaseAuth.signOut();
|
|
1043
|
-
});
|
|
1044
|
-
}
|
|
1047
|
+
class AuthenticationFirebaseAuthService {
|
|
1048
|
+
constructor(firebaseAuth) {
|
|
1049
|
+
this.firebaseAuth = firebaseAuth;
|
|
1050
|
+
}
|
|
1051
|
+
signInWithEmailAndPassword(data) {
|
|
1052
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1053
|
+
const credentials = yield this.firebaseAuth.signInWithEmailAndPassword(data.email, data.password);
|
|
1054
|
+
const user = credentials.user;
|
|
1055
|
+
return { id: user.uid, displayName: user.displayName, email: user.email, phone: user.phoneNumber };
|
|
1056
|
+
});
|
|
1057
|
+
}
|
|
1058
|
+
signInWithGoogle() {
|
|
1059
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1060
|
+
const credentials = yield this.firebaseAuth.signInWithPopup(new firebase$1.auth.GoogleAuthProvider());
|
|
1061
|
+
const user = credentials.user;
|
|
1062
|
+
return { id: user.uid, displayName: user.displayName, email: user.email, phone: user.phoneNumber };
|
|
1063
|
+
});
|
|
1064
|
+
}
|
|
1065
|
+
signOut() {
|
|
1066
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1067
|
+
this.firebaseAuth.signOut();
|
|
1068
|
+
});
|
|
1069
|
+
}
|
|
1045
1070
|
}
|
|
1046
1071
|
|
|
1047
|
-
/**
|
|
1048
|
-
* Generated bundle index. Do not edit.
|
|
1072
|
+
/**
|
|
1073
|
+
* Generated bundle index. Do not edit.
|
|
1049
1074
|
*/
|
|
1050
1075
|
|
|
1051
1076
|
export { Address, Area, Authentication, AuthenticationFirebaseAuthService, Base, BaseModel, BeardSizes, BeautyProfile, BillingStatus, Buy2Win, Buy2WinFirestoreRepository, Category, CategoryFirestoreRepository, Checkout, CheckoutFirestoreRepository, CheckoutSubscription, CheckoutSubscriptionFirestoreRepository, CheckoutTypes, Coupon, CouponFirestoreRepository, CouponSubtypes, CouponTypes, DuplicatedResultsError, Edition, EditionStatus, Exclusivities, FinancialCoupon, HairTypes, Home, HomeFirestoreRepository, InvalidArgumentError, LineItem, NotFoundError, OfficePosition, Order, OrderFirestoreRepository, OrderStatus, Payment, PaymentFirestoreRepository, PaymentType, Product, ProductFirestoreRepository, ProductVariantFirestoreRepository, RequiredArgumentError, ShippingMethod, ShopMenu, ShopMenuFirestoreRepository, Shops, SignInMethods, SignOut, Status, Subscription, SubscriptionEditionFirestoreRepository, SubscriptionFirestoreRepository, SubscriptionPayment, SubscriptionPaymentFirestoreRepository, SubscriptionPlan, SubscriptionPlanFirestoreRepository, UnauthorizedError, UpdateOptionActions, User, UserAddress, UserAddressFirestoreRepository, UserBeautyProfileFirestoreRepository, UserFirestoreRepository, UserType, Variant, Where, withCreateFirestore, withCrudFirestore, withDeleteFirestore, withFindFirestore, withFirestore, withGetFirestore, withHelpers, withSubCollection, withUpdateFirestore };
|