@medusajs/medusa 1.3.2 → 1.3.3
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 +43 -0
- package/dist/api/index.d.ts +15 -14
- package/dist/api/index.js +15 -14
- 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/error-handler.d.ts +3 -1
- package/dist/api/middlewares/error-handler.js.map +1 -1
- package/dist/api/middlewares/feature-flag-enabled.d.ts +2 -0
- package/dist/api/middlewares/feature-flag-enabled.js +57 -0
- package/dist/api/middlewares/feature-flag-enabled.js.map +1 -0
- package/dist/api/middlewares/index.d.ts +10 -10
- package/dist/api/middlewares/index.js +5 -1
- 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/batch/cancel-batch-job.d.ts +22 -0
- package/dist/api/routes/admin/batch/cancel-batch-job.js +74 -0
- package/dist/api/routes/admin/batch/cancel-batch-job.js.map +1 -0
- package/dist/api/routes/admin/batch/confirm-batch-job.d.ts +22 -0
- package/dist/api/routes/admin/batch/confirm-batch-job.js +74 -0
- package/dist/api/routes/admin/batch/confirm-batch-job.js.map +1 -0
- package/dist/api/routes/admin/batch/create-batch-job.d.ts +30 -0
- package/dist/api/routes/admin/batch/create-batch-job.js +125 -0
- package/dist/api/routes/admin/batch/create-batch-job.js.map +1 -0
- package/dist/api/routes/admin/batch/get-batch-job.d.ts +22 -0
- package/dist/api/routes/admin/batch/get-batch-job.js +67 -0
- package/dist/api/routes/admin/batch/get-batch-job.js.map +1 -0
- package/dist/api/routes/admin/batch/index.d.ts +4 -0
- package/dist/api/routes/admin/batch/index.js +36 -7
- package/dist/api/routes/admin/batch/index.js.map +1 -1
- package/dist/api/routes/admin/batch/list-batch-jobs.d.ts +15 -7
- package/dist/api/routes/admin/batch/list-batch-jobs.js +61 -46
- package/dist/api/routes/admin/batch/list-batch-jobs.js.map +1 -1
- package/dist/api/routes/admin/collections/add-products.d.ts +2 -1
- package/dist/api/routes/admin/collections/add-products.js +4 -7
- package/dist/api/routes/admin/collections/add-products.js.map +1 -1
- package/dist/api/routes/admin/collections/create-collection.d.ts +2 -1
- package/dist/api/routes/admin/collections/create-collection.js +6 -8
- package/dist/api/routes/admin/collections/create-collection.js.map +1 -1
- package/dist/api/routes/admin/collections/delete-collection.d.ts +2 -1
- package/dist/api/routes/admin/collections/delete-collection.js.map +1 -1
- package/dist/api/routes/admin/collections/get-collection.d.ts +2 -1
- package/dist/api/routes/admin/collections/get-collection.js +4 -5
- package/dist/api/routes/admin/collections/get-collection.js.map +1 -1
- package/dist/api/routes/admin/collections/index.js +32 -12
- package/dist/api/routes/admin/collections/index.js.map +1 -1
- package/dist/api/routes/admin/collections/list-collections.d.ts +2 -1
- package/dist/api/routes/admin/collections/list-collections.js +9 -19
- package/dist/api/routes/admin/collections/list-collections.js.map +1 -1
- package/dist/api/routes/admin/collections/remove-products.d.ts +2 -1
- package/dist/api/routes/admin/collections/remove-products.js +5 -8
- package/dist/api/routes/admin/collections/remove-products.js.map +1 -1
- package/dist/api/routes/admin/collections/update-collection.d.ts +2 -1
- package/dist/api/routes/admin/collections/update-collection.js +5 -8
- package/dist/api/routes/admin/collections/update-collection.js.map +1 -1
- package/dist/api/routes/admin/customer-groups/add-customers-batch.d.ts +2 -1
- package/dist/api/routes/admin/customer-groups/add-customers-batch.js.map +1 -1
- package/dist/api/routes/admin/customer-groups/create-customer-group.d.ts +2 -1
- package/dist/api/routes/admin/customer-groups/create-customer-group.js.map +1 -1
- package/dist/api/routes/admin/customer-groups/delete-customer-group.d.ts +2 -1
- package/dist/api/routes/admin/customer-groups/delete-customer-group.js.map +1 -1
- package/dist/api/routes/admin/customer-groups/delete-customers-batch.d.ts +2 -1
- package/dist/api/routes/admin/customer-groups/delete-customers-batch.js.map +1 -1
- package/dist/api/routes/admin/customer-groups/get-customer-group-customers.d.ts +2 -1
- package/dist/api/routes/admin/customer-groups/get-customer-group-customers.js.map +1 -1
- package/dist/api/routes/admin/customer-groups/get-customer-group.d.ts +2 -1
- package/dist/api/routes/admin/customer-groups/get-customer-group.js +3 -17
- package/dist/api/routes/admin/customer-groups/get-customer-group.js.map +1 -1
- package/dist/api/routes/admin/customer-groups/index.js +29 -11
- package/dist/api/routes/admin/customer-groups/index.js.map +1 -1
- package/dist/api/routes/admin/customer-groups/list-customer-groups.d.ts +2 -1
- package/dist/api/routes/admin/customer-groups/list-customer-groups.js +10 -45
- package/dist/api/routes/admin/customer-groups/list-customer-groups.js.map +1 -1
- package/dist/api/routes/admin/customer-groups/update-customer-group.d.ts +2 -1
- package/dist/api/routes/admin/customer-groups/update-customer-group.js.map +1 -1
- package/dist/api/routes/admin/customers/create-customer.d.ts +1 -1
- package/dist/api/routes/admin/customers/create-customer.js.map +1 -1
- package/dist/api/routes/admin/customers/update-customer.d.ts +1 -1
- package/dist/api/routes/admin/customers/update-customer.js.map +1 -1
- package/dist/api/routes/admin/discounts/add-valid-product.d.ts +23 -0
- package/dist/api/routes/admin/discounts/add-valid-product.js +82 -0
- package/dist/api/routes/admin/discounts/add-valid-product.js.map +1 -0
- package/dist/api/routes/admin/discounts/remove-valid-product.d.ts +23 -0
- package/dist/api/routes/admin/discounts/remove-valid-product.js +82 -0
- package/dist/api/routes/admin/discounts/remove-valid-product.js.map +1 -0
- package/dist/api/routes/admin/draft-orders/index.d.ts +1 -1
- package/dist/api/routes/admin/draft-orders/index.js +1 -0
- 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/gift-cards/create-gift-card.d.ts +2 -2
- package/dist/api/routes/admin/gift-cards/create-gift-card.js +0 -1
- package/dist/api/routes/admin/gift-cards/create-gift-card.js.map +1 -1
- package/dist/api/routes/admin/gift-cards/index.d.ts +1 -1
- package/dist/api/routes/admin/gift-cards/index.js +19 -5
- package/dist/api/routes/admin/gift-cards/index.js.map +1 -1
- package/dist/api/routes/admin/gift-cards/list-gift-cards.js +24 -18
- package/dist/api/routes/admin/gift-cards/list-gift-cards.js.map +1 -1
- package/dist/api/routes/admin/gift-cards/update-gift-card.d.ts +1 -1
- package/dist/api/routes/admin/gift-cards/update-gift-card.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 +3 -14
- package/dist/api/routes/admin/orders/create-claim.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/update-claim.d.ts +1 -1
- package/dist/api/routes/admin/orders/update-claim.js.map +1 -1
- package/dist/api/routes/admin/price-lists/create-price-list.d.ts +2 -1
- package/dist/api/routes/admin/price-lists/create-price-list.js +4 -7
- package/dist/api/routes/admin/price-lists/create-price-list.js.map +1 -1
- package/dist/api/routes/admin/price-lists/index.js +26 -7
- package/dist/api/routes/admin/price-lists/index.js.map +1 -1
- package/dist/api/routes/admin/price-lists/list-price-list-products.d.ts +3 -7
- package/dist/api/routes/admin/price-lists/list-price-list-products.js +21 -59
- package/dist/api/routes/admin/price-lists/list-price-list-products.js.map +1 -1
- package/dist/api/routes/admin/price-lists/list-price-lists.d.ts +2 -1
- package/dist/api/routes/admin/price-lists/list-price-lists.js +8 -40
- package/dist/api/routes/admin/price-lists/list-price-lists.js.map +1 -1
- package/dist/api/routes/admin/products/add-option.js +26 -6
- package/dist/api/routes/admin/products/add-option.js.map +1 -1
- package/dist/api/routes/admin/products/create-product.d.ts +3 -3
- package/dist/api/routes/admin/products/create-product.js +13 -9
- package/dist/api/routes/admin/products/create-product.js.map +1 -1
- package/dist/api/routes/admin/products/delete-variant.js +26 -6
- package/dist/api/routes/admin/products/delete-variant.js.map +1 -1
- package/dist/api/routes/admin/products/get-product.js +24 -4
- package/dist/api/routes/admin/products/get-product.js.map +1 -1
- package/dist/api/routes/admin/products/get-variants.d.ts +24 -0
- package/dist/api/routes/admin/products/get-variants.js +76 -0
- package/dist/api/routes/admin/products/get-variants.js.map +1 -0
- package/dist/api/routes/admin/products/index.d.ts +3 -2
- package/dist/api/routes/admin/products/index.js +1 -4
- package/dist/api/routes/admin/products/index.js.map +1 -1
- package/dist/api/routes/admin/products/list-products.d.ts +1 -6
- package/dist/api/routes/admin/products/list-products.js +3 -9
- package/dist/api/routes/admin/products/list-products.js.map +1 -1
- package/dist/api/routes/admin/products/update-product.d.ts +3 -3
- package/dist/api/routes/admin/products/update-product.js +28 -7
- package/dist/api/routes/admin/products/update-product.js.map +1 -1
- package/dist/api/routes/admin/products/update-variant.js +27 -10
- package/dist/api/routes/admin/products/update-variant.js.map +1 -1
- package/dist/api/routes/admin/shipping-options/list-shipping-options.js +6 -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/uploads/create-upload.d.ts +1 -1
- package/dist/api/routes/admin/uploads/create-upload.js +5 -5
- package/dist/api/routes/admin/uploads/create-upload.js.map +1 -1
- package/dist/api/routes/admin/uploads/delete-upload.d.ts +4 -1
- package/dist/api/routes/admin/uploads/delete-upload.js +29 -11
- package/dist/api/routes/admin/uploads/delete-upload.js.map +1 -1
- package/dist/api/routes/admin/uploads/get-download-url.d.ts +28 -0
- package/dist/api/routes/admin/uploads/get-download-url.js +99 -0
- package/dist/api/routes/admin/uploads/get-download-url.js.map +1 -0
- package/dist/api/routes/admin/uploads/index.d.ts +10 -3
- package/dist/api/routes/admin/uploads/index.js +19 -4
- package/dist/api/routes/admin/uploads/index.js.map +1 -1
- package/dist/api/routes/store/carts/add-shipping-method.js +6 -2
- package/dist/api/routes/store/carts/add-shipping-method.js.map +1 -1
- package/dist/api/routes/store/carts/calculate-taxes.js +9 -2
- package/dist/api/routes/store/carts/calculate-taxes.js.map +1 -1
- package/dist/api/routes/store/carts/create-cart.js +6 -2
- package/dist/api/routes/store/carts/create-cart.js.map +1 -1
- package/dist/api/routes/store/carts/create-line-item.js +6 -2
- package/dist/api/routes/store/carts/create-line-item.js.map +1 -1
- package/dist/api/routes/store/carts/create-payment-sessions.js +6 -2
- package/dist/api/routes/store/carts/create-payment-sessions.js.map +1 -1
- package/dist/api/routes/store/carts/decorate-line-items-with-totals.d.ts +5 -0
- package/dist/api/routes/store/carts/decorate-line-items-with-totals.js +71 -0
- package/dist/api/routes/store/carts/decorate-line-items-with-totals.js.map +1 -0
- package/dist/api/routes/store/carts/delete-discount.js +6 -2
- package/dist/api/routes/store/carts/delete-discount.js.map +1 -1
- package/dist/api/routes/store/carts/delete-line-item.js +6 -2
- package/dist/api/routes/store/carts/delete-line-item.js.map +1 -1
- package/dist/api/routes/store/carts/delete-payment-session.js +6 -2
- package/dist/api/routes/store/carts/delete-payment-session.js.map +1 -1
- package/dist/api/routes/store/carts/get-cart.js +6 -2
- package/dist/api/routes/store/carts/get-cart.js.map +1 -1
- package/dist/api/routes/store/carts/refresh-payment-session.js +6 -2
- package/dist/api/routes/store/carts/refresh-payment-session.js.map +1 -1
- package/dist/api/routes/store/carts/set-payment-session.js +6 -2
- package/dist/api/routes/store/carts/set-payment-session.js.map +1 -1
- package/dist/api/routes/store/carts/update-cart.js +6 -2
- package/dist/api/routes/store/carts/update-cart.js.map +1 -1
- package/dist/api/routes/store/carts/update-line-item.js +6 -2
- package/dist/api/routes/store/carts/update-line-item.js.map +1 -1
- package/dist/api/routes/store/carts/update-payment-method.d.ts +38 -0
- package/dist/api/routes/store/carts/update-payment-method.js +122 -0
- package/dist/api/routes/store/carts/update-payment-method.js.map +1 -0
- package/dist/api/routes/store/carts/update-payment-session.js +6 -2
- package/dist/api/routes/store/carts/update-payment-session.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/customers/index.d.ts +1 -1
- package/dist/api/routes/store/customers/index.js.map +1 -1
- package/dist/api/routes/store/customers/update-address.js +1 -1
- package/dist/api/routes/store/customers/update-address.js.map +1 -1
- package/dist/api/routes/store/customers/update-customer.d.ts +1 -1
- package/dist/api/routes/store/customers/update-customer.js.map +1 -1
- package/dist/api/routes/store/gift-cards/index.d.ts +1 -1
- package/dist/api/routes/store/gift-cards/index.js +6 -1
- package/dist/api/routes/store/gift-cards/index.js.map +1 -1
- package/dist/api/routes/store/products/get-product.js +51 -12
- package/dist/api/routes/store/products/get-product.js.map +1 -1
- package/dist/api/routes/store/products/list-products.js +30 -7
- package/dist/api/routes/store/products/list-products.js.map +1 -1
- package/dist/api/routes/store/shipping-options/list-options.js +6 -2
- package/dist/api/routes/store/shipping-options/list-options.js.map +1 -1
- package/dist/api/routes/store/shipping-options/list-shipping-options.js +8 -2
- package/dist/api/routes/store/shipping-options/list-shipping-options.js.map +1 -1
- package/dist/api/routes/store/variants/get-variant.js +51 -12
- package/dist/api/routes/store/variants/get-variant.js.map +1 -1
- package/dist/api/routes/store/variants/list-variants.js +29 -6
- package/dist/api/routes/store/variants/list-variants.js.map +1 -1
- package/dist/commands/migrate.js +29 -14
- package/dist/commands/migrate.js.map +1 -1
- package/dist/commands/seed.js +14 -10
- package/dist/commands/seed.js.map +1 -1
- package/dist/commands/start.js +1 -1
- package/dist/commands/utils/get-migrations.d.ts +2 -1
- package/dist/commands/utils/get-migrations.js +95 -36
- package/dist/commands/utils/get-migrations.js.map +1 -1
- package/dist/config/index.d.ts +14 -0
- package/dist/config/index.js +40 -0
- package/dist/config/index.js.map +1 -0
- package/dist/controllers/products/admin-list-products.js +16 -8
- package/dist/controllers/products/admin-list-products.js.map +1 -1
- package/dist/helpers/test-request.js +21 -15
- package/dist/helpers/test-request.js.map +1 -1
- package/dist/interfaces/abstract-parser.d.ts +25 -0
- package/dist/interfaces/abstract-parser.js +14 -0
- package/dist/interfaces/abstract-parser.js.map +1 -0
- 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 +34 -0
- package/dist/interfaces/batch-job-strategy.js +182 -0
- package/dist/interfaces/batch-job-strategy.js.map +1 -0
- package/dist/interfaces/csv-parser.d.ts +46 -0
- package/dist/interfaces/csv-parser.js +15 -0
- package/dist/interfaces/csv-parser.js.map +1 -0
- package/dist/interfaces/file-service.d.ts +66 -0
- package/dist/interfaces/file-service.js +32 -0
- package/dist/interfaces/file-service.js.map +1 -0
- package/dist/interfaces/index.d.ts +2 -0
- package/dist/interfaces/index.js +2 -0
- package/dist/interfaces/index.js.map +1 -1
- package/dist/loaders/config.js +3 -2
- package/dist/loaders/config.js.map +1 -1
- package/dist/loaders/feature-flags/index.d.ts +6 -0
- package/dist/loaders/feature-flags/index.js +71 -0
- package/dist/loaders/feature-flags/index.js.map +1 -0
- package/dist/loaders/index.d.ts +1 -1
- package/dist/loaders/index.js +8 -5
- package/dist/loaders/index.js.map +1 -1
- package/dist/loaders/plugins.d.ts +4 -3
- package/dist/loaders/plugins.js +71 -34
- package/dist/loaders/plugins.js.map +1 -1
- package/dist/loaders/redis.d.ts +1 -1
- package/dist/loaders/redis.js.map +1 -1
- package/dist/loaders/search-index.js +1 -0
- package/dist/loaders/search-index.js.map +1 -1
- package/dist/loaders/strategies.d.ts +2 -2
- package/dist/loaders/strategies.js +21 -7
- package/dist/loaders/strategies.js.map +1 -1
- package/dist/migrations/1649775522087-add_batch_job_model.js +4 -4
- package/dist/migrations/1649775522087-add_batch_job_model.js.map +1 -1
- package/dist/models/batch-job.d.ts +45 -4
- package/dist/models/batch-job.js +94 -7
- package/dist/models/batch-job.js.map +1 -1
- package/dist/models/customer.d.ts +1 -1
- package/dist/models/customer.js +1 -1
- package/dist/models/customer.js.map +1 -1
- package/dist/models/draft-order.d.ts +1 -2
- package/dist/models/draft-order.js +2 -2
- package/dist/models/draft-order.js.map +1 -1
- package/dist/models/line-item.d.ts +9 -2
- package/dist/models/line-item.js +2 -2
- package/dist/models/line-item.js.map +1 -1
- package/dist/models/product.d.ts +17 -17
- package/dist/models/product.js +34 -34
- package/dist/models/product.js.map +1 -1
- package/dist/models/shipping-method.d.ts +1 -1
- package/dist/models/shipping-method.js +1 -1
- package/dist/models/shipping-method.js.map +1 -1
- package/dist/models/shipping-option.d.ts +1 -1
- package/dist/models/shipping-option.js +1 -1
- package/dist/models/shipping-option.js.map +1 -1
- package/dist/repositories/customer.d.ts +2 -1
- package/dist/repositories/customer.js +18 -7
- package/dist/repositories/customer.js.map +1 -1
- package/dist/repositories/gift-card.d.ts +5 -1
- package/dist/repositories/gift-card.js +124 -29
- package/dist/repositories/gift-card.js.map +1 -1
- package/dist/repositories/image.d.ts +1 -0
- package/dist/repositories/image.js +100 -0
- package/dist/repositories/image.js.map +1 -1
- package/dist/repositories/price-list.js.map +1 -1
- package/dist/repositories/product-tag.d.ts +6 -0
- package/dist/repositories/product-tag.js +113 -0
- package/dist/repositories/product-tag.js.map +1 -1
- package/dist/repositories/product-type.d.ts +5 -0
- package/dist/repositories/product-type.js +64 -0
- package/dist/repositories/product-type.js.map +1 -1
- package/dist/repositories/product-variant.js +4 -5
- package/dist/repositories/product-variant.js.map +1 -1
- package/dist/repositories/product.d.ts +14 -17
- package/dist/repositories/product.js +64 -2
- package/dist/repositories/product.js.map +1 -1
- package/dist/repositories/tax-rate.d.ts +1 -1
- package/dist/repositories/tax-rate.js +2 -9
- package/dist/repositories/tax-rate.js.map +1 -1
- package/dist/services/auth.d.ts +16 -7
- package/dist/services/auth.js +130 -93
- package/dist/services/auth.js.map +1 -1
- package/dist/services/batch-job.d.ts +30 -5
- package/dist/services/batch-job.js +437 -2
- package/dist/services/batch-job.js.map +1 -1
- package/dist/services/cart.js +34 -13
- 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 +911 -879
- package/dist/services/claim.js.map +1 -1
- package/dist/services/csv-parser.d.ts +17 -0
- package/dist/services/csv-parser.js +319 -0
- package/dist/services/csv-parser.js.map +1 -0
- package/dist/services/custom-shipping-option.d.ts +30 -32
- package/dist/services/custom-shipping-option.js +78 -74
- package/dist/services/custom-shipping-option.js.map +1 -1
- package/dist/services/customer.d.ts +48 -50
- package/dist/services/customer.js +465 -428
- package/dist/services/customer.js.map +1 -1
- package/dist/services/discount-condition.d.ts +13 -13
- package/dist/services/discount-condition.js +5 -16
- package/dist/services/discount-condition.js.map +1 -1
- package/dist/services/discount.d.ts +22 -16
- package/dist/services/discount.js +530 -484
- package/dist/services/discount.js.map +1 -1
- package/dist/services/draft-order.d.ts +69 -66
- package/dist/services/draft-order.js +375 -353
- 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.d.ts +63 -64
- package/dist/services/fulfillment.js +200 -194
- package/dist/services/fulfillment.js.map +1 -1
- package/dist/services/gift-card.d.ts +54 -45
- package/dist/services/gift-card.js +239 -221
- package/dist/services/gift-card.js.map +1 -1
- package/dist/services/idempotency-key.d.ts +1 -5
- package/dist/services/idempotency-key.js +2 -5
- package/dist/services/idempotency-key.js.map +1 -1
- package/dist/services/index.d.ts +11 -9
- package/dist/services/index.js +23 -19
- package/dist/services/index.js.map +1 -1
- package/dist/services/line-item.d.ts +3 -2
- package/dist/services/line-item.js +9 -7
- package/dist/services/line-item.js.map +1 -1
- package/dist/services/price-list.d.ts +4 -1
- package/dist/services/price-list.js +7 -4
- package/dist/services/price-list.js.map +1 -1
- package/dist/services/pricing.d.ts +101 -0
- package/dist/services/pricing.js +588 -0
- package/dist/services/pricing.js.map +1 -0
- package/dist/services/product-variant.d.ts +0 -11
- package/dist/services/product-variant.js +28 -138
- package/dist/services/product-variant.js.map +1 -1
- package/dist/services/product.d.ts +107 -145
- package/dist/services/product.js +708 -1036
- package/dist/services/product.js.map +1 -1
- package/dist/services/region.js +4 -4
- package/dist/services/region.js.map +1 -1
- package/dist/services/shipping-option.d.ts +43 -108
- package/dist/services/shipping-option.js +305 -352
- package/dist/services/shipping-option.js.map +1 -1
- package/dist/services/shipping-profile.d.ts +2 -2
- package/dist/services/shipping-profile.js +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/strategy-resolver.d.ts +13 -0
- package/dist/services/strategy-resolver.js +40 -0
- package/dist/services/strategy-resolver.js.map +1 -0
- package/dist/services/tax-provider.d.ts +7 -3
- package/dist/services/tax-provider.js +6 -6
- package/dist/services/tax-provider.js.map +1 -1
- package/dist/services/tax-rate.d.ts +1 -1
- package/dist/services/tax-rate.js +2 -2
- package/dist/services/tax-rate.js.map +1 -1
- package/dist/services/totals.js.map +1 -1
- package/dist/services/user.d.ts +8 -9
- package/dist/services/user.js +216 -168
- package/dist/services/user.js.map +1 -1
- package/dist/strategies/__fixtures__/order-export-data.d.ts +3 -0
- package/dist/strategies/__fixtures__/order-export-data.js +70 -0
- package/dist/strategies/__fixtures__/order-export-data.js.map +1 -0
- package/dist/strategies/__fixtures__/product-export-data.d.ts +319 -0
- package/dist/strategies/__fixtures__/product-export-data.js +401 -0
- package/dist/strategies/__fixtures__/product-export-data.js.map +1 -0
- package/dist/strategies/batch-jobs/order/export.d.ts +36 -0
- package/dist/strategies/batch-jobs/order/export.js +351 -0
- package/dist/strategies/batch-jobs/order/export.js.map +1 -0
- package/dist/strategies/batch-jobs/order/index.d.ts +29 -0
- package/dist/strategies/batch-jobs/order/index.js +115 -0
- package/dist/strategies/batch-jobs/order/index.js.map +1 -0
- package/dist/strategies/batch-jobs/product/export.d.ts +36 -0
- package/dist/strategies/batch-jobs/product/export.js +546 -0
- package/dist/strategies/batch-jobs/product/export.js.map +1 -0
- package/dist/strategies/batch-jobs/product/index.d.ts +45 -0
- package/dist/strategies/batch-jobs/product/index.js +272 -0
- package/dist/strategies/batch-jobs/product/index.js.map +1 -0
- package/dist/subscribers/batch-job.d.ts +17 -0
- package/dist/subscribers/batch-job.js +96 -0
- package/dist/subscribers/batch-job.js.map +1 -0
- package/dist/types/batch-job.d.ts +23 -2
- package/dist/types/batch-job.js +4 -1
- package/dist/types/batch-job.js.map +1 -1
- 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 +27 -3
- package/dist/types/common.js.map +1 -1
- package/dist/types/customers.d.ts +24 -0
- package/dist/types/customers.js.map +1 -1
- package/dist/types/discount.d.ts +2 -1
- package/dist/types/discount.js.map +1 -1
- package/dist/types/feature-flags.d.ts +9 -0
- package/dist/types/feature-flags.js +3 -0
- package/dist/types/feature-flags.js.map +1 -0
- package/dist/types/fulfillment.d.ts +27 -0
- package/dist/types/fulfillment.js +3 -0
- package/dist/types/fulfillment.js.map +1 -0
- package/dist/types/gift-card.d.ts +21 -0
- package/dist/types/gift-card.js +3 -0
- package/dist/types/gift-card.js.map +1 -0
- package/dist/types/global.d.ts +12 -1
- package/dist/types/price-list.d.ts +9 -0
- package/dist/types/pricing.d.ts +30 -0
- package/dist/types/pricing.js +3 -0
- package/dist/types/pricing.js.map +1 -0
- package/dist/types/product-variant.d.ts +4 -3
- package/dist/types/product-variant.js.map +1 -1
- package/dist/types/product.d.ts +110 -8
- package/dist/types/product.js +8 -11
- package/dist/types/product.js.map +1 -1
- package/dist/types/shipping-options.d.ts +62 -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/utils/build-query.d.ts +7 -7
- package/dist/utils/build-query.js +9 -5
- package/dist/utils/build-query.js.map +1 -1
- 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/db-aware-column.js +2 -2
- package/dist/utils/db-aware-column.js.map +1 -1
- package/dist/utils/feature-flag-decorators.d.ts +4 -0
- package/dist/utils/feature-flag-decorators.js +52 -0
- package/dist/utils/feature-flag-decorators.js.map +1 -0
- package/dist/utils/flag-router.d.ts +7 -0
- package/dist/utils/flag-router.js +19 -0
- package/dist/utils/flag-router.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/get-query-config.d.ts +4 -6
- package/dist/utils/get-query-config.js +46 -1
- package/dist/utils/get-query-config.js.map +1 -1
- package/dist/utils/omit-relation-if-exists.d.ts +7 -0
- package/dist/utils/omit-relation-if-exists.js +16 -0
- package/dist/utils/omit-relation-if-exists.js.map +1 -0
- package/dist/utils/set-metadata.d.ts +6 -6
- package/dist/utils/set-metadata.js +5 -5
- package/dist/utils/set-metadata.js.map +1 -1
- package/dist/utils/sleep.d.ts +1 -0
- package/dist/utils/sleep.js +50 -0
- package/dist/utils/sleep.js.map +1 -0
- package/package.json +6 -4
- package/yarn-error.log +29038 -0
|
@@ -0,0 +1,588 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
var __assign = (this && this.__assign) || function () {
|
|
18
|
+
__assign = Object.assign || function(t) {
|
|
19
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
20
|
+
s = arguments[i];
|
|
21
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
22
|
+
t[p] = s[p];
|
|
23
|
+
}
|
|
24
|
+
return t;
|
|
25
|
+
};
|
|
26
|
+
return __assign.apply(this, arguments);
|
|
27
|
+
};
|
|
28
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
29
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
30
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
31
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
32
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
33
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
34
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
38
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
39
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
40
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
41
|
+
function step(op) {
|
|
42
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
43
|
+
while (_) try {
|
|
44
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
45
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
46
|
+
switch (op[0]) {
|
|
47
|
+
case 0: case 1: t = op; break;
|
|
48
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
49
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
50
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
51
|
+
default:
|
|
52
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
53
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
54
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
55
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
56
|
+
if (t[2]) _.ops.pop();
|
|
57
|
+
_.trys.pop(); continue;
|
|
58
|
+
}
|
|
59
|
+
op = body.call(thisArg, _);
|
|
60
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
61
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
var __values = (this && this.__values) || function(o) {
|
|
65
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
66
|
+
if (m) return m.call(o);
|
|
67
|
+
if (o && typeof o.length === "number") return {
|
|
68
|
+
next: function () {
|
|
69
|
+
if (o && i >= o.length) o = void 0;
|
|
70
|
+
return { value: o && o[i++], done: !o };
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
74
|
+
};
|
|
75
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
76
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
77
|
+
if (!m) return o;
|
|
78
|
+
var i = m.call(o), r, ar = [], e;
|
|
79
|
+
try {
|
|
80
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
81
|
+
}
|
|
82
|
+
catch (error) { e = { error: error }; }
|
|
83
|
+
finally {
|
|
84
|
+
try {
|
|
85
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
86
|
+
}
|
|
87
|
+
finally { if (e) throw e.error; }
|
|
88
|
+
}
|
|
89
|
+
return ar;
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
101
|
+
var medusa_core_utils_1 = require("medusa-core-utils");
|
|
102
|
+
var interfaces_1 = require("../interfaces");
|
|
103
|
+
/**
|
|
104
|
+
* Allows retrieval of prices.
|
|
105
|
+
* @extends BaseService
|
|
106
|
+
*/
|
|
107
|
+
var PricingService = /** @class */ (function (_super) {
|
|
108
|
+
__extends(PricingService, _super);
|
|
109
|
+
function PricingService(_a) {
|
|
110
|
+
var manager = _a.manager, productVariantService = _a.productVariantService, taxProviderService = _a.taxProviderService, regionService = _a.regionService, priceSelectionStrategy = _a.priceSelectionStrategy;
|
|
111
|
+
var _this =
|
|
112
|
+
// eslint-disable-next-line prefer-rest-params
|
|
113
|
+
_super.call(this, arguments[0]) || this;
|
|
114
|
+
_this.manager_ = manager;
|
|
115
|
+
_this.regionService = regionService;
|
|
116
|
+
_this.taxProviderService = taxProviderService;
|
|
117
|
+
_this.priceSelectionStrategy = priceSelectionStrategy;
|
|
118
|
+
_this.productVariantService = productVariantService;
|
|
119
|
+
return _this;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Collects additional information neccessary for completing the price
|
|
123
|
+
* selection.
|
|
124
|
+
* @param context - the price selection context to use
|
|
125
|
+
* @return The pricing context
|
|
126
|
+
*/
|
|
127
|
+
PricingService.prototype.collectPricingContext = function (context) {
|
|
128
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
129
|
+
var _this = this;
|
|
130
|
+
return __generator(this, function (_a) {
|
|
131
|
+
switch (_a.label) {
|
|
132
|
+
case 0: return [4 /*yield*/, this.atomicPhase_(function (transactionManager) { return __awaiter(_this, void 0, void 0, function () {
|
|
133
|
+
var automaticTaxes, taxRate, currencyCode, region;
|
|
134
|
+
return __generator(this, function (_a) {
|
|
135
|
+
switch (_a.label) {
|
|
136
|
+
case 0:
|
|
137
|
+
automaticTaxes = false;
|
|
138
|
+
taxRate = null;
|
|
139
|
+
currencyCode = context.currency_code;
|
|
140
|
+
if (!context.region_id) return [3 /*break*/, 2];
|
|
141
|
+
return [4 /*yield*/, this.regionService
|
|
142
|
+
.withTransaction(transactionManager)
|
|
143
|
+
.retrieve(context.region_id, {
|
|
144
|
+
select: ["id", "currency_code", "automatic_taxes", "tax_rate"],
|
|
145
|
+
})];
|
|
146
|
+
case 1:
|
|
147
|
+
region = _a.sent();
|
|
148
|
+
currencyCode = region.currency_code;
|
|
149
|
+
automaticTaxes = region.automatic_taxes;
|
|
150
|
+
taxRate = region.tax_rate;
|
|
151
|
+
_a.label = 2;
|
|
152
|
+
case 2: return [2 /*return*/, {
|
|
153
|
+
price_selection: __assign(__assign({}, context), { currency_code: currencyCode }),
|
|
154
|
+
automatic_taxes: automaticTaxes,
|
|
155
|
+
tax_rate: taxRate,
|
|
156
|
+
}];
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
}); })];
|
|
160
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
});
|
|
164
|
+
};
|
|
165
|
+
/**
|
|
166
|
+
* Gets the prices for a product variant
|
|
167
|
+
* @param variantPricing - the prices retrieved from a variant
|
|
168
|
+
* @param productRates - the tax rates that the product has applied
|
|
169
|
+
* @return The tax related variant prices.
|
|
170
|
+
*/
|
|
171
|
+
PricingService.prototype.calculateTaxes = function (variantPricing, productRates) {
|
|
172
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
173
|
+
var rate, taxedPricing, taxAmount, taxAmount;
|
|
174
|
+
return __generator(this, function (_a) {
|
|
175
|
+
rate = productRates.reduce(function (accRate, nextTaxRate) {
|
|
176
|
+
return accRate + (nextTaxRate.rate || 0) / 100;
|
|
177
|
+
}, 0);
|
|
178
|
+
taxedPricing = {
|
|
179
|
+
original_tax: null,
|
|
180
|
+
calculated_tax: null,
|
|
181
|
+
original_price_incl_tax: null,
|
|
182
|
+
calculated_price_incl_tax: null,
|
|
183
|
+
tax_rates: productRates,
|
|
184
|
+
};
|
|
185
|
+
if (variantPricing.calculated_price !== null) {
|
|
186
|
+
taxAmount = Math.round(variantPricing.calculated_price * rate);
|
|
187
|
+
taxedPricing.calculated_tax = taxAmount;
|
|
188
|
+
taxedPricing.calculated_price_incl_tax =
|
|
189
|
+
variantPricing.calculated_price + taxAmount;
|
|
190
|
+
}
|
|
191
|
+
if (variantPricing.original_price !== null) {
|
|
192
|
+
taxAmount = Math.round(variantPricing.original_price * rate);
|
|
193
|
+
taxedPricing.original_tax = taxAmount;
|
|
194
|
+
taxedPricing.original_price_incl_tax =
|
|
195
|
+
variantPricing.original_price + taxAmount;
|
|
196
|
+
}
|
|
197
|
+
return [2 /*return*/, taxedPricing];
|
|
198
|
+
});
|
|
199
|
+
});
|
|
200
|
+
};
|
|
201
|
+
PricingService.prototype.getProductVariantPricing_ = function (variantId, taxRates, context) {
|
|
202
|
+
var _a;
|
|
203
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
204
|
+
var transactionManager, pricing, pricingResult, taxResults;
|
|
205
|
+
return __generator(this, function (_b) {
|
|
206
|
+
switch (_b.label) {
|
|
207
|
+
case 0:
|
|
208
|
+
transactionManager = (_a = this.transactionManager_) !== null && _a !== void 0 ? _a : this.manager_;
|
|
209
|
+
return [4 /*yield*/, this.priceSelectionStrategy
|
|
210
|
+
.withTransaction(transactionManager)
|
|
211
|
+
.calculateVariantPrice(variantId, context.price_selection)];
|
|
212
|
+
case 1:
|
|
213
|
+
pricing = _b.sent();
|
|
214
|
+
pricingResult = {
|
|
215
|
+
prices: pricing.prices,
|
|
216
|
+
original_price: pricing.originalPrice,
|
|
217
|
+
calculated_price: pricing.calculatedPrice,
|
|
218
|
+
calculated_price_type: pricing.calculatedPriceType,
|
|
219
|
+
original_price_incl_tax: null,
|
|
220
|
+
calculated_price_incl_tax: null,
|
|
221
|
+
original_tax: null,
|
|
222
|
+
calculated_tax: null,
|
|
223
|
+
tax_rates: null,
|
|
224
|
+
};
|
|
225
|
+
if (!(context.automatic_taxes && context.price_selection.region_id)) return [3 /*break*/, 3];
|
|
226
|
+
return [4 /*yield*/, this.calculateTaxes(pricingResult, taxRates)];
|
|
227
|
+
case 2:
|
|
228
|
+
taxResults = _b.sent();
|
|
229
|
+
pricingResult.original_price_incl_tax = taxResults.original_price_incl_tax;
|
|
230
|
+
pricingResult.calculated_price_incl_tax =
|
|
231
|
+
taxResults.calculated_price_incl_tax;
|
|
232
|
+
pricingResult.original_tax = taxResults.original_tax;
|
|
233
|
+
pricingResult.calculated_tax = taxResults.calculated_tax;
|
|
234
|
+
pricingResult.tax_rates = taxResults.tax_rates;
|
|
235
|
+
_b.label = 3;
|
|
236
|
+
case 3: return [2 /*return*/, pricingResult];
|
|
237
|
+
}
|
|
238
|
+
});
|
|
239
|
+
});
|
|
240
|
+
};
|
|
241
|
+
/**
|
|
242
|
+
* Gets the prices for a product variant.
|
|
243
|
+
* @param variant - the id of the variant to get prices for
|
|
244
|
+
* @param context - the price selection context to use
|
|
245
|
+
* @return The product variant prices
|
|
246
|
+
*/
|
|
247
|
+
PricingService.prototype.getProductVariantPricing = function (variant, context) {
|
|
248
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
249
|
+
var pricingContext, productRates;
|
|
250
|
+
return __generator(this, function (_a) {
|
|
251
|
+
switch (_a.label) {
|
|
252
|
+
case 0:
|
|
253
|
+
if (!("automatic_taxes" in context)) return [3 /*break*/, 1];
|
|
254
|
+
pricingContext = context;
|
|
255
|
+
return [3 /*break*/, 3];
|
|
256
|
+
case 1: return [4 /*yield*/, this.collectPricingContext(context)];
|
|
257
|
+
case 2:
|
|
258
|
+
pricingContext = _a.sent();
|
|
259
|
+
_a.label = 3;
|
|
260
|
+
case 3:
|
|
261
|
+
productRates = [];
|
|
262
|
+
if (!(pricingContext.automatic_taxes &&
|
|
263
|
+
pricingContext.price_selection.region_id)) return [3 /*break*/, 5];
|
|
264
|
+
return [4 /*yield*/, this.taxProviderService.getRegionRatesForProduct(variant.product_id, {
|
|
265
|
+
id: pricingContext.price_selection.region_id,
|
|
266
|
+
tax_rate: pricingContext.tax_rate,
|
|
267
|
+
})];
|
|
268
|
+
case 4:
|
|
269
|
+
productRates = _a.sent();
|
|
270
|
+
_a.label = 5;
|
|
271
|
+
case 5: return [4 /*yield*/, this.getProductVariantPricing_(variant.id, productRates, pricingContext)];
|
|
272
|
+
case 6: return [2 /*return*/, _a.sent()];
|
|
273
|
+
}
|
|
274
|
+
});
|
|
275
|
+
});
|
|
276
|
+
};
|
|
277
|
+
/**
|
|
278
|
+
* Gets the prices for a product variant by a variant id.
|
|
279
|
+
* @param variantId - the id of the variant to get prices for
|
|
280
|
+
* @param context - the price selection context to use
|
|
281
|
+
* @return The product variant prices
|
|
282
|
+
*/
|
|
283
|
+
PricingService.prototype.getProductVariantPricingById = function (variantId, context) {
|
|
284
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
285
|
+
var pricingContext, productRates, product_id;
|
|
286
|
+
return __generator(this, function (_a) {
|
|
287
|
+
switch (_a.label) {
|
|
288
|
+
case 0:
|
|
289
|
+
if (!("automatic_taxes" in context)) return [3 /*break*/, 1];
|
|
290
|
+
pricingContext = context;
|
|
291
|
+
return [3 /*break*/, 3];
|
|
292
|
+
case 1: return [4 /*yield*/, this.collectPricingContext(context)];
|
|
293
|
+
case 2:
|
|
294
|
+
pricingContext = _a.sent();
|
|
295
|
+
_a.label = 3;
|
|
296
|
+
case 3:
|
|
297
|
+
productRates = [];
|
|
298
|
+
if (!(pricingContext.automatic_taxes &&
|
|
299
|
+
pricingContext.price_selection.region_id)) return [3 /*break*/, 6];
|
|
300
|
+
return [4 /*yield*/, this.productVariantService.retrieve(variantId, { select: ["id", "product_id"] })];
|
|
301
|
+
case 4:
|
|
302
|
+
product_id = (_a.sent()).product_id;
|
|
303
|
+
return [4 /*yield*/, this.taxProviderService.getRegionRatesForProduct(product_id, {
|
|
304
|
+
id: pricingContext.price_selection.region_id,
|
|
305
|
+
tax_rate: pricingContext.tax_rate,
|
|
306
|
+
})];
|
|
307
|
+
case 5:
|
|
308
|
+
productRates = _a.sent();
|
|
309
|
+
_a.label = 6;
|
|
310
|
+
case 6: return [4 /*yield*/, this.getProductVariantPricing_(variantId, productRates, pricingContext)];
|
|
311
|
+
case 7: return [2 /*return*/, _a.sent()];
|
|
312
|
+
}
|
|
313
|
+
});
|
|
314
|
+
});
|
|
315
|
+
};
|
|
316
|
+
PricingService.prototype.getProductPricing_ = function (productId, variants, context) {
|
|
317
|
+
var _a;
|
|
318
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
319
|
+
var transactionManager, taxRates, pricings;
|
|
320
|
+
var _this = this;
|
|
321
|
+
return __generator(this, function (_b) {
|
|
322
|
+
switch (_b.label) {
|
|
323
|
+
case 0:
|
|
324
|
+
transactionManager = (_a = this.transactionManager_) !== null && _a !== void 0 ? _a : this.manager_;
|
|
325
|
+
taxRates = [];
|
|
326
|
+
if (!(context.automatic_taxes && context.price_selection.region_id)) return [3 /*break*/, 2];
|
|
327
|
+
return [4 /*yield*/, this.taxProviderService
|
|
328
|
+
.withTransaction(transactionManager)
|
|
329
|
+
.getRegionRatesForProduct(productId, {
|
|
330
|
+
id: context.price_selection.region_id,
|
|
331
|
+
tax_rate: context.tax_rate,
|
|
332
|
+
})];
|
|
333
|
+
case 1:
|
|
334
|
+
taxRates = _b.sent();
|
|
335
|
+
_b.label = 2;
|
|
336
|
+
case 2:
|
|
337
|
+
pricings = {};
|
|
338
|
+
return [4 /*yield*/, Promise.all(variants.map(function (_a) {
|
|
339
|
+
var id = _a.id;
|
|
340
|
+
return __awaiter(_this, void 0, void 0, function () {
|
|
341
|
+
var variantPricing;
|
|
342
|
+
return __generator(this, function (_b) {
|
|
343
|
+
switch (_b.label) {
|
|
344
|
+
case 0: return [4 /*yield*/, this.getProductVariantPricing_(id, taxRates, context)];
|
|
345
|
+
case 1:
|
|
346
|
+
variantPricing = _b.sent();
|
|
347
|
+
pricings[id] = variantPricing;
|
|
348
|
+
return [2 /*return*/];
|
|
349
|
+
}
|
|
350
|
+
});
|
|
351
|
+
});
|
|
352
|
+
}))];
|
|
353
|
+
case 3:
|
|
354
|
+
_b.sent();
|
|
355
|
+
return [2 /*return*/, pricings];
|
|
356
|
+
}
|
|
357
|
+
});
|
|
358
|
+
});
|
|
359
|
+
};
|
|
360
|
+
/**
|
|
361
|
+
* Gets all the variant prices for a product. All the product's variants will
|
|
362
|
+
* be fetched.
|
|
363
|
+
* @param product - the product to get pricing for.
|
|
364
|
+
* @param context - the price selection context to use
|
|
365
|
+
* @return A map of variant ids to their corresponding prices
|
|
366
|
+
*/
|
|
367
|
+
PricingService.prototype.getProductPricing = function (product, context) {
|
|
368
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
369
|
+
var pricingContext;
|
|
370
|
+
return __generator(this, function (_a) {
|
|
371
|
+
switch (_a.label) {
|
|
372
|
+
case 0: return [4 /*yield*/, this.collectPricingContext(context)];
|
|
373
|
+
case 1:
|
|
374
|
+
pricingContext = _a.sent();
|
|
375
|
+
return [4 /*yield*/, this.getProductPricing_(product.id, product.variants, pricingContext)];
|
|
376
|
+
case 2: return [2 /*return*/, _a.sent()];
|
|
377
|
+
}
|
|
378
|
+
});
|
|
379
|
+
});
|
|
380
|
+
};
|
|
381
|
+
/**
|
|
382
|
+
* Gets all the variant prices for a product by the product id
|
|
383
|
+
* @param productId - the id of the product to get prices for
|
|
384
|
+
* @param context - the price selection context to use
|
|
385
|
+
* @return A map of variant ids to their corresponding prices
|
|
386
|
+
*/
|
|
387
|
+
PricingService.prototype.getProductPricingById = function (productId, context) {
|
|
388
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
389
|
+
var pricingContext, variants;
|
|
390
|
+
return __generator(this, function (_a) {
|
|
391
|
+
switch (_a.label) {
|
|
392
|
+
case 0: return [4 /*yield*/, this.collectPricingContext(context)];
|
|
393
|
+
case 1:
|
|
394
|
+
pricingContext = _a.sent();
|
|
395
|
+
return [4 /*yield*/, this.productVariantService.list({ product_id: productId }, { select: ["id"] })];
|
|
396
|
+
case 2:
|
|
397
|
+
variants = _a.sent();
|
|
398
|
+
return [4 /*yield*/, this.getProductPricing_(productId, variants, pricingContext)];
|
|
399
|
+
case 3: return [2 /*return*/, _a.sent()];
|
|
400
|
+
}
|
|
401
|
+
});
|
|
402
|
+
});
|
|
403
|
+
};
|
|
404
|
+
/**
|
|
405
|
+
* Set additional prices on a list of product variants.
|
|
406
|
+
* @param variants - list of variants on which to set additional prices
|
|
407
|
+
* @param context - the price selection context to use
|
|
408
|
+
* @return A list of products with variants decorated with prices
|
|
409
|
+
*/
|
|
410
|
+
PricingService.prototype.setVariantPrices = function (variants, context) {
|
|
411
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
412
|
+
var pricingContext;
|
|
413
|
+
var _this = this;
|
|
414
|
+
return __generator(this, function (_a) {
|
|
415
|
+
switch (_a.label) {
|
|
416
|
+
case 0: return [4 /*yield*/, this.collectPricingContext(context)];
|
|
417
|
+
case 1:
|
|
418
|
+
pricingContext = _a.sent();
|
|
419
|
+
return [4 /*yield*/, Promise.all(variants.map(function (variant) { return __awaiter(_this, void 0, void 0, function () {
|
|
420
|
+
var variantPricing;
|
|
421
|
+
return __generator(this, function (_a) {
|
|
422
|
+
switch (_a.label) {
|
|
423
|
+
case 0: return [4 /*yield*/, this.getProductVariantPricing(variant, pricingContext)];
|
|
424
|
+
case 1:
|
|
425
|
+
variantPricing = _a.sent();
|
|
426
|
+
return [2 /*return*/, __assign(__assign({}, variant), variantPricing)];
|
|
427
|
+
}
|
|
428
|
+
});
|
|
429
|
+
}); }))];
|
|
430
|
+
case 2: return [2 /*return*/, _a.sent()];
|
|
431
|
+
}
|
|
432
|
+
});
|
|
433
|
+
});
|
|
434
|
+
};
|
|
435
|
+
/**
|
|
436
|
+
* Set additional prices on a list of products.
|
|
437
|
+
* @param products - list of products on which to set additional prices
|
|
438
|
+
* @param context - the price selection context to use
|
|
439
|
+
* @return A list of products with variants decorated with prices
|
|
440
|
+
*/
|
|
441
|
+
PricingService.prototype.setProductPrices = function (products, context) {
|
|
442
|
+
if (context === void 0) { context = {}; }
|
|
443
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
444
|
+
var pricingContext;
|
|
445
|
+
var _this = this;
|
|
446
|
+
return __generator(this, function (_a) {
|
|
447
|
+
switch (_a.label) {
|
|
448
|
+
case 0: return [4 /*yield*/, this.collectPricingContext(context)];
|
|
449
|
+
case 1:
|
|
450
|
+
pricingContext = _a.sent();
|
|
451
|
+
return [4 /*yield*/, Promise.all(products.map(function (product) { return __awaiter(_this, void 0, void 0, function () {
|
|
452
|
+
var variantPricing, pricedVariants, pricedProduct;
|
|
453
|
+
var _a;
|
|
454
|
+
return __generator(this, function (_b) {
|
|
455
|
+
switch (_b.label) {
|
|
456
|
+
case 0:
|
|
457
|
+
if (!((_a = product === null || product === void 0 ? void 0 : product.variants) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
458
|
+
return [2 /*return*/, product];
|
|
459
|
+
}
|
|
460
|
+
return [4 /*yield*/, this.getProductPricing_(product.id, product.variants, pricingContext)];
|
|
461
|
+
case 1:
|
|
462
|
+
variantPricing = _b.sent();
|
|
463
|
+
pricedVariants = product.variants.map(function (productVariant) {
|
|
464
|
+
var pricing = variantPricing[productVariant.id];
|
|
465
|
+
return __assign(__assign({}, productVariant), pricing);
|
|
466
|
+
});
|
|
467
|
+
pricedProduct = __assign(__assign({}, product), { variants: pricedVariants });
|
|
468
|
+
return [2 /*return*/, pricedProduct];
|
|
469
|
+
}
|
|
470
|
+
});
|
|
471
|
+
}); }))];
|
|
472
|
+
case 2: return [2 /*return*/, _a.sent()];
|
|
473
|
+
}
|
|
474
|
+
});
|
|
475
|
+
});
|
|
476
|
+
};
|
|
477
|
+
/**
|
|
478
|
+
* Gets the prices for a shipping option.
|
|
479
|
+
* @param shippingOption - the shipping option to get prices for
|
|
480
|
+
* @param context - the price selection context to use
|
|
481
|
+
* @return The shipping option prices
|
|
482
|
+
*/
|
|
483
|
+
PricingService.prototype.getShippingOptionPricing = function (shippingOption, context) {
|
|
484
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
485
|
+
var pricingContext, shippingOptionRates, price, rate, tax, total;
|
|
486
|
+
return __generator(this, function (_a) {
|
|
487
|
+
switch (_a.label) {
|
|
488
|
+
case 0:
|
|
489
|
+
if (!("automatic_taxes" in context)) return [3 /*break*/, 1];
|
|
490
|
+
pricingContext = context;
|
|
491
|
+
return [3 /*break*/, 3];
|
|
492
|
+
case 1: return [4 /*yield*/, this.collectPricingContext(context)];
|
|
493
|
+
case 2:
|
|
494
|
+
pricingContext = _a.sent();
|
|
495
|
+
_a.label = 3;
|
|
496
|
+
case 3:
|
|
497
|
+
shippingOptionRates = [];
|
|
498
|
+
if (!(pricingContext.automatic_taxes &&
|
|
499
|
+
pricingContext.price_selection.region_id)) return [3 /*break*/, 5];
|
|
500
|
+
return [4 /*yield*/, this.taxProviderService.getRegionRatesForShipping(shippingOption.id, {
|
|
501
|
+
id: pricingContext.price_selection.region_id,
|
|
502
|
+
tax_rate: pricingContext.tax_rate,
|
|
503
|
+
})];
|
|
504
|
+
case 4:
|
|
505
|
+
shippingOptionRates =
|
|
506
|
+
_a.sent();
|
|
507
|
+
_a.label = 5;
|
|
508
|
+
case 5:
|
|
509
|
+
price = shippingOption.amount || 0;
|
|
510
|
+
rate = shippingOptionRates.reduce(function (accRate, nextTaxRate) {
|
|
511
|
+
return accRate + (nextTaxRate.rate || 0) / 100;
|
|
512
|
+
}, 0);
|
|
513
|
+
tax = Math.round(price * rate);
|
|
514
|
+
total = price + tax;
|
|
515
|
+
return [2 /*return*/, __assign(__assign({}, shippingOption), { price_incl_tax: total, tax_rates: shippingOptionRates })];
|
|
516
|
+
}
|
|
517
|
+
});
|
|
518
|
+
});
|
|
519
|
+
};
|
|
520
|
+
/**
|
|
521
|
+
* Set additional prices on a list of shipping options.
|
|
522
|
+
* @param shippingOptions - list of shipping options on which to set additional prices
|
|
523
|
+
* @param context - the price selection context to use
|
|
524
|
+
* @return A list of shipping options with prices
|
|
525
|
+
*/
|
|
526
|
+
PricingService.prototype.setShippingOptionPrices = function (shippingOptions, context) {
|
|
527
|
+
if (context === void 0) { context = {}; }
|
|
528
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
529
|
+
var regions, shippingOptions_1, shippingOptions_1_1, shippingOption, contexts;
|
|
530
|
+
var e_1, _a;
|
|
531
|
+
var _this = this;
|
|
532
|
+
return __generator(this, function (_b) {
|
|
533
|
+
switch (_b.label) {
|
|
534
|
+
case 0:
|
|
535
|
+
regions = new Set();
|
|
536
|
+
try {
|
|
537
|
+
for (shippingOptions_1 = __values(shippingOptions), shippingOptions_1_1 = shippingOptions_1.next(); !shippingOptions_1_1.done; shippingOptions_1_1 = shippingOptions_1.next()) {
|
|
538
|
+
shippingOption = shippingOptions_1_1.value;
|
|
539
|
+
regions.add(shippingOption.region_id);
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
543
|
+
finally {
|
|
544
|
+
try {
|
|
545
|
+
if (shippingOptions_1_1 && !shippingOptions_1_1.done && (_a = shippingOptions_1.return)) _a.call(shippingOptions_1);
|
|
546
|
+
}
|
|
547
|
+
finally { if (e_1) throw e_1.error; }
|
|
548
|
+
}
|
|
549
|
+
return [4 /*yield*/, Promise.all(__spreadArray([], __read(regions), false).map(function (regionId) { return __awaiter(_this, void 0, void 0, function () {
|
|
550
|
+
var _a;
|
|
551
|
+
return __generator(this, function (_b) {
|
|
552
|
+
switch (_b.label) {
|
|
553
|
+
case 0:
|
|
554
|
+
_a = {};
|
|
555
|
+
return [4 /*yield*/, this.collectPricingContext(__assign(__assign({}, context), { region_id: regionId }))];
|
|
556
|
+
case 1: return [2 /*return*/, (_a.context = _b.sent(),
|
|
557
|
+
_a.region_id = regionId,
|
|
558
|
+
_a)];
|
|
559
|
+
}
|
|
560
|
+
});
|
|
561
|
+
}); }))];
|
|
562
|
+
case 1:
|
|
563
|
+
contexts = _b.sent();
|
|
564
|
+
return [4 /*yield*/, Promise.all(shippingOptions.map(function (shippingOption) { return __awaiter(_this, void 0, void 0, function () {
|
|
565
|
+
var pricingContext, shippingOptionPricing;
|
|
566
|
+
return __generator(this, function (_a) {
|
|
567
|
+
switch (_a.label) {
|
|
568
|
+
case 0:
|
|
569
|
+
pricingContext = contexts.find(function (c) { return c.region_id === shippingOption.region_id; });
|
|
570
|
+
if (!pricingContext) {
|
|
571
|
+
throw new medusa_core_utils_1.MedusaError(medusa_core_utils_1.MedusaError.Types.UNEXPECTED_STATE, "Could not find pricing context for shipping option");
|
|
572
|
+
}
|
|
573
|
+
return [4 /*yield*/, this.getShippingOptionPricing(shippingOption, pricingContext.context)];
|
|
574
|
+
case 1:
|
|
575
|
+
shippingOptionPricing = _a.sent();
|
|
576
|
+
return [2 /*return*/, __assign(__assign({}, shippingOption), shippingOptionPricing)];
|
|
577
|
+
}
|
|
578
|
+
});
|
|
579
|
+
}); }))];
|
|
580
|
+
case 2: return [2 /*return*/, _b.sent()];
|
|
581
|
+
}
|
|
582
|
+
});
|
|
583
|
+
});
|
|
584
|
+
};
|
|
585
|
+
return PricingService;
|
|
586
|
+
}(interfaces_1.TransactionBaseService));
|
|
587
|
+
exports.default = PricingService;
|
|
588
|
+
//# sourceMappingURL=pricing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pricing.js","sourceRoot":"","sources":["../../src/services/pricing.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,uDAA+C;AAY/C,4CAAsD;AActD;;;GAGG;AACH;IAA6B,kCAAsC;IAQjE,wBAAY,EAMW;YALrB,OAAO,aAAA,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rD,CAAA;6CACF;4CAE6B,qBAAM,IAAI,CAAC,wBAAwB,CAC/D,cAAc,EACd,cAAc,CAAC,OAAO,CACvB,EAAA;;4CAHK,qBAAqB,GAAG,SAG7B;4CACD,4CACK,cAAc,GACd,qBAAqB,GACzB;;;iCACF,CAAC,CACH,EAAA;4BAtBD,sBAAO,SAsBN,EAAA;;;;KACF;IACH,qBAAC;AAAD,CAAC,AA3cD,CAA6B,mCAAsB,GA2clD;AAED,kBAAe,cAAc,CAAA"}
|
|
@@ -180,16 +180,5 @@ declare class ProductVariantService extends BaseService {
|
|
|
180
180
|
* count of products that matches the query as the second element.
|
|
181
181
|
*/
|
|
182
182
|
getFreeTextQueryBuilder_(variantRepo: ProductVariantRepository, query: FindWithRelationsOptions, q?: string): SelectQueryBuilder<ProductVariant>;
|
|
183
|
-
/**
|
|
184
|
-
* Set additional prices on a list of variants.
|
|
185
|
-
* @param {ProductVariant | ProductVariant[] } variant variant on which to set additional prices
|
|
186
|
-
* @param {string} currency_code currency code to fetch prices for
|
|
187
|
-
* @param {string} region_id region to fetch prices for
|
|
188
|
-
* @param {string} cart_id string of cart to use as a basis for getting currency and region
|
|
189
|
-
* @param {string} customer_id id of potentially logged in customer, used to get prices valid for their customer groups
|
|
190
|
-
* @param {boolean} include_discount_prices should result include discount pricing
|
|
191
|
-
* @return {Promise<ProductVariant | ProductVariant[]>} A list of variants with variants decorated with "additional_prices"
|
|
192
|
-
*/
|
|
193
|
-
setAdditionalPrices(variant: any, currency_code: any, region_id: any, cart_id: any, customer_id: any, include_discount_prices?: boolean): Promise<ProductVariant | ProductVariant[]>;
|
|
194
183
|
}
|
|
195
184
|
export default ProductVariantService;
|