@infrab4a/connect 1.0.0-beta.42 → 1.0.0-beta.5
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/bundles/infrab4a-connect.umd.js +212 -2119
- package/bundles/infrab4a-connect.umd.js.map +1 -1
- package/domain/catalog/models/category.d.ts +4 -5
- package/domain/catalog/models/index.d.ts +2 -3
- package/domain/catalog/models/product.d.ts +4 -9
- package/domain/catalog/models/types/product-review.type.d.ts +8 -10
- package/domain/catalog/models/variant.d.ts +3 -7
- package/domain/catalog/repositories/category.repository.d.ts +1 -1
- package/domain/catalog/repositories/product.repository.d.ts +3 -10
- package/domain/catalog/repositories/subscription-product.repository.d.ts +1 -1
- package/domain/catalog/repositories/variant.repository.d.ts +1 -1
- package/domain/general/model/base-model-with-identifier-fields.d.ts +3 -0
- package/domain/general/model/base.model.d.ts +6 -0
- package/domain/{generic → general}/model/index.d.ts +1 -0
- package/domain/general/model/types/base-model-builder.type.d.ts +5 -0
- package/domain/{generic → general}/model/types/index.d.ts +0 -2
- package/domain/general/model/types/non-function-properties.type.d.ts +2 -0
- package/domain/general/model/types/non-function-property-name.type.d.ts +3 -0
- package/domain/general/repository/create.repository.d.ts +5 -0
- package/domain/general/repository/crud.repository.d.ts +7 -0
- package/domain/general/repository/delete.repository.d.ts +5 -0
- package/domain/{generic → general}/repository/enums/where.enum.d.ts +2 -5
- package/domain/general/repository/find.repository.d.ts +5 -0
- package/domain/general/repository/get.repository.d.ts +5 -0
- package/domain/general/repository/read.repository.d.ts +5 -0
- package/domain/{generic → general}/repository/types/index.d.ts +0 -1
- package/domain/general/repository/types/repository-find-filters.type.d.ts +14 -0
- package/domain/{generic → general}/repository/types/repository-update-params.type.d.ts +4 -4
- package/domain/general/repository/update.repository.d.ts +5 -0
- package/domain/index.d.ts +1 -1
- package/domain/location/models/address.d.ts +2 -3
- package/domain/shop-settings/models/home.d.ts +3 -3
- package/domain/shop-settings/models/shop-menu.d.ts +3 -3
- package/domain/shop-settings/repositories/home.repository.d.ts +1 -1
- package/domain/shop-settings/repositories/shop-menu.repository.d.ts +1 -1
- package/domain/shopping/models/buy-2-win.d.ts +5 -3
- package/domain/shopping/models/checkout.d.ts +9 -7
- package/domain/shopping/models/coupons/club-coupon.d.ts +7 -0
- package/domain/shopping/models/coupons/coupon.d.ts +15 -13
- package/domain/shopping/models/coupons/enums/discount-type.enum.d.ts +5 -0
- package/domain/shopping/models/coupons/enums/index.d.ts +1 -2
- package/domain/shopping/models/coupons/index.d.ts +2 -1
- package/domain/shopping/models/coupons/store-coupon.d.ts +8 -0
- package/domain/shopping/models/payment.d.ts +5 -3
- package/domain/shopping/models/shipping-method.d.ts +5 -3
- package/domain/shopping/models/subscription/checkout.d.ts +5 -3
- package/domain/shopping/models/subscription/plan.d.ts +5 -3
- package/domain/shopping/repositories/buy-2-win.repository.d.ts +1 -1
- package/domain/shopping/repositories/checkout.repository.d.ts +1 -1
- package/domain/shopping/repositories/coupon.repository.d.ts +1 -1
- package/domain/shopping/repositories/order.repository.d.ts +1 -1
- package/domain/shopping/repositories/payment.repository.d.ts +1 -1
- package/domain/shopping/repositories/subscription/checkout.repository.d.ts +1 -1
- package/domain/shopping/repositories/subscription/plan.repository.d.ts +1 -1
- package/domain/users/errors/unauthorized.error.d.ts +1 -2
- package/domain/users/errors/user-already-registered.error.d.ts +1 -2
- package/domain/users/errors/weak-password.error.d.ts +1 -2
- package/domain/users/models/beauty-profile.d.ts +5 -4
- package/domain/users/models/lead.d.ts +5 -3
- package/domain/users/models/subscription/edition.d.ts +5 -4
- package/domain/users/models/subscription/payment.d.ts +5 -4
- package/domain/users/models/subscription/subscription.d.ts +5 -3
- package/domain/users/models/user-address.d.ts +3 -3
- package/domain/users/models/user-payment-method.d.ts +4 -4
- package/domain/users/models/user.d.ts +10 -11
- package/domain/users/repositories/beauty-profile.repository.d.ts +1 -1
- package/domain/users/repositories/edition.repository.d.ts +1 -1
- package/domain/users/repositories/lead.repository.d.ts +1 -1
- package/domain/users/repositories/subscription-payment.repository.d.ts +1 -1
- package/domain/users/repositories/subscription.repository.d.ts +1 -1
- package/domain/users/repositories/user-address.repository.d.ts +1 -1
- package/domain/users/repositories/user-payment-method.repository.d.ts +1 -1
- package/domain/users/repositories/user.repository.d.ts +2 -2
- package/errors/duplicated-results.error.d.ts +1 -2
- package/errors/invalid-argument.error.d.ts +1 -2
- package/errors/not-found.error.d.ts +1 -2
- package/errors/required-argument.error.d.ts +1 -2
- package/esm2015/domain/catalog/models/category.js +2 -5
- package/esm2015/domain/catalog/models/index.js +3 -4
- package/esm2015/domain/catalog/models/product.js +2 -12
- package/esm2015/domain/catalog/models/types/product-review.type.js +1 -1
- package/esm2015/domain/catalog/models/variant.js +2 -5
- package/esm2015/domain/catalog/repositories/category.repository.js +1 -1
- package/esm2015/domain/catalog/repositories/product.repository.js +1 -1
- package/esm2015/domain/catalog/repositories/subscription-product.repository.js +1 -1
- package/esm2015/domain/catalog/repositories/variant.repository.js +1 -1
- package/esm2015/domain/{generic → general}/index.js +1 -1
- package/esm2015/domain/general/model/base-model-with-identifier-fields.js +2 -0
- package/esm2015/domain/general/model/base.model.js +13 -0
- package/esm2015/domain/{generic → general}/model/identifier-fields.js +1 -1
- package/esm2015/domain/general/model/index.js +5 -0
- package/esm2015/domain/general/model/types/base-model-builder.type.js +2 -0
- package/esm2015/domain/general/model/types/index.js +4 -0
- package/esm2015/domain/general/model/types/non-function-properties.type.js +2 -0
- package/esm2015/domain/general/model/types/non-function-property-name.type.js +2 -0
- package/esm2015/domain/general/repository/create.repository.js +2 -0
- package/esm2015/domain/general/repository/crud.repository.js +2 -0
- package/esm2015/domain/general/repository/delete.repository.js +2 -0
- package/esm2015/domain/{generic → general}/repository/enums/index.js +1 -1
- package/esm2015/domain/{generic → general}/repository/enums/update-option-actions.enum.js +1 -1
- package/esm2015/domain/general/repository/enums/where.enum.js +12 -0
- package/esm2015/domain/general/repository/find.repository.js +2 -0
- package/esm2015/domain/general/repository/get.repository.js +2 -0
- package/esm2015/domain/{generic → general}/repository/index.js +1 -1
- package/esm2015/domain/general/repository/read.repository.js +2 -0
- package/esm2015/domain/general/repository/types/index.js +6 -0
- package/esm2015/domain/general/repository/types/repository-find-filters.type.js +2 -0
- package/esm2015/domain/{generic → general}/repository/types/repository-find-result.type.js +1 -1
- package/esm2015/domain/{generic → general}/repository/types/repository-limit-options.type.js +1 -1
- package/esm2015/domain/{generic → general}/repository/types/repository-order-by-list.type.js +1 -1
- package/esm2015/domain/general/repository/types/repository-update-params.type.js +2 -0
- package/esm2015/domain/general/repository/update.repository.js +2 -0
- package/esm2015/domain/index.js +2 -2
- package/esm2015/domain/location/models/address.js +2 -5
- package/esm2015/domain/shop-settings/models/home.js +3 -3
- package/esm2015/domain/shop-settings/models/shop-menu.js +3 -3
- package/esm2015/domain/shop-settings/repositories/home.repository.js +1 -1
- package/esm2015/domain/shop-settings/repositories/shop-menu.repository.js +1 -1
- package/esm2015/domain/shopping/models/buy-2-win.js +3 -3
- package/esm2015/domain/shopping/models/checkout.js +14 -6
- package/esm2015/domain/shopping/models/coupons/club-coupon.js +18 -0
- package/esm2015/domain/shopping/models/coupons/coupon.js +12 -4
- package/esm2015/domain/shopping/models/coupons/enums/discount-type.enum.js +7 -0
- package/esm2015/domain/shopping/models/coupons/enums/index.js +2 -3
- package/esm2015/domain/shopping/models/coupons/index.js +3 -2
- package/esm2015/domain/shopping/models/coupons/store-coupon.js +23 -0
- package/esm2015/domain/shopping/models/payment.js +3 -3
- package/esm2015/domain/shopping/models/shipping-method.js +3 -3
- package/esm2015/domain/shopping/models/subscription/checkout.js +3 -3
- package/esm2015/domain/shopping/models/subscription/plan.js +3 -3
- package/esm2015/domain/shopping/repositories/buy-2-win.repository.js +1 -1
- package/esm2015/domain/shopping/repositories/checkout.repository.js +1 -1
- package/esm2015/domain/shopping/repositories/coupon.repository.js +1 -1
- package/esm2015/domain/shopping/repositories/order.repository.js +1 -1
- package/esm2015/domain/shopping/repositories/payment.repository.js +1 -1
- package/esm2015/domain/shopping/repositories/subscription/checkout.repository.js +1 -1
- package/esm2015/domain/shopping/repositories/subscription/plan.repository.js +1 -1
- package/esm2015/domain/users/errors/unauthorized.error.js +2 -3
- package/esm2015/domain/users/errors/user-already-registered.error.js +2 -3
- package/esm2015/domain/users/errors/weak-password.error.js +2 -3
- package/esm2015/domain/users/models/beauty-profile.js +4 -4
- package/esm2015/domain/users/models/lead.js +3 -3
- package/esm2015/domain/users/models/subscription/edition.js +4 -4
- package/esm2015/domain/users/models/subscription/payment.js +4 -4
- package/esm2015/domain/users/models/subscription/subscription.js +3 -3
- package/esm2015/domain/users/models/user-address.js +3 -3
- package/esm2015/domain/users/models/user-payment-method.js +4 -4
- package/esm2015/domain/users/models/user.js +5 -5
- package/esm2015/domain/users/repositories/beauty-profile.repository.js +1 -1
- package/esm2015/domain/users/repositories/edition.repository.js +1 -1
- package/esm2015/domain/users/repositories/lead.repository.js +1 -1
- package/esm2015/domain/users/repositories/subscription-payment.repository.js +1 -1
- package/esm2015/domain/users/repositories/subscription.repository.js +1 -1
- package/esm2015/domain/users/repositories/user-address.repository.js +1 -1
- package/esm2015/domain/users/repositories/user-payment-method.repository.js +1 -1
- package/esm2015/domain/users/repositories/user.repository.js +1 -1
- package/esm2015/errors/duplicated-results.error.js +2 -3
- package/esm2015/errors/invalid-argument.error.js +2 -3
- package/esm2015/errors/not-found.error.js +2 -3
- package/esm2015/errors/required-argument.error.js +2 -3
- package/esm2015/infra/elasticsearch/adapters/axios.adapter.js +1 -36
- package/esm2015/infra/elasticsearch/adapters/elastic-search.adapter.js +1 -1
- package/esm2015/infra/elasticsearch/indexes/products-index.js +1 -35
- package/esm2015/infra/firebase/auth/authentication-firebase-auth.service.js +2 -2
- package/esm2015/infra/firebase/auth/register-firebase-auth.service.js +1 -1
- package/esm2015/infra/firebase/firestore/mixins/with-create-firestore.mixin.js +2 -2
- package/esm2015/infra/firebase/firestore/mixins/with-crud-firestore.mixin.js +1 -1
- package/esm2015/infra/firebase/firestore/mixins/with-delete-firestore.mixin.js +1 -1
- package/esm2015/infra/firebase/firestore/mixins/with-find-firestore.mixin.js +10 -9
- package/esm2015/infra/firebase/firestore/mixins/with-firestore.mixin.js +6 -2
- package/esm2015/infra/firebase/firestore/mixins/with-get-firestore.mixin.js +1 -1
- package/esm2015/infra/firebase/firestore/mixins/with-helpers.mixin.js +1 -1
- package/esm2015/infra/firebase/firestore/mixins/with-sub-collection.mixin.js +1 -1
- package/esm2015/infra/firebase/firestore/mixins/with-update-firestore.mixin.js +4 -4
- package/esm2015/infra/firebase/firestore/models/user-search.js +3 -3
- package/esm2015/infra/firebase/firestore/repositories/catalog/category-firestore.repository.js +2 -4
- package/esm2015/infra/firebase/firestore/repositories/catalog/product-firestore.repository.js +8 -37
- package/esm2015/infra/firebase/firestore/repositories/shopping/coupon-firestore.repository.js +21 -11
- package/esm2015/infra/firebase/firestore/repositories/users/user-firestore.repository.js +2 -2
- package/esm2015/infra/firebase/firestore/types/firestore-sub.repository.type.js +1 -1
- package/esm2015/infra/firebase/firestore/types/firestore.helpers.type.js +1 -1
- package/esm2015/infra/firebase/firestore/types/firestore.repository.type.js +1 -1
- package/esm2015/infra/index.js +1 -2
- package/esm2015/utils/index.js +4 -6
- package/esm2015/utils/mixins/index.js +1 -2
- package/esm2015/utils/mixins/mixin-ctor.type.js +1 -1
- package/esm2015/utils/types/index.js +1 -2
- package/fesm2015/infrab4a-connect.js +141 -1375
- package/fesm2015/infrab4a-connect.js.map +1 -1
- package/infra/elasticsearch/adapters/axios.adapter.d.ts +0 -3
- package/infra/elasticsearch/adapters/elastic-search.adapter.d.ts +0 -3
- package/infra/elasticsearch/indexes/products-index.d.ts +1 -5
- package/infra/firebase/auth/authentication-firebase-auth.service.d.ts +1 -1
- package/infra/firebase/auth/register-firebase-auth.service.d.ts +1 -1
- package/infra/firebase/firestore/mixins/with-create-firestore.mixin.d.ts +16 -3
- package/infra/firebase/firestore/mixins/with-crud-firestore.mixin.d.ts +28 -3
- package/infra/firebase/firestore/mixins/with-delete-firestore.mixin.d.ts +14 -3
- package/infra/firebase/firestore/mixins/with-find-firestore.mixin.d.ts +19 -3
- package/infra/firebase/firestore/mixins/with-firestore.mixin.d.ts +14 -3
- package/infra/firebase/firestore/mixins/with-get-firestore.mixin.d.ts +14 -3
- package/infra/firebase/firestore/mixins/with-helpers.mixin.d.ts +4 -5
- package/infra/firebase/firestore/mixins/with-sub-collection.mixin.d.ts +14 -7
- package/infra/firebase/firestore/mixins/with-update-firestore.mixin.d.ts +15 -6
- package/infra/firebase/firestore/models/user-search.d.ts +3 -3
- package/infra/firebase/firestore/repositories/catalog/category-firestore.repository.d.ts +42 -1
- package/infra/firebase/firestore/repositories/catalog/product-firestore.repository.d.ts +44 -5
- package/infra/firebase/firestore/repositories/catalog/product-variant-firestore.repository.d.ts +51 -4
- package/infra/firebase/firestore/repositories/catalog/subscription-product-firestore.repository.d.ts +42 -1
- package/infra/firebase/firestore/repositories/shop-settings/home-firestore.repository.d.ts +42 -1
- package/infra/firebase/firestore/repositories/shop-settings/shop-menu-firestore.repository.d.ts +42 -1
- package/infra/firebase/firestore/repositories/shopping/buy-2-win-firestore.repository.d.ts +42 -1
- package/infra/firebase/firestore/repositories/shopping/checkout-firestore.repository.d.ts +42 -1
- package/infra/firebase/firestore/repositories/shopping/checkout-subscription-firestore.repository.d.ts +42 -1
- package/infra/firebase/firestore/repositories/shopping/coupon-firestore.repository.d.ts +42 -1
- package/infra/firebase/firestore/repositories/shopping/order-firestore.repository.d.ts +42 -1
- package/infra/firebase/firestore/repositories/shopping/payment-firestore.repository.d.ts +42 -1
- package/infra/firebase/firestore/repositories/shopping/subscription-plan-firestore.repository.d.ts +42 -1
- package/infra/firebase/firestore/repositories/users/lead-firestore.repository.d.ts +42 -1
- package/infra/firebase/firestore/repositories/users/subscription-edition-firestore.repository.d.ts +51 -4
- package/infra/firebase/firestore/repositories/users/subscription-firestore.repository.d.ts +42 -1
- package/infra/firebase/firestore/repositories/users/subscription-payment-firestore.repository.d.ts +51 -4
- package/infra/firebase/firestore/repositories/users/user-address-firestore.repository.d.ts +51 -4
- package/infra/firebase/firestore/repositories/users/user-beauty-profile-firestore.repository.d.ts +51 -4
- package/infra/firebase/firestore/repositories/users/user-firestore.repository.d.ts +42 -1
- package/infra/firebase/firestore/repositories/users/user-payment-method-firestore.repository.d.ts +51 -4
- package/infra/firebase/firestore/repositories/users/user-search-firestore.repository.d.ts +42 -1
- package/infra/firebase/firestore/types/firestore-sub.repository.type.d.ts +3 -3
- package/infra/firebase/firestore/types/firestore.helpers.type.d.ts +3 -3
- package/infra/firebase/firestore/types/firestore.repository.type.d.ts +3 -7
- package/infra/index.d.ts +0 -1
- package/package.json +3 -5
- package/utils/index.d.ts +4 -5
- package/utils/mixins/index.d.ts +0 -1
- package/utils/mixins/mixin-ctor.type.d.ts +1 -1
- package/utils/types/index.d.ts +0 -1
- package/domain/catalog/models/kit-product.d.ts +0 -12
- package/domain/generic/model/base.model.d.ts +0 -10
- package/domain/generic/model/types/base-model-builder.type.d.ts +0 -15
- package/domain/generic/model/types/identifier-model.type.d.ts +0 -7
- package/domain/generic/model/types/model-base-structure.type.d.ts +0 -6
- package/domain/generic/model/types/non-function-properties.type.d.ts +0 -12
- package/domain/generic/model/types/non-function-property-name.type.d.ts +0 -4
- package/domain/generic/repository/create.repository.d.ts +0 -8
- package/domain/generic/repository/crud.repository.d.ts +0 -19
- package/domain/generic/repository/delete.repository.d.ts +0 -7
- package/domain/generic/repository/find.repository.d.ts +0 -11
- package/domain/generic/repository/get.repository.d.ts +0 -5
- package/domain/generic/repository/read.repository.d.ts +0 -14
- package/domain/generic/repository/types/repository-find-filters.type.d.ts +0 -13
- package/domain/generic/repository/types/where-options.type.d.ts +0 -2
- package/domain/generic/repository/update.repository.d.ts +0 -6
- package/domain/shopping/models/coupons/enums/coupon-subtypes.enum.d.ts +0 -4
- package/domain/shopping/models/coupons/enums/coupon-types.enum.d.ts +0 -6
- package/domain/shopping/models/coupons/financial-coupon.d.ts +0 -9
- package/esm2015/domain/catalog/models/kit-product.js +0 -18
- package/esm2015/domain/generic/model/base.model.js +0 -23
- package/esm2015/domain/generic/model/index.js +0 -4
- package/esm2015/domain/generic/model/types/base-model-builder.type.js +0 -2
- package/esm2015/domain/generic/model/types/identifier-model.type.js +0 -2
- package/esm2015/domain/generic/model/types/index.js +0 -6
- package/esm2015/domain/generic/model/types/model-base-structure.type.js +0 -2
- package/esm2015/domain/generic/model/types/non-function-properties.type.js +0 -2
- package/esm2015/domain/generic/model/types/non-function-property-name.type.js +0 -2
- package/esm2015/domain/generic/repository/create.repository.js +0 -2
- package/esm2015/domain/generic/repository/crud.repository.js +0 -2
- package/esm2015/domain/generic/repository/delete.repository.js +0 -2
- package/esm2015/domain/generic/repository/enums/where.enum.js +0 -15
- package/esm2015/domain/generic/repository/find.repository.js +0 -2
- package/esm2015/domain/generic/repository/get.repository.js +0 -2
- package/esm2015/domain/generic/repository/read.repository.js +0 -2
- package/esm2015/domain/generic/repository/types/index.js +0 -7
- package/esm2015/domain/generic/repository/types/repository-find-filters.type.js +0 -2
- package/esm2015/domain/generic/repository/types/repository-update-params.type.js +0 -2
- package/esm2015/domain/generic/repository/types/where-options.type.js +0 -2
- package/esm2015/domain/generic/repository/update.repository.js +0 -2
- package/esm2015/domain/shopping/models/coupons/enums/coupon-subtypes.enum.js +0 -6
- package/esm2015/domain/shopping/models/coupons/enums/coupon-types.enum.js +0 -8
- package/esm2015/domain/shopping/models/coupons/financial-coupon.js +0 -28
- package/esm2015/infra/hasura-graphql/enums/hasura-graphql-column-type.enum.js +0 -13
- package/esm2015/infra/hasura-graphql/enums/hasura-graphql-where.enum.js +0 -15
- package/esm2015/infra/hasura-graphql/enums/index.js +0 -3
- package/esm2015/infra/hasura-graphql/index.js +0 -5
- package/esm2015/infra/hasura-graphql/mixins/helpers/attribute-option.helper.js +0 -31
- package/esm2015/infra/hasura-graphql/mixins/helpers/filter-option.helper.js +0 -18
- package/esm2015/infra/hasura-graphql/mixins/helpers/graphql-field.helper.js +0 -72
- package/esm2015/infra/hasura-graphql/mixins/helpers/index.js +0 -4
- package/esm2015/infra/hasura-graphql/mixins/index.js +0 -8
- package/esm2015/infra/hasura-graphql/mixins/with-create-hasura-graphql.mixin.js +0 -45
- package/esm2015/infra/hasura-graphql/mixins/with-crud-hasura-graphql.mixin.js +0 -10
- package/esm2015/infra/hasura-graphql/mixins/with-delete-hasura-graphql.mixin.js +0 -29
- package/esm2015/infra/hasura-graphql/mixins/with-find-hasura-graphql.mixin.js +0 -93
- package/esm2015/infra/hasura-graphql/mixins/with-get-hasura-graphql.mixin.js +0 -35
- package/esm2015/infra/hasura-graphql/mixins/with-hasura-graphql.mixin.js +0 -94
- package/esm2015/infra/hasura-graphql/mixins/with-update-hasura-graphql.mixin.js +0 -56
- package/esm2015/infra/hasura-graphql/models/category-hasura-graphql.js +0 -4
- package/esm2015/infra/hasura-graphql/models/index.js +0 -5
- package/esm2015/infra/hasura-graphql/models/kit-product-hasura-graphql.js +0 -15
- package/esm2015/infra/hasura-graphql/models/product-hasura-graphql.js +0 -11
- package/esm2015/infra/hasura-graphql/models/variant-hasura-graphql.js +0 -9
- package/esm2015/infra/hasura-graphql/repositories/catalog/category-hasura-graphql.repository.js +0 -136
- package/esm2015/infra/hasura-graphql/repositories/catalog/index.js +0 -4
- package/esm2015/infra/hasura-graphql/repositories/catalog/product-hasura-graphql.repository.js +0 -375
- package/esm2015/infra/hasura-graphql/repositories/catalog/variant-hasura-graphql.repository.js +0 -107
- package/esm2015/infra/hasura-graphql/repositories/index.js +0 -2
- package/esm2015/infra/hasura-graphql/types/fields.type.js +0 -2
- package/esm2015/infra/hasura-graphql/types/graphql.repository.type.js +0 -2
- package/esm2015/infra/hasura-graphql/types/hasura-graphql-auth-options.type.js +0 -2
- package/esm2015/infra/hasura-graphql/types/hasura-graphql-fields.type.js +0 -2
- package/esm2015/infra/hasura-graphql/types/hasura-graphql-headers.type.js +0 -2
- package/esm2015/infra/hasura-graphql/types/index.js +0 -9
- package/esm2015/infra/hasura-graphql/types/nested-field.type.js +0 -2
- package/esm2015/infra/hasura-graphql/types/query-builder-options.type.js +0 -2
- package/esm2015/infra/hasura-graphql/types/variable-options.type.js +0 -2
- package/esm2015/utils/is-uuid.js +0 -3
- package/esm2015/utils/mixins/merge-constructor-params.type.js +0 -2
- package/esm2015/utils/parse-datetime.js +0 -14
- package/esm2015/utils/types/array-element.type.js +0 -2
- package/infra/hasura-graphql/enums/hasura-graphql-column-type.enum.d.ts +0 -11
- package/infra/hasura-graphql/enums/hasura-graphql-where.enum.d.ts +0 -13
- package/infra/hasura-graphql/enums/index.d.ts +0 -2
- package/infra/hasura-graphql/index.d.ts +0 -4
- package/infra/hasura-graphql/mixins/helpers/attribute-option.helper.d.ts +0 -13
- package/infra/hasura-graphql/mixins/helpers/filter-option.helper.d.ts +0 -6
- package/infra/hasura-graphql/mixins/helpers/graphql-field.helper.d.ts +0 -8
- package/infra/hasura-graphql/mixins/helpers/index.d.ts +0 -3
- package/infra/hasura-graphql/mixins/index.d.ts +0 -7
- package/infra/hasura-graphql/mixins/with-create-hasura-graphql.mixin.d.ts +0 -8
- package/infra/hasura-graphql/mixins/with-crud-hasura-graphql.mixin.d.ts +0 -11
- package/infra/hasura-graphql/mixins/with-delete-hasura-graphql.mixin.d.ts +0 -7
- package/infra/hasura-graphql/mixins/with-find-hasura-graphql.mixin.d.ts +0 -31
- package/infra/hasura-graphql/mixins/with-get-hasura-graphql.mixin.d.ts +0 -24
- package/infra/hasura-graphql/mixins/with-hasura-graphql.mixin.d.ts +0 -11
- package/infra/hasura-graphql/mixins/with-update-hasura-graphql.mixin.d.ts +0 -14
- package/infra/hasura-graphql/models/category-hasura-graphql.d.ts +0 -6
- package/infra/hasura-graphql/models/index.d.ts +0 -4
- package/infra/hasura-graphql/models/kit-product-hasura-graphql.d.ts +0 -6
- package/infra/hasura-graphql/models/product-hasura-graphql.d.ts +0 -9
- package/infra/hasura-graphql/models/variant-hasura-graphql.d.ts +0 -9
- package/infra/hasura-graphql/repositories/catalog/category-hasura-graphql.repository.d.ts +0 -22
- package/infra/hasura-graphql/repositories/catalog/index.d.ts +0 -3
- package/infra/hasura-graphql/repositories/catalog/product-hasura-graphql.repository.d.ts +0 -26
- package/infra/hasura-graphql/repositories/catalog/variant-hasura-graphql.repository.d.ts +0 -13
- package/infra/hasura-graphql/repositories/index.d.ts +0 -1
- package/infra/hasura-graphql/types/fields.type.d.ts +0 -2
- package/infra/hasura-graphql/types/graphql.repository.type.d.ts +0 -21
- package/infra/hasura-graphql/types/hasura-graphql-auth-options.type.d.ts +0 -8
- package/infra/hasura-graphql/types/hasura-graphql-fields.type.d.ts +0 -36
- package/infra/hasura-graphql/types/hasura-graphql-headers.type.d.ts +0 -7
- package/infra/hasura-graphql/types/index.d.ts +0 -8
- package/infra/hasura-graphql/types/nested-field.type.d.ts +0 -7
- package/infra/hasura-graphql/types/query-builder-options.type.d.ts +0 -7
- package/infra/hasura-graphql/types/variable-options.type.d.ts +0 -9
- package/utils/is-uuid.d.ts +0 -1
- package/utils/mixins/merge-constructor-params.type.d.ts +0 -3
- package/utils/parse-datetime.d.ts +0 -1
- package/utils/types/array-element.type.d.ts +0 -1
- /package/domain/{generic → general}/index.d.ts +0 -0
- /package/domain/{generic → general}/model/identifier-fields.d.ts +0 -0
- /package/domain/{generic → general}/repository/enums/index.d.ts +0 -0
- /package/domain/{generic → general}/repository/enums/update-option-actions.enum.d.ts +0 -0
- /package/domain/{generic → general}/repository/index.d.ts +0 -0
- /package/domain/{generic → general}/repository/types/repository-find-result.type.d.ts +0 -0
- /package/domain/{generic → general}/repository/types/repository-limit-options.type.d.ts +0 -0
- /package/domain/{generic → general}/repository/types/repository-order-by-list.type.d.ts +0 -0
|
@@ -1,52 +1,35 @@
|
|
|
1
1
|
import 'reflect-metadata';
|
|
2
|
-
import {
|
|
3
|
-
import { __decorate, __metadata, __awaiter
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export { chunk, isBoolean, isDate, isEmpty, isInteger, isNaN, isNil, isNumber, isObject, isString, now, omit, pick, set } from 'lodash';
|
|
8
|
-
import { CustomError } from 'ts-custom-error';
|
|
9
|
-
import { Md5 } from 'ts-md5';
|
|
2
|
+
import { plainToClass, classToPlain, Expose, Type } from 'class-transformer';
|
|
3
|
+
import { __decorate, __metadata, __awaiter } from 'tslib';
|
|
4
|
+
export { add, sub } from 'date-fns';
|
|
5
|
+
import { isNil, isNumber, isString, isDate, set, isObject, isEmpty, chunk } from 'lodash';
|
|
6
|
+
export { chunk, get, isDate, isEmpty, isNil, isNumber, isObject, isString, pick, set } from 'lodash';
|
|
10
7
|
import axios from 'axios';
|
|
11
8
|
import firebase from 'firebase';
|
|
12
|
-
import
|
|
13
|
-
import fetch from 'node-fetch';
|
|
9
|
+
import firebase$1 from 'firebase/app';
|
|
14
10
|
|
|
15
11
|
class BaseModel {
|
|
16
|
-
get identifier() {
|
|
17
|
-
const fields = this.constructor.identifiersFields.filter((field) => field !== 'identifier');
|
|
18
|
-
return fields.reduce((object, field) => (Object.assign(Object.assign({}, object), { [field]: this[field] })), {});
|
|
19
|
-
}
|
|
20
|
-
get identifiersFields() {
|
|
21
|
-
return this.constructor.identifiersFields;
|
|
22
|
-
}
|
|
23
12
|
constructor(args) {
|
|
24
13
|
Object.assign(this, args);
|
|
25
14
|
}
|
|
26
15
|
static toInstance(data) {
|
|
27
|
-
return
|
|
28
|
-
}
|
|
29
|
-
static isModel(value) {
|
|
30
|
-
return value instanceof this;
|
|
16
|
+
return plainToClass(this, data);
|
|
31
17
|
}
|
|
32
18
|
toPlain() {
|
|
33
|
-
return
|
|
19
|
+
return classToPlain(this, { exposeUnsetFields: false });
|
|
34
20
|
}
|
|
35
21
|
}
|
|
36
22
|
|
|
37
23
|
var Where;
|
|
38
24
|
(function (Where) {
|
|
39
25
|
Where["EQUALS"] = "==";
|
|
26
|
+
Where["NOTEQUALS"] = "!=";
|
|
40
27
|
Where["GT"] = ">";
|
|
41
28
|
Where["GTE"] = ">=";
|
|
42
29
|
Where["IN"] = "in";
|
|
43
|
-
Where["NOTIN"] = "not in";
|
|
44
30
|
Where["LT"] = "<";
|
|
45
31
|
Where["LTE"] = "<=";
|
|
46
32
|
Where["LIKE"] = "like";
|
|
47
|
-
Where["NOTLIKE"] = "not like";
|
|
48
|
-
Where["ISNULL"] = "is null";
|
|
49
|
-
Where["ISNOTNULL"] = "is not null";
|
|
50
33
|
})(Where || (Where = {}));
|
|
51
34
|
|
|
52
35
|
var UpdateOptionActions;
|
|
@@ -279,13 +262,13 @@ var Status;
|
|
|
279
262
|
})(Status || (Status = {}));
|
|
280
263
|
|
|
281
264
|
class Edition extends BaseModel {
|
|
282
|
-
|
|
283
|
-
return ['id'
|
|
265
|
+
identifierFields() {
|
|
266
|
+
return ['id'];
|
|
284
267
|
}
|
|
285
268
|
}
|
|
286
269
|
|
|
287
270
|
class Payment extends BaseModel {
|
|
288
|
-
|
|
271
|
+
identifierFields() {
|
|
289
272
|
return ['id'];
|
|
290
273
|
}
|
|
291
274
|
}
|
|
@@ -451,8 +434,8 @@ __decorate([
|
|
|
451
434
|
], Payment.prototype, "pixExpirationDate", void 0);
|
|
452
435
|
|
|
453
436
|
class SubscriptionPayment extends BaseModel {
|
|
454
|
-
|
|
455
|
-
return ['id'
|
|
437
|
+
identifierFields() {
|
|
438
|
+
return ['id'];
|
|
456
439
|
}
|
|
457
440
|
}
|
|
458
441
|
__decorate([
|
|
@@ -461,9 +444,6 @@ __decorate([
|
|
|
461
444
|
], SubscriptionPayment.prototype, "payment", void 0);
|
|
462
445
|
|
|
463
446
|
class Address extends BaseModel {
|
|
464
|
-
static get identifiersFields() {
|
|
465
|
-
return ['id'];
|
|
466
|
-
}
|
|
467
447
|
}
|
|
468
448
|
|
|
469
449
|
var CheckoutTypes;
|
|
@@ -478,33 +458,12 @@ class Base {
|
|
|
478
458
|
}
|
|
479
459
|
}
|
|
480
460
|
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
!/^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])T\d{2}:\d{2}:\d{2}/.test(value))
|
|
488
|
-
return value;
|
|
489
|
-
const date = parseISO(value);
|
|
490
|
-
if (isNaN(date.getTime()))
|
|
491
|
-
return value;
|
|
492
|
-
return date;
|
|
493
|
-
};
|
|
494
|
-
|
|
495
|
-
var CouponTypes;
|
|
496
|
-
(function (CouponTypes) {
|
|
497
|
-
CouponTypes[CouponTypes["FINANCIAL"] = 1] = "FINANCIAL";
|
|
498
|
-
CouponTypes[CouponTypes["PRODUCT"] = 2] = "PRODUCT";
|
|
499
|
-
CouponTypes[CouponTypes["GIFTCARD"] = 3] = "GIFTCARD";
|
|
500
|
-
CouponTypes[CouponTypes["VOUCHER"] = 4] = "VOUCHER";
|
|
501
|
-
})(CouponTypes || (CouponTypes = {}));
|
|
502
|
-
|
|
503
|
-
var CouponSubtypes;
|
|
504
|
-
(function (CouponSubtypes) {
|
|
505
|
-
CouponSubtypes[CouponSubtypes["ABSOLUTE"] = 1] = "ABSOLUTE";
|
|
506
|
-
CouponSubtypes[CouponSubtypes["PERCENTAGE"] = 2] = "PERCENTAGE";
|
|
507
|
-
})(CouponSubtypes || (CouponSubtypes = {}));
|
|
461
|
+
var DiscountType;
|
|
462
|
+
(function (DiscountType) {
|
|
463
|
+
DiscountType[DiscountType["ABSOLUTE"] = 1] = "ABSOLUTE";
|
|
464
|
+
DiscountType[DiscountType["PERCENTAGE"] = 2] = "PERCENTAGE";
|
|
465
|
+
DiscountType[DiscountType["FREE_SHIPPING"] = 3] = "FREE_SHIPPING";
|
|
466
|
+
})(DiscountType || (DiscountType = {}));
|
|
508
467
|
|
|
509
468
|
var Exclusivities;
|
|
510
469
|
(function (Exclusivities) {
|
|
@@ -517,9 +476,17 @@ class Coupon extends BaseModel {
|
|
|
517
476
|
get isInfluencer() {
|
|
518
477
|
return !isNil(this.influencerEmail);
|
|
519
478
|
}
|
|
520
|
-
|
|
479
|
+
identifierFields() {
|
|
521
480
|
return ['id'];
|
|
522
481
|
}
|
|
482
|
+
calculeDiscount(amount) {
|
|
483
|
+
switch (this.discountType) {
|
|
484
|
+
case DiscountType.ABSOLUTE:
|
|
485
|
+
return this.discount < amount ? this.discount : amount;
|
|
486
|
+
case DiscountType.PERCENTAGE:
|
|
487
|
+
return this.discount * 0.01 * amount;
|
|
488
|
+
}
|
|
489
|
+
}
|
|
523
490
|
}
|
|
524
491
|
__decorate([
|
|
525
492
|
Expose({ name: 'checkout_type' }),
|
|
@@ -531,7 +498,7 @@ __decorate([
|
|
|
531
498
|
], Coupon.prototype, "exclusivityType", void 0);
|
|
532
499
|
|
|
533
500
|
class SubscriptionPlan extends BaseModel {
|
|
534
|
-
|
|
501
|
+
identifierFields() {
|
|
535
502
|
return ['id'];
|
|
536
503
|
}
|
|
537
504
|
}
|
|
@@ -542,8 +509,8 @@ class BeautyProfile extends BaseModel {
|
|
|
542
509
|
delete plain.id;
|
|
543
510
|
return plain;
|
|
544
511
|
}
|
|
545
|
-
|
|
546
|
-
return ['id'
|
|
512
|
+
identifierFields() {
|
|
513
|
+
return ['id'];
|
|
547
514
|
}
|
|
548
515
|
}
|
|
549
516
|
|
|
@@ -554,14 +521,14 @@ class User extends BaseModel {
|
|
|
554
521
|
instance.displayName = `${data.firstName}${!isNil(data.lastName) ? ` ${data.lastName}` : ''}`;
|
|
555
522
|
return instance;
|
|
556
523
|
}
|
|
524
|
+
identifierFields() {
|
|
525
|
+
return ['id'];
|
|
526
|
+
}
|
|
557
527
|
toPlain() {
|
|
558
528
|
const plain = super.toPlain();
|
|
559
529
|
delete plain.beautyProfile;
|
|
560
530
|
return plain;
|
|
561
531
|
}
|
|
562
|
-
static get identifiersFields() {
|
|
563
|
-
return ['id'];
|
|
564
|
-
}
|
|
565
532
|
}
|
|
566
533
|
__decorate([
|
|
567
534
|
Type(() => BeautyProfile),
|
|
@@ -569,7 +536,7 @@ __decorate([
|
|
|
569
536
|
], User.prototype, "beautyProfile", void 0);
|
|
570
537
|
|
|
571
538
|
class Subscription extends BaseModel {
|
|
572
|
-
|
|
539
|
+
identifierFields() {
|
|
573
540
|
return ['id'];
|
|
574
541
|
}
|
|
575
542
|
}
|
|
@@ -603,24 +570,24 @@ __decorate([
|
|
|
603
570
|
], Subscription.prototype, "payment", void 0);
|
|
604
571
|
|
|
605
572
|
class UserAddress extends Address {
|
|
606
|
-
|
|
607
|
-
return ['id'
|
|
573
|
+
identifierFields() {
|
|
574
|
+
return ['id'];
|
|
608
575
|
}
|
|
609
576
|
}
|
|
610
577
|
|
|
611
578
|
class UserPaymentMethod extends BaseModel {
|
|
612
|
-
|
|
613
|
-
return ['id'
|
|
579
|
+
identifierFields() {
|
|
580
|
+
return ['id'];
|
|
614
581
|
}
|
|
615
582
|
}
|
|
616
583
|
|
|
617
584
|
class Lead extends BaseModel {
|
|
618
|
-
|
|
585
|
+
identifierFields() {
|
|
619
586
|
return ['id'];
|
|
620
587
|
}
|
|
621
588
|
}
|
|
622
589
|
|
|
623
|
-
class UnauthorizedError extends
|
|
590
|
+
class UnauthorizedError extends Error {
|
|
624
591
|
constructor(message) {
|
|
625
592
|
super(message);
|
|
626
593
|
this.message = message;
|
|
@@ -663,14 +630,14 @@ class Authentication {
|
|
|
663
630
|
}
|
|
664
631
|
}
|
|
665
632
|
|
|
666
|
-
class UserAlreadyRegisteredError extends
|
|
633
|
+
class UserAlreadyRegisteredError extends Error {
|
|
667
634
|
constructor(message) {
|
|
668
635
|
super(message);
|
|
669
636
|
this.message = message;
|
|
670
637
|
}
|
|
671
638
|
}
|
|
672
639
|
|
|
673
|
-
class WeakPasswordError extends
|
|
640
|
+
class WeakPasswordError extends Error {
|
|
674
641
|
constructor(message = 'Weak password') {
|
|
675
642
|
super(message);
|
|
676
643
|
this.message = message;
|
|
@@ -730,15 +697,6 @@ class RecoveryPassword {
|
|
|
730
697
|
}
|
|
731
698
|
}
|
|
732
699
|
|
|
733
|
-
class Category extends BaseModel {
|
|
734
|
-
identifierFields() {
|
|
735
|
-
return ['id'];
|
|
736
|
-
}
|
|
737
|
-
static get identifiersFields() {
|
|
738
|
-
return ['id'];
|
|
739
|
-
}
|
|
740
|
-
}
|
|
741
|
-
|
|
742
700
|
var Shops;
|
|
743
701
|
(function (Shops) {
|
|
744
702
|
Shops["MENSMARKET"] = "mensmarket";
|
|
@@ -746,6 +704,12 @@ var Shops;
|
|
|
746
704
|
Shops["GLAMPOINTS"] = "Glampoints";
|
|
747
705
|
})(Shops || (Shops = {}));
|
|
748
706
|
|
|
707
|
+
class Category extends BaseModel {
|
|
708
|
+
identifierFields() {
|
|
709
|
+
return ['id'];
|
|
710
|
+
}
|
|
711
|
+
}
|
|
712
|
+
|
|
749
713
|
class Product extends BaseModel {
|
|
750
714
|
identifierFields() {
|
|
751
715
|
return ['id'];
|
|
@@ -754,61 +718,45 @@ class Product extends BaseModel {
|
|
|
754
718
|
var _a, _b, _c, _d, _e, _f;
|
|
755
719
|
return Object.assign(Object.assign(Object.assign({}, (((_b = (_a = this.description) === null || _a === void 0 ? void 0 : _a[shop]) === null || _b === void 0 ? void 0 : _b.description) ? { description: (_d = (_c = this.description) === null || _c === void 0 ? void 0 : _c[shop]) === null || _d === void 0 ? void 0 : _d.description } : {})), (((_e = this.price) === null || _e === void 0 ? void 0 : _e[shop]) || {})), (((_f = this.stock) === null || _f === void 0 ? void 0 : _f[shop]) || {}));
|
|
756
720
|
}
|
|
757
|
-
static get identifiersFields() {
|
|
758
|
-
return ['id'];
|
|
759
|
-
}
|
|
760
721
|
}
|
|
761
|
-
__decorate([
|
|
762
|
-
Type(() => KitProduct),
|
|
763
|
-
__metadata("design:type", Array)
|
|
764
|
-
], Product.prototype, "kitProducts", void 0);
|
|
765
|
-
|
|
766
|
-
class KitProduct extends BaseModel {
|
|
767
|
-
static get identifiersFields() {
|
|
768
|
-
return ['productId', 'kitProducId'];
|
|
769
|
-
}
|
|
770
|
-
}
|
|
771
|
-
__decorate([
|
|
772
|
-
Type(() => Product),
|
|
773
|
-
__metadata("design:type", Product)
|
|
774
|
-
], KitProduct.prototype, "kit", void 0);
|
|
775
|
-
__decorate([
|
|
776
|
-
Type(() => Product),
|
|
777
|
-
__metadata("design:type", Product)
|
|
778
|
-
], KitProduct.prototype, "product", void 0);
|
|
779
722
|
|
|
780
723
|
class Variant extends BaseModel {
|
|
781
724
|
identifierFields() {
|
|
782
725
|
return ['id'];
|
|
783
726
|
}
|
|
784
|
-
|
|
785
|
-
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
class ClubCoupon extends Coupon {
|
|
730
|
+
constructor() {
|
|
731
|
+
super(...arguments);
|
|
732
|
+
this.checkoutType = CheckoutTypes.SUBSCRIPTION;
|
|
733
|
+
}
|
|
734
|
+
static isClubCoupon(coupon) {
|
|
735
|
+
return coupon instanceof ClubCoupon;
|
|
786
736
|
}
|
|
787
737
|
}
|
|
738
|
+
__decorate([
|
|
739
|
+
Expose({ name: 'checkout_type' }),
|
|
740
|
+
__metadata("design:type", Object)
|
|
741
|
+
], ClubCoupon.prototype, "checkoutType", void 0);
|
|
788
742
|
|
|
789
|
-
|
|
790
|
-
class FinancialCoupon extends Coupon {
|
|
743
|
+
class StoreCoupon extends Coupon {
|
|
791
744
|
constructor() {
|
|
792
745
|
super(...arguments);
|
|
793
|
-
this.
|
|
794
|
-
}
|
|
795
|
-
static
|
|
796
|
-
return coupon
|
|
797
|
-
}
|
|
798
|
-
static createCoupon(userId) {
|
|
799
|
-
return this.toInstance({
|
|
800
|
-
name: Md5.hashStr(`${userId}_${Date.now}`).toString(),
|
|
801
|
-
nickname: `${Date.now()}`,
|
|
802
|
-
type: CouponTypes.FINANCIAL,
|
|
803
|
-
subtype: CouponSubtypes.PERCENTAGE,
|
|
804
|
-
checkoutType: CheckoutTypes.ECOMMERCE,
|
|
805
|
-
discount: 30,
|
|
806
|
-
user: userId,
|
|
807
|
-
createdAt: new Date(Date.now()),
|
|
808
|
-
expiresIn: new Date(Date.now() + COUPON_EXPIRATION),
|
|
809
|
-
});
|
|
746
|
+
this.checkoutType = CheckoutTypes.ECOMMERCE;
|
|
747
|
+
}
|
|
748
|
+
static isStoreCoupon(coupon) {
|
|
749
|
+
return coupon instanceof StoreCoupon;
|
|
810
750
|
}
|
|
811
751
|
}
|
|
752
|
+
__decorate([
|
|
753
|
+
Expose({ name: 'checkout_type' }),
|
|
754
|
+
__metadata("design:type", Object)
|
|
755
|
+
], StoreCoupon.prototype, "checkoutType", void 0);
|
|
756
|
+
__decorate([
|
|
757
|
+
Type(() => Category),
|
|
758
|
+
__metadata("design:type", Array)
|
|
759
|
+
], StoreCoupon.prototype, "categories", void 0);
|
|
812
760
|
|
|
813
761
|
var OrderStatus;
|
|
814
762
|
(function (OrderStatus) {
|
|
@@ -826,13 +774,21 @@ class LineItem extends Product {
|
|
|
826
774
|
}
|
|
827
775
|
|
|
828
776
|
class ShippingMethod extends BaseModel {
|
|
829
|
-
|
|
777
|
+
identifierFields() {
|
|
830
778
|
return ['id'];
|
|
831
779
|
}
|
|
832
780
|
}
|
|
833
781
|
|
|
834
782
|
class Checkout extends BaseModel {
|
|
835
|
-
|
|
783
|
+
get subTotalPrice() {
|
|
784
|
+
return this.lineItems.reduce((total, item) => {
|
|
785
|
+
return total + item.pricePaid;
|
|
786
|
+
}, 0);
|
|
787
|
+
}
|
|
788
|
+
get totalPrice() {
|
|
789
|
+
return this.totalPrice - this.discount;
|
|
790
|
+
}
|
|
791
|
+
identifierFields() {
|
|
836
792
|
return ['id'];
|
|
837
793
|
}
|
|
838
794
|
}
|
|
@@ -857,8 +813,8 @@ __decorate([
|
|
|
857
813
|
__metadata("design:type", ShippingMethod)
|
|
858
814
|
], Checkout.prototype, "shipping", void 0);
|
|
859
815
|
__decorate([
|
|
860
|
-
Type(() =>
|
|
861
|
-
__metadata("design:type",
|
|
816
|
+
Type(() => StoreCoupon),
|
|
817
|
+
__metadata("design:type", StoreCoupon)
|
|
862
818
|
], Checkout.prototype, "coupon", void 0);
|
|
863
819
|
|
|
864
820
|
class Order extends Checkout {
|
|
@@ -869,7 +825,7 @@ __decorate([
|
|
|
869
825
|
], Order.prototype, "payment", void 0);
|
|
870
826
|
|
|
871
827
|
class CheckoutSubscription extends BaseModel {
|
|
872
|
-
|
|
828
|
+
identifierFields() {
|
|
873
829
|
return ['id'];
|
|
874
830
|
}
|
|
875
831
|
}
|
|
@@ -891,7 +847,7 @@ __decorate([
|
|
|
891
847
|
], CheckoutSubscription.prototype, "coupon", void 0);
|
|
892
848
|
|
|
893
849
|
class Buy2Win extends BaseModel {
|
|
894
|
-
|
|
850
|
+
identifierFields() {
|
|
895
851
|
return ['id'];
|
|
896
852
|
}
|
|
897
853
|
}
|
|
@@ -987,25 +943,25 @@ class BeautyQuestionsHelper {
|
|
|
987
943
|
}
|
|
988
944
|
|
|
989
945
|
class Home extends BaseModel {
|
|
990
|
-
|
|
946
|
+
identifierFields() {
|
|
991
947
|
return ['id'];
|
|
992
948
|
}
|
|
993
949
|
}
|
|
994
950
|
|
|
995
951
|
class ShopMenu extends BaseModel {
|
|
996
|
-
|
|
952
|
+
identifierFields() {
|
|
997
953
|
return ['id'];
|
|
998
954
|
}
|
|
999
955
|
}
|
|
1000
956
|
|
|
1001
|
-
class InvalidArgumentError extends
|
|
957
|
+
class InvalidArgumentError extends Error {
|
|
1002
958
|
constructor(message) {
|
|
1003
959
|
super(message);
|
|
1004
960
|
this.message = message;
|
|
1005
961
|
}
|
|
1006
962
|
}
|
|
1007
963
|
|
|
1008
|
-
class RequiredArgumentError extends
|
|
964
|
+
class RequiredArgumentError extends Error {
|
|
1009
965
|
constructor(args) {
|
|
1010
966
|
super(`Required arguments: ${args.join(', ')}`);
|
|
1011
967
|
this.args = args;
|
|
@@ -1013,14 +969,14 @@ class RequiredArgumentError extends CustomError {
|
|
|
1013
969
|
}
|
|
1014
970
|
}
|
|
1015
971
|
|
|
1016
|
-
class NotFoundError extends
|
|
972
|
+
class NotFoundError extends Error {
|
|
1017
973
|
constructor(message) {
|
|
1018
974
|
super(message);
|
|
1019
975
|
this.message = message;
|
|
1020
976
|
}
|
|
1021
977
|
}
|
|
1022
978
|
|
|
1023
|
-
class DuplicatedResultsError extends
|
|
979
|
+
class DuplicatedResultsError extends Error {
|
|
1024
980
|
constructor(message) {
|
|
1025
981
|
super(message);
|
|
1026
982
|
this.message = message;
|
|
@@ -1031,21 +987,6 @@ class AxiosAdapter {
|
|
|
1031
987
|
constructor(config) {
|
|
1032
988
|
this.config = config;
|
|
1033
989
|
}
|
|
1034
|
-
get(index) {
|
|
1035
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1036
|
-
try {
|
|
1037
|
-
const { data } = yield axios({
|
|
1038
|
-
url: `${this.config.url}/${index}`,
|
|
1039
|
-
method: 'GET',
|
|
1040
|
-
headers: { Authorization: `Basic ${this.config.credential}` },
|
|
1041
|
-
});
|
|
1042
|
-
return data._source;
|
|
1043
|
-
}
|
|
1044
|
-
catch (error) {
|
|
1045
|
-
throw new NotFoundError(error.message);
|
|
1046
|
-
}
|
|
1047
|
-
});
|
|
1048
|
-
}
|
|
1049
990
|
query(index, query) {
|
|
1050
991
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1051
992
|
const { data } = yield axios({
|
|
@@ -1060,37 +1001,12 @@ class AxiosAdapter {
|
|
|
1060
1001
|
};
|
|
1061
1002
|
});
|
|
1062
1003
|
}
|
|
1063
|
-
save(index, data) {
|
|
1064
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1065
|
-
yield axios({
|
|
1066
|
-
url: `${this.config.url}/${index}`,
|
|
1067
|
-
method: 'PUT',
|
|
1068
|
-
headers: { Authorization: `Basic ${this.config.credential}` },
|
|
1069
|
-
data,
|
|
1070
|
-
});
|
|
1071
|
-
});
|
|
1072
|
-
}
|
|
1073
|
-
delete(index) {
|
|
1074
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1075
|
-
yield axios({
|
|
1076
|
-
url: `${this.config.url}/${index}`,
|
|
1077
|
-
method: 'DELETE',
|
|
1078
|
-
headers: { Authorization: `Basic ${this.config.credential}` },
|
|
1079
|
-
});
|
|
1080
|
-
});
|
|
1081
|
-
}
|
|
1082
1004
|
}
|
|
1083
1005
|
|
|
1084
1006
|
class ProductsIndex {
|
|
1085
1007
|
constructor(adapter) {
|
|
1086
1008
|
this.adapter = adapter;
|
|
1087
1009
|
}
|
|
1088
|
-
get(id) {
|
|
1089
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1090
|
-
const data = yield this.adapter.get(`products/_doc/${id}`);
|
|
1091
|
-
return Product.toInstance(data);
|
|
1092
|
-
});
|
|
1093
|
-
}
|
|
1094
1010
|
findById(ids, options) {
|
|
1095
1011
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1096
1012
|
const publishedField = options.shop === Shops.GLAMSHOP ? 'publishedGlam' : 'published';
|
|
@@ -1142,38 +1058,13 @@ class ProductsIndex {
|
|
|
1142
1058
|
return hits.map((hit) => Product.toInstance(hit._source));
|
|
1143
1059
|
});
|
|
1144
1060
|
}
|
|
1145
|
-
save(product) {
|
|
1146
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1147
|
-
delete product.createdAt;
|
|
1148
|
-
delete product.updatedAt;
|
|
1149
|
-
delete product.kitProducts;
|
|
1150
|
-
try {
|
|
1151
|
-
if (!product.firestoreId)
|
|
1152
|
-
throw new Error('Is not a product from firestore');
|
|
1153
|
-
yield this.get(product.firestoreId);
|
|
1154
|
-
yield this.adapter.save(`products/_doc/${product.firestoreId}`, product.toPlain());
|
|
1155
|
-
}
|
|
1156
|
-
catch (error) {
|
|
1157
|
-
console.info(error.message);
|
|
1158
|
-
yield this.adapter.save(`products/_doc/${product.id}`, product.toPlain());
|
|
1159
|
-
}
|
|
1160
|
-
});
|
|
1161
|
-
}
|
|
1162
|
-
delete(product) {
|
|
1163
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1164
|
-
try {
|
|
1165
|
-
yield this.get(product.firestoreId);
|
|
1166
|
-
yield this.adapter.delete(`products/_doc/${product.firestoreId}`);
|
|
1167
|
-
}
|
|
1168
|
-
catch (error) {
|
|
1169
|
-
yield this.adapter.delete(`products/_doc/${product.id}`);
|
|
1170
|
-
}
|
|
1171
|
-
});
|
|
1172
|
-
}
|
|
1173
1061
|
}
|
|
1174
1062
|
|
|
1175
1063
|
const withFirestore = (MixinBase) => {
|
|
1176
1064
|
return class extends MixinBase {
|
|
1065
|
+
constructor(...args) {
|
|
1066
|
+
super(args);
|
|
1067
|
+
}
|
|
1177
1068
|
collection(path) {
|
|
1178
1069
|
return this.firestore.collection(path || this.collectionName).withConverter(this.buildModelInstance());
|
|
1179
1070
|
}
|
|
@@ -1183,7 +1074,7 @@ const withFirestore = (MixinBase) => {
|
|
|
1183
1074
|
fromFirestore: (snap) => {
|
|
1184
1075
|
const data = snap.data();
|
|
1185
1076
|
Object.keys(data).forEach((key) => {
|
|
1186
|
-
if (data[key]
|
|
1077
|
+
if (data[key] instanceof firebase.firestore.Timestamp) {
|
|
1187
1078
|
data[key] = data[key].toDate();
|
|
1188
1079
|
}
|
|
1189
1080
|
});
|
|
@@ -1263,16 +1154,16 @@ const withFindFirestore = (MixinBase) => {
|
|
|
1263
1154
|
if ((options === null || options === void 0 ? void 0 : options.operator) === Where.IN && Array.isArray(options === null || options === void 0 ? void 0 : options.value))
|
|
1264
1155
|
return queryReference.where(firestoreFieldName, 'array-contains', options.value);
|
|
1265
1156
|
if (isObject(options) && isNil(options === null || options === void 0 ? void 0 : options.operator) && isNil(options === null || options === void 0 ? void 0 : options.value)) {
|
|
1266
|
-
return Object.keys(options).reduce((queryReferenceWithWhere, key) => this.buildWhereSentence(queryReferenceWithWhere, `${fieldName
|
|
1157
|
+
return Object.keys(options).reduce((queryReferenceWithWhere, key) => this.buildWhereSentence(queryReferenceWithWhere, `${fieldName}.${key}`, options[key]), queryReference);
|
|
1267
1158
|
}
|
|
1268
1159
|
return queryReference.where(firestoreFieldName, (options === null || options === void 0 ? void 0 : options.operator) || '==', (options === null || options === void 0 ? void 0 : options.value) || options);
|
|
1269
1160
|
};
|
|
1270
1161
|
}
|
|
1271
|
-
find(
|
|
1162
|
+
find(filters, limits, orderBy) {
|
|
1272
1163
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1273
|
-
let query = this.collection(this.buildCollectionPathForFind(filters
|
|
1274
|
-
query = this.makeFirestoreWhere(query,
|
|
1275
|
-
|
|
1164
|
+
let query = this.collection(this.buildCollectionPathForFind(filters));
|
|
1165
|
+
filters === null || filters === void 0 ? void 0 : filters.forEach((filterer) => (query = this.makeFirestoreWhere(query, filterer)));
|
|
1166
|
+
orderBy === null || orderBy === void 0 ? void 0 : orderBy.forEach((orderer) => Object.keys(orderer).forEach((fieldName) => (query = query.orderBy(fieldName, orderer[fieldName]))));
|
|
1276
1167
|
query = yield this.defineLimits(query, filters, limits);
|
|
1277
1168
|
const docs = yield query.get();
|
|
1278
1169
|
const data = docs.docs.map((doc) => doc.data());
|
|
@@ -1283,18 +1174,19 @@ const withFindFirestore = (MixinBase) => {
|
|
|
1283
1174
|
});
|
|
1284
1175
|
}
|
|
1285
1176
|
buildCollectionPathForFind(filters) {
|
|
1177
|
+
var _a;
|
|
1286
1178
|
if (!this.isSubCollection(this))
|
|
1287
1179
|
return this.collectionName;
|
|
1288
1180
|
const parentIdField = this.parentIdField;
|
|
1289
|
-
const parentId = getValueFromFilter(filters === null ||
|
|
1181
|
+
const parentId = getValueFromFilter((_a = filters.find((groupFilter) => Boolean(getValueFromFilter(groupFilter[parentIdField])))) === null || _a === void 0 ? void 0 : _a[parentIdField]);
|
|
1290
1182
|
return `${this.parentRepository.collectionName}/${parentId}/${this.collectionName}`;
|
|
1291
1183
|
}
|
|
1292
1184
|
defineLimits(query, filters, limits) {
|
|
1293
1185
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1294
1186
|
if (limits === null || limits === void 0 ? void 0 : limits.offset) {
|
|
1295
|
-
if (this.model
|
|
1187
|
+
if (limits.offset instanceof this.model)
|
|
1296
1188
|
query = query.startAfter(yield this.collection(this.buildCollectionPathForFind(filters))
|
|
1297
|
-
.doc(limits.offset[limits.offset.
|
|
1189
|
+
.doc(limits.offset[limits.offset.identifierFields().shift()])
|
|
1298
1190
|
.get());
|
|
1299
1191
|
else if (isNumber(limits.offset) || isString(limits.offset))
|
|
1300
1192
|
query = query.startAt(limits.offset);
|
|
@@ -1326,7 +1218,7 @@ const withCreateFirestore = (MixinBase) => {
|
|
|
1326
1218
|
save(data) {
|
|
1327
1219
|
var _a;
|
|
1328
1220
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1329
|
-
const id = (_a = data[data.
|
|
1221
|
+
const id = (_a = data[data.identifierFields().shift()]) === null || _a === void 0 ? void 0 : _a.toString();
|
|
1330
1222
|
const collectionPath = this.buildCollectionPathForAdd(data);
|
|
1331
1223
|
if (isEmpty(id))
|
|
1332
1224
|
return this.collection(collectionPath).add(data);
|
|
@@ -1363,7 +1255,7 @@ const withUpdateFirestore = (MixinBase) => {
|
|
|
1363
1255
|
update(data) {
|
|
1364
1256
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1365
1257
|
const model = new this.model();
|
|
1366
|
-
const keyField = model.
|
|
1258
|
+
const keyField = model.identifierFields().shift();
|
|
1367
1259
|
const docRef = this.collection(this.buildCollectionPathForUpdate(data)).doc(getValueFromParams(data, keyField).toString());
|
|
1368
1260
|
yield docRef.set(this.paramsToPlain(data), { merge: true });
|
|
1369
1261
|
const doc = yield docRef.get();
|
|
@@ -1377,8 +1269,8 @@ const withUpdateFirestore = (MixinBase) => {
|
|
|
1377
1269
|
}
|
|
1378
1270
|
paramsToPlain(params) {
|
|
1379
1271
|
const model = this.model;
|
|
1380
|
-
if (model
|
|
1381
|
-
return params
|
|
1272
|
+
if (params instanceof model)
|
|
1273
|
+
return params;
|
|
1382
1274
|
return Object.keys(params).reduce((data, currentKey) => (Object.assign(Object.assign({}, data), { [currentKey]: getValueByAction(params[currentKey]) })), {});
|
|
1383
1275
|
}
|
|
1384
1276
|
};
|
|
@@ -1427,7 +1319,7 @@ class SubscriptionFirestoreRepository extends withCrudFirestore(withHelpers(with
|
|
|
1427
1319
|
}
|
|
1428
1320
|
|
|
1429
1321
|
class UserSearch extends BaseModel {
|
|
1430
|
-
|
|
1322
|
+
identifierFields() {
|
|
1431
1323
|
return ['id'];
|
|
1432
1324
|
}
|
|
1433
1325
|
}
|
|
@@ -1462,7 +1354,7 @@ class UserFirestoreRepository extends withCrudFirestore(withHelpers(withFirestor
|
|
|
1462
1354
|
}
|
|
1463
1355
|
checkIfExistsByField(field, value) {
|
|
1464
1356
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1465
|
-
const result = yield this.userSearchFirestoreRepository.find({ [field]: { operator: Where.EQUALS, value } });
|
|
1357
|
+
const result = yield this.userSearchFirestoreRepository.find([{ [field]: { operator: Where.EQUALS, value } }]);
|
|
1466
1358
|
return result.count > 0;
|
|
1467
1359
|
});
|
|
1468
1360
|
}
|
|
@@ -1620,9 +1512,7 @@ class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFire
|
|
|
1620
1512
|
for (const productIds of chunks) {
|
|
1621
1513
|
if ((options === null || options === void 0 ? void 0 : options.limit) && products.length >= (options === null || options === void 0 ? void 0 : options.limit))
|
|
1622
1514
|
break;
|
|
1623
|
-
let query = yield this.collection('
|
|
1624
|
-
.where(publishedField, '==', true)
|
|
1625
|
-
.where('id', 'in', productIds);
|
|
1515
|
+
let query = yield this.collection('products').where(publishedField, '==', true).where('id', 'in', productIds);
|
|
1626
1516
|
if (options === null || options === void 0 ? void 0 : options.hasStock)
|
|
1627
1517
|
query = query.where('stock.quantity', '>', 0);
|
|
1628
1518
|
if (options === null || options === void 0 ? void 0 : options.limit)
|
|
@@ -1641,48 +1531,19 @@ class ProductFirestoreRepository extends withCrudFirestore(withHelpers(withFires
|
|
|
1641
1531
|
constructor(firestore) {
|
|
1642
1532
|
super();
|
|
1643
1533
|
this.firestore = firestore;
|
|
1644
|
-
this.
|
|
1645
|
-
this.collectionName = 'productsErpVitrine';
|
|
1534
|
+
this.collectionName = 'products';
|
|
1646
1535
|
this.model = Product;
|
|
1647
1536
|
}
|
|
1648
|
-
getBySlug(slug) {
|
|
1537
|
+
getBySlug(slug, shop) {
|
|
1649
1538
|
var _a;
|
|
1650
1539
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1651
|
-
const result = yield this.find(
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
});
|
|
1540
|
+
const result = yield this.find([
|
|
1541
|
+
{ slug: { operator: Where.EQUALS, value: slug } },
|
|
1542
|
+
{ shopAvailability: { operator: Where.IN, value: [shop] } },
|
|
1543
|
+
]);
|
|
1656
1544
|
return (_a = result === null || result === void 0 ? void 0 : result.data) === null || _a === void 0 ? void 0 : _a.shift();
|
|
1657
1545
|
});
|
|
1658
1546
|
}
|
|
1659
|
-
fetchReviews(status) {
|
|
1660
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1661
|
-
const { data: products } = yield this.find();
|
|
1662
|
-
products.forEach((product) => {
|
|
1663
|
-
var _a;
|
|
1664
|
-
if ([undefined, 0].includes((_a = product.reviews) === null || _a === void 0 ? void 0 : _a.length))
|
|
1665
|
-
return;
|
|
1666
|
-
const productInfo = {
|
|
1667
|
-
productId: product.id,
|
|
1668
|
-
productName: product.name,
|
|
1669
|
-
productSku: product.sku,
|
|
1670
|
-
};
|
|
1671
|
-
this.reviews.pending = [];
|
|
1672
|
-
this.reviews.approved = [];
|
|
1673
|
-
this.reviews.rejected = [];
|
|
1674
|
-
product.reviews.forEach((review) => {
|
|
1675
|
-
if ([null, undefined].includes(review.status))
|
|
1676
|
-
return this.reviews.pending.push(Object.assign(Object.assign({}, review), productInfo));
|
|
1677
|
-
if (review.status === false)
|
|
1678
|
-
return this.reviews.rejected.push(Object.assign(Object.assign({}, review), productInfo));
|
|
1679
|
-
if (!!review.status)
|
|
1680
|
-
return this.reviews.approved.push(Object.assign(Object.assign({}, review), productInfo));
|
|
1681
|
-
});
|
|
1682
|
-
});
|
|
1683
|
-
return this.reviews[status];
|
|
1684
|
-
});
|
|
1685
|
-
}
|
|
1686
1547
|
}
|
|
1687
1548
|
|
|
1688
1549
|
class ProductVariantFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), Product) {
|
|
@@ -1722,19 +1583,28 @@ class CouponFirestoreRepository extends withCrudFirestore(withHelpers(withFirest
|
|
|
1722
1583
|
this.model = Coupon;
|
|
1723
1584
|
}
|
|
1724
1585
|
buildModelInstance() {
|
|
1725
|
-
const { fromFirestore, toFirestore } = super.buildModelInstance();
|
|
1726
1586
|
return {
|
|
1727
1587
|
toFirestore: (data) => {
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1588
|
+
var _a;
|
|
1589
|
+
const plain = (data === null || data === void 0 ? void 0 : data.toPlain) ? data.toPlain() : data;
|
|
1590
|
+
if (!!plain.categories)
|
|
1591
|
+
plain.categories = (_a = plain === null || plain === void 0 ? void 0 : plain.categories) === null || _a === void 0 ? void 0 : _a.map((category) => category.id);
|
|
1731
1592
|
return plain;
|
|
1732
1593
|
},
|
|
1733
1594
|
fromFirestore: (snap) => {
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1595
|
+
var _a;
|
|
1596
|
+
const data = snap.data();
|
|
1597
|
+
Object.keys(data).forEach((key) => {
|
|
1598
|
+
if (data[key] instanceof firebase.firestore.Timestamp) {
|
|
1599
|
+
data[key] = data[key].toDate();
|
|
1600
|
+
}
|
|
1601
|
+
});
|
|
1602
|
+
data.categories = (_a = data === null || data === void 0 ? void 0 : data.categories) === null || _a === void 0 ? void 0 : _a.map((category) => ({ id: category }));
|
|
1603
|
+
if (data.checkout_type === CheckoutTypes.SUBSCRIPTION)
|
|
1604
|
+
return ClubCoupon.toInstance(Object.assign({ id: snap.id }, data));
|
|
1605
|
+
if (data.checkout_type === CheckoutTypes.ECOMMERCE)
|
|
1606
|
+
return StoreCoupon.toInstance(Object.assign({ id: snap.id }, data));
|
|
1607
|
+
return this.model.toInstance(Object.assign({ id: snap.id }, data));
|
|
1738
1608
|
},
|
|
1739
1609
|
};
|
|
1740
1610
|
}
|
|
@@ -1873,7 +1743,7 @@ class AuthenticationFirebaseAuthService {
|
|
|
1873
1743
|
}
|
|
1874
1744
|
signInWithGoogle() {
|
|
1875
1745
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1876
|
-
const credentials = yield this.firebaseAuth.signInWithPopup(new firebase.auth.GoogleAuthProvider());
|
|
1746
|
+
const credentials = yield this.firebaseAuth.signInWithPopup(new firebase$1.auth.GoogleAuthProvider());
|
|
1877
1747
|
const user = credentials.user;
|
|
1878
1748
|
return {
|
|
1879
1749
|
id: user.uid,
|
|
@@ -1928,1113 +1798,9 @@ class RegisterFirebaseAuthService {
|
|
|
1928
1798
|
}
|
|
1929
1799
|
}
|
|
1930
1800
|
|
|
1931
|
-
class AttributeOptionHelper {
|
|
1932
|
-
}
|
|
1933
|
-
AttributeOptionHelper.FindByAttribute = (attributeName, fields) => {
|
|
1934
|
-
if (fields.includes(attributeName))
|
|
1935
|
-
return { columnName: attributeName.toString(), attributeName };
|
|
1936
|
-
const field = fields.find((columnOption) => isObject(columnOption) && Object.keys(columnOption).includes(attributeName.toString()));
|
|
1937
|
-
const fieldOption = field === null || field === void 0 ? void 0 : field[attributeName.toString()];
|
|
1938
|
-
if (isNil(fieldOption))
|
|
1939
|
-
return { columnName: attributeName.toString(), attributeName };
|
|
1940
|
-
if (Array.isArray(fieldOption))
|
|
1941
|
-
return { columnName: attributeName.toString(), attributeName, fields: fieldOption };
|
|
1942
|
-
return Object.assign({ attributeName, columnName: attributeName.toString() }, fieldOption);
|
|
1943
|
-
};
|
|
1944
|
-
AttributeOptionHelper.CheckIsColumnOption = (fieldValue) => !!fieldValue.columnName;
|
|
1945
|
-
AttributeOptionHelper.FindColumnOptionFromList = (columnName, fields) => {
|
|
1946
|
-
if (fields.includes(columnName))
|
|
1947
|
-
return { columnName, attributeName: columnName };
|
|
1948
|
-
const field = fields.find((columnOption) => {
|
|
1949
|
-
var _a;
|
|
1950
|
-
return isObject(columnOption) &&
|
|
1951
|
-
((_a = Object.values(columnOption).find((option) => AttributeOptionHelper.CheckIsColumnOption(option) && option.columnName === columnName)) === null || _a === void 0 ? void 0 : _a.columnName) === columnName;
|
|
1952
|
-
}) || {};
|
|
1953
|
-
const attributeName = Object.keys(field).find((fieldOptionFromList) => AttributeOptionHelper.CheckIsColumnOption(field[fieldOptionFromList]) ||
|
|
1954
|
-
Array.isArray(field[fieldOptionFromList]));
|
|
1955
|
-
const fieldOption = field === null || field === void 0 ? void 0 : field[attributeName];
|
|
1956
|
-
if (Array.isArray(fieldOption))
|
|
1957
|
-
return { attributeName: attributeName, fields: fieldOption };
|
|
1958
|
-
return Object.assign({ attributeName: attributeName || columnName, columnName }, fieldOption);
|
|
1959
|
-
};
|
|
1960
|
-
|
|
1961
|
-
class GraphQLFieldHelper {
|
|
1962
|
-
}
|
|
1963
|
-
GraphQLFieldHelper.CheckIsGraphQLParams = (params) => !isString(params) && Array.isArray(params) && params.length >= 0 && !!params[0].operation;
|
|
1964
|
-
GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields = (fields) => {
|
|
1965
|
-
return fields === null || fields === void 0 ? void 0 : fields.map((field) => {
|
|
1966
|
-
if (isString(field))
|
|
1967
|
-
return field.toString();
|
|
1968
|
-
const fieldName = Object.keys(field).shift();
|
|
1969
|
-
const fieldValue = field[fieldName];
|
|
1970
|
-
if (Array.isArray(fieldValue))
|
|
1971
|
-
return { [fieldName]: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(fieldValue) };
|
|
1972
|
-
if (!AttributeOptionHelper.CheckIsColumnOption(fieldValue))
|
|
1973
|
-
return;
|
|
1974
|
-
if (fieldValue.fields)
|
|
1975
|
-
return {
|
|
1976
|
-
[fieldValue.columnName || fieldName]: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(fieldValue.fields),
|
|
1977
|
-
};
|
|
1978
|
-
return fieldValue.columnName;
|
|
1979
|
-
}).filter((field) => !!field);
|
|
1980
|
-
};
|
|
1981
|
-
GraphQLFieldHelper.ConvertFieldValueFrom = (data, fields) => Object.keys(data).reduce((result, columnName) => {
|
|
1982
|
-
const { attributeName, fields: attributeFields, from, } = AttributeOptionHelper.FindColumnOptionFromList(columnName, fields);
|
|
1983
|
-
if (!!attributeFields && Array.isArray(attributeFields)) {
|
|
1984
|
-
if (Array.isArray(data[columnName]))
|
|
1985
|
-
return Object.assign(Object.assign({}, result), { [attributeName]: from
|
|
1986
|
-
? from(data[columnName], data)
|
|
1987
|
-
: data[columnName].map((value) => GraphQLFieldHelper.ConvertFieldValueFrom(value, attributeFields)) });
|
|
1988
|
-
if (isObject(data[columnName]))
|
|
1989
|
-
return Object.assign(Object.assign({}, result), { [attributeName]: !!from
|
|
1990
|
-
? from(data[columnName])
|
|
1991
|
-
: GraphQLFieldHelper.ConvertFieldValueFrom(data[columnName], attributeFields) });
|
|
1992
|
-
}
|
|
1993
|
-
if (!!from)
|
|
1994
|
-
return Object.assign(Object.assign({}, result), { [attributeName]: from(data[columnName], data) });
|
|
1995
|
-
return Object.assign(Object.assign({}, result), { [attributeName]: parseDateTime(data[columnName]) });
|
|
1996
|
-
}, {});
|
|
1997
|
-
GraphQLFieldHelper.ConvertFieldValueTo = (instance, fields, update = false) => {
|
|
1998
|
-
var _a;
|
|
1999
|
-
const data = ((_a = instance.toPlain) === null || _a === void 0 ? void 0 : _a.call(instance)) || instance;
|
|
2000
|
-
return Object.keys(data).reduce((result, attributeName) => {
|
|
2001
|
-
const { columnName, fields: attributeFields, foreignKeyColumn, to, bindPersistData, } = AttributeOptionHelper.FindByAttribute(attributeName, fields);
|
|
2002
|
-
if (bindPersistData)
|
|
2003
|
-
return Object.assign(Object.assign({}, result), bindPersistData(data[attributeName], instance));
|
|
2004
|
-
if (isNil(columnName))
|
|
2005
|
-
return result;
|
|
2006
|
-
if (!!foreignKeyColumn &&
|
|
2007
|
-
!isEmpty(foreignKeyColumn) &&
|
|
2008
|
-
!Object.keys(foreignKeyColumn).filter((key) => { var _a; return !((_a = data[attributeName]) === null || _a === void 0 ? void 0 : _a[key]); }).length)
|
|
2009
|
-
return Object.keys(foreignKeyColumn).reduce((object, current) => { var _a; return (Object.assign(Object.assign({}, object), { [foreignKeyColumn[current]]: (_a = data[attributeName]) === null || _a === void 0 ? void 0 : _a[current] })); }, Object.assign({}, result));
|
|
2010
|
-
if (update && isObject(data[attributeName]) && !isNil(attributeFields) && !isDate(data[attributeName]))
|
|
2011
|
-
return result;
|
|
2012
|
-
if (!!columnName && Array.isArray(attributeFields) && isObject(data[attributeName])) {
|
|
2013
|
-
const converted = !isNil(columnName) && to ? to(instance[attributeName], instance) : data[attributeName];
|
|
2014
|
-
return Object.assign(Object.assign({}, result), (converted !== undefined
|
|
2015
|
-
? {
|
|
2016
|
-
[columnName]: {
|
|
2017
|
-
data: instance[attributeName] instanceof BaseModel
|
|
2018
|
-
? GraphQLFieldHelper.ConvertFieldValueTo(data[attributeName], attributeFields)
|
|
2019
|
-
: converted,
|
|
2020
|
-
},
|
|
2021
|
-
}
|
|
2022
|
-
: {}));
|
|
2023
|
-
}
|
|
2024
|
-
if (!!to)
|
|
2025
|
-
return Object.assign(Object.assign({}, result), { [columnName]: to(instance[attributeName], instance) });
|
|
2026
|
-
return Object.assign(Object.assign({}, result), { [columnName]: data[attributeName] });
|
|
2027
|
-
}, {});
|
|
2028
|
-
};
|
|
2029
|
-
|
|
2030
|
-
class FilterOptionHelper {
|
|
2031
|
-
}
|
|
2032
|
-
FilterOptionHelper.CheckIfIsFilterOption = (filter) => !isNil(filter === null || filter === void 0 ? void 0 : filter.operator);
|
|
2033
|
-
FilterOptionHelper.GetValueFromFilter = (filter, fieldOption) => {
|
|
2034
|
-
if (!FilterOptionHelper.CheckIfIsFilterOption(filter))
|
|
2035
|
-
return filter;
|
|
2036
|
-
if (filter.operator === Where.ISNULL)
|
|
2037
|
-
return true;
|
|
2038
|
-
if (filter.operator === Where.ISNOTNULL)
|
|
2039
|
-
return false;
|
|
2040
|
-
const converter = fieldOption.to ? fieldOption.to : (value) => value;
|
|
2041
|
-
return Array.isArray(filter.value) && !fieldOption.fields && [Where.IN, Where.NOTIN].includes(filter.operator)
|
|
2042
|
-
? filter.value.map((fieldValue) => converter(fieldValue))
|
|
2043
|
-
: converter(filter.value);
|
|
2044
|
-
};
|
|
2045
|
-
|
|
2046
|
-
const withCreateHasuraGraphQL = (MixinBase) => {
|
|
2047
|
-
return class CreateHasuraGraphQLMixin extends MixinBase {
|
|
2048
|
-
constructor(...params) {
|
|
2049
|
-
const options = params === null || params === void 0 ? void 0 : params[0];
|
|
2050
|
-
super(...params);
|
|
2051
|
-
this.insertGraphQLOperation = (options === null || options === void 0 ? void 0 : options.insertGraphQLOperation) || `insert_${this.tableName}_one`;
|
|
2052
|
-
this.insertGraphQLObjectType = (options === null || options === void 0 ? void 0 : options.insertGraphQLObjectType) || `${this.tableName}_insert_input`;
|
|
2053
|
-
}
|
|
2054
|
-
create(data) {
|
|
2055
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
2056
|
-
const newData = yield this.save(this.model.toInstance(data));
|
|
2057
|
-
return this.model.toInstance(newData);
|
|
2058
|
-
});
|
|
2059
|
-
}
|
|
2060
|
-
save(data) {
|
|
2061
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
2062
|
-
const primaryKeyColumns = this.model.identifiersFields.map((field) => AttributeOptionHelper.FindByAttribute(field, this.fields).columnName);
|
|
2063
|
-
const foreignKeyColumns = this.fields
|
|
2064
|
-
.map((field) => {
|
|
2065
|
-
const columnOptions = Object.values(field).shift();
|
|
2066
|
-
return (AttributeOptionHelper.CheckIsColumnOption(columnOptions) &&
|
|
2067
|
-
columnOptions.foreignKeyColumn && [
|
|
2068
|
-
...Object.values(columnOptions.foreignKeyColumn),
|
|
2069
|
-
{
|
|
2070
|
-
[columnOptions.columnName]: Object.keys(columnOptions.foreignKeyColumn).map((foreignKeyField) => {
|
|
2071
|
-
var _a;
|
|
2072
|
-
return ((_a = AttributeOptionHelper.FindByAttribute(foreignKeyField, columnOptions === null || columnOptions === void 0 ? void 0 : columnOptions.fields)) === null || _a === void 0 ? void 0 : _a.columnName) ||
|
|
2073
|
-
foreignKeyField;
|
|
2074
|
-
}),
|
|
2075
|
-
},
|
|
2076
|
-
]);
|
|
2077
|
-
})
|
|
2078
|
-
.filter(Boolean)
|
|
2079
|
-
.reduce((keys, current) => [...keys, ...current], []);
|
|
2080
|
-
const result = yield this.mutation(this.insertGraphQLOperation, [...primaryKeyColumns, ...foreignKeyColumns], {
|
|
2081
|
-
object: { type: this.insertGraphQLObjectType, required: true, value: this.convertDataToHasura(data) },
|
|
2082
|
-
});
|
|
2083
|
-
return Object.assign(Object.assign({}, data.toPlain()), this.convertDataFromHasura(result[this.insertGraphQLOperation]).toPlain());
|
|
2084
|
-
});
|
|
2085
|
-
}
|
|
2086
|
-
};
|
|
2087
|
-
};
|
|
2088
|
-
|
|
2089
|
-
const withDeleteHasuraGraphQL = (MixinBase) => {
|
|
2090
|
-
return class DeleteHasuraGraphQLMixin extends MixinBase {
|
|
2091
|
-
constructor(...params) {
|
|
2092
|
-
const options = params === null || params === void 0 ? void 0 : params[0];
|
|
2093
|
-
super(...params);
|
|
2094
|
-
this.deleteGraphQLOperation = (options === null || options === void 0 ? void 0 : options.deleteGraphQLOperation) || `delete_${this.tableName}_by_pk`;
|
|
2095
|
-
}
|
|
2096
|
-
delete(identifiers) {
|
|
2097
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
2098
|
-
const instance = this.model.toInstance(identifiers);
|
|
2099
|
-
yield this.mutation(this.deleteGraphQLOperation, this.model.identifiersFields.map((field) => AttributeOptionHelper.FindByAttribute(field, this.fields).columnName), this.model.identifiersFields.reduce((ids, identifier) => {
|
|
2100
|
-
if (isNil(instance[identifier]))
|
|
2101
|
-
return ids;
|
|
2102
|
-
const columnOption = AttributeOptionHelper.FindByAttribute(identifier, this.fields);
|
|
2103
|
-
const value = columnOption.to(identifiers[identifier.toString()], instance);
|
|
2104
|
-
return Object.assign(Object.assign({}, ids), { [columnOption.columnName]: {
|
|
2105
|
-
type: this.getAttributeGraphQLTypeOf(columnOption.type || value),
|
|
2106
|
-
value,
|
|
2107
|
-
required: true,
|
|
2108
|
-
} });
|
|
2109
|
-
}, {}));
|
|
2110
|
-
});
|
|
2111
|
-
}
|
|
2112
|
-
};
|
|
2113
|
-
};
|
|
2114
|
-
|
|
2115
|
-
const withHasuraGraphQL = (MixinBase) => {
|
|
2116
|
-
return class HasuraGraphQLMixin extends MixinBase {
|
|
2117
|
-
constructor(...params) {
|
|
2118
|
-
const options = params[0];
|
|
2119
|
-
super(...params);
|
|
2120
|
-
this.tableName = options.tableName;
|
|
2121
|
-
this.endpoint = options.endpoint;
|
|
2122
|
-
this.authOptions = options.authOptions;
|
|
2123
|
-
this.model = options.model;
|
|
2124
|
-
this.fields = options.fields || this.model.identifiersFields;
|
|
2125
|
-
}
|
|
2126
|
-
get headers() {
|
|
2127
|
-
return Object.assign(Object.assign(Object.assign({ 'Content-Type': 'application/json' }, (isNil(this.authOptions.authToken) ? {} : { Authorization: this.authOptions.authToken })), (isNil(this.authOptions.adminSecret) ? {} : { 'X-Hasura-Admin-Secret': this.authOptions.adminSecret })), (isNil(this.authOptions.authRole)
|
|
2128
|
-
? {}
|
|
2129
|
-
: { 'X-Hasura-Role': this.authOptions.authRole.role, 'X-Hasura-User-Id': this.authOptions.authRole.userId }));
|
|
2130
|
-
}
|
|
2131
|
-
mutation(operation, fields, variables) {
|
|
2132
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
2133
|
-
const resultQuery = mutation({
|
|
2134
|
-
operation,
|
|
2135
|
-
variables,
|
|
2136
|
-
fields: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(fields),
|
|
2137
|
-
});
|
|
2138
|
-
return this.fetch(resultQuery);
|
|
2139
|
-
});
|
|
2140
|
-
}
|
|
2141
|
-
query(operation, fields, variables) {
|
|
2142
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
2143
|
-
const resultQuery = GraphQLFieldHelper.CheckIsGraphQLParams(operation)
|
|
2144
|
-
? query(operation.map((option) => ({
|
|
2145
|
-
operation: option.operation,
|
|
2146
|
-
variables: option.variables,
|
|
2147
|
-
fields: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(option.fields),
|
|
2148
|
-
})))
|
|
2149
|
-
: query({
|
|
2150
|
-
operation,
|
|
2151
|
-
variables,
|
|
2152
|
-
fields: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(fields),
|
|
2153
|
-
});
|
|
2154
|
-
return this.fetch(resultQuery);
|
|
2155
|
-
});
|
|
2156
|
-
}
|
|
2157
|
-
fetch(params) {
|
|
2158
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
2159
|
-
const headers = this.headers;
|
|
2160
|
-
const response = yield fetch(`${this.endpoint}`, {
|
|
2161
|
-
method: 'POST',
|
|
2162
|
-
body: JSON.stringify(params),
|
|
2163
|
-
headers,
|
|
2164
|
-
});
|
|
2165
|
-
const result = yield response.json();
|
|
2166
|
-
if (!isNil(result.errors))
|
|
2167
|
-
throw new Error(JSON.stringify(result.errors));
|
|
2168
|
-
return result.data;
|
|
2169
|
-
});
|
|
2170
|
-
}
|
|
2171
|
-
getAttributeGraphQLTypeOf(value) {
|
|
2172
|
-
if (isUUID(value))
|
|
2173
|
-
return 'uuid';
|
|
2174
|
-
if (isString(value))
|
|
2175
|
-
return 'String';
|
|
2176
|
-
if (isBoolean(value))
|
|
2177
|
-
return 'Boolean';
|
|
2178
|
-
if (value instanceof Date)
|
|
2179
|
-
return 'timestamptz';
|
|
2180
|
-
if (isInteger(value))
|
|
2181
|
-
return 'Int';
|
|
2182
|
-
if (isNumber(value))
|
|
2183
|
-
return 'numeric';
|
|
2184
|
-
throw new Error('Type not implemented yet');
|
|
2185
|
-
}
|
|
2186
|
-
checkIfIsDateTimeAndParse(value) {
|
|
2187
|
-
if (!/^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])$/.test(value))
|
|
2188
|
-
return value;
|
|
2189
|
-
const date = parseISO(value);
|
|
2190
|
-
if (isNaN$1(date.getTime()))
|
|
2191
|
-
return value;
|
|
2192
|
-
return date;
|
|
2193
|
-
}
|
|
2194
|
-
convertDataFromHasura(data) {
|
|
2195
|
-
const plain = GraphQLFieldHelper.ConvertFieldValueFrom(data, this.fields);
|
|
2196
|
-
return this.model.toInstance(plain);
|
|
2197
|
-
}
|
|
2198
|
-
convertDataToHasura(instance, update = false) {
|
|
2199
|
-
return GraphQLFieldHelper.ConvertFieldValueTo(instance, this.fields, update);
|
|
2200
|
-
}
|
|
2201
|
-
};
|
|
2202
|
-
};
|
|
2203
|
-
|
|
2204
|
-
const withUpdateHasuraGraphQL = (MixinBase) => {
|
|
2205
|
-
const getValueByAction = (options) => {
|
|
2206
|
-
if (options instanceof BaseModel)
|
|
2207
|
-
return options.toPlain();
|
|
2208
|
-
if (isNil(options === null || options === void 0 ? void 0 : options.action))
|
|
2209
|
-
return options;
|
|
2210
|
-
if ([UpdateOptionActions.REMOVE_FIELD.toString(), UpdateOptionActions.NULL.toString()].includes(options.action))
|
|
2211
|
-
return null;
|
|
2212
|
-
return options.value;
|
|
2213
|
-
};
|
|
2214
|
-
return class UpdateHasuraGraphQLMixin extends MixinBase {
|
|
2215
|
-
constructor(...params) {
|
|
2216
|
-
const options = params === null || params === void 0 ? void 0 : params[0];
|
|
2217
|
-
super(...params);
|
|
2218
|
-
this.updateGraphQLOperation = (options === null || options === void 0 ? void 0 : options.updateGraphQLOperation) || `update_${this.tableName}_by_pk`;
|
|
2219
|
-
this.updateGraphQLObjectType = (options === null || options === void 0 ? void 0 : options.updateGraphQLObjectType) || `${this.tableName}_set_input`;
|
|
2220
|
-
this.updateGraphQLPKType = (options === null || options === void 0 ? void 0 : options.updateGraphQLPKType) || `${this.tableName}_pk_columns_input`;
|
|
2221
|
-
}
|
|
2222
|
-
update(data) {
|
|
2223
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
2224
|
-
const plainData = this.paramsToPlain(data);
|
|
2225
|
-
yield this.mutation(this.updateGraphQLOperation, this.model.identifiersFields.map((field) => AttributeOptionHelper.FindByAttribute(field, this.fields).columnName), {
|
|
2226
|
-
_set: {
|
|
2227
|
-
type: this.updateGraphQLObjectType,
|
|
2228
|
-
value: this.convertDataToHasura(this.model.toInstance(plainData), true),
|
|
2229
|
-
required: true,
|
|
2230
|
-
},
|
|
2231
|
-
pk_columns: { type: this.updateGraphQLPKType, value: this.getUpdateModelKeys(plainData), required: true },
|
|
2232
|
-
});
|
|
2233
|
-
return this.model.toInstance(plainData);
|
|
2234
|
-
});
|
|
2235
|
-
}
|
|
2236
|
-
paramsToPlain(params) {
|
|
2237
|
-
const model = this.model;
|
|
2238
|
-
if (model.isModel(params))
|
|
2239
|
-
return params.toPlain();
|
|
2240
|
-
return Object.keys(params).reduce((data, currentKey) => (Object.assign(Object.assign({}, data), (params[currentKey] !== undefined && { [currentKey]: getValueByAction(params[currentKey]) }))), {});
|
|
2241
|
-
}
|
|
2242
|
-
getUpdateModelKeys(data) {
|
|
2243
|
-
const instance = this.model.toInstance(data);
|
|
2244
|
-
return this.model.identifiersFields.reduce((ids, identifier) => {
|
|
2245
|
-
var _a;
|
|
2246
|
-
if (isNil(instance[identifier]))
|
|
2247
|
-
return ids;
|
|
2248
|
-
const columnOption = AttributeOptionHelper.FindByAttribute(identifier, this.fields);
|
|
2249
|
-
const value = ((_a = columnOption === null || columnOption === void 0 ? void 0 : columnOption.to) === null || _a === void 0 ? void 0 : _a.call(columnOption, data[identifier.toString()], instance)) || data[columnOption.attributeName];
|
|
2250
|
-
return Object.assign(Object.assign({}, ids), { [columnOption.columnName]: value });
|
|
2251
|
-
}, {});
|
|
2252
|
-
}
|
|
2253
|
-
};
|
|
2254
|
-
};
|
|
2255
|
-
|
|
2256
|
-
const withGetHasuraGraphQL = (MixinBase) => {
|
|
2257
|
-
return class GetHasuraGraphQLMixin extends MixinBase {
|
|
2258
|
-
constructor(...params) {
|
|
2259
|
-
const options = params === null || params === void 0 ? void 0 : params[0];
|
|
2260
|
-
super(...params);
|
|
2261
|
-
this.getGraphQLOperation = (options === null || options === void 0 ? void 0 : options.getGraphQLOperation) || `${this.tableName}_by_pk`;
|
|
2262
|
-
}
|
|
2263
|
-
get(identifiers) {
|
|
2264
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
2265
|
-
const instance = this.model.toInstance(identifiers);
|
|
2266
|
-
const result = yield this.query(this.getGraphQLOperation, this.fields, this.model.identifiersFields.reduce((ids, identifier) => {
|
|
2267
|
-
var _a;
|
|
2268
|
-
if (isNil(instance[identifier]))
|
|
2269
|
-
return ids;
|
|
2270
|
-
const columnOption = AttributeOptionHelper.FindByAttribute(identifier, this.fields);
|
|
2271
|
-
const value = ((_a = columnOption === null || columnOption === void 0 ? void 0 : columnOption.to) === null || _a === void 0 ? void 0 : _a.call(columnOption, identifiers[identifier.toString()], instance)) || identifiers[identifier.toString()];
|
|
2272
|
-
return Object.assign(Object.assign({}, ids), { [columnOption.columnName]: {
|
|
2273
|
-
type: this.getAttributeGraphQLTypeOf(columnOption.type || value),
|
|
2274
|
-
value,
|
|
2275
|
-
required: true,
|
|
2276
|
-
} });
|
|
2277
|
-
}, {}));
|
|
2278
|
-
const data = result[this.getGraphQLOperation];
|
|
2279
|
-
if (isNil(data))
|
|
2280
|
-
throw new NotFoundError(`${instance.constructor.name} not found`);
|
|
2281
|
-
return this.convertDataFromHasura(result[this.getGraphQLOperation]);
|
|
2282
|
-
});
|
|
2283
|
-
}
|
|
2284
|
-
};
|
|
2285
|
-
};
|
|
2286
|
-
|
|
2287
|
-
var HasuraGraphQLWhere;
|
|
2288
|
-
(function (HasuraGraphQLWhere) {
|
|
2289
|
-
HasuraGraphQLWhere["EQUALS"] = "_eq";
|
|
2290
|
-
HasuraGraphQLWhere["GT"] = "_gt";
|
|
2291
|
-
HasuraGraphQLWhere["GTE"] = "_gte";
|
|
2292
|
-
HasuraGraphQLWhere["IN"] = "_in";
|
|
2293
|
-
HasuraGraphQLWhere["NOTIN"] = "_nin";
|
|
2294
|
-
HasuraGraphQLWhere["LT"] = "_lt";
|
|
2295
|
-
HasuraGraphQLWhere["LTE"] = "_lte";
|
|
2296
|
-
HasuraGraphQLWhere["LIKE"] = "_like";
|
|
2297
|
-
HasuraGraphQLWhere["NOTLIKE"] = "_nlike";
|
|
2298
|
-
HasuraGraphQLWhere["ISNULL"] = "_is_null";
|
|
2299
|
-
HasuraGraphQLWhere["ISNOTNULL"] = "_is_null";
|
|
2300
|
-
})(HasuraGraphQLWhere || (HasuraGraphQLWhere = {}));
|
|
2301
|
-
|
|
2302
|
-
var HasuraGraphQLColumnType;
|
|
2303
|
-
(function (HasuraGraphQLColumnType) {
|
|
2304
|
-
HasuraGraphQLColumnType["Int"] = "Int";
|
|
2305
|
-
HasuraGraphQLColumnType["Float"] = "Float";
|
|
2306
|
-
HasuraGraphQLColumnType["Boolean"] = "Boolean";
|
|
2307
|
-
HasuraGraphQLColumnType["String"] = "String";
|
|
2308
|
-
HasuraGraphQLColumnType["DateTime"] = "timestampz";
|
|
2309
|
-
HasuraGraphQLColumnType["Json"] = "json";
|
|
2310
|
-
HasuraGraphQLColumnType["Jsonb"] = "jsonb";
|
|
2311
|
-
HasuraGraphQLColumnType["Enum"] = "enum";
|
|
2312
|
-
HasuraGraphQLColumnType["Uuid"] = "uuid";
|
|
2313
|
-
})(HasuraGraphQLColumnType || (HasuraGraphQLColumnType = {}));
|
|
2314
|
-
|
|
2315
|
-
const withFindHasuraGraphQL = (MixinBase) => {
|
|
2316
|
-
return class FindHasuraGraphQLMixin extends MixinBase {
|
|
2317
|
-
constructor() {
|
|
2318
|
-
super(...arguments);
|
|
2319
|
-
this.makeGraphQLWhere = (filter, fields) => Object.keys(filter).reduce((variables, fieldName) => {
|
|
2320
|
-
const columnOption = AttributeOptionHelper.FindByAttribute(fieldName, fields);
|
|
2321
|
-
if (!columnOption.bindFindFilter)
|
|
2322
|
-
return Object.assign(Object.assign({}, variables), { [columnOption.columnName]: this.buildWhereSentence(fieldName, filter[fieldName], fields) });
|
|
2323
|
-
const builtFilter = columnOption.bindFindFilter(filter[fieldName]);
|
|
2324
|
-
return Object.assign(Object.assign({}, variables), Object.keys(builtFilter).reduce((variablesList, columnName) => (Object.assign(Object.assign({}, variablesList), { [columnName]: this.buildWhereSentence(fieldName, builtFilter[columnName], fields) })), {}));
|
|
2325
|
-
}, {});
|
|
2326
|
-
this.buildWhereSentence = (field, options, fields) => {
|
|
2327
|
-
const fieldSentenceOptions = AttributeOptionHelper.FindByAttribute(field, fields);
|
|
2328
|
-
if (!Array.isArray(options) &&
|
|
2329
|
-
isObject(options) &&
|
|
2330
|
-
isNil(options === null || options === void 0 ? void 0 : options.operator) &&
|
|
2331
|
-
isNil(options === null || options === void 0 ? void 0 : options.value) &&
|
|
2332
|
-
isNil(fieldSentenceOptions === null || fieldSentenceOptions === void 0 ? void 0 : fieldSentenceOptions.to))
|
|
2333
|
-
return Object.keys(options).reduce((variables, key) => {
|
|
2334
|
-
const fieldOptions = AttributeOptionHelper.FindByAttribute(key, (fieldSentenceOptions === null || fieldSentenceOptions === void 0 ? void 0 : fieldSentenceOptions.fields) || fields);
|
|
2335
|
-
const columnName = fieldOptions.columnName;
|
|
2336
|
-
const columnFields = fieldOptions.fields;
|
|
2337
|
-
return Object.assign(Object.assign({}, variables), { [columnName]: this.buildWhereSentence(key, options[key], columnFields || []) });
|
|
2338
|
-
}, {});
|
|
2339
|
-
if (!Array.isArray(options) && !isNil(fieldSentenceOptions.fields))
|
|
2340
|
-
return {
|
|
2341
|
-
[fieldSentenceOptions.fields[0]]: this.buildOperatorSentence(options, fieldSentenceOptions),
|
|
2342
|
-
};
|
|
2343
|
-
if (isObject(options) && !FilterOptionHelper.CheckIfIsFilterOption(options))
|
|
2344
|
-
options = Object.values(options)[0];
|
|
2345
|
-
return Array.isArray(options)
|
|
2346
|
-
? options.reduce((whereSentence, option) => (Object.assign(Object.assign({}, whereSentence), this.buildOperatorSentence(option, fieldSentenceOptions))), {})
|
|
2347
|
-
: this.buildOperatorSentence(options, fieldSentenceOptions);
|
|
2348
|
-
};
|
|
2349
|
-
this.buildOperatorSentence = (options, fieldOption) => ({
|
|
2350
|
-
[this.getHasuraOperator(options, fieldOption)]: FilterOptionHelper.GetValueFromFilter(options, fieldOption),
|
|
2351
|
-
});
|
|
2352
|
-
this.getHasuraOperator = (options, fieldOption) => FilterOptionHelper.CheckIfIsFilterOption(options)
|
|
2353
|
-
? fieldOption.type === HasuraGraphQLColumnType.Jsonb
|
|
2354
|
-
? this.getHasuraJsonbOperator(options)
|
|
2355
|
-
: HasuraGraphQLWhere[Object.keys(HasuraGraphQLWhere).find((graphQLOperator) => graphQLOperator === Object.keys(Where).find((operator) => Where[operator] === (options === null || options === void 0 ? void 0 : options.operator)))]
|
|
2356
|
-
: HasuraGraphQLWhere.EQUALS;
|
|
2357
|
-
this.getHasuraJsonbOperator = (options) => options.operator === Where.IN
|
|
2358
|
-
? '_contains'
|
|
2359
|
-
: options.operator === Where.LIKE
|
|
2360
|
-
? '_has_keys_any'
|
|
2361
|
-
: HasuraGraphQLWhere[Object.keys(HasuraGraphQLWhere).find((graphQLOperator) => graphQLOperator === Object.keys(Where).find((operator) => Where[operator] === (options === null || options === void 0 ? void 0 : options.operator)))];
|
|
2362
|
-
}
|
|
2363
|
-
find(options) {
|
|
2364
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
2365
|
-
const { filters, limits, orderBy } = options || {};
|
|
2366
|
-
const variablesCount = Object.assign(Object.assign({}, (isNil(orderBy) ? {} : { order_by: { type: `${this.tableName}_order_by!`, list: true, value: orderBy } })), (isNil(filters)
|
|
2367
|
-
? {}
|
|
2368
|
-
: {
|
|
2369
|
-
where: {
|
|
2370
|
-
value: this.makeGraphQLWhere(filters, this.fields),
|
|
2371
|
-
type: `${this.tableName}_bool_exp`,
|
|
2372
|
-
required: true,
|
|
2373
|
-
},
|
|
2374
|
-
}));
|
|
2375
|
-
const variables = Object.assign(Object.assign({}, (isNil(limits) ? {} : limits)), variablesCount);
|
|
2376
|
-
const result = yield this.query([
|
|
2377
|
-
{
|
|
2378
|
-
operation: this.tableName,
|
|
2379
|
-
fields: options.fields
|
|
2380
|
-
? options.fields
|
|
2381
|
-
.map((fieldName) => {
|
|
2382
|
-
var _a;
|
|
2383
|
-
return (_a = this.fields.find((fieldOption) => fieldOption === fieldName)) !== null && _a !== void 0 ? _a : this.fields.find((fieldOption) => Object.keys(fieldOption).shift() === fieldName);
|
|
2384
|
-
})
|
|
2385
|
-
.filter(Boolean)
|
|
2386
|
-
: this.fields,
|
|
2387
|
-
variables,
|
|
2388
|
-
},
|
|
2389
|
-
{
|
|
2390
|
-
operation: `${this.tableName}_aggregate`,
|
|
2391
|
-
fields: [{ aggregate: ['count'] }],
|
|
2392
|
-
variables: variablesCount,
|
|
2393
|
-
},
|
|
2394
|
-
]);
|
|
2395
|
-
const data = result[this.tableName].map((row) => this.convertDataFromHasura(row));
|
|
2396
|
-
const count = result[`${this.tableName}_aggregate`].aggregate.count;
|
|
2397
|
-
return { count, data };
|
|
2398
|
-
});
|
|
2399
|
-
}
|
|
2400
|
-
};
|
|
2401
|
-
};
|
|
2402
|
-
|
|
2403
|
-
const withCrudHasuraGraphQL = (MixinBase) => {
|
|
2404
|
-
return class CrudHasuraGraphQLMixin extends withUpdateHasuraGraphQL(withGetHasuraGraphQL(withFindHasuraGraphQL(withDeleteHasuraGraphQL(withCreateHasuraGraphQL(MixinBase))))) {
|
|
2405
|
-
};
|
|
2406
|
-
};
|
|
2407
|
-
|
|
2408
|
-
class CategoryHasuraGraphQL extends Category {
|
|
2409
|
-
}
|
|
2410
|
-
|
|
2411
|
-
class ProductHasuraGraphQL extends Product {
|
|
2412
|
-
}
|
|
2413
|
-
__decorate([
|
|
2414
|
-
Type(() => KitProductHasuraGraphQL),
|
|
2415
|
-
__metadata("design:type", Array)
|
|
2416
|
-
], ProductHasuraGraphQL.prototype, "kitProducts", void 0);
|
|
2417
|
-
|
|
2418
|
-
class KitProductHasuraGraphQL extends KitProduct {
|
|
2419
|
-
}
|
|
2420
|
-
__decorate([
|
|
2421
|
-
Type(() => ProductHasuraGraphQL),
|
|
2422
|
-
__metadata("design:type", ProductHasuraGraphQL)
|
|
2423
|
-
], KitProductHasuraGraphQL.prototype, "kit", void 0);
|
|
2424
|
-
__decorate([
|
|
2425
|
-
Type(() => ProductHasuraGraphQL),
|
|
2426
|
-
__metadata("design:type", ProductHasuraGraphQL)
|
|
2427
|
-
], KitProductHasuraGraphQL.prototype, "product", void 0);
|
|
2428
|
-
|
|
2429
|
-
class VariantHasuraGraphQL extends Variant {
|
|
2430
|
-
constructor() {
|
|
2431
|
-
super(...arguments);
|
|
2432
|
-
this.name = '';
|
|
2433
|
-
this.hasVariants = false;
|
|
2434
|
-
}
|
|
2435
|
-
}
|
|
2436
|
-
|
|
2437
|
-
class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
2438
|
-
constructor(endpoint, authOptions, productRepository) {
|
|
2439
|
-
super({
|
|
2440
|
-
tableName: 'category',
|
|
2441
|
-
model: Category,
|
|
2442
|
-
endpoint,
|
|
2443
|
-
authOptions,
|
|
2444
|
-
fields: [
|
|
2445
|
-
{ id: { columnName: 'id', to: (value) => +value, from: (value) => value.toString() } },
|
|
2446
|
-
{ firestoreId: { columnName: 'firestore_id' } },
|
|
2447
|
-
'name',
|
|
2448
|
-
'description',
|
|
2449
|
-
'image',
|
|
2450
|
-
'published',
|
|
2451
|
-
'shop',
|
|
2452
|
-
'slug',
|
|
2453
|
-
{ brandCategory: { columnName: 'brand_category' } },
|
|
2454
|
-
{ brandCategoryBanner: { columnName: 'brand_banner' } },
|
|
2455
|
-
{ brandCategoryBannerMobile: { columnName: 'brand_banner_mobile' } },
|
|
2456
|
-
{ brandLogo: { columnName: 'brand_logo' } },
|
|
2457
|
-
{ brandCondition: { columnName: 'brand_condition' } },
|
|
2458
|
-
{
|
|
2459
|
-
conditions: {
|
|
2460
|
-
columnName: 'tag_condition',
|
|
2461
|
-
type: HasuraGraphQLColumnType.Jsonb,
|
|
2462
|
-
from: (tags, row) => ({ brand: row.brand_condition, tags: Array.isArray(tags) ? tags : [] }),
|
|
2463
|
-
bindPersistData: (value) => {
|
|
2464
|
-
var _a, _b;
|
|
2465
|
-
return {
|
|
2466
|
-
brand_condition: value.brand,
|
|
2467
|
-
tag_condition: `{"${((_b = (_a = value === null || value === void 0 ? void 0 : value.tags) === null || _a === void 0 ? void 0 : _a.join) === null || _b === void 0 ? void 0 : _b.call(_a, '","')) || ''}"}`,
|
|
2468
|
-
};
|
|
2469
|
-
},
|
|
2470
|
-
bindFindFilter: (sentence) => {
|
|
2471
|
-
return Object.assign(Object.assign({}, (sentence.brand ? { brand_condition: sentence.brand } : {})), (sentence.tags ? { tag_condition: sentence.tags } : {}));
|
|
2472
|
-
},
|
|
2473
|
-
},
|
|
2474
|
-
},
|
|
2475
|
-
'filters',
|
|
2476
|
-
{ createdAt: { columnName: 'created_at' } },
|
|
2477
|
-
{ updatedAt: { columnName: 'updated_at' } },
|
|
2478
|
-
{
|
|
2479
|
-
products: {
|
|
2480
|
-
columnName: 'products',
|
|
2481
|
-
fields: ['product_id'],
|
|
2482
|
-
from: (value) => value.map((product) => product.product_id.toString()),
|
|
2483
|
-
to: (productIds) => productIds.map((productId) => ({
|
|
2484
|
-
product_id: +productId,
|
|
2485
|
-
})),
|
|
2486
|
-
},
|
|
2487
|
-
},
|
|
2488
|
-
],
|
|
2489
|
-
});
|
|
2490
|
-
this.productRepository = productRepository;
|
|
2491
|
-
}
|
|
2492
|
-
get(identifiers) {
|
|
2493
|
-
const _super = Object.create(null, {
|
|
2494
|
-
get: { get: () => super.get }
|
|
2495
|
-
});
|
|
2496
|
-
var _a;
|
|
2497
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
2498
|
-
return Number.isNaN(+identifiers.id)
|
|
2499
|
-
? (_a = (yield this.find({ filters: { firestoreId: identifiers.id } })).data) === null || _a === void 0 ? void 0 : _a[0]
|
|
2500
|
-
: _super.get.call(this, identifiers);
|
|
2501
|
-
});
|
|
2502
|
-
}
|
|
2503
|
-
getCategoryBySlug(slug, shop) {
|
|
2504
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
2505
|
-
if (!slug)
|
|
2506
|
-
return;
|
|
2507
|
-
const { data, count } = yield this.find({ filters: { slug, shop, published: true } });
|
|
2508
|
-
if (count > 1)
|
|
2509
|
-
throw new DuplicatedResultsError('Query returned duplicated values');
|
|
2510
|
-
if (!count)
|
|
2511
|
-
throw new NotFoundError(`Category with slug ${slug} not found`);
|
|
2512
|
-
return data.shift();
|
|
2513
|
-
});
|
|
2514
|
-
}
|
|
2515
|
-
getCategoriesForHome(categoryIds, limit = 4) {
|
|
2516
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
2517
|
-
const { data: categories, count } = yield this.find({
|
|
2518
|
-
filters: { firestoreId: { operator: Where.IN, value: categoryIds.filter(Boolean) }, published: true },
|
|
2519
|
-
});
|
|
2520
|
-
if (!count)
|
|
2521
|
-
throw new NotFoundError('Categories not found');
|
|
2522
|
-
const homeSections = yield Promise.all(categories.map((category) => __awaiter(this, void 0, void 0, function* () {
|
|
2523
|
-
return ({
|
|
2524
|
-
category,
|
|
2525
|
-
products: yield this.mountCategory(category, { limit, hasStock: true }),
|
|
2526
|
-
});
|
|
2527
|
-
})));
|
|
2528
|
-
return homeSections;
|
|
2529
|
-
});
|
|
2530
|
-
}
|
|
2531
|
-
mountCategory(category, options) {
|
|
2532
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
2533
|
-
if (!category.products)
|
|
2534
|
-
throw new RequiredArgumentError(['Category products is empty']);
|
|
2535
|
-
const products = [];
|
|
2536
|
-
const publishedField = category.shop === Shops.GLAMSHOP ? 'publishedGlam' : 'published';
|
|
2537
|
-
const { data: productsData } = yield this.productRepository.find(Object.assign({ filters: Object.assign({ id: { operator: Where.IN, value: category.products }, [publishedField]: true }, ((options === null || options === void 0 ? void 0 : options.hasStock) ? { stock: { quantity: { operator: Where.GT, value: 0 } } } : {})), fields: [
|
|
2538
|
-
'id',
|
|
2539
|
-
'name',
|
|
2540
|
-
'slug',
|
|
2541
|
-
'images',
|
|
2542
|
-
'miniatures',
|
|
2543
|
-
'price',
|
|
2544
|
-
'fullPrice',
|
|
2545
|
-
'subscriberDiscountPercentage',
|
|
2546
|
-
'subscriberPrice',
|
|
2547
|
-
'stock',
|
|
2548
|
-
'published',
|
|
2549
|
-
'publishedGlam',
|
|
2550
|
-
'CEST',
|
|
2551
|
-
'EAN',
|
|
2552
|
-
'NCM',
|
|
2553
|
-
'brand',
|
|
2554
|
-
'costPrice',
|
|
2555
|
-
'hasVariants',
|
|
2556
|
-
'isKit',
|
|
2557
|
-
'shopAvailability',
|
|
2558
|
-
'sku',
|
|
2559
|
-
'rate',
|
|
2560
|
-
] }, ((options === null || options === void 0 ? void 0 : options.limit) ? { limits: { limit: options === null || options === void 0 ? void 0 : options.limit } } : {})));
|
|
2561
|
-
products.push(...productsData);
|
|
2562
|
-
return products;
|
|
2563
|
-
});
|
|
2564
|
-
}
|
|
2565
|
-
}
|
|
2566
|
-
|
|
2567
|
-
class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
2568
|
-
constructor(endpoint, authOptions) {
|
|
2569
|
-
super({
|
|
2570
|
-
tableName: 'product',
|
|
2571
|
-
model: ProductHasuraGraphQL,
|
|
2572
|
-
endpoint,
|
|
2573
|
-
authOptions,
|
|
2574
|
-
fields: [],
|
|
2575
|
-
});
|
|
2576
|
-
this.bindReviewToModel = (plain) => (Object.assign(Object.assign({}, omit(plain, ['product_id', 'created_at', 'updated_at', 'person_id', 'order_id'])), { createdAt: typeof plain.created_at === 'string' ? new Date(plain.created_at) : plain.created_at, updatedAt: typeof plain.updated_at === 'string' ? new Date(plain.updated_at) : plain.updated_at, personId: plain.person_id, orderId: plain.order_id }));
|
|
2577
|
-
this.bindReviewToHasura = (review) => (Object.assign(Object.assign({}, omit(review, ['productId', 'createdAt', 'updatedAt', 'personId', 'orderId'])), { person_id: review.personId, order_id: review.orderId }));
|
|
2578
|
-
const commonFields = [
|
|
2579
|
-
{ id: { columnName: 'id', to: (value) => +value, from: (value) => value.toString() } },
|
|
2580
|
-
{ firestoreId: { columnName: 'firestore_id' } },
|
|
2581
|
-
{ CEST: { columnName: 'cest' } },
|
|
2582
|
-
{ EAN: { columnName: 'ean' } },
|
|
2583
|
-
{ NCM: { columnName: 'ncm' } },
|
|
2584
|
-
'brand',
|
|
2585
|
-
{ costPrice: { columnName: 'cost_price' } },
|
|
2586
|
-
{
|
|
2587
|
-
description: {
|
|
2588
|
-
columnName: 'description',
|
|
2589
|
-
from: (description) => Object.values(Shops).reduce((shops, shop) => (Object.assign(Object.assign({}, shops), { [shop]: { description } })), {}),
|
|
2590
|
-
to: (value) => Object.values(value).shift().description,
|
|
2591
|
-
},
|
|
2592
|
-
},
|
|
2593
|
-
{ hasVariants: { columnName: 'has_variants' } },
|
|
2594
|
-
{ images: { columnName: 'images', to: (value) => { var _a; return `{"${((_a = value === null || value === void 0 ? void 0 : value.join) === null || _a === void 0 ? void 0 : _a.call(value, `","`)) || ''}"}`; } } },
|
|
2595
|
-
{ miniatures: { columnName: 'miniatures', to: (value) => { var _a; return `{"${((_a = value === null || value === void 0 ? void 0 : value.join) === null || _a === void 0 ? void 0 : _a.call(value, `","`)) || ''}"}`; } } },
|
|
2596
|
-
'name',
|
|
2597
|
-
{
|
|
2598
|
-
price: {
|
|
2599
|
-
columnName: 'price',
|
|
2600
|
-
from: (price, data) => Object.values(Shops).reduce((prices, shop) => (Object.assign(Object.assign({}, prices), { [shop]: {
|
|
2601
|
-
price,
|
|
2602
|
-
fullPrice: data.full_price,
|
|
2603
|
-
subscriberDiscountPercentage: data.subscriber_discount_percentage,
|
|
2604
|
-
subscriberPrice: data.subscriber_price,
|
|
2605
|
-
} })), {}),
|
|
2606
|
-
bindFindFilter: (sentence) => {
|
|
2607
|
-
const filters = Object.values(sentence).shift();
|
|
2608
|
-
return Object.assign(Object.assign(Object.assign(Object.assign({}, (((filters === null || filters === void 0 ? void 0 : filters.price) || (filters === null || filters === void 0 ? void 0 : filters.price) === 0) && { price: filters.price })), ((filters.fullPrice || filters.fullPrice === 0) && { full_price: filters.fullPrice })), ((filters.subscriberDiscountPercentage || filters.subscriberDiscountPercentage === 0) && {
|
|
2609
|
-
subscriber_discount_percentage: filters.subscriberDiscountPercentage,
|
|
2610
|
-
})), ((filters.subscriberPrice || filters.subscriberPrice === 0) && {
|
|
2611
|
-
subscriber_price: filters.subscriberPrice,
|
|
2612
|
-
}));
|
|
2613
|
-
},
|
|
2614
|
-
bindPersistData: (value) => {
|
|
2615
|
-
const priceData = Object.values(value).shift();
|
|
2616
|
-
return Object.assign(Object.assign(Object.assign(Object.assign({}, ((priceData === null || priceData === void 0 ? void 0 : priceData.price) >= 0 && { price: priceData.price })), (priceData.fullPrice >= 0 && { full_price: priceData.fullPrice })), (priceData.subscriberDiscountPercentage >= 0 && {
|
|
2617
|
-
subscriber_discount_percentage: priceData.subscriberDiscountPercentage,
|
|
2618
|
-
})), (priceData.subscriberPrice >= 0 && { subscriber_price: priceData.subscriberPrice }));
|
|
2619
|
-
},
|
|
2620
|
-
},
|
|
2621
|
-
},
|
|
2622
|
-
{ fullPrice: { columnName: 'full_price' } },
|
|
2623
|
-
{ subscriberDiscountPercentage: { columnName: 'subscriber_discount_percentage' } },
|
|
2624
|
-
{ subscriberPrice: { columnName: 'subscriber_price' } },
|
|
2625
|
-
'published',
|
|
2626
|
-
{ publishedGlam: { columnName: 'published_glam' } },
|
|
2627
|
-
'sku',
|
|
2628
|
-
{
|
|
2629
|
-
stock: {
|
|
2630
|
-
columnName: 'stock',
|
|
2631
|
-
from: (quantity) => ({ quantity }),
|
|
2632
|
-
to: (value) => (isNil(value === null || value === void 0 ? void 0 : value.quantity) ? value : value === null || value === void 0 ? void 0 : value.quantity),
|
|
2633
|
-
},
|
|
2634
|
-
},
|
|
2635
|
-
'slug',
|
|
2636
|
-
'type',
|
|
2637
|
-
'video',
|
|
2638
|
-
'weight',
|
|
2639
|
-
{
|
|
2640
|
-
shopAvailability: {
|
|
2641
|
-
columnName: 'shop_availabilities',
|
|
2642
|
-
fields: ['shop'],
|
|
2643
|
-
from: (shop) => (Array.isArray(shop) ? shop.map((row) => row.shop) : []),
|
|
2644
|
-
bindPersistData: (shops) => ({ shop_availabilities: { data: shops.map((shop) => ({ shop })) } }),
|
|
2645
|
-
},
|
|
2646
|
-
},
|
|
2647
|
-
{ tags: { columnName: 'tags', type: HasuraGraphQLColumnType.Jsonb } },
|
|
2648
|
-
{ isKit: { columnName: 'is_kit' } },
|
|
2649
|
-
{ createdAt: { columnName: 'created_at' } },
|
|
2650
|
-
{ updatedAt: { columnName: 'updated_at' } },
|
|
2651
|
-
{
|
|
2652
|
-
rate: {
|
|
2653
|
-
columnName: 'reviews_aggregate',
|
|
2654
|
-
fields: [{ aggregate: [{ avg: ['rate'] }] }],
|
|
2655
|
-
from: (value) => value.aggregate.avg.rate,
|
|
2656
|
-
},
|
|
2657
|
-
},
|
|
2658
|
-
];
|
|
2659
|
-
this.fields = [
|
|
2660
|
-
...commonFields,
|
|
2661
|
-
{
|
|
2662
|
-
categories: {
|
|
2663
|
-
columnName: 'categories',
|
|
2664
|
-
fields: ['category_id'],
|
|
2665
|
-
bindPersistData: (value) => ({
|
|
2666
|
-
categories: { data: value.map((category) => ({ category_id: +category })) },
|
|
2667
|
-
}),
|
|
2668
|
-
to: (categories) => categories.map((categoryId) => +categoryId),
|
|
2669
|
-
from: (categories) => (categories === null || categories === void 0 ? void 0 : categories.map((category) => { var _a; return (_a = category === null || category === void 0 ? void 0 : category.category_id) === null || _a === void 0 ? void 0 : _a.toString(); })) || [],
|
|
2670
|
-
},
|
|
2671
|
-
},
|
|
2672
|
-
{
|
|
2673
|
-
kitProducts: {
|
|
2674
|
-
columnName: 'kit_products',
|
|
2675
|
-
foreignKeyColumn: { productId: 'id' },
|
|
2676
|
-
fields: [
|
|
2677
|
-
{ productId: { columnName: 'product_id' } },
|
|
2678
|
-
{ kitProductId: { columnName: 'kit_product_id' } },
|
|
2679
|
-
'quantity',
|
|
2680
|
-
{ product: { columnName: 'product', foreignKeyColumn: { id: 'product_id' }, fields: commonFields } },
|
|
2681
|
-
],
|
|
2682
|
-
},
|
|
2683
|
-
},
|
|
2684
|
-
];
|
|
2685
|
-
}
|
|
2686
|
-
get reviewsFields() {
|
|
2687
|
-
return [
|
|
2688
|
-
'id',
|
|
2689
|
-
'shop',
|
|
2690
|
-
'rate',
|
|
2691
|
-
'author',
|
|
2692
|
-
'email',
|
|
2693
|
-
'location',
|
|
2694
|
-
'review',
|
|
2695
|
-
'status',
|
|
2696
|
-
'title',
|
|
2697
|
-
'person_id',
|
|
2698
|
-
'points',
|
|
2699
|
-
'order_id',
|
|
2700
|
-
'created_at',
|
|
2701
|
-
'updated_at',
|
|
2702
|
-
];
|
|
2703
|
-
}
|
|
2704
|
-
create(data) {
|
|
2705
|
-
const _super = Object.create(null, {
|
|
2706
|
-
create: { get: () => super.create }
|
|
2707
|
-
});
|
|
2708
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
2709
|
-
const product = yield _super.create.call(this, omit(data, ['reviews']));
|
|
2710
|
-
try {
|
|
2711
|
-
product.reviews = yield this.updateReviews(+product.id, data);
|
|
2712
|
-
}
|
|
2713
|
-
catch (error) {
|
|
2714
|
-
yield this.delete({ id: product.id });
|
|
2715
|
-
throw error;
|
|
2716
|
-
}
|
|
2717
|
-
return product;
|
|
2718
|
-
});
|
|
2719
|
-
}
|
|
2720
|
-
get(identifiers) {
|
|
2721
|
-
const _super = Object.create(null, {
|
|
2722
|
-
get: { get: () => super.get }
|
|
2723
|
-
});
|
|
2724
|
-
var _a;
|
|
2725
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
2726
|
-
const product = Number.isNaN(+identifiers.id)
|
|
2727
|
-
? (_a = (yield this.find({ filters: { firestoreId: identifiers.id } })).data) === null || _a === void 0 ? void 0 : _a[0]
|
|
2728
|
-
: yield _super.get.call(this, identifiers);
|
|
2729
|
-
product.reviews = yield this.findReviewsByProduct(+product.id);
|
|
2730
|
-
return product;
|
|
2731
|
-
});
|
|
2732
|
-
}
|
|
2733
|
-
getBySlug(slug) {
|
|
2734
|
-
var _a;
|
|
2735
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
2736
|
-
const result = yield this.find({
|
|
2737
|
-
filters: {
|
|
2738
|
-
slug,
|
|
2739
|
-
},
|
|
2740
|
-
});
|
|
2741
|
-
const product = (_a = result === null || result === void 0 ? void 0 : result.data) === null || _a === void 0 ? void 0 : _a.shift();
|
|
2742
|
-
product.reviews = yield this.findReviewsByProduct(+product.id);
|
|
2743
|
-
return product;
|
|
2744
|
-
});
|
|
2745
|
-
}
|
|
2746
|
-
update(params) {
|
|
2747
|
-
const _super = Object.create(null, {
|
|
2748
|
-
update: { get: () => super.update }
|
|
2749
|
-
});
|
|
2750
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
2751
|
-
const { categories, kitProducts, reviews, id: checkId, shopAvailability, rate } = params, data = __rest(params, ["categories", "kitProducts", "reviews", "id", "shopAvailability", "rate"]);
|
|
2752
|
-
const plainData = this.paramsToPlain({ id: checkId });
|
|
2753
|
-
const id = yield this.getId(plainData.id);
|
|
2754
|
-
const product = yield _super.update.call(this, Object.assign({ id }, data));
|
|
2755
|
-
product.categories = categories && (yield this.updateCategories(+id, { categories }));
|
|
2756
|
-
product.kitProducts = kitProducts && (yield this.updateKitProducts(+id, { kitProducts }));
|
|
2757
|
-
product.reviews = reviews && (yield this.updateReviews(+id, { reviews }));
|
|
2758
|
-
return product;
|
|
2759
|
-
});
|
|
2760
|
-
}
|
|
2761
|
-
fetchReviews(status) {
|
|
2762
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
2763
|
-
const reviews = {
|
|
2764
|
-
status: status === 'pending'
|
|
2765
|
-
? { [HasuraGraphQLWhere.ISNULL]: true }
|
|
2766
|
-
: { [HasuraGraphQLWhere.EQUALS]: status === 'approved' },
|
|
2767
|
-
};
|
|
2768
|
-
const { product: data } = yield this.query('product', ['id', 'name', 'sku', { reviews: { columnName: 'reviews', fields: this.reviewsFields } }], {
|
|
2769
|
-
where: { value: { reviews }, type: 'product_bool_exp', required: true },
|
|
2770
|
-
});
|
|
2771
|
-
return data.reduce((reviews, product) => [
|
|
2772
|
-
...reviews,
|
|
2773
|
-
...product.reviews
|
|
2774
|
-
.filter((review) => (status === 'pending' && [undefined, null].includes(review.status)) ||
|
|
2775
|
-
(status === 'approved' && review.status === true) ||
|
|
2776
|
-
(status === 'rejected' && review.status === false))
|
|
2777
|
-
.map((review) => (Object.assign(Object.assign({}, this.bindReviewToModel(review)), { productId: product.id, productName: product.name, productSku: product.sku }))),
|
|
2778
|
-
], []);
|
|
2779
|
-
});
|
|
2780
|
-
}
|
|
2781
|
-
updateCategories(productId, { categories }) {
|
|
2782
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
2783
|
-
const plainData = this.paramsToPlain({ categories });
|
|
2784
|
-
yield this.mutation('delete_category_product', ['affected_rows'], {
|
|
2785
|
-
where: {
|
|
2786
|
-
type: 'category_product_bool_exp',
|
|
2787
|
-
required: true,
|
|
2788
|
-
value: { product_id: { _eq: productId } },
|
|
2789
|
-
},
|
|
2790
|
-
});
|
|
2791
|
-
yield this.mutation('insert_category_product', ['affected_rows'], {
|
|
2792
|
-
objects: {
|
|
2793
|
-
type: '[category_product_insert_input!]',
|
|
2794
|
-
required: true,
|
|
2795
|
-
value: plainData.categories.map((categoryId) => ({ category_id: categoryId, product_id: productId })),
|
|
2796
|
-
},
|
|
2797
|
-
});
|
|
2798
|
-
return plainData.categories;
|
|
2799
|
-
});
|
|
2800
|
-
}
|
|
2801
|
-
updateKitProducts(productId, { kitProducts }) {
|
|
2802
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
2803
|
-
const plainData = this.paramsToPlain({ kitProducts });
|
|
2804
|
-
yield this.mutation('delete_product_kit', ['affected_rows'], {
|
|
2805
|
-
where: {
|
|
2806
|
-
type: 'product_kit_bool_exp',
|
|
2807
|
-
required: true,
|
|
2808
|
-
value: { product_id: { _eq: productId } },
|
|
2809
|
-
},
|
|
2810
|
-
});
|
|
2811
|
-
yield this.mutation('insert_product_kit', ['affected_rows'], {
|
|
2812
|
-
objects: {
|
|
2813
|
-
type: '[product_kit_insert_input!]',
|
|
2814
|
-
required: true,
|
|
2815
|
-
value: plainData.kitProducts.map((kitProduct) => ({
|
|
2816
|
-
kit_product_id: kitProduct.productId || kitProduct.product.id,
|
|
2817
|
-
product_id: productId,
|
|
2818
|
-
quantity: kitProduct.quantity,
|
|
2819
|
-
})),
|
|
2820
|
-
},
|
|
2821
|
-
});
|
|
2822
|
-
return plainData.kitProducts;
|
|
2823
|
-
});
|
|
2824
|
-
}
|
|
2825
|
-
updateReviews(productId, { reviews }) {
|
|
2826
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
2827
|
-
if (!reviews)
|
|
2828
|
-
return [];
|
|
2829
|
-
if ('action' in reviews && reviews.action === 'remove') {
|
|
2830
|
-
const reviewIds = yield Promise.all(reviews.value.map((reviewData) => __awaiter(this, void 0, void 0, function* () {
|
|
2831
|
-
const review = yield this.findReview(reviewData, productId);
|
|
2832
|
-
return review === null || review === void 0 ? void 0 : review.id;
|
|
2833
|
-
})));
|
|
2834
|
-
yield this.mutation('delete_product_review', ['affected_rows'], {
|
|
2835
|
-
where: { value: { id: { _in: reviewIds.filter(Boolean) } }, type: 'product_review_bool_exp', required: true },
|
|
2836
|
-
});
|
|
2837
|
-
return reviews.value.map((review, index) => !reviewIds[index] && review).filter(Boolean);
|
|
2838
|
-
}
|
|
2839
|
-
const plainData = this.paramsToPlain({ reviews });
|
|
2840
|
-
return Promise.all(plainData.reviews.map((reviewData) => __awaiter(this, void 0, void 0, function* () {
|
|
2841
|
-
const review = yield this.findReview(reviewData, productId);
|
|
2842
|
-
if (review.id)
|
|
2843
|
-
return this.bindReviewToModel((yield this.mutation('update_product_review_by_pk', this.reviewsFields, {
|
|
2844
|
-
pk_columns: {
|
|
2845
|
-
value: { id: review.id },
|
|
2846
|
-
type: 'product_review_pk_columns_input',
|
|
2847
|
-
required: true,
|
|
2848
|
-
},
|
|
2849
|
-
_set: {
|
|
2850
|
-
value: omit(this.bindReviewToHasura(reviewData), ['id', 'product_id']),
|
|
2851
|
-
type: 'product_review_set_input',
|
|
2852
|
-
required: true,
|
|
2853
|
-
},
|
|
2854
|
-
})).update_product_review_by_pk);
|
|
2855
|
-
return this.bindReviewToModel((yield this.mutation('insert_product_review_one', this.reviewsFields, {
|
|
2856
|
-
object: {
|
|
2857
|
-
value: omit(Object.assign(Object.assign({}, this.bindReviewToHasura(reviewData)), { product_id: productId }), ['id']),
|
|
2858
|
-
type: 'product_review_insert_input',
|
|
2859
|
-
required: true,
|
|
2860
|
-
},
|
|
2861
|
-
})).insert_product_review_one);
|
|
2862
|
-
})));
|
|
2863
|
-
});
|
|
2864
|
-
}
|
|
2865
|
-
getId(id) {
|
|
2866
|
-
var _a, _b;
|
|
2867
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
2868
|
-
if (!Number.isNaN(+id))
|
|
2869
|
-
return id;
|
|
2870
|
-
const { data } = yield this.find({ filters: { firestoreId: id } });
|
|
2871
|
-
if ((_a = data === null || data === void 0 ? void 0 : data[0]) === null || _a === void 0 ? void 0 : _a.id)
|
|
2872
|
-
return (_b = data === null || data === void 0 ? void 0 : data[0]) === null || _b === void 0 ? void 0 : _b.id;
|
|
2873
|
-
throw new NotFoundError(`Product with id ${id} not found`);
|
|
2874
|
-
});
|
|
2875
|
-
}
|
|
2876
|
-
findReviewsByProduct(productId) {
|
|
2877
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
2878
|
-
const { product_review: data } = yield this.query('product_review', this.reviewsFields, {
|
|
2879
|
-
where: {
|
|
2880
|
-
value: {
|
|
2881
|
-
product_id: { _eq: productId },
|
|
2882
|
-
},
|
|
2883
|
-
type: 'product_review_bool_exp',
|
|
2884
|
-
required: true,
|
|
2885
|
-
},
|
|
2886
|
-
});
|
|
2887
|
-
return data && data.map((review) => this.bindReviewToModel(review));
|
|
2888
|
-
});
|
|
2889
|
-
}
|
|
2890
|
-
findReview(review, productId) {
|
|
2891
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
2892
|
-
if (review.id)
|
|
2893
|
-
return review;
|
|
2894
|
-
let loadedReview;
|
|
2895
|
-
if (review.personId)
|
|
2896
|
-
loadedReview = yield this.getReviewByPersonId(review.personId, productId);
|
|
2897
|
-
if (!loadedReview && review.author && review.email)
|
|
2898
|
-
loadedReview = yield this.getReviewByAuthorAndEmail(review.author, review.email, productId);
|
|
2899
|
-
return loadedReview || review;
|
|
2900
|
-
});
|
|
2901
|
-
}
|
|
2902
|
-
getReviewByPersonId(personId, productId) {
|
|
2903
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
2904
|
-
const { product_review: data } = yield this.query('product_review', this.reviewsFields, {
|
|
2905
|
-
where: {
|
|
2906
|
-
value: {
|
|
2907
|
-
product_id: { _eq: productId },
|
|
2908
|
-
person_id: { _eq: personId },
|
|
2909
|
-
},
|
|
2910
|
-
type: `product_review_bool_exp`,
|
|
2911
|
-
required: true,
|
|
2912
|
-
},
|
|
2913
|
-
});
|
|
2914
|
-
return data && data[0] && this.bindReviewToModel(data[0]);
|
|
2915
|
-
});
|
|
2916
|
-
}
|
|
2917
|
-
getReviewByAuthorAndEmail(author, email, productId) {
|
|
2918
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
2919
|
-
const { product_review: data } = yield this.query('product_review', this.reviewsFields, {
|
|
2920
|
-
where: {
|
|
2921
|
-
value: {
|
|
2922
|
-
product_id: { _eq: productId },
|
|
2923
|
-
author: { _eq: author },
|
|
2924
|
-
email: { _eq: email },
|
|
2925
|
-
},
|
|
2926
|
-
type: `product_review_bool_exp`,
|
|
2927
|
-
required: true,
|
|
2928
|
-
},
|
|
2929
|
-
});
|
|
2930
|
-
return data && data[0] && this.bindReviewToModel(data[0]);
|
|
2931
|
-
});
|
|
2932
|
-
}
|
|
2933
|
-
}
|
|
2934
|
-
|
|
2935
|
-
class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
2936
|
-
constructor(endpoint, authOptions) {
|
|
2937
|
-
super({
|
|
2938
|
-
tableName: 'product',
|
|
2939
|
-
model: VariantHasuraGraphQL,
|
|
2940
|
-
endpoint,
|
|
2941
|
-
authOptions,
|
|
2942
|
-
fields: [
|
|
2943
|
-
{ id: { columnName: 'id', to: (value) => +value, from: (value) => value.toString() } },
|
|
2944
|
-
{ firestoreId: { columnName: 'firestore_id' } },
|
|
2945
|
-
{ productId: { columnName: 'main_product_id', to: (value) => +value, from: (value) => value === null || value === void 0 ? void 0 : value.toString() } },
|
|
2946
|
-
{ EAN: { columnName: 'ean' } },
|
|
2947
|
-
{ costPrice: { columnName: 'cost_price' } },
|
|
2948
|
-
{
|
|
2949
|
-
price: {
|
|
2950
|
-
columnName: 'price',
|
|
2951
|
-
from: (price, data) => Object.values(Shops).reduce((prices, shop) => (Object.assign(Object.assign({}, prices), { [shop]: {
|
|
2952
|
-
price,
|
|
2953
|
-
fullPrice: data.full_price,
|
|
2954
|
-
subscriberDiscountPercentage: data.subscriber_discount_percentage,
|
|
2955
|
-
subscriberPrice: data.subscriber_price,
|
|
2956
|
-
} })), {}),
|
|
2957
|
-
bindFindFilter: (sentence) => {
|
|
2958
|
-
const filters = Object.values(sentence).shift();
|
|
2959
|
-
return Object.assign(Object.assign(Object.assign(Object.assign({}, (((filters === null || filters === void 0 ? void 0 : filters.price) || (filters === null || filters === void 0 ? void 0 : filters.price) === 0) && { price: filters.price })), ((filters.fullPrice || filters.fullPrice === 0) && { full_price: filters.fullPrice })), ((filters.subscriberDiscountPercentage || filters.subscriberDiscountPercentage === 0) && {
|
|
2960
|
-
subscriber_discount_percentage: filters.subscriberDiscountPercentage,
|
|
2961
|
-
})), ((filters.subscriberPrice || filters.subscriberPrice === 0) && {
|
|
2962
|
-
subscriber_price: filters.subscriberPrice,
|
|
2963
|
-
}));
|
|
2964
|
-
},
|
|
2965
|
-
bindPersistData: (value) => {
|
|
2966
|
-
const priceData = Object.values(value).shift();
|
|
2967
|
-
return Object.assign(Object.assign(Object.assign(Object.assign({}, ((priceData === null || priceData === void 0 ? void 0 : priceData.price) >= 0 && { price: priceData.price })), (priceData.fullPrice >= 0 && { full_price: priceData.fullPrice })), (priceData.subscriberDiscountPercentage >= 0 && {
|
|
2968
|
-
subscriber_discount_percentage: priceData.subscriberDiscountPercentage,
|
|
2969
|
-
})), (priceData.subscriberPrice >= 0 && { subscriber_price: priceData.subscriberPrice }));
|
|
2970
|
-
},
|
|
2971
|
-
},
|
|
2972
|
-
},
|
|
2973
|
-
{ fullPrice: { columnName: 'full_price' } },
|
|
2974
|
-
{ subscriberDiscountPercentage: { columnName: 'subscriber_discount_percentage' } },
|
|
2975
|
-
{ subscriberPrice: { columnName: 'subscriber_price' } },
|
|
2976
|
-
'sku',
|
|
2977
|
-
{
|
|
2978
|
-
stock: {
|
|
2979
|
-
columnName: 'stock',
|
|
2980
|
-
from: (quantity) => ({ quantity }),
|
|
2981
|
-
to: (value) => (isNil(value === null || value === void 0 ? void 0 : value.quantity) ? value : value === null || value === void 0 ? void 0 : value.quantity),
|
|
2982
|
-
},
|
|
2983
|
-
},
|
|
2984
|
-
'weight',
|
|
2985
|
-
{ name: { to: () => '', from: () => undefined } },
|
|
2986
|
-
{ hasVariants: { columnName: 'has_variants', to: () => false, from: () => undefined } },
|
|
2987
|
-
{ createdAt: { columnName: 'created_at' } },
|
|
2988
|
-
{ updatedAt: { columnName: 'updated_at' } },
|
|
2989
|
-
{
|
|
2990
|
-
grade: {
|
|
2991
|
-
columnName: 'grade',
|
|
2992
|
-
type: HasuraGraphQLColumnType.Jsonb,
|
|
2993
|
-
},
|
|
2994
|
-
},
|
|
2995
|
-
],
|
|
2996
|
-
});
|
|
2997
|
-
}
|
|
2998
|
-
get(identifiers) {
|
|
2999
|
-
const _super = Object.create(null, {
|
|
3000
|
-
get: { get: () => super.get }
|
|
3001
|
-
});
|
|
3002
|
-
var _a;
|
|
3003
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
3004
|
-
return Number.isNaN(+identifiers.id)
|
|
3005
|
-
? (_a = (yield this.find({ filters: { firestoreId: identifiers.id } })).data) === null || _a === void 0 ? void 0 : _a[0]
|
|
3006
|
-
: _super.get.call(this, identifiers);
|
|
3007
|
-
});
|
|
3008
|
-
}
|
|
3009
|
-
update(params) {
|
|
3010
|
-
const _super = Object.create(null, {
|
|
3011
|
-
update: { get: () => super.update }
|
|
3012
|
-
});
|
|
3013
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
3014
|
-
const { productId, id: checkId } = params, data = __rest(params, ["productId", "id"]);
|
|
3015
|
-
const dataWithProductId = this.paramsToPlain({ id: checkId, productId });
|
|
3016
|
-
const id = yield this.getId(dataWithProductId.id);
|
|
3017
|
-
const product = yield _super.update.call(this, Object.assign({ id }, data));
|
|
3018
|
-
product.productId = dataWithProductId.productId;
|
|
3019
|
-
return product;
|
|
3020
|
-
});
|
|
3021
|
-
}
|
|
3022
|
-
getId(id) {
|
|
3023
|
-
var _a, _b;
|
|
3024
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
3025
|
-
if (!Number.isNaN(+id))
|
|
3026
|
-
return id;
|
|
3027
|
-
const { data } = yield this.find({ filters: { firestoreId: id } });
|
|
3028
|
-
if ((_a = data === null || data === void 0 ? void 0 : data[0]) === null || _a === void 0 ? void 0 : _a.id)
|
|
3029
|
-
return (_b = data === null || data === void 0 ? void 0 : data[0]) === null || _b === void 0 ? void 0 : _b.id;
|
|
3030
|
-
throw new NotFoundError(`Product with id ${id} not found`);
|
|
3031
|
-
});
|
|
3032
|
-
}
|
|
3033
|
-
}
|
|
3034
|
-
|
|
3035
1801
|
/**
|
|
3036
1802
|
* Generated bundle index. Do not edit.
|
|
3037
1803
|
*/
|
|
3038
1804
|
|
|
3039
|
-
export { AccessoryImportances, Address, Area, Authentication, AuthenticationFirebaseAuthService, AxiosAdapter, Base, BaseModel, BeardProblems, BeardSizes, BeautyProductImportances, BeautyProfile, BeautyQuestionsHelper, BillingStatus, BodyProblems, BodyShapes, BodyTattoos, Buy2Win, Buy2WinFirestoreRepository, Category, CategoryFirestoreRepository,
|
|
1805
|
+
export { AccessoryImportances, Address, Area, Authentication, AuthenticationFirebaseAuthService, AxiosAdapter, Base, BaseModel, BeardProblems, BeardSizes, BeautyProductImportances, BeautyProfile, BeautyQuestionsHelper, BillingStatus, BodyProblems, BodyShapes, BodyTattoos, Buy2Win, Buy2WinFirestoreRepository, Category, CategoryFirestoreRepository, Checkout, CheckoutFirestoreRepository, CheckoutSubscription, CheckoutSubscriptionFirestoreRepository, CheckoutTypes, ClubCoupon, Coupon, CouponFirestoreRepository, DiscountType, DuplicatedResultsError, Edition, EditionStatus, Exclusivities, FaceSkinOilinesses, FaceSkinProblems, FaceSkinTones, FamilyIncomes, FilterType, FragranceImportances, HairColors, HairProblems, HairStrands, HairTypes, Home, HomeFirestoreRepository, InvalidArgumentError, Lead, LeadFirestoreRepository, LegacyOrderFirestoreRepository, LineItem, NotFoundError, OfficePosition, Order, OrderFirestoreRepository, OrderStatus, Payment, PaymentFirestoreRepository, PaymentType, Product, ProductFirestoreRepository, ProductSpents, ProductVariantFirestoreRepository, ProductsIndex, QuestionsFilters, RecoveryPassword, Register, RegisterFirebaseAuthService, RequiredArgumentError, ShippingMethod, ShopMenu, ShopMenuFirestoreRepository, Shops, SignInMethods, SignOut, Status, StoreCoupon, Subscription, SubscriptionEditionFirestoreRepository, SubscriptionFirestoreRepository, SubscriptionPayment, SubscriptionPaymentFirestoreRepository, SubscriptionPlan, SubscriptionPlanFirestoreRepository, SubscriptionProductFirestoreRepository, UnauthorizedError, UpdateOptionActions, User, UserAddress, UserAddressFirestoreRepository, UserAlreadyRegisteredError, UserBeautyProfileFirestoreRepository, UserFirestoreRepository, UserPaymentMethod, UserPaymentMethodFirestoreRepository, UserSearchFirestoreRepository, UserType, Variant, WeakPasswordError, Where, withCreateFirestore, withCrudFirestore, withDeleteFirestore, withFindFirestore, withFirestore, withGetFirestore, withHelpers, withSubCollection, withUpdateFirestore };
|
|
3040
1806
|
//# sourceMappingURL=infrab4a-connect.js.map
|