@infrab4a/connect 0.4.8 → 0.4.9
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 +1610 -1556
- 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 +7 -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 -50
- 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 +40 -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 +888 -864
- 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 +32 -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 -11
- 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 +7 -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 +23 -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 -54
- 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 +52 -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,1022 +6,1046 @@ 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
242
|
}
|
|
243
243
|
|
|
244
|
-
class Variant extends BaseModel {
|
|
245
|
-
identifierFields() {
|
|
246
|
-
return ['id'];
|
|
247
|
-
}
|
|
244
|
+
class Variant extends BaseModel {
|
|
245
|
+
identifierFields() {
|
|
246
|
+
return ['id'];
|
|
247
|
+
}
|
|
248
248
|
}
|
|
249
249
|
|
|
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";
|
|
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";
|
|
256
256
|
})(CouponTypes || (CouponTypes = {}));
|
|
257
257
|
|
|
258
|
-
var CouponSubtypes;
|
|
259
|
-
(function (CouponSubtypes) {
|
|
260
|
-
CouponSubtypes[CouponSubtypes["ABSOLUTE"] = 1] = "ABSOLUTE";
|
|
261
|
-
CouponSubtypes[CouponSubtypes["PERCENTAGE"] = 2] = "PERCENTAGE";
|
|
258
|
+
var CouponSubtypes;
|
|
259
|
+
(function (CouponSubtypes) {
|
|
260
|
+
CouponSubtypes[CouponSubtypes["ABSOLUTE"] = 1] = "ABSOLUTE";
|
|
261
|
+
CouponSubtypes[CouponSubtypes["PERCENTAGE"] = 2] = "PERCENTAGE";
|
|
262
262
|
})(CouponSubtypes || (CouponSubtypes = {}));
|
|
263
263
|
|
|
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";
|
|
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";
|
|
269
269
|
})(Exclusivities || (Exclusivities = {}));
|
|
270
270
|
|
|
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' })
|
|
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' })
|
|
281
281
|
], Coupon.prototype, "exclusivityType", void 0);
|
|
282
282
|
|
|
283
|
-
var CheckoutTypes;
|
|
284
|
-
(function (CheckoutTypes) {
|
|
285
|
-
CheckoutTypes[CheckoutTypes["ECOMMERCE"] = 1] = "ECOMMERCE";
|
|
286
|
-
CheckoutTypes[CheckoutTypes["SUBSCRIPTION"] = 2] = "SUBSCRIPTION";
|
|
283
|
+
var CheckoutTypes;
|
|
284
|
+
(function (CheckoutTypes) {
|
|
285
|
+
CheckoutTypes[CheckoutTypes["ECOMMERCE"] = 1] = "ECOMMERCE";
|
|
286
|
+
CheckoutTypes[CheckoutTypes["SUBSCRIPTION"] = 2] = "SUBSCRIPTION";
|
|
287
287
|
})(CheckoutTypes || (CheckoutTypes = {}));
|
|
288
288
|
|
|
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
|
-
}
|
|
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
|
+
}
|
|
311
311
|
}
|
|
312
312
|
|
|
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";
|
|
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";
|
|
323
323
|
})(OrderStatus || (OrderStatus = {}));
|
|
324
324
|
|
|
325
|
-
class Checkout extends BaseModel {
|
|
326
|
-
identifierFields() {
|
|
327
|
-
return ['id'];
|
|
328
|
-
}
|
|
325
|
+
class Checkout extends BaseModel {
|
|
326
|
+
identifierFields() {
|
|
327
|
+
return ['id'];
|
|
328
|
+
}
|
|
329
329
|
}
|
|
330
330
|
|
|
331
|
-
class LineItem extends Product {
|
|
331
|
+
class LineItem extends Product {
|
|
332
332
|
}
|
|
333
333
|
|
|
334
|
-
class Order extends Checkout {
|
|
334
|
+
class Order extends Checkout {
|
|
335
335
|
}
|
|
336
336
|
|
|
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' })
|
|
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' })
|
|
461
461
|
], Payment.prototype, "pixExpirationDate", void 0);
|
|
462
462
|
|
|
463
|
-
class ShippingMethod extends BaseModel {
|
|
464
|
-
identifierFields() {
|
|
465
|
-
return ['id'];
|
|
466
|
-
}
|
|
463
|
+
class ShippingMethod extends BaseModel {
|
|
464
|
+
identifierFields() {
|
|
465
|
+
return ['id'];
|
|
466
|
+
}
|
|
467
467
|
}
|
|
468
468
|
|
|
469
|
-
class CheckoutSubscription extends BaseModel {
|
|
470
|
-
identifierFields() {
|
|
471
|
-
return ['id'];
|
|
472
|
-
}
|
|
469
|
+
class CheckoutSubscription extends BaseModel {
|
|
470
|
+
identifierFields() {
|
|
471
|
+
return ['id'];
|
|
472
|
+
}
|
|
473
473
|
}
|
|
474
474
|
|
|
475
|
-
class SubscriptionPlan extends BaseModel {
|
|
476
|
-
identifierFields() {
|
|
477
|
-
return ['id'];
|
|
478
|
-
}
|
|
475
|
+
class SubscriptionPlan extends BaseModel {
|
|
476
|
+
identifierFields() {
|
|
477
|
+
return ['id'];
|
|
478
|
+
}
|
|
479
479
|
}
|
|
480
480
|
|
|
481
|
-
class Buy2Win extends BaseModel {
|
|
482
|
-
identifierFields() {
|
|
483
|
-
return ['id'];
|
|
484
|
-
}
|
|
481
|
+
class Buy2Win extends BaseModel {
|
|
482
|
+
identifierFields() {
|
|
483
|
+
return ['id'];
|
|
484
|
+
}
|
|
485
485
|
}
|
|
486
486
|
|
|
487
|
-
class Home extends BaseModel {
|
|
488
|
-
identifierFields() {
|
|
489
|
-
return ['id'];
|
|
490
|
-
}
|
|
487
|
+
class Home extends BaseModel {
|
|
488
|
+
identifierFields() {
|
|
489
|
+
return ['id'];
|
|
490
|
+
}
|
|
491
491
|
}
|
|
492
492
|
|
|
493
|
-
class ShopMenu extends BaseModel {
|
|
494
|
-
identifierFields() {
|
|
495
|
-
return ['id'];
|
|
496
|
-
}
|
|
493
|
+
class ShopMenu extends BaseModel {
|
|
494
|
+
identifierFields() {
|
|
495
|
+
return ['id'];
|
|
496
|
+
}
|
|
497
497
|
}
|
|
498
498
|
|
|
499
|
-
class InvalidArgumentError extends Error {
|
|
500
|
-
constructor(message) {
|
|
501
|
-
super(message);
|
|
502
|
-
this.message = message;
|
|
503
|
-
}
|
|
499
|
+
class InvalidArgumentError extends Error {
|
|
500
|
+
constructor(message) {
|
|
501
|
+
super(message);
|
|
502
|
+
this.message = message;
|
|
503
|
+
}
|
|
504
504
|
}
|
|
505
505
|
|
|
506
|
-
class RequiredArgumentError extends Error {
|
|
507
|
-
constructor(args) {
|
|
508
|
-
super(`Required arguments: ${args.join(', ')}`);
|
|
509
|
-
this.args = args;
|
|
510
|
-
this.arguments = args;
|
|
511
|
-
}
|
|
506
|
+
class RequiredArgumentError extends Error {
|
|
507
|
+
constructor(args) {
|
|
508
|
+
super(`Required arguments: ${args.join(', ')}`);
|
|
509
|
+
this.args = args;
|
|
510
|
+
this.arguments = args;
|
|
511
|
+
}
|
|
512
512
|
}
|
|
513
513
|
|
|
514
|
-
class NotFoundError extends Error {
|
|
515
|
-
constructor(message) {
|
|
516
|
-
super(message);
|
|
517
|
-
this.message = message;
|
|
518
|
-
}
|
|
514
|
+
class NotFoundError extends Error {
|
|
515
|
+
constructor(message) {
|
|
516
|
+
super(message);
|
|
517
|
+
this.message = message;
|
|
518
|
+
}
|
|
519
519
|
}
|
|
520
520
|
|
|
521
|
-
class DuplicatedResultsError extends Error {
|
|
522
|
-
constructor(message) {
|
|
523
|
-
super(message);
|
|
524
|
-
this.message = message;
|
|
525
|
-
}
|
|
521
|
+
class DuplicatedResultsError extends Error {
|
|
522
|
+
constructor(message) {
|
|
523
|
+
super(message);
|
|
524
|
+
this.message = message;
|
|
525
|
+
}
|
|
526
526
|
}
|
|
527
527
|
|
|
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
|
-
};
|
|
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
|
+
};
|
|
551
551
|
};
|
|
552
552
|
|
|
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
|
-
};
|
|
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
|
+
};
|
|
567
567
|
};
|
|
568
568
|
|
|
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
|
-
};
|
|
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
|
+
};
|
|
588
588
|
};
|
|
589
589
|
|
|
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
|
-
};
|
|
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
|
+
};
|
|
649
649
|
};
|
|
650
650
|
|
|
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
|
-
};
|
|
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
|
+
};
|
|
677
677
|
};
|
|
678
678
|
|
|
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
|
-
};
|
|
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
|
+
};
|
|
718
718
|
};
|
|
719
719
|
|
|
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
|
-
};
|
|
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
|
+
};
|
|
735
735
|
};
|
|
736
736
|
|
|
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
|
-
};
|
|
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
|
+
};
|
|
746
746
|
};
|
|
747
747
|
|
|
748
|
-
const withCrudFirestore = (MixinBase) => {
|
|
749
|
-
return class CrudFirestore extends withUpdateFirestore(withGetFirestore(withFindFirestore(withDeleteFirestore(withCreateFirestore(MixinBase))))) {
|
|
750
|
-
};
|
|
748
|
+
const withCrudFirestore = (MixinBase) => {
|
|
749
|
+
return class CrudFirestore extends withUpdateFirestore(withGetFirestore(withFindFirestore(withDeleteFirestore(withCreateFirestore(MixinBase))))) {
|
|
750
|
+
};
|
|
751
751
|
};
|
|
752
752
|
|
|
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
|
-
}
|
|
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
|
+
}
|
|
760
760
|
}
|
|
761
761
|
|
|
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
|
-
return user;
|
|
777
|
-
});
|
|
778
|
-
}
|
|
779
|
-
getBeautyProfile(userId) {
|
|
780
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
781
|
-
const beautyProfile = yield this.collection()
|
|
782
|
-
.doc(userId)
|
|
783
|
-
.collection('CX')
|
|
784
|
-
.withConverter(this.buildBeautyProfileModelInstance())
|
|
785
|
-
.doc('beautyProfile')
|
|
786
|
-
.get();
|
|
787
|
-
return beautyProfile.data();
|
|
788
|
-
});
|
|
789
|
-
}
|
|
790
|
-
buildBeautyProfileModelInstance() {
|
|
791
|
-
return {
|
|
792
|
-
toFirestore: (data) => data.toPlain(),
|
|
793
|
-
fromFirestore: (snap) => BeautyProfile.toInstance(snap.data()),
|
|
794
|
-
};
|
|
795
|
-
}
|
|
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
|
+
return user;
|
|
777
|
+
});
|
|
778
|
+
}
|
|
779
|
+
getBeautyProfile(userId) {
|
|
780
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
781
|
+
const beautyProfile = yield this.collection()
|
|
782
|
+
.doc(userId)
|
|
783
|
+
.collection('CX')
|
|
784
|
+
.withConverter(this.buildBeautyProfileModelInstance())
|
|
785
|
+
.doc('beautyProfile')
|
|
786
|
+
.get();
|
|
787
|
+
return beautyProfile.data();
|
|
788
|
+
});
|
|
789
|
+
}
|
|
790
|
+
buildBeautyProfileModelInstance() {
|
|
791
|
+
return {
|
|
792
|
+
toFirestore: (data) => data.toPlain(),
|
|
793
|
+
fromFirestore: (snap) => BeautyProfile.toInstance(snap.data()),
|
|
794
|
+
};
|
|
795
|
+
}
|
|
796
796
|
}
|
|
797
797
|
|
|
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
|
-
}
|
|
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
|
+
}
|
|
807
807
|
}
|
|
808
808
|
|
|
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
|
-
}
|
|
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
|
+
}
|
|
818
818
|
}
|
|
819
819
|
|
|
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
|
-
}
|
|
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
|
+
}
|
|
829
829
|
}
|
|
830
830
|
|
|
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
|
-
}
|
|
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
|
+
}
|
|
840
840
|
}
|
|
841
841
|
|
|
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
|
-
}
|
|
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
|
+
}
|
|
885
909
|
}
|
|
886
910
|
|
|
887
|
-
class ProductFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
888
|
-
constructor(firestore) {
|
|
889
|
-
super();
|
|
890
|
-
this.firestore = firestore;
|
|
891
|
-
this.collectionName = 'products';
|
|
892
|
-
this.model = Product;
|
|
893
|
-
}
|
|
894
|
-
getBySlug(slug, shop) {
|
|
895
|
-
var _a;
|
|
896
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
897
|
-
const result = yield this.find([
|
|
898
|
-
{ slug: { operator: Where.EQUALS, value: slug } },
|
|
899
|
-
{ shopAvailability: { operator: Where.IN, value: [shop] } },
|
|
900
|
-
]);
|
|
901
|
-
return (_a = result === null || result === void 0 ? void 0 : result.data) === null || _a === void 0 ? void 0 : _a.shift();
|
|
902
|
-
});
|
|
903
|
-
}
|
|
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
|
+
}
|
|
904
928
|
}
|
|
905
929
|
|
|
906
|
-
class ProductVariantFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), Product) {
|
|
907
|
-
constructor(firestore, parentRepository) {
|
|
908
|
-
super();
|
|
909
|
-
this.firestore = firestore;
|
|
910
|
-
this.parentRepository = parentRepository;
|
|
911
|
-
this.collectionName = 'variants';
|
|
912
|
-
this.parentIdField = 'productId';
|
|
913
|
-
this.model = Variant;
|
|
914
|
-
}
|
|
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
|
+
}
|
|
915
939
|
}
|
|
916
940
|
|
|
917
|
-
class CheckoutFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
918
|
-
constructor(firestore) {
|
|
919
|
-
super();
|
|
920
|
-
this.firestore = firestore;
|
|
921
|
-
this.collectionName = 'checkouts';
|
|
922
|
-
this.model = Checkout;
|
|
923
|
-
}
|
|
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
|
+
}
|
|
924
948
|
}
|
|
925
949
|
|
|
926
|
-
class CouponFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
927
|
-
constructor(firestore) {
|
|
928
|
-
super();
|
|
929
|
-
this.firestore = firestore;
|
|
930
|
-
this.collectionName = 'coupons';
|
|
931
|
-
this.model = Coupon;
|
|
932
|
-
}
|
|
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
|
+
}
|
|
933
957
|
}
|
|
934
958
|
|
|
935
|
-
class OrderFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
936
|
-
constructor(firestore) {
|
|
937
|
-
super();
|
|
938
|
-
this.firestore = firestore;
|
|
939
|
-
this.collectionName = 'orders';
|
|
940
|
-
this.model = Order;
|
|
941
|
-
}
|
|
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
|
+
}
|
|
942
966
|
}
|
|
943
967
|
|
|
944
|
-
class PaymentFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
945
|
-
constructor(firestore) {
|
|
946
|
-
super();
|
|
947
|
-
this.firestore = firestore;
|
|
948
|
-
this.collectionName = 'payments';
|
|
949
|
-
this.model = Payment;
|
|
950
|
-
}
|
|
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
|
+
}
|
|
951
975
|
}
|
|
952
976
|
|
|
953
|
-
class CheckoutSubscriptionFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
954
|
-
constructor(firestore) {
|
|
955
|
-
super();
|
|
956
|
-
this.firestore = firestore;
|
|
957
|
-
this.collectionName = 'checkoutsSubscription';
|
|
958
|
-
this.model = CheckoutSubscription;
|
|
959
|
-
}
|
|
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
|
+
}
|
|
960
984
|
}
|
|
961
985
|
|
|
962
|
-
class SubscriptionPlanFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
963
|
-
constructor(firestore) {
|
|
964
|
-
super();
|
|
965
|
-
this.firestore = firestore;
|
|
966
|
-
this.collectionName = 'subscriptionPlans';
|
|
967
|
-
this.model = SubscriptionPlan;
|
|
968
|
-
}
|
|
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
|
+
}
|
|
969
993
|
}
|
|
970
994
|
|
|
971
|
-
class Buy2WinFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
972
|
-
constructor(firestore) {
|
|
973
|
-
super();
|
|
974
|
-
this.firestore = firestore;
|
|
975
|
-
this.collectionName = 'buy2win';
|
|
976
|
-
this.model = Buy2Win;
|
|
977
|
-
}
|
|
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
|
+
}
|
|
978
1002
|
}
|
|
979
1003
|
|
|
980
|
-
class HomeFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
981
|
-
constructor(firestore) {
|
|
982
|
-
super();
|
|
983
|
-
this.firestore = firestore;
|
|
984
|
-
this.collectionName = 'dms';
|
|
985
|
-
this.model = Home;
|
|
986
|
-
}
|
|
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
|
+
}
|
|
987
1011
|
}
|
|
988
1012
|
|
|
989
|
-
class ShopMenuFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
990
|
-
constructor(firestore) {
|
|
991
|
-
super();
|
|
992
|
-
this.firestore = firestore;
|
|
993
|
-
this.collectionName = 'shopMenus';
|
|
994
|
-
this.model = ShopMenu;
|
|
995
|
-
}
|
|
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
|
+
}
|
|
996
1020
|
}
|
|
997
1021
|
|
|
998
|
-
class AuthenticationFirebaseAuthService {
|
|
999
|
-
constructor(firebaseAuth) {
|
|
1000
|
-
this.firebaseAuth = firebaseAuth;
|
|
1001
|
-
}
|
|
1002
|
-
signInWithEmailAndPassword(data) {
|
|
1003
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1004
|
-
const credentials = yield this.firebaseAuth.signInWithEmailAndPassword(data.email, data.password);
|
|
1005
|
-
const user = credentials.user;
|
|
1006
|
-
return { id: user.uid, displayName: user.displayName, email: user.email, phone: user.phoneNumber };
|
|
1007
|
-
});
|
|
1008
|
-
}
|
|
1009
|
-
signInWithGoogle() {
|
|
1010
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1011
|
-
const credentials = yield this.firebaseAuth.signInWithPopup(new firebase$1.auth.GoogleAuthProvider());
|
|
1012
|
-
const user = credentials.user;
|
|
1013
|
-
return { id: user.uid, displayName: user.displayName, email: user.email, phone: user.phoneNumber };
|
|
1014
|
-
});
|
|
1015
|
-
}
|
|
1016
|
-
signOut() {
|
|
1017
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1018
|
-
this.firebaseAuth.signOut();
|
|
1019
|
-
});
|
|
1020
|
-
}
|
|
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
|
+
}
|
|
1021
1045
|
}
|
|
1022
1046
|
|
|
1023
|
-
/**
|
|
1024
|
-
* Generated bundle index. Do not edit.
|
|
1047
|
+
/**
|
|
1048
|
+
* Generated bundle index. Do not edit.
|
|
1025
1049
|
*/
|
|
1026
1050
|
|
|
1027
1051
|
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 };
|