@infrab4a/connect 0.4.4 → 0.4.6
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 +1542 -1462
- 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 -0
- package/esm2015/lib/errors/index.js +5 -4
- 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 -62
- 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 +50 -12
- package/esm2015/lib/infra/firebase/firestore/repositories/catalog/index.js +4 -4
- package/esm2015/lib/infra/firebase/firestore/repositories/catalog/product-firestore.repository.js +12 -12
- 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 +945 -900
- 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 +31 -31
- 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 +11 -4
- package/lib/domain/catalog/repositories/index.d.ts +3 -3
- package/lib/domain/catalog/repositories/product.repository.d.ts +4 -4
- 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 -0
- package/lib/errors/index.d.ts +4 -3
- 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 +54 -49
- package/lib/infra/firebase/firestore/repositories/catalog/index.d.ts +3 -3
- package/lib/infra/firebase/firestore/repositories/catalog/product-firestore.repository.d.ts +49 -49
- 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,968 +6,1013 @@ 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
|
-
}
|
|
19
|
-
}
|
|
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";
|
|
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
|
+
}
|
|
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";
|
|
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
|
-
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
class SubscriptionPayment extends BaseModel {
|
|
119
|
-
identifierFields() {
|
|
120
|
-
return ['id'];
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
class Subscription extends BaseModel {
|
|
125
|
-
identifierFields() {
|
|
126
|
-
return ['id'];
|
|
127
|
-
}
|
|
128
|
-
}
|
|
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
|
-
}
|
|
144
|
-
}
|
|
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
|
-
}
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
class Address extends BaseModel {
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
class UserAddress extends Address {
|
|
161
|
-
identifierFields() {
|
|
162
|
-
return ['id'];
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
class Base {
|
|
167
|
-
constructor(...args) {
|
|
168
|
-
Object.assign(this, ...args);
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
class UnauthorizedError extends Error {
|
|
173
|
-
constructor(message) {
|
|
174
|
-
super(message);
|
|
175
|
-
this.message = message;
|
|
176
|
-
}
|
|
177
|
-
}
|
|
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
|
-
}
|
|
213
|
-
}
|
|
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
|
-
}
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
var Shops;
|
|
227
|
-
(function (Shops) {
|
|
228
|
-
Shops["MENSMARKET"] = "Men's Market";
|
|
229
|
-
Shops["GLAMSHOP"] = "Glamshop";
|
|
112
|
+
class Edition extends BaseModel {
|
|
113
|
+
identifierFields() {
|
|
114
|
+
return ['id'];
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
class SubscriptionPayment extends BaseModel {
|
|
119
|
+
identifierFields() {
|
|
120
|
+
return ['id'];
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
class Subscription extends BaseModel {
|
|
125
|
+
identifierFields() {
|
|
126
|
+
return ['id'];
|
|
127
|
+
}
|
|
128
|
+
}
|
|
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
|
+
}
|
|
144
|
+
}
|
|
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
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
class Address extends BaseModel {
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
class UserAddress extends Address {
|
|
161
|
+
identifierFields() {
|
|
162
|
+
return ['id'];
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
class Base {
|
|
167
|
+
constructor(...args) {
|
|
168
|
+
Object.assign(this, ...args);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
class UnauthorizedError extends Error {
|
|
173
|
+
constructor(message) {
|
|
174
|
+
super(message);
|
|
175
|
+
this.message = message;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
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
|
+
}
|
|
213
|
+
}
|
|
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
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
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
|
-
}
|
|
311
|
-
}
|
|
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";
|
|
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
|
+
}
|
|
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";
|
|
323
323
|
})(OrderStatus || (OrderStatus = {}));
|
|
324
324
|
|
|
325
|
-
class Checkout extends BaseModel {
|
|
326
|
-
identifierFields() {
|
|
327
|
-
return ['id'];
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
class LineItem extends Product {
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
class Order extends Checkout {
|
|
335
|
-
}
|
|
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' })
|
|
325
|
+
class Checkout extends BaseModel {
|
|
326
|
+
identifierFields() {
|
|
327
|
+
return ['id'];
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
class LineItem extends Product {
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
class Order extends Checkout {
|
|
335
|
+
}
|
|
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' })
|
|
461
461
|
], Payment.prototype, "pixExpirationDate", void 0);
|
|
462
462
|
|
|
463
|
-
class ShippingMethod extends BaseModel {
|
|
464
|
-
identifierFields() {
|
|
465
|
-
return ['id'];
|
|
466
|
-
}
|
|
467
|
-
}
|
|
468
|
-
|
|
469
|
-
class CheckoutSubscription extends BaseModel {
|
|
470
|
-
identifierFields() {
|
|
471
|
-
return ['id'];
|
|
472
|
-
}
|
|
473
|
-
}
|
|
474
|
-
|
|
475
|
-
class SubscriptionPlan extends BaseModel {
|
|
476
|
-
identifierFields() {
|
|
477
|
-
return ['id'];
|
|
478
|
-
}
|
|
479
|
-
}
|
|
480
|
-
|
|
481
|
-
class Buy2Win extends BaseModel {
|
|
482
|
-
identifierFields() {
|
|
483
|
-
return ['id'];
|
|
484
|
-
}
|
|
485
|
-
}
|
|
486
|
-
|
|
487
|
-
class Home extends BaseModel {
|
|
488
|
-
identifierFields() {
|
|
489
|
-
return ['id'];
|
|
490
|
-
}
|
|
491
|
-
}
|
|
492
|
-
|
|
493
|
-
class ShopMenu extends BaseModel {
|
|
494
|
-
identifierFields() {
|
|
495
|
-
return ['id'];
|
|
496
|
-
}
|
|
497
|
-
}
|
|
498
|
-
|
|
499
|
-
class InvalidArgumentError extends Error {
|
|
500
|
-
constructor(message) {
|
|
501
|
-
super(message);
|
|
502
|
-
this.message = message;
|
|
503
|
-
}
|
|
504
|
-
}
|
|
505
|
-
|
|
506
|
-
class RequiredArgumentError extends Error {
|
|
507
|
-
constructor(args) {
|
|
508
|
-
super(`Required arguments: ${args.join(', ')}`);
|
|
509
|
-
this.args = args;
|
|
510
|
-
this.arguments = args;
|
|
511
|
-
}
|
|
512
|
-
}
|
|
513
|
-
|
|
514
|
-
class NotFoundError extends Error {
|
|
515
|
-
constructor(message) {
|
|
516
|
-
super(message);
|
|
517
|
-
this.message = message;
|
|
518
|
-
}
|
|
519
|
-
}
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
463
|
+
class ShippingMethod extends BaseModel {
|
|
464
|
+
identifierFields() {
|
|
465
|
+
return ['id'];
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
class CheckoutSubscription extends BaseModel {
|
|
470
|
+
identifierFields() {
|
|
471
|
+
return ['id'];
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
class SubscriptionPlan extends BaseModel {
|
|
476
|
+
identifierFields() {
|
|
477
|
+
return ['id'];
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
class Buy2Win extends BaseModel {
|
|
482
|
+
identifierFields() {
|
|
483
|
+
return ['id'];
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
class Home extends BaseModel {
|
|
488
|
+
identifierFields() {
|
|
489
|
+
return ['id'];
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
class ShopMenu extends BaseModel {
|
|
494
|
+
identifierFields() {
|
|
495
|
+
return ['id'];
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
class InvalidArgumentError extends Error {
|
|
500
|
+
constructor(message) {
|
|
501
|
+
super(message);
|
|
502
|
+
this.message = message;
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
class RequiredArgumentError extends Error {
|
|
507
|
+
constructor(args) {
|
|
508
|
+
super(`Required arguments: ${args.join(', ')}`);
|
|
509
|
+
this.args = args;
|
|
510
|
+
this.arguments = args;
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
class NotFoundError extends Error {
|
|
515
|
+
constructor(message) {
|
|
516
|
+
super(message);
|
|
517
|
+
this.message = message;
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
class DuplicatedResultsError extends Error {
|
|
522
|
+
constructor(message) {
|
|
523
|
+
super(message);
|
|
524
|
+
this.message = message;
|
|
525
|
+
}
|
|
526
|
+
}
|
|
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
|
+
};
|
|
544
551
|
};
|
|
545
552
|
|
|
546
|
-
const withHelpers = (MixinBase) => {
|
|
547
|
-
return class extends MixinBase {
|
|
548
|
-
toArray(snapShot) {
|
|
549
|
-
if (Array.isArray(snapShot)) {
|
|
550
|
-
return snapShot.map((doc) => doc.data());
|
|
551
|
-
}
|
|
552
|
-
else {
|
|
553
|
-
return snapShot.docs.map((doc) => doc.data());
|
|
554
|
-
}
|
|
555
|
-
}
|
|
556
|
-
isSubCollection(repository) {
|
|
557
|
-
return !isNil(Object.keys(this).find((key) => key === 'parentRepository'));
|
|
558
|
-
}
|
|
559
|
-
};
|
|
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
|
+
};
|
|
560
567
|
};
|
|
561
568
|
|
|
562
|
-
const withGetFirestore = (MixinBase) => {
|
|
563
|
-
return class GetFirestore extends MixinBase {
|
|
564
|
-
get(identifiers) {
|
|
565
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
566
|
-
const doc = yield this.collection(this.buildCollectionPathForGet(identifiers))
|
|
567
|
-
.doc(Object.values(identifiers).shift().toString())
|
|
568
|
-
.get();
|
|
569
|
-
const data = doc.data();
|
|
570
|
-
if (isNil(data))
|
|
571
|
-
throw new NotFoundError(`Document ${JSON.stringify(identifiers)} not found`);
|
|
572
|
-
return data;
|
|
573
|
-
});
|
|
574
|
-
}
|
|
575
|
-
buildCollectionPathForGet(identifiers) {
|
|
576
|
-
return this.isSubCollection(this)
|
|
577
|
-
? `${this.parentRepository.collectionName}/${identifiers[this.parentIdField]}/${this.collectionName}`
|
|
578
|
-
: this.collectionName;
|
|
579
|
-
}
|
|
580
|
-
};
|
|
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
|
+
};
|
|
581
588
|
};
|
|
582
589
|
|
|
583
|
-
const withFindFirestore = (MixinBase) => {
|
|
584
|
-
return class FindFirestore extends MixinBase {
|
|
585
|
-
constructor() {
|
|
586
|
-
super(...arguments);
|
|
587
|
-
this.makeFirestoreWhere = (queryReference, filter) => Object.keys(filter).reduce((query, fieldName) => this.buildWhereSentence(query, fieldName, filter[fieldName]), queryReference);
|
|
588
|
-
this.buildWhereSentence = (queryReference, fieldName, options) => {
|
|
589
|
-
if (this.isSubCollection(this) && fieldName === this.parentIdField)
|
|
590
|
-
return queryReference;
|
|
591
|
-
if (options.operator === Where.LIKE) {
|
|
592
|
-
queryReference = queryReference.where(fieldName.toString(), '>=', options.value);
|
|
593
|
-
queryReference = queryReference.where(fieldName.toString(), '<=', `${options.value}~`);
|
|
594
|
-
return queryReference;
|
|
595
|
-
}
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
query = this.
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
if (
|
|
626
|
-
query = query.
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
if (data.length
|
|
636
|
-
return
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
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
|
+
};
|
|
640
649
|
};
|
|
641
650
|
|
|
642
|
-
const withCreateFirestore = (MixinBase) => {
|
|
643
|
-
return class CreateFirestore extends MixinBase {
|
|
644
|
-
create(data) {
|
|
645
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
646
|
-
const docRef = yield this.save(this.model.toInstance(data));
|
|
647
|
-
const doc = yield docRef.get();
|
|
648
|
-
return doc.data();
|
|
649
|
-
});
|
|
650
|
-
}
|
|
651
|
-
save(data) {
|
|
652
|
-
var _a;
|
|
653
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
654
|
-
const id = (_a = data[data.identifierFields().shift()]) === null || _a === void 0 ? void 0 : _a.toString();
|
|
655
|
-
if (isEmpty(id))
|
|
656
|
-
return this.collection(this.buildCollectionPathForAdd(data)).add(data);
|
|
657
|
-
const docRef = this.collection().doc(id);
|
|
658
|
-
yield docRef.set(data);
|
|
659
|
-
return docRef;
|
|
660
|
-
});
|
|
661
|
-
}
|
|
662
|
-
buildCollectionPathForAdd(identifiers) {
|
|
663
|
-
return this.isSubCollection(this)
|
|
664
|
-
? `${this.parentRepository.collectionName}/${identifiers[this.parentIdField]}/${this.collectionName}`
|
|
665
|
-
: this.collectionName;
|
|
666
|
-
}
|
|
667
|
-
};
|
|
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
|
+
};
|
|
668
677
|
};
|
|
669
678
|
|
|
670
|
-
const withUpdateFirestore = (MixinBase) => {
|
|
671
|
-
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; };
|
|
672
|
-
const getValueByAction = (options) => {
|
|
673
|
-
const fieldValues = firebase.firestore.FieldValue;
|
|
674
|
-
if (isNil(options.action))
|
|
675
|
-
return options;
|
|
676
|
-
if (options.action === UpdateOptionActions.REMOVE_FIELD)
|
|
677
|
-
return fieldValues.delete();
|
|
678
|
-
if (Array.isArray(options.value)) {
|
|
679
|
-
if (options.action === UpdateOptionActions.MERGE)
|
|
680
|
-
return fieldValues.arrayUnion(...options.value);
|
|
681
|
-
if (options.action === UpdateOptionActions.REMOVE)
|
|
682
|
-
return fieldValues.arrayRemove(...options.value);
|
|
683
|
-
}
|
|
684
|
-
return options.value;
|
|
685
|
-
};
|
|
686
|
-
return class UpdateFirestore extends MixinBase {
|
|
687
|
-
update(data) {
|
|
688
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
689
|
-
const model = new this.model();
|
|
690
|
-
const keyField = model.identifierFields().shift();
|
|
691
|
-
const docRef = this.collection(this.buildCollectionPathForUpdate(data)).doc(getValueFromParams(data, keyField).toString());
|
|
692
|
-
yield docRef.update(this.paramsToPlain(data));
|
|
693
|
-
const doc = yield docRef.get();
|
|
694
|
-
return doc.data();
|
|
695
|
-
});
|
|
696
|
-
}
|
|
697
|
-
buildCollectionPathForUpdate(identifiers) {
|
|
698
|
-
return this.isSubCollection(this)
|
|
699
|
-
? `${this.parentRepository.collectionName}/${getValueFromParams(identifiers, this.parentIdField)}/${this.collectionName}`
|
|
700
|
-
: this.collectionName;
|
|
701
|
-
}
|
|
702
|
-
paramsToPlain(params) {
|
|
703
|
-
const model = this.model;
|
|
704
|
-
if (params instanceof model)
|
|
705
|
-
return params.toPlain();
|
|
706
|
-
return Object.keys(params).reduce((data, currentKey) => (Object.assign(Object.assign({}, data), { [currentKey]: getValueByAction(params[currentKey]) })), {});
|
|
707
|
-
}
|
|
708
|
-
};
|
|
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
|
+
};
|
|
709
718
|
};
|
|
710
719
|
|
|
711
|
-
const withDeleteFirestore = (MixinBase) => {
|
|
712
|
-
return class DeleteFirestore extends MixinBase {
|
|
713
|
-
delete(identifiers) {
|
|
714
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
715
|
-
yield this.collection(this.buildCollectionPathForRemove(identifiers))
|
|
716
|
-
.doc(Object.values(identifiers).shift().toString())
|
|
717
|
-
.delete();
|
|
718
|
-
});
|
|
719
|
-
}
|
|
720
|
-
buildCollectionPathForRemove(identifiers) {
|
|
721
|
-
return this.isSubCollection(this)
|
|
722
|
-
? `${this.parentRepository.collectionName}/${identifiers[this.parentIdField]}/${this.collectionName}`
|
|
723
|
-
: this.collectionName;
|
|
724
|
-
}
|
|
725
|
-
};
|
|
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
|
+
};
|
|
726
735
|
};
|
|
727
736
|
|
|
728
|
-
const withSubCollection = (MixinBase, ParentModel) => {
|
|
729
|
-
return class SubCollectionMix extends MixinBase {
|
|
730
|
-
constructor(...args) {
|
|
731
|
-
super(args);
|
|
732
|
-
}
|
|
733
|
-
collection(path) {
|
|
734
|
-
return super.collection(path);
|
|
735
|
-
}
|
|
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
746
|
};
|
|
738
747
|
|
|
739
|
-
const withCrudFirestore = (MixinBase) => {
|
|
740
|
-
return class CrudFirestore extends withUpdateFirestore(withGetFirestore(withFindFirestore(withDeleteFirestore(withCreateFirestore(MixinBase))))) {
|
|
741
|
-
};
|
|
748
|
+
const withCrudFirestore = (MixinBase) => {
|
|
749
|
+
return class CrudFirestore extends withUpdateFirestore(withGetFirestore(withFindFirestore(withDeleteFirestore(withCreateFirestore(MixinBase))))) {
|
|
750
|
+
};
|
|
742
751
|
};
|
|
743
752
|
|
|
744
|
-
class SubscriptionFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
745
|
-
constructor(firestore) {
|
|
746
|
-
super();
|
|
747
|
-
this.firestore = firestore;
|
|
748
|
-
this.collectionName = 'subscription';
|
|
749
|
-
this.model = Subscription;
|
|
750
|
-
}
|
|
751
|
-
}
|
|
752
|
-
|
|
753
|
-
class UserFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
754
|
-
constructor(firestore) {
|
|
755
|
-
super();
|
|
756
|
-
this.firestore = firestore;
|
|
757
|
-
this.collectionName = 'users';
|
|
758
|
-
this.model = User;
|
|
759
|
-
}
|
|
760
|
-
get(identifiers) {
|
|
761
|
-
const _super = Object.create(null, {
|
|
762
|
-
get: { get: () => super.get }
|
|
763
|
-
});
|
|
764
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
765
|
-
const user = yield _super.get.call(this, { id: identifiers.id });
|
|
766
|
-
user.beautyProfile = yield this.getBeautyProfile(user.id);
|
|
767
|
-
return user;
|
|
768
|
-
});
|
|
769
|
-
}
|
|
770
|
-
getBeautyProfile(userId) {
|
|
771
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
772
|
-
const beautyProfile = yield this.collection()
|
|
773
|
-
.doc(userId)
|
|
774
|
-
.collection('CX')
|
|
775
|
-
.withConverter(this.buildBeautyProfileModelInstance())
|
|
776
|
-
.doc('beautyProfile')
|
|
777
|
-
.get();
|
|
778
|
-
return beautyProfile.data();
|
|
779
|
-
});
|
|
780
|
-
}
|
|
781
|
-
buildBeautyProfileModelInstance() {
|
|
782
|
-
return {
|
|
783
|
-
toFirestore: (data) => data.toPlain(),
|
|
784
|
-
fromFirestore: (snap) => BeautyProfile.toInstance(snap.data()),
|
|
785
|
-
};
|
|
786
|
-
}
|
|
787
|
-
}
|
|
788
|
-
|
|
789
|
-
class SubscriptionEditionFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), Subscription) {
|
|
790
|
-
constructor(firestore, parentRepository) {
|
|
791
|
-
super();
|
|
792
|
-
this.firestore = firestore;
|
|
793
|
-
this.parentRepository = parentRepository;
|
|
794
|
-
this.collectionName = 'editions';
|
|
795
|
-
this.parentIdField = 'subscriptionId';
|
|
796
|
-
this.model = Edition;
|
|
797
|
-
}
|
|
798
|
-
}
|
|
799
|
-
|
|
800
|
-
class UserBeautyProfileFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), User) {
|
|
801
|
-
constructor(firestore, parentRepository) {
|
|
802
|
-
super();
|
|
803
|
-
this.firestore = firestore;
|
|
804
|
-
this.parentRepository = parentRepository;
|
|
805
|
-
this.collectionName = 'CX';
|
|
806
|
-
this.parentIdField = 'userId';
|
|
807
|
-
this.model = BeautyProfile;
|
|
808
|
-
}
|
|
809
|
-
}
|
|
810
|
-
|
|
811
|
-
class UserAddressFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), User) {
|
|
812
|
-
constructor(firestore, parentRepository) {
|
|
813
|
-
super();
|
|
814
|
-
this.firestore = firestore;
|
|
815
|
-
this.parentRepository = parentRepository;
|
|
816
|
-
this.collectionName = 'address';
|
|
817
|
-
this.parentIdField = 'userId';
|
|
818
|
-
this.model = UserAddress;
|
|
819
|
-
}
|
|
820
|
-
}
|
|
821
|
-
|
|
822
|
-
class SubscriptionPaymentFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), Subscription) {
|
|
823
|
-
constructor(firestore, parentRepository) {
|
|
824
|
-
super();
|
|
825
|
-
this.firestore = firestore;
|
|
826
|
-
this.parentRepository = parentRepository;
|
|
827
|
-
this.collectionName = 'Payments';
|
|
828
|
-
this.parentIdField = 'subscriptionId';
|
|
829
|
-
this.model = SubscriptionPayment;
|
|
830
|
-
}
|
|
831
|
-
}
|
|
832
|
-
|
|
833
|
-
class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
834
|
-
constructor(firestore) {
|
|
835
|
-
super();
|
|
836
|
-
this.firestore = firestore;
|
|
837
|
-
this.collectionName = 'categories';
|
|
838
|
-
this.model = Category;
|
|
839
|
-
}
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
}
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
this
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
this.
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
this.
|
|
893
|
-
this.
|
|
894
|
-
this.model =
|
|
895
|
-
}
|
|
896
|
-
}
|
|
897
|
-
|
|
898
|
-
class
|
|
899
|
-
constructor(firestore) {
|
|
900
|
-
super();
|
|
901
|
-
this.firestore = firestore;
|
|
902
|
-
this.collectionName = '
|
|
903
|
-
this.model =
|
|
904
|
-
}
|
|
905
|
-
}
|
|
906
|
-
|
|
907
|
-
class
|
|
908
|
-
constructor(firestore) {
|
|
909
|
-
super();
|
|
910
|
-
this.firestore = firestore;
|
|
911
|
-
this.collectionName = '
|
|
912
|
-
this.model =
|
|
913
|
-
}
|
|
914
|
-
}
|
|
915
|
-
|
|
916
|
-
class
|
|
917
|
-
constructor(firestore) {
|
|
918
|
-
super();
|
|
919
|
-
this.firestore = firestore;
|
|
920
|
-
this.collectionName = '
|
|
921
|
-
this.model =
|
|
922
|
-
}
|
|
923
|
-
}
|
|
924
|
-
|
|
925
|
-
class
|
|
926
|
-
constructor(firestore) {
|
|
927
|
-
super();
|
|
928
|
-
this.firestore = firestore;
|
|
929
|
-
this.collectionName = '
|
|
930
|
-
this.model =
|
|
931
|
-
}
|
|
932
|
-
}
|
|
933
|
-
|
|
934
|
-
class
|
|
935
|
-
constructor(firestore) {
|
|
936
|
-
super();
|
|
937
|
-
this.firestore = firestore;
|
|
938
|
-
this.collectionName = '
|
|
939
|
-
this.model =
|
|
940
|
-
}
|
|
941
|
-
}
|
|
942
|
-
|
|
943
|
-
class
|
|
944
|
-
constructor(
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
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
|
+
}
|
|
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
|
+
}
|
|
796
|
+
}
|
|
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
|
+
}
|
|
807
|
+
}
|
|
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
|
+
}
|
|
818
|
+
}
|
|
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
|
+
}
|
|
829
|
+
}
|
|
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
|
+
}
|
|
840
|
+
}
|
|
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
|
+
}
|
|
885
|
+
}
|
|
886
|
+
|
|
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
|
+
}
|
|
895
|
+
|
|
896
|
+
class ProductVariantFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), Product) {
|
|
897
|
+
constructor(firestore, parentRepository) {
|
|
898
|
+
super();
|
|
899
|
+
this.firestore = firestore;
|
|
900
|
+
this.parentRepository = parentRepository;
|
|
901
|
+
this.collectionName = 'Variants';
|
|
902
|
+
this.parentIdField = 'productId';
|
|
903
|
+
this.model = Variant;
|
|
904
|
+
}
|
|
905
|
+
}
|
|
906
|
+
|
|
907
|
+
class CheckoutFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
908
|
+
constructor(firestore) {
|
|
909
|
+
super();
|
|
910
|
+
this.firestore = firestore;
|
|
911
|
+
this.collectionName = 'checkouts';
|
|
912
|
+
this.model = Checkout;
|
|
913
|
+
}
|
|
914
|
+
}
|
|
915
|
+
|
|
916
|
+
class CouponFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
917
|
+
constructor(firestore) {
|
|
918
|
+
super();
|
|
919
|
+
this.firestore = firestore;
|
|
920
|
+
this.collectionName = 'coupons';
|
|
921
|
+
this.model = Coupon;
|
|
922
|
+
}
|
|
923
|
+
}
|
|
924
|
+
|
|
925
|
+
class OrderFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
926
|
+
constructor(firestore) {
|
|
927
|
+
super();
|
|
928
|
+
this.firestore = firestore;
|
|
929
|
+
this.collectionName = 'orders';
|
|
930
|
+
this.model = Order;
|
|
931
|
+
}
|
|
932
|
+
}
|
|
933
|
+
|
|
934
|
+
class PaymentFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
935
|
+
constructor(firestore) {
|
|
936
|
+
super();
|
|
937
|
+
this.firestore = firestore;
|
|
938
|
+
this.collectionName = 'payments';
|
|
939
|
+
this.model = Payment;
|
|
940
|
+
}
|
|
941
|
+
}
|
|
942
|
+
|
|
943
|
+
class CheckoutSubscriptionFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
944
|
+
constructor(firestore) {
|
|
945
|
+
super();
|
|
946
|
+
this.firestore = firestore;
|
|
947
|
+
this.collectionName = 'checkoutsSubscription';
|
|
948
|
+
this.model = CheckoutSubscription;
|
|
949
|
+
}
|
|
950
|
+
}
|
|
951
|
+
|
|
952
|
+
class SubscriptionPlanFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
953
|
+
constructor(firestore) {
|
|
954
|
+
super();
|
|
955
|
+
this.firestore = firestore;
|
|
956
|
+
this.collectionName = 'subscriptionPlans';
|
|
957
|
+
this.model = SubscriptionPlan;
|
|
958
|
+
}
|
|
959
|
+
}
|
|
960
|
+
|
|
961
|
+
class Buy2WinFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
962
|
+
constructor(firestore) {
|
|
963
|
+
super();
|
|
964
|
+
this.firestore = firestore;
|
|
965
|
+
this.collectionName = 'buy2win';
|
|
966
|
+
this.model = Buy2Win;
|
|
967
|
+
}
|
|
968
|
+
}
|
|
969
|
+
|
|
970
|
+
class HomeFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
971
|
+
constructor(firestore) {
|
|
972
|
+
super();
|
|
973
|
+
this.firestore = firestore;
|
|
974
|
+
this.collectionName = 'dms';
|
|
975
|
+
this.model = Home;
|
|
976
|
+
}
|
|
977
|
+
}
|
|
978
|
+
|
|
979
|
+
class ShopMenuFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
980
|
+
constructor(firestore) {
|
|
981
|
+
super();
|
|
982
|
+
this.firestore = firestore;
|
|
983
|
+
this.collectionName = 'shopMenus';
|
|
984
|
+
this.model = ShopMenu;
|
|
985
|
+
}
|
|
986
|
+
}
|
|
987
|
+
|
|
988
|
+
class AuthenticationFirebaseAuthService {
|
|
989
|
+
constructor(firebaseAuth) {
|
|
990
|
+
this.firebaseAuth = firebaseAuth;
|
|
991
|
+
}
|
|
992
|
+
signInWithEmailAndPassword(data) {
|
|
993
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
994
|
+
const credentials = yield this.firebaseAuth.signInWithEmailAndPassword(data.email, data.password);
|
|
995
|
+
const user = credentials.user;
|
|
996
|
+
return { id: user.uid, displayName: user.displayName, email: user.email, phone: user.phoneNumber };
|
|
997
|
+
});
|
|
998
|
+
}
|
|
999
|
+
signInWithGoogle() {
|
|
1000
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1001
|
+
const credentials = yield this.firebaseAuth.signInWithPopup(new firebase$1.auth.GoogleAuthProvider());
|
|
1002
|
+
const user = credentials.user;
|
|
1003
|
+
return { id: user.uid, displayName: user.displayName, email: user.email, phone: user.phoneNumber };
|
|
1004
|
+
});
|
|
1005
|
+
}
|
|
1006
|
+
signOut() {
|
|
1007
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1008
|
+
this.firebaseAuth.signOut();
|
|
1009
|
+
});
|
|
1010
|
+
}
|
|
1011
|
+
}
|
|
1012
|
+
|
|
1013
|
+
/**
|
|
1014
|
+
* Generated bundle index. Do not edit.
|
|
970
1015
|
*/
|
|
971
1016
|
|
|
972
|
-
export { Address, Area, Authentication, AuthenticationFirebaseAuthService, Base, BaseModel, BeardSizes, BeautyProfile, BillingStatus, Buy2Win, Buy2WinFirestoreRepository, Category, CategoryFirestoreRepository, Checkout, CheckoutFirestoreRepository, CheckoutSubscription, CheckoutSubscriptionFirestoreRepository, CheckoutTypes, Coupon, CouponFirestoreRepository, CouponSubtypes, CouponTypes, 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 };
|
|
1017
|
+
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 };
|
|
973
1018
|
//# sourceMappingURL=infrab4a-connect.js.map
|