@medusajs/medusa 1.2.2-dev.53 → 1.3.1-alpha.63
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/CHANGELOG.md +98 -0
- package/dist/api/index.d.ts +1 -0
- package/dist/api/index.js +1 -0
- package/dist/api/index.js.map +1 -1
- package/dist/api/middlewares/authenticate-customer.d.ts +2 -1
- package/dist/api/middlewares/authenticate-customer.js +1 -2
- package/dist/api/middlewares/authenticate-customer.js.map +1 -1
- package/dist/api/middlewares/authenticate.d.ts +2 -1
- package/dist/api/middlewares/authenticate.js.map +1 -1
- package/dist/api/middlewares/await-middleware.d.ts +3 -1
- package/dist/api/middlewares/await-middleware.js +2 -31
- package/dist/api/middlewares/await-middleware.js.map +1 -1
- package/dist/api/middlewares/batch-job/can-access-batch-job.d.ts +1 -0
- package/dist/api/middlewares/batch-job/can-access-batch-job.js +70 -0
- package/dist/api/middlewares/batch-job/can-access-batch-job.js.map +1 -0
- package/dist/api/middlewares/batch-job/get-requested-batch-job.d.ts +1 -0
- package/dist/api/middlewares/batch-job/get-requested-batch-job.js +67 -0
- package/dist/api/middlewares/batch-job/get-requested-batch-job.js.map +1 -0
- package/dist/api/middlewares/error-handler.d.ts +3 -1
- package/dist/api/middlewares/error-handler.js +4 -4
- package/dist/api/middlewares/error-handler.js.map +1 -1
- package/dist/api/middlewares/index.d.ts +12 -10
- package/dist/api/middlewares/index.js +9 -0
- package/dist/api/middlewares/index.js.map +1 -1
- package/dist/api/middlewares/normalized-query.d.ts +6 -1
- package/dist/api/middlewares/normalized-query.js +5 -2
- package/dist/api/middlewares/normalized-query.js.map +1 -1
- package/dist/api/middlewares/transform-body.d.ts +4 -0
- package/dist/api/middlewares/transform-body.js +66 -0
- package/dist/api/middlewares/transform-body.js.map +1 -0
- package/dist/api/middlewares/transform-query.d.ts +6 -0
- package/dist/api/middlewares/transform-query.js +86 -0
- package/dist/api/middlewares/transform-query.js.map +1 -0
- package/dist/api/routes/admin/auth/create-session.js +5 -5
- package/dist/api/routes/admin/auth/create-session.js.map +1 -1
- package/dist/api/routes/admin/batch/index.d.ts +13 -0
- package/dist/api/routes/admin/batch/index.js +50 -0
- package/dist/api/routes/admin/batch/index.js.map +1 -0
- package/dist/api/routes/admin/batch/list-batch-jobs.d.ts +48 -0
- package/dist/api/routes/admin/batch/list-batch-jobs.js +220 -0
- package/dist/api/routes/admin/batch/list-batch-jobs.js.map +1 -0
- package/dist/api/routes/admin/customer-groups/list-customer-groups.js +2 -2
- package/dist/api/routes/admin/customer-groups/list-customer-groups.js.map +1 -1
- package/dist/api/routes/admin/discounts/create-condition.d.ts +58 -0
- package/dist/api/routes/admin/discounts/create-condition.js +186 -0
- package/dist/api/routes/admin/discounts/create-condition.js.map +1 -0
- package/dist/api/routes/admin/discounts/create-discount.d.ts +14 -4
- package/dist/api/routes/admin/discounts/create-discount.js +72 -16
- package/dist/api/routes/admin/discounts/create-discount.js.map +1 -1
- package/dist/api/routes/admin/discounts/create-dynamic-code.d.ts +1 -0
- package/dist/api/routes/admin/discounts/create-dynamic-code.js +4 -1
- package/dist/api/routes/admin/discounts/create-dynamic-code.js.map +1 -1
- package/dist/api/routes/admin/discounts/delete-condition.d.ts +36 -0
- package/dist/api/routes/admin/discounts/delete-condition.js +151 -0
- package/dist/api/routes/admin/discounts/delete-condition.js.map +1 -0
- package/dist/api/routes/admin/discounts/delete-dynamic-code.js +3 -1
- package/dist/api/routes/admin/discounts/delete-dynamic-code.js.map +1 -1
- package/dist/api/routes/admin/discounts/get-condition.d.ts +31 -0
- package/dist/api/routes/admin/discounts/get-condition.js +125 -0
- package/dist/api/routes/admin/discounts/get-condition.js.map +1 -0
- package/dist/api/routes/admin/discounts/get-discount-by-code.d.ts +4 -0
- package/dist/api/routes/admin/discounts/get-discount-by-code.js +40 -6
- package/dist/api/routes/admin/discounts/get-discount-by-code.js.map +1 -1
- package/dist/api/routes/admin/discounts/get-discount.d.ts +7 -0
- package/dist/api/routes/admin/discounts/get-discount.js +43 -9
- package/dist/api/routes/admin/discounts/get-discount.js.map +1 -1
- package/dist/api/routes/admin/discounts/index.d.ts +11 -3
- package/dist/api/routes/admin/discounts/index.js +13 -7
- package/dist/api/routes/admin/discounts/index.js.map +1 -1
- package/dist/api/routes/admin/discounts/list-discounts.d.ts +2 -6
- package/dist/api/routes/admin/discounts/list-discounts.js +15 -28
- package/dist/api/routes/admin/discounts/list-discounts.js.map +1 -1
- package/dist/api/routes/admin/discounts/update-condition.d.ts +55 -0
- package/dist/api/routes/admin/discounts/update-condition.js +184 -0
- package/dist/api/routes/admin/discounts/update-condition.js.map +1 -0
- package/dist/api/routes/admin/discounts/update-discount.d.ts +18 -12
- package/dist/api/routes/admin/discounts/update-discount.js +79 -33
- package/dist/api/routes/admin/discounts/update-discount.js.map +1 -1
- package/dist/api/routes/admin/draft-orders/create-draft-order.d.ts +3 -3
- package/dist/api/routes/admin/draft-orders/create-draft-order.js.map +1 -1
- package/dist/api/routes/admin/draft-orders/create-line-item.d.ts +1 -1
- package/dist/api/routes/admin/draft-orders/create-line-item.js.map +1 -1
- package/dist/api/routes/admin/draft-orders/index.d.ts +1 -1
- package/dist/api/routes/admin/draft-orders/index.js +7 -1
- package/dist/api/routes/admin/draft-orders/index.js.map +1 -1
- package/dist/api/routes/admin/draft-orders/list-draft-orders.js +7 -6
- package/dist/api/routes/admin/draft-orders/list-draft-orders.js.map +1 -1
- package/dist/api/routes/admin/draft-orders/register-payment.js +0 -1
- package/dist/api/routes/admin/draft-orders/register-payment.js.map +1 -1
- package/dist/api/routes/admin/draft-orders/update-line-item.d.ts +1 -1
- package/dist/api/routes/admin/draft-orders/update-line-item.js.map +1 -1
- package/dist/api/routes/admin/index.js +23 -19
- package/dist/api/routes/admin/index.js.map +1 -1
- package/dist/api/routes/admin/notifications/index.js.map +1 -1
- package/dist/api/routes/admin/notifications/list-notifications.js.map +1 -1
- package/dist/api/routes/admin/notifications/resend-notification.js.map +1 -1
- package/dist/api/routes/admin/orders/add-shipping-method.d.ts +1 -1
- package/dist/api/routes/admin/orders/add-shipping-method.js.map +1 -1
- package/dist/api/routes/admin/orders/create-claim.d.ts +4 -14
- package/dist/api/routes/admin/orders/create-claim.js +9 -14
- package/dist/api/routes/admin/orders/create-claim.js.map +1 -1
- package/dist/api/routes/admin/orders/create-order.js.map +1 -1
- package/dist/api/routes/admin/orders/create-swap.js +7 -3
- package/dist/api/routes/admin/orders/create-swap.js.map +1 -1
- package/dist/api/routes/admin/orders/fulfill-claim.d.ts +1 -1
- package/dist/api/routes/admin/orders/fulfill-claim.js.map +1 -1
- package/dist/api/routes/admin/orders/index.d.ts +1 -1
- package/dist/api/routes/admin/orders/index.js +1 -3
- package/dist/api/routes/admin/orders/index.js.map +1 -1
- package/dist/api/routes/admin/orders/list-orders.js.map +1 -1
- package/dist/api/routes/admin/orders/update-claim.d.ts +1 -1
- package/dist/api/routes/admin/orders/update-claim.js.map +1 -1
- package/dist/api/routes/admin/orders/update-order.js.map +1 -1
- package/dist/api/routes/admin/price-lists/add-prices-batch.d.ts +70 -0
- package/dist/api/routes/admin/price-lists/add-prices-batch.js +158 -0
- package/dist/api/routes/admin/price-lists/add-prices-batch.js.map +1 -0
- package/dist/api/routes/admin/price-lists/create-price-list.d.ts +88 -0
- package/dist/api/routes/admin/price-lists/create-price-list.js +190 -0
- package/dist/api/routes/admin/price-lists/create-price-list.js.map +1 -0
- package/dist/api/routes/admin/price-lists/delete-price-list.d.ts +28 -0
- package/dist/api/routes/admin/price-lists/delete-price-list.js +84 -0
- package/dist/api/routes/admin/price-lists/delete-price-list.js.map +1 -0
- package/dist/api/routes/admin/price-lists/delete-prices-batch.d.ts +43 -0
- package/dist/api/routes/admin/price-lists/delete-prices-batch.js +118 -0
- package/dist/api/routes/admin/price-lists/delete-prices-batch.js.map +1 -0
- package/dist/api/routes/admin/price-lists/delete-product-prices.d.ts +32 -0
- package/dist/api/routes/admin/price-lists/delete-product-prices.js +105 -0
- package/dist/api/routes/admin/price-lists/delete-product-prices.js.map +1 -0
- package/dist/api/routes/admin/price-lists/delete-variant-prices.d.ts +32 -0
- package/dist/api/routes/admin/price-lists/delete-variant-prices.js +105 -0
- package/dist/api/routes/admin/price-lists/delete-variant-prices.js.map +1 -0
- package/dist/api/routes/admin/price-lists/get-price-list.d.ts +22 -0
- package/dist/api/routes/admin/price-lists/get-price-list.js +78 -0
- package/dist/api/routes/admin/price-lists/get-price-list.js.map +1 -0
- package/dist/api/routes/admin/price-lists/index.d.ts +30 -0
- package/dist/api/routes/admin/price-lists/index.js +76 -0
- package/dist/api/routes/admin/price-lists/index.js.map +1 -0
- package/dist/api/routes/admin/price-lists/list-price-list-products.d.ts +75 -0
- package/dist/api/routes/admin/price-lists/list-price-list-products.js +255 -0
- package/dist/api/routes/admin/price-lists/list-price-list-products.js.map +1 -0
- package/dist/api/routes/admin/price-lists/list-price-lists.d.ts +39 -0
- package/dist/api/routes/admin/price-lists/list-price-lists.js +165 -0
- package/dist/api/routes/admin/price-lists/list-price-lists.js.map +1 -0
- package/dist/api/routes/admin/price-lists/update-price-list.d.ts +92 -0
- package/dist/api/routes/admin/price-lists/update-price-list.js +211 -0
- package/dist/api/routes/admin/price-lists/update-price-list.js.map +1 -0
- package/dist/api/routes/admin/product-tags/list-product-tags.d.ts +2 -1
- package/dist/api/routes/admin/product-tags/list-product-tags.js +6 -3
- package/dist/api/routes/admin/product-tags/list-product-tags.js.map +1 -1
- package/dist/api/routes/admin/product-types/list-product-types.d.ts +2 -1
- package/dist/api/routes/admin/product-types/list-product-types.js +6 -3
- package/dist/api/routes/admin/product-types/list-product-types.js.map +1 -1
- package/dist/api/routes/admin/products/create-product.d.ts +2 -7
- package/dist/api/routes/admin/products/create-product.js +2 -24
- package/dist/api/routes/admin/products/create-product.js.map +1 -1
- package/dist/api/routes/admin/products/create-variant.d.ts +7 -9
- package/dist/api/routes/admin/products/create-variant.js +7 -26
- package/dist/api/routes/admin/products/create-variant.js.map +1 -1
- package/dist/api/routes/admin/products/index.d.ts +3 -2
- package/dist/api/routes/admin/products/index.js +8 -3
- package/dist/api/routes/admin/products/index.js.map +1 -1
- package/dist/api/routes/admin/products/list-products.d.ts +2 -1
- package/dist/api/routes/admin/products/list-products.js +31 -65
- package/dist/api/routes/admin/products/list-products.js.map +1 -1
- package/dist/api/routes/admin/products/list-variants.d.ts +35 -0
- package/dist/api/routes/admin/products/list-variants.js +173 -0
- package/dist/api/routes/admin/products/list-variants.js.map +1 -0
- package/dist/api/routes/admin/products/update-product.d.ts +2 -7
- package/dist/api/routes/admin/products/update-product.js +2 -24
- package/dist/api/routes/admin/products/update-product.js.map +1 -1
- package/dist/api/routes/admin/products/update-variant.d.ts +10 -9
- package/dist/api/routes/admin/products/update-variant.js +21 -33
- package/dist/api/routes/admin/products/update-variant.js.map +1 -1
- package/dist/api/routes/admin/regions/index.d.ts +1 -1
- package/dist/api/routes/admin/shipping-options/list-shipping-options.d.ts +2 -2
- package/dist/api/routes/admin/shipping-options/list-shipping-options.js +2 -2
- package/dist/api/routes/admin/shipping-options/list-shipping-options.js.map +1 -1
- package/dist/api/routes/admin/store/get-store.js +4 -2
- package/dist/api/routes/admin/store/get-store.js.map +1 -1
- package/dist/api/routes/admin/store/update-store.d.ts +1 -0
- package/dist/api/routes/admin/store/update-store.js +5 -0
- package/dist/api/routes/admin/store/update-store.js.map +1 -1
- package/dist/api/routes/admin/swaps/index.js +3 -0
- package/dist/api/routes/admin/swaps/index.js.map +1 -1
- package/dist/api/routes/admin/tax-rates/list-tax-rates.js.map +1 -1
- package/dist/api/routes/admin/tax-rates/utils/get-query-config.d.ts +1 -1
- package/dist/api/routes/admin/tax-rates/utils/get-query-config.js +4 -2
- package/dist/api/routes/admin/tax-rates/utils/get-query-config.js.map +1 -1
- package/dist/api/routes/admin/uploads/index.d.ts +1 -1
- package/dist/api/routes/admin/users/update-user.d.ts +1 -1
- package/dist/api/routes/admin/users/update-user.js.map +1 -1
- package/dist/api/routes/store/auth/create-session.js +4 -5
- package/dist/api/routes/store/auth/create-session.js.map +1 -1
- package/dist/api/routes/store/carts/create-cart.js +8 -5
- package/dist/api/routes/store/carts/create-cart.js.map +1 -1
- package/dist/api/routes/store/carts/create-line-item.d.ts +1 -1
- package/dist/api/routes/store/carts/create-line-item.js +9 -6
- package/dist/api/routes/store/carts/create-line-item.js.map +1 -1
- package/dist/api/routes/store/carts/index.d.ts +0 -1
- package/dist/api/routes/store/carts/index.js +1 -3
- package/dist/api/routes/store/carts/index.js.map +1 -1
- package/dist/api/routes/store/carts/update-cart.js +8 -8
- package/dist/api/routes/store/carts/update-cart.js.map +1 -1
- package/dist/api/routes/store/collections/list-collections.d.ts +3 -0
- package/dist/api/routes/store/collections/list-collections.js +33 -16
- package/dist/api/routes/store/collections/list-collections.js.map +1 -1
- package/dist/api/routes/store/customers/create-customer.js +3 -4
- package/dist/api/routes/store/customers/create-customer.js.map +1 -1
- package/dist/api/routes/store/customers/get-payment-methods.js +6 -7
- package/dist/api/routes/store/customers/get-payment-methods.js.map +1 -1
- package/dist/api/routes/store/orders/index.js +0 -2
- package/dist/api/routes/store/orders/index.js.map +1 -1
- package/dist/api/routes/store/products/get-product.js +17 -5
- package/dist/api/routes/store/products/get-product.js.map +1 -1
- package/dist/api/routes/store/products/index.d.ts +2 -2
- package/dist/api/routes/store/products/list-products.d.ts +2 -2
- package/dist/api/routes/store/products/list-products.js +21 -14
- package/dist/api/routes/store/products/list-products.js.map +1 -1
- package/dist/api/routes/store/products/search.d.ts +1 -1
- package/dist/api/routes/store/products/search.js.map +1 -1
- package/dist/api/routes/store/regions/list-regions.d.ts +3 -0
- package/dist/api/routes/store/regions/list-regions.js +22 -7
- package/dist/api/routes/store/regions/list-regions.js.map +1 -1
- package/dist/api/routes/store/shipping-options/list-options.js.map +1 -1
- package/dist/api/routes/store/swaps/create-swap.js +7 -3
- package/dist/api/routes/store/swaps/create-swap.js.map +1 -1
- package/dist/api/routes/store/variants/get-variant.js +17 -5
- package/dist/api/routes/store/variants/get-variant.js.map +1 -1
- package/dist/api/routes/store/variants/list-variants.d.ts +2 -1
- package/dist/api/routes/store/variants/list-variants.js +38 -9
- package/dist/api/routes/store/variants/list-variants.js.map +1 -1
- package/dist/commands/develop.js +2 -2
- package/dist/commands/develop.js.map +1 -1
- package/dist/commands/migrate.js +17 -6
- package/dist/commands/migrate.js.map +1 -1
- package/dist/commands/start.js +6 -0
- package/dist/commands/start.js.map +1 -1
- package/dist/controllers/customers/index.d.ts +1 -1
- package/dist/controllers/customers/list-customers.d.ts +1 -1
- package/dist/controllers/customers/list-customers.js +34 -37
- package/dist/controllers/customers/list-customers.js.map +1 -1
- package/dist/controllers/products/admin-list-products.d.ts +16 -0
- package/dist/controllers/products/admin-list-products.js +103 -0
- package/dist/controllers/products/admin-list-products.js.map +1 -0
- package/dist/helpers/test-request.js +26 -17
- package/dist/helpers/test-request.js.map +1 -1
- package/dist/index.d.ts +4 -58
- package/dist/index.js +4 -61
- package/dist/index.js.map +1 -1
- package/dist/interfaces/base-service.d.ts +66 -0
- package/dist/interfaces/base-service.js +377 -0
- package/dist/interfaces/base-service.js.map +1 -0
- package/dist/interfaces/batch-job-strategy.d.ts +28 -0
- package/dist/interfaces/batch-job-strategy.js +75 -0
- package/dist/interfaces/batch-job-strategy.js.map +1 -0
- package/dist/interfaces/file-service.d.ts +62 -0
- package/dist/interfaces/file-service.js +32 -0
- package/dist/interfaces/file-service.js.map +1 -0
- package/dist/interfaces/index.d.ts +4 -0
- package/dist/interfaces/index.js +4 -0
- package/dist/interfaces/index.js.map +1 -1
- package/dist/interfaces/models/base-entity.d.ts +8 -0
- package/dist/interfaces/models/base-entity.js +36 -0
- package/dist/interfaces/models/base-entity.js.map +1 -0
- package/dist/interfaces/models/soft-deletable-entity.d.ts +4 -0
- package/dist/interfaces/models/soft-deletable-entity.js +43 -0
- package/dist/interfaces/models/soft-deletable-entity.js.map +1 -0
- package/dist/interfaces/price-selection-strategy.d.ts +50 -0
- package/dist/interfaces/price-selection-strategy.js +34 -0
- package/dist/interfaces/price-selection-strategy.js.map +1 -0
- package/dist/interfaces/tax-service.d.ts +6 -0
- package/dist/interfaces/tax-service.js +31 -0
- package/dist/interfaces/tax-service.js.map +1 -1
- package/dist/interfaces/transaction-base-service.d.ts +23 -0
- package/dist/interfaces/transaction-base-service.js +200 -0
- package/dist/interfaces/transaction-base-service.js.map +1 -0
- package/dist/loaders/api.d.ts +9 -5
- package/dist/loaders/api.js +2 -6
- package/dist/loaders/api.js.map +1 -1
- package/dist/loaders/config.d.ts +3 -0
- package/dist/loaders/config.js +47 -0
- package/dist/loaders/config.js.map +1 -0
- package/dist/loaders/database.d.ts +8 -4
- package/dist/loaders/database.js.map +1 -1
- package/dist/loaders/defaults.d.ts +4 -3
- package/dist/loaders/defaults.js +39 -31
- package/dist/loaders/defaults.js.map +1 -1
- package/dist/loaders/express.d.ts +7 -4
- package/dist/loaders/express.js +7 -5
- package/dist/loaders/express.js.map +1 -1
- package/dist/loaders/index.d.ts +13 -8
- package/dist/loaders/index.js +29 -54
- package/dist/loaders/index.js.map +1 -1
- package/dist/loaders/logger.d.ts +1 -0
- package/dist/loaders/logger.js.map +1 -1
- package/dist/loaders/models.d.ts +8 -3
- package/dist/loaders/models.js +19 -17
- package/dist/loaders/models.js.map +1 -1
- package/dist/loaders/passport.d.ts +7 -4
- package/dist/loaders/passport.js +23 -21
- package/dist/loaders/passport.js.map +1 -1
- package/dist/loaders/plugins.d.ts +38 -10
- package/dist/loaders/plugins.js +43 -30
- package/dist/loaders/plugins.js.map +1 -1
- package/dist/loaders/redis.d.ts +8 -5
- package/dist/loaders/redis.js +3 -3
- package/dist/loaders/redis.js.map +1 -1
- package/dist/loaders/repositories.d.ts +7 -3
- package/dist/loaders/repositories.js +1 -1
- package/dist/loaders/repositories.js.map +1 -1
- package/dist/loaders/search-index.d.ts +4 -3
- package/dist/loaders/search-index.js.map +1 -1
- package/dist/loaders/services.d.ts +10 -5
- package/dist/loaders/services.js.map +1 -1
- package/dist/loaders/strategies.d.ts +1 -1
- package/dist/loaders/subscribers.d.ts +7 -3
- package/dist/loaders/subscribers.js.map +1 -1
- package/dist/migrations/1646324713514-discount_conditions.d.ts +6 -0
- package/dist/migrations/1646324713514-discount_conditions.js +335 -0
- package/dist/migrations/1646324713514-discount_conditions.js.map +1 -0
- package/dist/migrations/1646915480108-update_money_amount_add_price_list.d.ts +6 -0
- package/dist/migrations/1646915480108-update_money_amount_add_price_list.js +143 -0
- package/dist/migrations/1646915480108-update_money_amount_add_price_list.js.map +1 -0
- package/dist/migrations/1648600574750-add_line_item_adjustments.d.ts +6 -0
- package/dist/migrations/1648600574750-add_line_item_adjustments.js +101 -0
- package/dist/migrations/1648600574750-add_line_item_adjustments.js.map +1 -0
- package/dist/migrations/1648641130007-tax_line_constraints.d.ts +6 -0
- package/dist/migrations/1648641130007-tax_line_constraints.js +77 -0
- package/dist/migrations/1648641130007-tax_line_constraints.js.map +1 -0
- package/dist/migrations/1649775522087-add_batch_job_model.d.ts +6 -0
- package/dist/migrations/1649775522087-add_batch_job_model.js +77 -0
- package/dist/migrations/1649775522087-add_batch_job_model.js.map +1 -0
- package/dist/models/address.d.ts +3 -6
- package/dist/models/address.js +23 -24
- package/dist/models/address.js.map +1 -1
- package/dist/models/batch-job.d.ts +55 -0
- package/dist/models/batch-job.js +118 -0
- package/dist/models/batch-job.js.map +1 -0
- package/dist/models/cart.d.ts +5 -8
- package/dist/models/cart.js +35 -36
- package/dist/models/cart.js.map +1 -1
- package/dist/models/claim-image.d.ts +3 -6
- package/dist/models/claim-image.js +22 -23
- package/dist/models/claim-image.js.map +1 -1
- package/dist/models/claim-item.d.ts +3 -6
- package/dist/models/claim-item.js +25 -24
- package/dist/models/claim-item.js.map +1 -1
- package/dist/models/claim-order.d.ts +4 -4
- package/dist/models/claim-order.js +28 -13
- package/dist/models/claim-order.js.map +1 -1
- package/dist/models/claim-tag.d.ts +3 -6
- package/dist/models/claim-tag.js +22 -23
- package/dist/models/claim-tag.js.map +1 -1
- package/dist/models/country.d.ts +1 -1
- package/dist/models/country.js +1 -1
- package/dist/models/country.js.map +1 -1
- package/dist/models/custom-shipping-option.d.ts +3 -6
- package/dist/models/custom-shipping-option.js +23 -24
- package/dist/models/custom-shipping-option.js.map +1 -1
- package/dist/models/customer-group.d.ts +6 -7
- package/dist/models/customer-group.js +30 -36
- package/dist/models/customer-group.js.map +1 -1
- package/dist/models/customer.d.ts +3 -6
- package/dist/models/customer.js +23 -25
- package/dist/models/customer.js.map +1 -1
- package/dist/models/discount-condition-customer-group.d.ts +39 -0
- package/dist/models/discount-condition-customer-group.js +84 -0
- package/dist/models/discount-condition-customer-group.js.map +1 -0
- package/dist/models/discount-condition-product-collection.d.ts +39 -0
- package/dist/models/discount-condition-product-collection.js +84 -0
- package/dist/models/discount-condition-product-collection.js.map +1 -0
- package/dist/models/discount-condition-product-tag.d.ts +39 -0
- package/dist/models/discount-condition-product-tag.js +84 -0
- package/dist/models/discount-condition-product-tag.js.map +1 -0
- package/dist/models/discount-condition-product-type.d.ts +39 -0
- package/dist/models/discount-condition-product-type.js +84 -0
- package/dist/models/discount-condition-product-type.js.map +1 -0
- package/dist/models/discount-condition-product.d.ts +39 -0
- package/dist/models/discount-condition-product.js +84 -0
- package/dist/models/discount-condition-product.js.map +1 -0
- package/dist/models/discount-condition.d.ts +65 -0
- package/dist/models/discount-condition.js +209 -0
- package/dist/models/discount-condition.js.map +1 -0
- package/dist/models/discount-rule.d.ts +8 -11
- package/dist/models/discount-rule.js +28 -38
- package/dist/models/discount-rule.js.map +1 -1
- package/dist/models/discount.d.ts +7 -10
- package/dist/models/discount.js +30 -30
- package/dist/models/discount.js.map +1 -1
- package/dist/models/draft-order.d.ts +4 -7
- package/dist/models/draft-order.js +25 -22
- package/dist/models/draft-order.js.map +1 -1
- package/dist/models/fulfillment-item.js.map +1 -1
- package/dist/models/fulfillment-provider.js.map +1 -1
- package/dist/models/fulfillment.d.ts +5 -7
- package/dist/models/fulfillment.js +29 -21
- package/dist/models/fulfillment.js.map +1 -1
- package/dist/models/gift-card-transaction.js +2 -5
- package/dist/models/gift-card-transaction.js.map +1 -1
- package/dist/models/gift-card.d.ts +3 -6
- package/dist/models/gift-card.js +22 -23
- package/dist/models/gift-card.js.map +1 -1
- package/dist/models/idempotency-key.d.ts +2 -2
- package/dist/models/idempotency-key.js +2 -3
- package/dist/models/idempotency-key.js.map +1 -1
- package/dist/models/image.d.ts +3 -6
- package/dist/models/image.js +22 -23
- package/dist/models/image.js.map +1 -1
- package/dist/models/index.d.ts +67 -0
- package/dist/models/index.js +80 -0
- package/dist/models/index.js.map +1 -0
- package/dist/models/invite.d.ts +3 -6
- package/dist/models/invite.js +22 -24
- package/dist/models/invite.js.map +1 -1
- package/dist/models/line-item-adjustment.d.ts +13 -0
- package/dist/models/line-item-adjustment.js +76 -0
- package/dist/models/line-item-adjustment.js.map +1 -0
- package/dist/models/line-item-tax-line.js +4 -6
- package/dist/models/line-item-tax-line.js.map +1 -1
- package/dist/models/line-item.d.ts +5 -5
- package/dist/models/line-item.js +29 -19
- package/dist/models/line-item.js.map +1 -1
- package/dist/models/money-amount.d.ts +12 -8
- package/dist/models/money-amount.js +47 -30
- package/dist/models/money-amount.js.map +1 -1
- package/dist/models/note.d.ts +3 -6
- package/dist/models/note.js +22 -23
- package/dist/models/note.js.map +1 -1
- package/dist/models/notification.d.ts +3 -5
- package/dist/models/notification.js +22 -19
- package/dist/models/notification.js.map +1 -1
- package/dist/models/oauth.d.ts +1 -1
- package/dist/models/oauth.js +2 -5
- package/dist/models/oauth.js.map +1 -1
- package/dist/models/order.d.ts +3 -5
- package/dist/models/order.js +25 -21
- package/dist/models/order.js.map +1 -1
- package/dist/models/payment-provider.js.map +1 -1
- package/dist/models/payment-session.d.ts +3 -5
- package/dist/models/payment-session.js +22 -19
- package/dist/models/payment-session.js.map +1 -1
- package/dist/models/payment.d.ts +4 -6
- package/dist/models/payment.js +22 -19
- package/dist/models/payment.js.map +1 -1
- package/dist/models/price-list.d.ts +54 -0
- package/dist/models/price-list.js +144 -0
- package/dist/models/price-list.js.map +1 -0
- package/dist/models/product-collection.d.ts +4 -7
- package/dist/models/product-collection.js +25 -24
- package/dist/models/product-collection.js.map +1 -1
- package/dist/models/product-option-value.d.ts +3 -6
- package/dist/models/product-option-value.js +24 -26
- package/dist/models/product-option-value.js.map +1 -1
- package/dist/models/product-option.d.ts +3 -6
- package/dist/models/product-option.js +23 -24
- package/dist/models/product-option.js.map +1 -1
- package/dist/models/product-tag.d.ts +3 -6
- package/dist/models/product-tag.js +22 -23
- package/dist/models/product-tag.js.map +1 -1
- package/dist/models/product-tax-rate.d.ts +1 -1
- package/dist/models/product-tax-rate.js.map +1 -1
- package/dist/models/product-type-tax-rate.d.ts +1 -1
- package/dist/models/product-type-tax-rate.js.map +1 -1
- package/dist/models/product-type.d.ts +3 -6
- package/dist/models/product-type.js +22 -23
- package/dist/models/product-type.js.map +1 -1
- package/dist/models/product-variant.d.ts +3 -6
- package/dist/models/product-variant.js +30 -26
- package/dist/models/product-variant.js.map +1 -1
- package/dist/models/product.d.ts +3 -6
- package/dist/models/product.js +25 -22
- package/dist/models/product.js.map +1 -1
- package/dist/models/refund.d.ts +3 -5
- package/dist/models/refund.js +22 -17
- package/dist/models/refund.js.map +1 -1
- package/dist/models/region.d.ts +3 -6
- package/dist/models/region.js +23 -24
- package/dist/models/region.js.map +1 -1
- package/dist/models/return-item.d.ts +1 -1
- package/dist/models/return-item.js.map +1 -1
- package/dist/models/return-reason.d.ts +3 -6
- package/dist/models/return-reason.js +24 -25
- package/dist/models/return-reason.js.map +1 -1
- package/dist/models/return.d.ts +5 -7
- package/dist/models/return.js +29 -21
- package/dist/models/return.js.map +1 -1
- package/dist/models/shipping-method-tax-line.js +4 -6
- package/dist/models/shipping-method-tax-line.js.map +1 -1
- package/dist/models/shipping-method.d.ts +2 -2
- package/dist/models/shipping-method.js +3 -6
- package/dist/models/shipping-method.js.map +1 -1
- package/dist/models/shipping-option-requirement.js +2 -5
- package/dist/models/shipping-option-requirement.js.map +1 -1
- package/dist/models/shipping-option.d.ts +5 -8
- package/dist/models/shipping-option.js +26 -25
- package/dist/models/shipping-option.js.map +1 -1
- package/dist/models/shipping-profile.d.ts +3 -6
- package/dist/models/shipping-profile.js +22 -23
- package/dist/models/shipping-profile.js.map +1 -1
- package/dist/models/shipping-tax-rate.d.ts +1 -1
- package/dist/models/shipping-tax-rate.js.map +1 -1
- package/dist/models/staged-job.d.ts +1 -1
- package/dist/models/staged-job.js +2 -3
- package/dist/models/staged-job.js.map +1 -1
- package/dist/models/store.d.ts +3 -5
- package/dist/models/store.js +22 -17
- package/dist/models/store.js.map +1 -1
- package/dist/models/swap.d.ts +9 -12
- package/dist/models/swap.js +55 -52
- package/dist/models/swap.js.map +1 -1
- package/dist/models/tax-line.d.ts +3 -5
- package/dist/models/tax-line.js +20 -14
- package/dist/models/tax-line.js.map +1 -1
- package/dist/models/tax-rate.d.ts +3 -5
- package/dist/models/tax-rate.js +22 -19
- package/dist/models/tax-rate.js.map +1 -1
- package/dist/models/tracking-link.d.ts +3 -6
- package/dist/models/tracking-link.js +26 -27
- package/dist/models/tracking-link.js.map +1 -1
- package/dist/models/user.d.ts +3 -6
- package/dist/models/user.js +22 -23
- package/dist/models/user.js.map +1 -1
- package/dist/repositories/batch-job.d.ts +4 -0
- package/dist/repositories/batch-job.js +38 -0
- package/dist/repositories/batch-job.js.map +1 -0
- package/dist/repositories/cart.d.ts +2 -2
- package/dist/repositories/cart.js.map +1 -1
- package/dist/repositories/customer.d.ts +1 -1
- package/dist/repositories/customer.js +7 -9
- package/dist/repositories/customer.js.map +1 -1
- package/dist/repositories/discount-condition.d.ts +38 -0
- package/dist/repositories/discount-condition.js +398 -0
- package/dist/repositories/discount-condition.js.map +1 -0
- package/dist/repositories/line-item-adjustment.d.ts +4 -0
- package/dist/repositories/line-item-adjustment.js +38 -0
- package/dist/repositories/line-item-adjustment.js.map +1 -0
- package/dist/repositories/line-item-tax-line.d.ts +2 -0
- package/dist/repositories/line-item-tax-line.js +80 -0
- package/dist/repositories/line-item-tax-line.js.map +1 -1
- package/dist/repositories/line-item.js +1 -0
- package/dist/repositories/line-item.js.map +1 -1
- package/dist/repositories/money-amount.d.ts +8 -2
- package/dist/repositories/money-amount.js +177 -2
- package/dist/repositories/money-amount.js.map +1 -1
- package/dist/repositories/order.d.ts +1 -1
- package/dist/repositories/price-list.d.ts +11 -0
- package/dist/repositories/price-list.js +247 -0
- package/dist/repositories/price-list.js.map +1 -0
- package/dist/repositories/product.d.ts +5 -1
- package/dist/repositories/product.js +96 -18
- package/dist/repositories/product.js.map +1 -1
- package/dist/repositories/shipping-method-tax-line.d.ts +2 -0
- package/dist/repositories/shipping-method-tax-line.js +80 -0
- package/dist/repositories/shipping-method-tax-line.js.map +1 -1
- package/dist/scripts/discount-rule-migration.d.ts +4 -0
- package/dist/scripts/discount-rule-migration.js +189 -0
- package/dist/scripts/discount-rule-migration.js.map +1 -0
- package/dist/scripts/line-item-adjustment-migration.d.ts +4 -0
- package/dist/scripts/line-item-adjustment-migration.js +173 -0
- package/dist/scripts/line-item-adjustment-migration.js.map +1 -0
- package/dist/services/batch-job.d.ts +24 -0
- package/dist/services/batch-job.js +126 -0
- package/dist/services/batch-job.js.map +1 -0
- package/dist/services/cart.d.ts +66 -55
- package/dist/services/cart.js +1315 -1405
- package/dist/services/cart.js.map +1 -1
- package/dist/services/claim-item.d.ts +23 -27
- package/dist/services/claim-item.js +217 -247
- package/dist/services/claim-item.js.map +1 -1
- package/dist/services/claim.d.ts +89 -71
- package/dist/services/claim.js +915 -840
- package/dist/services/claim.js.map +1 -1
- package/dist/services/customer.d.ts +0 -7
- package/dist/services/customer.js +8 -35
- package/dist/services/customer.js.map +1 -1
- package/dist/services/discount-condition.d.ts +31 -0
- package/dist/services/discount-condition.js +232 -0
- package/dist/services/discount-condition.js.map +1 -0
- package/dist/services/discount.d.ts +50 -59
- package/dist/services/discount.js +274 -176
- package/dist/services/discount.js.map +1 -1
- package/dist/services/draft-order.d.ts +69 -66
- package/dist/services/draft-order.js +375 -352
- package/dist/services/draft-order.js.map +1 -1
- package/dist/services/event-bus.d.ts +72 -56
- package/dist/services/event-bus.js +122 -99
- package/dist/services/event-bus.js.map +1 -1
- package/dist/services/file.d.ts +14 -0
- package/dist/services/file.js +43 -0
- package/dist/services/file.js.map +1 -0
- package/dist/services/fulfillment-provider.js +23 -17
- package/dist/services/fulfillment-provider.js.map +1 -1
- package/dist/services/invite.d.ts +4 -2
- package/dist/services/invite.js +11 -9
- package/dist/services/invite.js.map +1 -1
- package/dist/services/line-item-adjustment.d.ts +87 -0
- package/dist/services/line-item-adjustment.js +434 -0
- package/dist/services/line-item-adjustment.js.map +1 -0
- package/dist/services/line-item.d.ts +48 -40
- package/dist/services/line-item.js +226 -193
- package/dist/services/line-item.js.map +1 -1
- package/dist/services/order.d.ts +0 -13
- package/dist/services/order.js +4 -30
- package/dist/services/order.js.map +1 -1
- package/dist/services/payment-provider.js +23 -17
- package/dist/services/payment-provider.js.map +1 -1
- package/dist/services/price-list.d.ts +107 -0
- package/dist/services/price-list.js +740 -0
- package/dist/services/price-list.js.map +1 -0
- package/dist/services/pricing.d.ts +87 -0
- package/dist/services/pricing.js +443 -0
- package/dist/services/pricing.js.map +1 -0
- package/dist/services/product-tag.d.ts +2 -2
- package/dist/services/product-tag.js +15 -2
- package/dist/services/product-tag.js.map +1 -1
- package/dist/services/product-type.d.ts +1 -1
- package/dist/services/product-type.js +14 -1
- package/dist/services/product-type.js.map +1 -1
- package/dist/services/product-variant.d.ts +40 -16
- package/dist/services/product-variant.js +259 -109
- package/dist/services/product-variant.js.map +1 -1
- package/dist/services/product.d.ts +22 -11
- package/dist/services/product.js +251 -87
- package/dist/services/product.js.map +1 -1
- package/dist/services/region.js +12 -8
- package/dist/services/region.js.map +1 -1
- package/dist/services/return.js +2 -1
- package/dist/services/return.js.map +1 -1
- package/dist/services/shipping-option.d.ts +44 -109
- package/dist/services/shipping-option.js +309 -353
- package/dist/services/shipping-option.js.map +1 -1
- package/dist/services/store.d.ts +36 -45
- package/dist/services/store.js +207 -217
- package/dist/services/store.js.map +1 -1
- package/dist/services/swap.d.ts +4 -1
- package/dist/services/swap.js +29 -16
- package/dist/services/swap.js.map +1 -1
- package/dist/services/system-tax.d.ts +2 -3
- package/dist/services/system-tax.js +2 -2
- package/dist/services/system-tax.js.map +1 -1
- package/dist/services/tax-provider.d.ts +2 -0
- package/dist/services/tax-provider.js +96 -7
- package/dist/services/tax-provider.js.map +1 -1
- package/dist/services/tax-rate.d.ts +3 -3
- package/dist/services/tax-rate.js +1 -1
- package/dist/services/tax-rate.js.map +1 -1
- package/dist/services/totals.d.ts +9 -8
- package/dist/services/totals.js +41 -88
- package/dist/services/totals.js.map +1 -1
- package/dist/strategies/cart-completion.js.map +1 -1
- package/dist/strategies/price-selection.d.ts +13 -0
- package/dist/strategies/price-selection.js +185 -0
- package/dist/strategies/price-selection.js.map +1 -0
- package/dist/subscribers/order.js +1 -7
- package/dist/subscribers/order.js.map +1 -1
- package/dist/types/batch-job.d.ts +15 -0
- package/dist/types/batch-job.js +63 -0
- package/dist/types/batch-job.js.map +1 -0
- package/dist/types/cart.d.ts +2 -2
- package/dist/types/claim.d.ts +67 -0
- package/dist/types/claim.js +3 -0
- package/dist/types/claim.js.map +1 -0
- package/dist/types/common.d.ts +53 -13
- package/dist/types/common.js +1 -0
- package/dist/types/common.js.map +1 -1
- package/dist/types/discount.d.ts +68 -1
- package/dist/types/discount.js +129 -5
- package/dist/types/discount.js.map +1 -1
- package/dist/types/global.d.ts +53 -0
- package/dist/types/global.js +3 -0
- package/dist/types/global.js.map +1 -0
- package/dist/types/line-item-adjustment.d.ts +9 -0
- package/dist/types/line-item-adjustment.js +50 -0
- package/dist/types/line-item-adjustment.js.map +1 -0
- package/dist/types/note.d.ts +1 -1
- package/dist/types/price-list.d.ts +73 -0
- package/dist/types/price-list.js +157 -0
- package/dist/types/price-list.js.map +1 -0
- package/dist/types/price-selection.d.ts +5 -0
- package/dist/types/price-selection.js +35 -0
- package/dist/types/price-selection.js.map +1 -0
- package/dist/types/pricing.d.ts +25 -0
- package/dist/types/pricing.js +3 -0
- package/dist/types/pricing.js.map +1 -0
- package/dist/types/product-variant.d.ts +24 -1
- package/dist/types/product-variant.js +65 -1
- package/dist/types/product-variant.js.map +1 -1
- package/dist/types/product.d.ts +18 -0
- package/dist/types/product.js +104 -5
- package/dist/types/product.js.map +1 -1
- package/dist/types/shipping-options.d.ts +56 -0
- package/dist/types/shipping-options.js +3 -0
- package/dist/types/shipping-options.js.map +1 -0
- package/dist/types/store.d.ts +9 -0
- package/dist/types/store.js +3 -0
- package/dist/types/store.js.map +1 -0
- package/dist/types/tax-service.d.ts +2 -2
- package/dist/types/user.d.ts +2 -2
- package/dist/types/validators/exactly-one.d.ts +6 -0
- package/dist/types/validators/exactly-one.js +37 -0
- package/dist/types/validators/exactly-one.js.map +1 -0
- package/dist/utils/build-query.d.ts +8 -0
- package/dist/utils/build-query.js +114 -0
- package/dist/utils/build-query.js.map +1 -0
- package/dist/utils/countries.d.ts +3 -2
- package/dist/utils/countries.js.map +1 -1
- package/dist/utils/currencies.d.ts +10 -1899
- package/dist/utils/currencies.js.map +1 -1
- package/dist/utils/date-helpers.d.ts +2 -0
- package/dist/utils/date-helpers.js +15 -0
- package/dist/utils/date-helpers.js.map +1 -0
- package/dist/utils/format-registration-name.d.ts +4 -4
- package/dist/utils/format-registration-name.js +7 -10
- package/dist/utils/format-registration-name.js.map +1 -1
- package/dist/utils/generate-entity-id.d.ts +6 -0
- package/dist/utils/generate-entity-id.js +19 -0
- package/dist/utils/generate-entity-id.js.map +1 -0
- package/dist/utils/get-query-config.d.ts +9 -0
- package/dist/utils/get-query-config.js +133 -0
- package/dist/utils/get-query-config.js.map +1 -0
- package/dist/utils/index.d.ts +4 -0
- package/dist/utils/index.js +17 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/set-metadata.d.ts +9 -0
- package/dist/utils/set-metadata.js +72 -0
- package/dist/utils/set-metadata.js.map +1 -0
- package/dist/utils/sleep.d.ts +1 -0
- package/dist/utils/sleep.js +50 -0
- package/dist/utils/sleep.js.map +1 -0
- package/dist/utils/validate-id.d.ts +4 -0
- package/dist/utils/validate-id.js +47 -0
- package/dist/utils/validate-id.js.map +1 -0
- package/jest.config.js +6 -0
- package/package.json +11 -9
- package/tsconfig.spec.json +10 -0
- package/yarn-error.log +23292 -1023
|
@@ -72,17 +72,6 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
72
72
|
}
|
|
73
73
|
return t;
|
|
74
74
|
};
|
|
75
|
-
var __values = (this && this.__values) || function(o) {
|
|
76
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
77
|
-
if (m) return m.call(o);
|
|
78
|
-
if (o && typeof o.length === "number") return {
|
|
79
|
-
next: function () {
|
|
80
|
-
if (o && i >= o.length) o = void 0;
|
|
81
|
-
return { value: o && o[i++], done: !o };
|
|
82
|
-
}
|
|
83
|
-
};
|
|
84
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
85
|
-
};
|
|
86
75
|
var __read = (this && this.__read) || function (o, n) {
|
|
87
76
|
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
88
77
|
if (!m) return o;
|
|
@@ -99,6 +88,26 @@ var __read = (this && this.__read) || function (o, n) {
|
|
|
99
88
|
}
|
|
100
89
|
return ar;
|
|
101
90
|
};
|
|
91
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
92
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
93
|
+
if (ar || !(i in from)) {
|
|
94
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
95
|
+
ar[i] = from[i];
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
99
|
+
};
|
|
100
|
+
var __values = (this && this.__values) || function(o) {
|
|
101
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
102
|
+
if (m) return m.call(o);
|
|
103
|
+
if (o && typeof o.length === "number") return {
|
|
104
|
+
next: function () {
|
|
105
|
+
if (o && i >= o.length) o = void 0;
|
|
106
|
+
return { value: o && o[i++], done: !o };
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
110
|
+
};
|
|
102
111
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
103
112
|
var medusa_core_utils_1 = require("medusa-core-utils");
|
|
104
113
|
var medusa_interfaces_1 = require("medusa-interfaces");
|
|
@@ -110,7 +119,7 @@ var typeorm_1 = require("typeorm");
|
|
|
110
119
|
var ProductVariantService = /** @class */ (function (_super) {
|
|
111
120
|
__extends(ProductVariantService, _super);
|
|
112
121
|
function ProductVariantService(_a) {
|
|
113
|
-
var manager = _a.manager, productVariantRepository = _a.productVariantRepository, productRepository = _a.productRepository, eventBusService = _a.eventBusService, regionService = _a.regionService, moneyAmountRepository = _a.moneyAmountRepository, productOptionValueRepository = _a.productOptionValueRepository;
|
|
122
|
+
var manager = _a.manager, productVariantRepository = _a.productVariantRepository, productRepository = _a.productRepository, eventBusService = _a.eventBusService, regionService = _a.regionService, moneyAmountRepository = _a.moneyAmountRepository, productOptionValueRepository = _a.productOptionValueRepository, cartRepository = _a.cartRepository, priceSelectionStrategy = _a.priceSelectionStrategy;
|
|
114
123
|
var _this = _super.call(this) || this;
|
|
115
124
|
/** @private @const {EntityManager} */
|
|
116
125
|
_this.manager_ = manager;
|
|
@@ -124,6 +133,8 @@ var ProductVariantService = /** @class */ (function (_super) {
|
|
|
124
133
|
_this.regionService_ = regionService;
|
|
125
134
|
_this.moneyAmountRepository_ = moneyAmountRepository;
|
|
126
135
|
_this.productOptionValueRepository_ = productOptionValueRepository;
|
|
136
|
+
_this.cartRepository_ = cartRepository;
|
|
137
|
+
_this.priceSelectionStrategy_ = priceSelectionStrategy;
|
|
127
138
|
return _this;
|
|
128
139
|
}
|
|
129
140
|
ProductVariantService.prototype.withTransaction = function (transactionManager) {
|
|
@@ -138,6 +149,8 @@ var ProductVariantService = /** @class */ (function (_super) {
|
|
|
138
149
|
regionService: this.regionService_,
|
|
139
150
|
moneyAmountRepository: this.moneyAmountRepository_,
|
|
140
151
|
productOptionValueRepository: this.productOptionValueRepository_,
|
|
152
|
+
cartRepository: this.cartRepository_,
|
|
153
|
+
priceSelectionStrategy: this.priceSelectionStrategy_,
|
|
141
154
|
});
|
|
142
155
|
cloned.transactionManager_ = transactionManager;
|
|
143
156
|
return cloned;
|
|
@@ -149,22 +162,38 @@ var ProductVariantService = /** @class */ (function (_super) {
|
|
|
149
162
|
* @return {Promise<Product>} the product document.
|
|
150
163
|
*/
|
|
151
164
|
ProductVariantService.prototype.retrieve = function (variantId, config) {
|
|
152
|
-
|
|
165
|
+
var _a, _b;
|
|
166
|
+
if (config === void 0) { config = {
|
|
167
|
+
include_discount_prices: false,
|
|
168
|
+
}; }
|
|
153
169
|
return __awaiter(this, void 0, void 0, function () {
|
|
154
|
-
var variantRepo, validatedId, query, variant;
|
|
155
|
-
return __generator(this, function (
|
|
156
|
-
switch (
|
|
170
|
+
var variantRepo, validatedId, priceIndex, query, variant, _c;
|
|
171
|
+
return __generator(this, function (_d) {
|
|
172
|
+
switch (_d.label) {
|
|
157
173
|
case 0:
|
|
158
174
|
variantRepo = this.manager_.getCustomRepository(this.productVariantRepository_);
|
|
159
175
|
validatedId = this.validateId_(variantId);
|
|
176
|
+
priceIndex = (_b = (_a = config.relations) === null || _a === void 0 ? void 0 : _a.indexOf("prices")) !== null && _b !== void 0 ? _b : -1;
|
|
177
|
+
if (priceIndex >= 0 && config.relations) {
|
|
178
|
+
config.relations = __spreadArray([], __read(config.relations), false);
|
|
179
|
+
config.relations.splice(priceIndex, 1);
|
|
180
|
+
}
|
|
160
181
|
query = this.buildQuery_({ id: validatedId }, config);
|
|
161
182
|
return [4 /*yield*/, variantRepo.findOne(query)];
|
|
162
183
|
case 1:
|
|
163
|
-
variant =
|
|
184
|
+
variant = _d.sent();
|
|
164
185
|
if (!variant) {
|
|
165
186
|
throw new medusa_core_utils_1.MedusaError(medusa_core_utils_1.MedusaError.Types.NOT_FOUND, "Variant with id: ".concat(variantId, " was not found"));
|
|
166
187
|
}
|
|
167
|
-
return [
|
|
188
|
+
if (!(priceIndex >= 0)) return [3 /*break*/, 3];
|
|
189
|
+
return [4 /*yield*/, this.setAdditionalPrices(variant, config.currency_code, config.region_id, config.cart_id, config.customer_id, config.include_discount_prices)];
|
|
190
|
+
case 2:
|
|
191
|
+
_c = (_d.sent());
|
|
192
|
+
return [3 /*break*/, 4];
|
|
193
|
+
case 3:
|
|
194
|
+
_c = variant;
|
|
195
|
+
_d.label = 4;
|
|
196
|
+
case 4: return [2 /*return*/, _c];
|
|
168
197
|
}
|
|
169
198
|
});
|
|
170
199
|
});
|
|
@@ -176,21 +205,37 @@ var ProductVariantService = /** @class */ (function (_super) {
|
|
|
176
205
|
* @return {Promise<Product>} the product document.
|
|
177
206
|
*/
|
|
178
207
|
ProductVariantService.prototype.retrieveBySKU = function (sku, config) {
|
|
179
|
-
|
|
208
|
+
var _a, _b;
|
|
209
|
+
if (config === void 0) { config = {
|
|
210
|
+
include_discount_prices: false,
|
|
211
|
+
}; }
|
|
180
212
|
return __awaiter(this, void 0, void 0, function () {
|
|
181
|
-
var variantRepo, query, variant;
|
|
182
|
-
return __generator(this, function (
|
|
183
|
-
switch (
|
|
213
|
+
var variantRepo, priceIndex, query, variant, _c;
|
|
214
|
+
return __generator(this, function (_d) {
|
|
215
|
+
switch (_d.label) {
|
|
184
216
|
case 0:
|
|
185
217
|
variantRepo = this.manager_.getCustomRepository(this.productVariantRepository_);
|
|
218
|
+
priceIndex = (_b = (_a = config.relations) === null || _a === void 0 ? void 0 : _a.indexOf("prices")) !== null && _b !== void 0 ? _b : -1;
|
|
219
|
+
if (priceIndex >= 0 && config.relations) {
|
|
220
|
+
config.relations = __spreadArray([], __read(config.relations), false);
|
|
221
|
+
config.relations.splice(priceIndex, 1);
|
|
222
|
+
}
|
|
186
223
|
query = this.buildQuery_({ sku: sku }, config);
|
|
187
224
|
return [4 /*yield*/, variantRepo.findOne(query)];
|
|
188
225
|
case 1:
|
|
189
|
-
variant =
|
|
226
|
+
variant = _d.sent();
|
|
190
227
|
if (!variant) {
|
|
191
228
|
throw new medusa_core_utils_1.MedusaError(medusa_core_utils_1.MedusaError.Types.NOT_FOUND, "Variant with sku: ".concat(sku, " was not found"));
|
|
192
229
|
}
|
|
193
|
-
return [
|
|
230
|
+
if (!(priceIndex >= 0)) return [3 /*break*/, 3];
|
|
231
|
+
return [4 /*yield*/, this.setAdditionalPrices(variant, config.currency_code, config.region_id, config.cart_id, config.customer_id, config.include_discount_prices)];
|
|
232
|
+
case 2:
|
|
233
|
+
_c = (_d.sent());
|
|
234
|
+
return [3 /*break*/, 4];
|
|
235
|
+
case 3:
|
|
236
|
+
_c = variant;
|
|
237
|
+
_d.label = 4;
|
|
238
|
+
case 4: return [2 /*return*/, _c];
|
|
194
239
|
}
|
|
195
240
|
});
|
|
196
241
|
});
|
|
@@ -268,7 +313,6 @@ var ProductVariantService = /** @class */ (function (_super) {
|
|
|
268
313
|
return [4 /*yield*/, this.setRegionPrice(result.id, {
|
|
269
314
|
amount: price.amount,
|
|
270
315
|
region_id: price.region_id,
|
|
271
|
-
sale_amount: price.sale_amount,
|
|
272
316
|
})];
|
|
273
317
|
case 7:
|
|
274
318
|
_b.sent();
|
|
@@ -312,6 +356,7 @@ var ProductVariantService = /** @class */ (function (_super) {
|
|
|
312
356
|
* The function will throw, if price updates are attempted.
|
|
313
357
|
* @param {string | ProductVariant} variantOrVariantId - variant or id of a variant.
|
|
314
358
|
* @param {object} update - an object with the update values.
|
|
359
|
+
* @param {object} config - an object with the config values for returning the variant.
|
|
315
360
|
* @return {Promise} resolves to the update result.
|
|
316
361
|
*/
|
|
317
362
|
ProductVariantService.prototype.update = function (variantOrVariantId, update) {
|
|
@@ -319,7 +364,7 @@ var ProductVariantService = /** @class */ (function (_super) {
|
|
|
319
364
|
var _this = this;
|
|
320
365
|
return __generator(this, function (_a) {
|
|
321
366
|
return [2 /*return*/, this.atomicPhase_(function (manager) { return __awaiter(_this, void 0, void 0, function () {
|
|
322
|
-
var variantRepo, variant, prices, options, metadata, inventory_quantity, rest, options_1, options_1_1, option, e_2_1, _a, _b, _c, key, value, result;
|
|
367
|
+
var variantRepo, variant, variantRes, prices, options, metadata, inventory_quantity, rest, options_1, options_1_1, option, e_2_1, _a, _b, _c, key, value, result;
|
|
323
368
|
var e_2, _d, e_3, _e;
|
|
324
369
|
return __generator(this, function (_f) {
|
|
325
370
|
switch (_f.label) {
|
|
@@ -327,9 +372,17 @@ var ProductVariantService = /** @class */ (function (_super) {
|
|
|
327
372
|
variantRepo = manager.getCustomRepository(this.productVariantRepository_);
|
|
328
373
|
variant = variantOrVariantId;
|
|
329
374
|
if (!(typeof variant === "string")) return [3 /*break*/, 2];
|
|
330
|
-
return [4 /*yield*/,
|
|
375
|
+
return [4 /*yield*/, variantRepo.findOne({
|
|
376
|
+
where: { id: variantOrVariantId },
|
|
377
|
+
})];
|
|
331
378
|
case 1:
|
|
332
|
-
|
|
379
|
+
variantRes = _f.sent();
|
|
380
|
+
if (typeof variant === "undefined") {
|
|
381
|
+
throw new medusa_core_utils_1.MedusaError(medusa_core_utils_1.MedusaError.Types.NOT_FOUND, "Variant with id ".concat(variantOrVariantId, " was not found"));
|
|
382
|
+
}
|
|
383
|
+
else {
|
|
384
|
+
variant = variantRes;
|
|
385
|
+
}
|
|
333
386
|
return [3 /*break*/, 3];
|
|
334
387
|
case 2:
|
|
335
388
|
if (!variant.id) {
|
|
@@ -372,7 +425,7 @@ var ProductVariantService = /** @class */ (function (_super) {
|
|
|
372
425
|
finally { if (e_2) throw e_2.error; }
|
|
373
426
|
return [7 /*endfinally*/];
|
|
374
427
|
case 13:
|
|
375
|
-
if (metadata) {
|
|
428
|
+
if (typeof metadata === "object") {
|
|
376
429
|
variant.metadata = this.setMetadata_(variant, metadata);
|
|
377
430
|
}
|
|
378
431
|
if (typeof inventory_quantity === "number") {
|
|
@@ -410,6 +463,13 @@ var ProductVariantService = /** @class */ (function (_super) {
|
|
|
410
463
|
});
|
|
411
464
|
});
|
|
412
465
|
};
|
|
466
|
+
/**
|
|
467
|
+
* Updates a variant's prices.
|
|
468
|
+
* Deletes any prices that are not in the update object, and is not associated with a price list.
|
|
469
|
+
* @param variantId - the id of variant variant
|
|
470
|
+
* @param prices - the update prices
|
|
471
|
+
* @returns {Promise<void>} empty promise
|
|
472
|
+
*/
|
|
413
473
|
ProductVariantService.prototype.updateVariantPrices = function (variantId, prices) {
|
|
414
474
|
return __awaiter(this, void 0, void 0, function () {
|
|
415
475
|
var _this = this;
|
|
@@ -436,7 +496,6 @@ var ProductVariantService = /** @class */ (function (_super) {
|
|
|
436
496
|
return [4 /*yield*/, this.setRegionPrice(variantId, {
|
|
437
497
|
region_id: price.region_id,
|
|
438
498
|
amount: price.amount,
|
|
439
|
-
sale_amount: price.sale_amount || undefined,
|
|
440
499
|
})];
|
|
441
500
|
case 4:
|
|
442
501
|
_b.sent();
|
|
@@ -469,80 +528,39 @@ var ProductVariantService = /** @class */ (function (_super) {
|
|
|
469
528
|
});
|
|
470
529
|
});
|
|
471
530
|
};
|
|
472
|
-
/**
|
|
473
|
-
* Sets the default price for the given currency.
|
|
474
|
-
* @param {string} variantId - the id of the variant to set prices for
|
|
475
|
-
* @param {ProductVariantPrice} price - the price for the variant
|
|
476
|
-
* @return {Promise} the result of the update operation
|
|
477
|
-
*/
|
|
478
|
-
ProductVariantService.prototype.setCurrencyPrice = function (variantId, price) {
|
|
479
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
480
|
-
var _this = this;
|
|
481
|
-
return __generator(this, function (_a) {
|
|
482
|
-
return [2 /*return*/, this.atomicPhase_(function (manager) { return __awaiter(_this, void 0, void 0, function () {
|
|
483
|
-
var moneyAmountRepo;
|
|
484
|
-
return __generator(this, function (_a) {
|
|
485
|
-
switch (_a.label) {
|
|
486
|
-
case 0:
|
|
487
|
-
moneyAmountRepo = manager.getCustomRepository(this.moneyAmountRepository_);
|
|
488
|
-
return [4 /*yield*/, moneyAmountRepo.upsertCurrencyPrice(variantId, price)];
|
|
489
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
490
|
-
}
|
|
491
|
-
});
|
|
492
|
-
}); })];
|
|
493
|
-
});
|
|
494
|
-
});
|
|
495
|
-
};
|
|
496
531
|
/**
|
|
497
532
|
* Gets the price specific to a region. If no region specific money amount
|
|
498
533
|
* exists the function will try to use a currency price. If no default
|
|
499
534
|
* currency price exists the function will throw an error.
|
|
500
535
|
* @param {string} variantId - the id of the variant to get price from
|
|
501
|
-
* @param {
|
|
536
|
+
* @param {GetRegionPriceContext} context - context for getting region price
|
|
502
537
|
* @return {number} the price specific to the region
|
|
503
538
|
*/
|
|
504
|
-
ProductVariantService.prototype.getRegionPrice = function (variantId,
|
|
539
|
+
ProductVariantService.prototype.getRegionPrice = function (variantId, context) {
|
|
505
540
|
return __awaiter(this, void 0, void 0, function () {
|
|
506
541
|
var _this = this;
|
|
507
542
|
return __generator(this, function (_a) {
|
|
508
543
|
return [2 /*return*/, this.atomicPhase_(function (manager) { return __awaiter(_this, void 0, void 0, function () {
|
|
509
|
-
var
|
|
544
|
+
var region, prices;
|
|
510
545
|
return __generator(this, function (_a) {
|
|
511
546
|
switch (_a.label) {
|
|
512
|
-
case 0:
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
.withTransaction(manager)
|
|
516
|
-
.retrieve(regionId)
|
|
517
|
-
// Find region price based on region id
|
|
518
|
-
];
|
|
547
|
+
case 0: return [4 /*yield*/, this.regionService_
|
|
548
|
+
.withTransaction(manager)
|
|
549
|
+
.retrieve(context.regionId)];
|
|
519
550
|
case 1:
|
|
520
551
|
region = _a.sent();
|
|
521
|
-
return [4 /*yield*/,
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
if (!!moneyAmount) return [3 /*break*/, 4];
|
|
530
|
-
return [4 /*yield*/, moneyAmountRepo.findOne({
|
|
531
|
-
where: { variant_id: variantId, currency_code: region.currency_code },
|
|
552
|
+
return [4 /*yield*/, this.priceSelectionStrategy_
|
|
553
|
+
.withTransaction(manager)
|
|
554
|
+
.calculateVariantPrice(variantId, {
|
|
555
|
+
region_id: context.regionId,
|
|
556
|
+
currency_code: region.currency_code,
|
|
557
|
+
quantity: context.quantity,
|
|
558
|
+
customer_id: context.customer_id,
|
|
559
|
+
include_discount_prices: !!context.include_discount_prices,
|
|
532
560
|
})];
|
|
533
|
-
case
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
case 4:
|
|
537
|
-
// Still, if no price is found, we throw
|
|
538
|
-
if (!moneyAmount) {
|
|
539
|
-
throw new medusa_core_utils_1.MedusaError(medusa_core_utils_1.MedusaError.Types.NOT_FOUND, "A price for region: ".concat(region.name, " could not be found"));
|
|
540
|
-
}
|
|
541
|
-
// Always return sale price, if present
|
|
542
|
-
if (moneyAmount.sale_amount) {
|
|
543
|
-
return [2 /*return*/, moneyAmount.sale_amount];
|
|
544
|
-
}
|
|
545
|
-
return [2 /*return*/, moneyAmount.amount];
|
|
561
|
+
case 2:
|
|
562
|
+
prices = _a.sent();
|
|
563
|
+
return [2 /*return*/, prices.calculatedPrice];
|
|
546
564
|
}
|
|
547
565
|
});
|
|
548
566
|
}); })];
|
|
@@ -550,7 +568,7 @@ var ProductVariantService = /** @class */ (function (_super) {
|
|
|
550
568
|
});
|
|
551
569
|
};
|
|
552
570
|
/**
|
|
553
|
-
* Sets the price of a specific region
|
|
571
|
+
* Sets the default price of a specific region
|
|
554
572
|
* @param {string} variantId - the id of the variant to update
|
|
555
573
|
* @param {string} price - the price for the variant.
|
|
556
574
|
* @return {Promise} the result of the update operation
|
|
@@ -569,6 +587,7 @@ var ProductVariantService = /** @class */ (function (_super) {
|
|
|
569
587
|
where: {
|
|
570
588
|
variant_id: variantId,
|
|
571
589
|
region_id: price.region_id,
|
|
590
|
+
price_list_id: null,
|
|
572
591
|
},
|
|
573
592
|
})];
|
|
574
593
|
case 1:
|
|
@@ -578,7 +597,6 @@ var ProductVariantService = /** @class */ (function (_super) {
|
|
|
578
597
|
}
|
|
579
598
|
else {
|
|
580
599
|
moneyAmount.amount = price.amount;
|
|
581
|
-
moneyAmount.sale_amount = price.sale_amount;
|
|
582
600
|
}
|
|
583
601
|
return [4 /*yield*/, moneyAmountRepo.save(moneyAmount)];
|
|
584
602
|
case 2:
|
|
@@ -590,6 +608,30 @@ var ProductVariantService = /** @class */ (function (_super) {
|
|
|
590
608
|
});
|
|
591
609
|
});
|
|
592
610
|
};
|
|
611
|
+
/**
|
|
612
|
+
* Sets the default price for the given currency.
|
|
613
|
+
* @param {string} variantId - the id of the variant to set prices for
|
|
614
|
+
* @param {ProductVariantPrice} price - the price for the variant
|
|
615
|
+
* @return {Promise} the result of the update operation
|
|
616
|
+
*/
|
|
617
|
+
ProductVariantService.prototype.setCurrencyPrice = function (variantId, price) {
|
|
618
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
619
|
+
var _this = this;
|
|
620
|
+
return __generator(this, function (_a) {
|
|
621
|
+
return [2 /*return*/, this.atomicPhase_(function (manager) { return __awaiter(_this, void 0, void 0, function () {
|
|
622
|
+
var moneyAmountRepo;
|
|
623
|
+
return __generator(this, function (_a) {
|
|
624
|
+
switch (_a.label) {
|
|
625
|
+
case 0:
|
|
626
|
+
moneyAmountRepo = manager.getCustomRepository(this.moneyAmountRepository_);
|
|
627
|
+
return [4 /*yield*/, moneyAmountRepo.upsertVariantCurrencyPrice(variantId, price)];
|
|
628
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
629
|
+
}
|
|
630
|
+
});
|
|
631
|
+
}); })];
|
|
632
|
+
});
|
|
633
|
+
});
|
|
634
|
+
};
|
|
593
635
|
/**
|
|
594
636
|
* Updates variant's option value.
|
|
595
637
|
* Option value must be of type string or number.
|
|
@@ -703,26 +745,48 @@ var ProductVariantService = /** @class */ (function (_super) {
|
|
|
703
745
|
* @return {Promise} the result of the find operation
|
|
704
746
|
*/
|
|
705
747
|
ProductVariantService.prototype.listAndCount = function (selector, config) {
|
|
706
|
-
var _a;
|
|
707
|
-
if (config === void 0) { config = {
|
|
748
|
+
var _a, _b, _c;
|
|
749
|
+
if (config === void 0) { config = {
|
|
750
|
+
relations: [],
|
|
751
|
+
skip: 0,
|
|
752
|
+
take: 20,
|
|
753
|
+
include_discount_prices: false,
|
|
754
|
+
}; }
|
|
708
755
|
return __awaiter(this, void 0, void 0, function () {
|
|
709
|
-
var variantRepo,
|
|
710
|
-
return __generator(this, function (
|
|
711
|
-
switch (
|
|
756
|
+
var variantRepo, priceIndex, _d, q, query, relations, qb, _e, raw, count_1, variants_1, res, _f, variants, count, res;
|
|
757
|
+
return __generator(this, function (_g) {
|
|
758
|
+
switch (_g.label) {
|
|
712
759
|
case 0:
|
|
713
760
|
variantRepo = this.manager_.getCustomRepository(this.productVariantRepository_);
|
|
714
|
-
_b =
|
|
715
|
-
if (
|
|
761
|
+
priceIndex = (_b = (_a = config.relations) === null || _a === void 0 ? void 0 : _a.indexOf("prices")) !== null && _b !== void 0 ? _b : -1;
|
|
762
|
+
if (priceIndex >= 0 && config.relations) {
|
|
763
|
+
config.relations = __spreadArray([], __read(config.relations), false);
|
|
764
|
+
config.relations.splice(priceIndex, 1);
|
|
765
|
+
}
|
|
766
|
+
_d = this.prepareListQuery_(selector, config), q = _d.q, query = _d.query, relations = _d.relations;
|
|
767
|
+
if (!q) return [3 /*break*/, 5];
|
|
716
768
|
qb = this.getFreeTextQueryBuilder_(variantRepo, query, q);
|
|
717
769
|
return [4 /*yield*/, qb.getManyAndCount()];
|
|
718
770
|
case 1:
|
|
719
|
-
|
|
720
|
-
return [4 /*yield*/, variantRepo.findWithRelations(relations, raw.map(function (i) { return i.id; }), (
|
|
771
|
+
_e = __read.apply(void 0, [_g.sent(), 2]), raw = _e[0], count_1 = _e[1];
|
|
772
|
+
return [4 /*yield*/, variantRepo.findWithRelations(relations, raw.map(function (i) { return i.id; }), (_c = query.withDeleted) !== null && _c !== void 0 ? _c : false)];
|
|
721
773
|
case 2:
|
|
722
|
-
|
|
723
|
-
return [
|
|
724
|
-
|
|
725
|
-
case
|
|
774
|
+
variants_1 = _g.sent();
|
|
775
|
+
if (!(priceIndex >= 0)) return [3 /*break*/, 4];
|
|
776
|
+
return [4 /*yield*/, this.setAdditionalPrices(variants_1, config.currency_code, config.region_id, config.cart_id, config.customer_id, config.include_discount_prices)];
|
|
777
|
+
case 3:
|
|
778
|
+
res = _g.sent();
|
|
779
|
+
return [2 /*return*/, [res, count_1]];
|
|
780
|
+
case 4: return [2 /*return*/, [variants_1, count_1]];
|
|
781
|
+
case 5: return [4 /*yield*/, variantRepo.findWithRelationsAndCount(relations, query)];
|
|
782
|
+
case 6:
|
|
783
|
+
_f = __read.apply(void 0, [_g.sent(), 2]), variants = _f[0], count = _f[1];
|
|
784
|
+
if (!(priceIndex >= 0)) return [3 /*break*/, 8];
|
|
785
|
+
return [4 /*yield*/, this.setAdditionalPrices(variants, config.currency_code, config.region_id, config.cart_id, config.customer_id, config.include_discount_prices)];
|
|
786
|
+
case 7:
|
|
787
|
+
res = _g.sent();
|
|
788
|
+
return [2 /*return*/, [res, count]];
|
|
789
|
+
case 8: return [2 /*return*/, [variants, count]];
|
|
726
790
|
}
|
|
727
791
|
});
|
|
728
792
|
});
|
|
@@ -733,13 +797,23 @@ var ProductVariantService = /** @class */ (function (_super) {
|
|
|
733
797
|
* @return {Promise} the result of the find operation
|
|
734
798
|
*/
|
|
735
799
|
ProductVariantService.prototype.list = function (selector, config) {
|
|
736
|
-
|
|
800
|
+
var _a, _b;
|
|
801
|
+
if (config === void 0) { config = {
|
|
802
|
+
relations: [],
|
|
803
|
+
skip: 0,
|
|
804
|
+
take: 20,
|
|
805
|
+
}; }
|
|
737
806
|
return __awaiter(this, void 0, void 0, function () {
|
|
738
|
-
var productVariantRepo, q, query, where_1;
|
|
739
|
-
return __generator(this, function (
|
|
740
|
-
switch (
|
|
807
|
+
var productVariantRepo, priceIndex, q, query, where_1, variants, _c;
|
|
808
|
+
return __generator(this, function (_d) {
|
|
809
|
+
switch (_d.label) {
|
|
741
810
|
case 0:
|
|
742
811
|
productVariantRepo = this.manager_.getCustomRepository(this.productVariantRepository_);
|
|
812
|
+
priceIndex = (_b = (_a = config.relations) === null || _a === void 0 ? void 0 : _a.indexOf("prices")) !== null && _b !== void 0 ? _b : -1;
|
|
813
|
+
if (priceIndex >= 0 && config.relations) {
|
|
814
|
+
config.relations = __spreadArray([], __read(config.relations), false);
|
|
815
|
+
config.relations.splice(priceIndex, 1);
|
|
816
|
+
}
|
|
743
817
|
if ("q" in selector) {
|
|
744
818
|
q = selector.q;
|
|
745
819
|
delete selector.q;
|
|
@@ -764,7 +838,17 @@ var ProductVariantService = /** @class */ (function (_super) {
|
|
|
764
838
|
};
|
|
765
839
|
}
|
|
766
840
|
return [4 /*yield*/, productVariantRepo.find(query)];
|
|
767
|
-
case 1:
|
|
841
|
+
case 1:
|
|
842
|
+
variants = _d.sent();
|
|
843
|
+
if (!(priceIndex >= 0)) return [3 /*break*/, 3];
|
|
844
|
+
return [4 /*yield*/, this.setAdditionalPrices(variants, config.currency_code, config.region_id, config.cart_id, config.customer_id, config.include_discount_prices)];
|
|
845
|
+
case 2:
|
|
846
|
+
_c = (_d.sent());
|
|
847
|
+
return [3 /*break*/, 4];
|
|
848
|
+
case 3:
|
|
849
|
+
_c = variants;
|
|
850
|
+
_d.label = 4;
|
|
851
|
+
case 4: return [2 /*return*/, _c];
|
|
768
852
|
}
|
|
769
853
|
});
|
|
770
854
|
});
|
|
@@ -786,7 +870,10 @@ var ProductVariantService = /** @class */ (function (_super) {
|
|
|
786
870
|
switch (_a.label) {
|
|
787
871
|
case 0:
|
|
788
872
|
variantRepo = manager.getCustomRepository(this.productVariantRepository_);
|
|
789
|
-
return [4 /*yield*/, variantRepo.findOne({
|
|
873
|
+
return [4 /*yield*/, variantRepo.findOne({
|
|
874
|
+
where: { id: variantId },
|
|
875
|
+
relations: ["prices", "options"],
|
|
876
|
+
})];
|
|
790
877
|
case 1:
|
|
791
878
|
variant = _a.sent();
|
|
792
879
|
if (!variant) {
|
|
@@ -902,6 +989,69 @@ var ProductVariantService = /** @class */ (function (_super) {
|
|
|
902
989
|
}
|
|
903
990
|
return qb;
|
|
904
991
|
};
|
|
992
|
+
/**
|
|
993
|
+
* Set additional prices on a list of variants.
|
|
994
|
+
* @param {ProductVariant | ProductVariant[] } variant variant on which to set additional prices
|
|
995
|
+
* @param {string} currency_code currency code to fetch prices for
|
|
996
|
+
* @param {string} region_id region to fetch prices for
|
|
997
|
+
* @param {string} cart_id string of cart to use as a basis for getting currency and region
|
|
998
|
+
* @param {string} customer_id id of potentially logged in customer, used to get prices valid for their customer groups
|
|
999
|
+
* @param {boolean} include_discount_prices should result include discount pricing
|
|
1000
|
+
* @return {Promise<ProductVariant | ProductVariant[]>} A list of variants with variants decorated with "additional_prices"
|
|
1001
|
+
*/
|
|
1002
|
+
ProductVariantService.prototype.setAdditionalPrices = function (variant, currency_code, region_id, cart_id, customer_id, include_discount_prices) {
|
|
1003
|
+
if (include_discount_prices === void 0) { include_discount_prices = false; }
|
|
1004
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1005
|
+
var _this = this;
|
|
1006
|
+
return __generator(this, function (_a) {
|
|
1007
|
+
return [2 /*return*/, this.atomicPhase_(function (manager) { return __awaiter(_this, void 0, void 0, function () {
|
|
1008
|
+
var cartRepo, regionId, currencyCode, cart, variantArray, priceSelectionStrategy, variantsWithPrices;
|
|
1009
|
+
var _this = this;
|
|
1010
|
+
return __generator(this, function (_a) {
|
|
1011
|
+
switch (_a.label) {
|
|
1012
|
+
case 0:
|
|
1013
|
+
cartRepo = manager.getCustomRepository(this.cartRepository_);
|
|
1014
|
+
regionId = region_id;
|
|
1015
|
+
currencyCode = currency_code;
|
|
1016
|
+
if (!cart_id) return [3 /*break*/, 2];
|
|
1017
|
+
return [4 /*yield*/, cartRepo.findOne({
|
|
1018
|
+
where: { id: cart_id },
|
|
1019
|
+
relations: ["region"],
|
|
1020
|
+
})];
|
|
1021
|
+
case 1:
|
|
1022
|
+
cart = _a.sent();
|
|
1023
|
+
regionId = cart.region.id;
|
|
1024
|
+
currencyCode = cart.region.currency_code;
|
|
1025
|
+
_a.label = 2;
|
|
1026
|
+
case 2:
|
|
1027
|
+
variantArray = Array.isArray(variant) ? variant : [variant];
|
|
1028
|
+
priceSelectionStrategy = this.priceSelectionStrategy_.withTransaction(manager);
|
|
1029
|
+
return [4 /*yield*/, Promise.all(variantArray.map(function (v) { return __awaiter(_this, void 0, void 0, function () {
|
|
1030
|
+
var prices;
|
|
1031
|
+
return __generator(this, function (_a) {
|
|
1032
|
+
switch (_a.label) {
|
|
1033
|
+
case 0: return [4 /*yield*/, priceSelectionStrategy.calculateVariantPrice(v.id, {
|
|
1034
|
+
region_id: regionId,
|
|
1035
|
+
currency_code: currencyCode,
|
|
1036
|
+
cart_id: cart_id,
|
|
1037
|
+
customer_id: customer_id,
|
|
1038
|
+
include_discount_prices: include_discount_prices,
|
|
1039
|
+
})];
|
|
1040
|
+
case 1:
|
|
1041
|
+
prices = _a.sent();
|
|
1042
|
+
return [2 /*return*/, __assign(__assign({}, v), { prices: prices.prices, original_price: prices.originalPrice, calculated_price: prices.calculatedPrice, calculated_price_type: prices.calculatedPriceType })];
|
|
1043
|
+
}
|
|
1044
|
+
});
|
|
1045
|
+
}); }))];
|
|
1046
|
+
case 3:
|
|
1047
|
+
variantsWithPrices = _a.sent();
|
|
1048
|
+
return [2 /*return*/, Array.isArray(variant) ? variantsWithPrices : variantsWithPrices[0]];
|
|
1049
|
+
}
|
|
1050
|
+
});
|
|
1051
|
+
}); })];
|
|
1052
|
+
});
|
|
1053
|
+
});
|
|
1054
|
+
};
|
|
905
1055
|
ProductVariantService.Events = {
|
|
906
1056
|
UPDATED: "product-variant.updated",
|
|
907
1057
|
CREATED: "product-variant.created",
|