@medusajs/medusa 1.2.2-dev.47 → 1.3.0
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 +48 -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/error-handler.js +1 -1
- 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/customer-groups/get-customer-group-customers.d.ts +20 -0
- package/dist/api/routes/admin/customer-groups/get-customer-group-customers.js +76 -0
- package/dist/api/routes/admin/customer-groups/get-customer-group-customers.js.map +1 -0
- package/dist/api/routes/admin/customer-groups/index.js +1 -0
- package/dist/api/routes/admin/customer-groups/index.js.map +1 -1
- 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/customers/index.js +1 -1
- package/dist/api/routes/admin/customers/index.js.map +1 -1
- package/dist/api/routes/admin/customers/list-customers.js +1 -0
- package/dist/api/routes/admin/customers/list-customers.js.map +1 -1
- package/dist/api/routes/admin/discounts/create-discount.d.ts +11 -2
- package/dist/api/routes/admin/discounts/create-discount.js +66 -12
- 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-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-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 +1 -3
- package/dist/api/routes/admin/discounts/index.js +1 -6
- 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-discount.d.ts +12 -2
- package/dist/api/routes/admin/discounts/update-discount.js +70 -15
- 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.js +7 -1
- package/dist/api/routes/admin/draft-orders/index.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 +21 -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-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/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-order.js.map +1 -1
- package/dist/api/routes/admin/price-lists/add-prices-batch.d.ts +70 -0
- package/dist/api/routes/admin/{orders/receive-swap.js → price-lists/add-prices-batch.js} +77 -78
- 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 +87 -0
- package/dist/api/routes/admin/price-lists/create-price-list.js +193 -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/{discounts/remove-valid-product.js → price-lists/delete-price-list.js} +27 -25
- 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/{store/carts/update-payment-method.js → admin/price-lists/delete-prices-batch.js} +42 -46
- package/dist/api/routes/admin/price-lists/delete-prices-batch.js.map +1 -0
- package/dist/api/routes/admin/price-lists/get-price-list.d.ts +22 -0
- package/dist/api/routes/admin/{discounts/add-valid-product.js → price-lists/get-price-list.js} +20 -24
- package/dist/api/routes/admin/price-lists/get-price-list.js.map +1 -0
- package/dist/api/routes/admin/price-lists/index.d.ts +28 -0
- package/dist/api/routes/admin/price-lists/index.js +55 -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 +74 -0
- package/dist/api/routes/admin/price-lists/list-price-list-products.js +246 -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 +38 -0
- package/dist/api/routes/admin/price-lists/list-price-lists.js +197 -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/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 +1 -1
- package/dist/api/routes/admin/products/index.js +7 -1
- 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/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/store/get-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/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 +7 -7
- 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/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 +5 -3
- package/dist/api/routes/store/products/list-products.js +60 -18
- 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 +6 -1
- package/dist/api/routes/store/variants/list-variants.js +63 -10
- package/dist/api/routes/store/variants/list-variants.js.map +1 -1
- package/dist/commands/develop.js +1 -1
- package/dist/commands/develop.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 +15 -7
- package/dist/helpers/test-request.js.map +1 -1
- package/dist/index.d.ts +3 -58
- package/dist/index.js +3 -61
- package/dist/index.js.map +1 -1
- package/dist/interfaces/base-service.d.ts +66 -0
- package/dist/interfaces/base-service.js +378 -0
- package/dist/interfaces/base-service.js.map +1 -0
- package/dist/interfaces/index.d.ts +1 -0
- package/dist/interfaces/index.js +1 -0
- package/dist/interfaces/index.js.map +1 -1
- 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/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 +18 -10
- package/dist/loaders/plugins.js +27 -24
- 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/batch-job.d.ts +58 -0
- package/dist/models/batch-job.js +119 -0
- package/dist/models/batch-job.js.map +1 -0
- 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/customer-group.d.ts +3 -1
- package/dist/models/customer-group.js +9 -13
- package/dist/models/customer-group.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 +68 -0
- package/dist/models/discount-condition.js +208 -0
- package/dist/models/discount-condition.js.map +1 -0
- package/dist/models/discount-rule.d.ts +5 -5
- package/dist/models/discount-rule.js +6 -17
- package/dist/models/discount-rule.js.map +1 -1
- package/dist/models/discount.js.map +1 -1
- package/dist/models/index.d.ts +66 -0
- package/dist/models/index.js +79 -0
- package/dist/models/index.js.map +1 -0
- package/dist/models/line-item-adjustment.d.ts +13 -0
- package/dist/models/line-item-adjustment.js +79 -0
- package/dist/models/line-item-adjustment.js.map +1 -0
- package/dist/models/line-item-tax-line.js +2 -1
- package/dist/models/line-item-tax-line.js.map +1 -1
- package/dist/models/line-item.d.ts +2 -0
- package/dist/models/line-item.js +5 -0
- package/dist/models/line-item.js.map +1 -1
- package/dist/models/money-amount.d.ts +10 -3
- package/dist/models/money-amount.js +25 -5
- package/dist/models/money-amount.js.map +1 -1
- package/dist/models/price-list.d.ts +57 -0
- package/dist/models/price-list.js +146 -0
- package/dist/models/price-list.js.map +1 -0
- package/dist/models/product-variant.js +9 -3
- package/dist/models/product-variant.js.map +1 -1
- package/dist/models/shipping-method-tax-line.js +2 -1
- package/dist/models/shipping-method-tax-line.js.map +1 -1
- package/dist/models/swap.d.ts +4 -4
- package/dist/models/swap.js +23 -23
- package/dist/models/swap.js.map +1 -1
- package/dist/repositories/cart.d.ts +2 -2
- package/dist/repositories/cart.js.map +1 -1
- package/dist/repositories/customer.d.ts +1 -0
- package/dist/repositories/customer.js +63 -0
- package/dist/repositories/customer.js.map +1 -1
- package/dist/repositories/discount-condition.d.ts +34 -0
- package/dist/repositories/discount-condition.js +384 -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 +7 -2
- package/dist/repositories/money-amount.js +149 -2
- package/dist/repositories/money-amount.js.map +1 -1
- package/dist/repositories/price-list.d.ts +4 -0
- package/dist/repositories/price-list.js +38 -0
- package/dist/repositories/price-list.js.map +1 -0
- package/dist/repositories/product.d.ts +3 -0
- package/dist/repositories/product.js +41 -19
- 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 +177 -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/cart.d.ts +58 -47
- package/dist/services/cart.js +1306 -1391
- package/dist/services/cart.js.map +1 -1
- package/dist/services/customer.js +18 -18
- package/dist/services/customer.js.map +1 -1
- package/dist/services/discount.d.ts +50 -58
- package/dist/services/discount.js +365 -154
- package/dist/services/discount.js.map +1 -1
- package/dist/services/draft-order.js +1 -0
- package/dist/services/draft-order.js.map +1 -1
- 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 +436 -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.js +4 -4
- 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 +86 -0
- package/dist/services/price-list.js +469 -0
- package/dist/services/price-list.js.map +1 -0
- 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 -4
- package/dist/services/product.js +239 -49
- package/dist/services/product.js.map +1 -1
- package/dist/services/region.js +8 -4
- package/dist/services/region.js.map +1 -1
- package/dist/services/return.js +0 -1
- package/dist/services/return.js.map +1 -1
- package/dist/services/shipping-option.d.ts +2 -2
- package/dist/services/shipping-option.js +7 -4
- package/dist/services/shipping-option.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/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 +6 -0
- package/dist/types/batch-job.js +11 -0
- package/dist/types/batch-job.js.map +1 -0
- package/dist/types/common.d.ts +1 -3
- package/dist/types/customers.d.ts +1 -0
- package/dist/types/customers.js +5 -0
- package/dist/types/customers.js.map +1 -1
- package/dist/types/discount.d.ts +69 -1
- package/dist/types/discount.js +129 -5
- package/dist/types/discount.js.map +1 -1
- package/dist/types/global.d.ts +34 -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/price-list.d.ts +70 -0
- package/dist/types/price-list.js +152 -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/product-variant.d.ts +26 -3
- package/dist/types/product-variant.js +69 -5
- package/dist/types/product-variant.js.map +1 -1
- package/dist/types/product.d.ts +16 -0
- package/dist/types/product.js +86 -1
- package/dist/types/product.js.map +1 -1
- 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/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/get-query-config.d.ts +11 -0
- package/dist/utils/get-query-config.js +88 -0
- package/dist/utils/get-query-config.js.map +1 -0
- package/package.json +7 -8
- package/dist/api/routes/admin/discounts/add-valid-product.d.ts +0 -23
- package/dist/api/routes/admin/discounts/add-valid-product.js.map +0 -1
- package/dist/api/routes/admin/discounts/remove-valid-product.d.ts +0 -23
- package/dist/api/routes/admin/discounts/remove-valid-product.js.map +0 -1
- package/dist/api/routes/admin/orders/receive-swap.d.ts +0 -46
- package/dist/api/routes/admin/orders/receive-swap.js.map +0 -1
- package/dist/api/routes/store/carts/update-payment-method.d.ts +0 -38
- package/dist/api/routes/store/carts/update-payment-method.js.map +0 -1
- package/dist/config/index.d.ts +0 -14
- package/dist/config/index.js +0 -40
- package/dist/config/index.js.map +0 -1
- package/dist/controllers/list-customers.d.ts +0 -0
- package/dist/controllers/list-customers.js +0 -1
- package/dist/controllers/list-customers.js.map +0 -1
- package/yarn-error.log +0 -6769
|
@@ -0,0 +1,436 @@
|
|
|
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 __rest = (this && this.__rest) || function (s, e) {
|
|
65
|
+
var t = {};
|
|
66
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
67
|
+
t[p] = s[p];
|
|
68
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
69
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
70
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
71
|
+
t[p[i]] = s[p[i]];
|
|
72
|
+
}
|
|
73
|
+
return t;
|
|
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
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
87
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
88
|
+
if (!m) return o;
|
|
89
|
+
var i = m.call(o), r, ar = [], e;
|
|
90
|
+
try {
|
|
91
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
92
|
+
}
|
|
93
|
+
catch (error) { e = { error: error }; }
|
|
94
|
+
finally {
|
|
95
|
+
try {
|
|
96
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
97
|
+
}
|
|
98
|
+
finally { if (e) throw e.error; }
|
|
99
|
+
}
|
|
100
|
+
return ar;
|
|
101
|
+
};
|
|
102
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
103
|
+
var medusa_interfaces_1 = require("medusa-interfaces");
|
|
104
|
+
var medusa_core_utils_1 = require("medusa-core-utils");
|
|
105
|
+
/**
|
|
106
|
+
* Provides layer to manipulate line item adjustments.
|
|
107
|
+
* @extends BaseService
|
|
108
|
+
*/
|
|
109
|
+
var LineItemAdjustmentService = /** @class */ (function (_super) {
|
|
110
|
+
__extends(LineItemAdjustmentService, _super);
|
|
111
|
+
function LineItemAdjustmentService(_a) {
|
|
112
|
+
var manager = _a.manager, lineItemAdjustmentRepository = _a.lineItemAdjustmentRepository, discountService = _a.discountService;
|
|
113
|
+
var _this = _super.call(this) || this;
|
|
114
|
+
_this.manager_ = manager;
|
|
115
|
+
_this.lineItemAdjustmentRepo_ = lineItemAdjustmentRepository;
|
|
116
|
+
_this.discountService = discountService;
|
|
117
|
+
return _this;
|
|
118
|
+
}
|
|
119
|
+
LineItemAdjustmentService.prototype.withTransaction = function (transactionManager) {
|
|
120
|
+
if (!transactionManager) {
|
|
121
|
+
return this;
|
|
122
|
+
}
|
|
123
|
+
var cloned = new LineItemAdjustmentService({
|
|
124
|
+
manager: transactionManager,
|
|
125
|
+
lineItemAdjustmentRepository: this.lineItemAdjustmentRepo_,
|
|
126
|
+
discountService: this.discountService,
|
|
127
|
+
});
|
|
128
|
+
cloned.transactionManager_ = transactionManager;
|
|
129
|
+
return cloned;
|
|
130
|
+
};
|
|
131
|
+
/**
|
|
132
|
+
* Retrieves a line item adjustment by id.
|
|
133
|
+
* @param id - the id of the line item adjustment to retrieve
|
|
134
|
+
* @param config - the config to retrieve the line item adjustment by
|
|
135
|
+
* @return the line item adjustment.
|
|
136
|
+
*/
|
|
137
|
+
LineItemAdjustmentService.prototype.retrieve = function (id, config) {
|
|
138
|
+
if (config === void 0) { config = {}; }
|
|
139
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
140
|
+
var lineItemAdjustmentRepo, query, lineItemAdjustment;
|
|
141
|
+
return __generator(this, function (_a) {
|
|
142
|
+
switch (_a.label) {
|
|
143
|
+
case 0:
|
|
144
|
+
lineItemAdjustmentRepo = this.manager_.getCustomRepository(this.lineItemAdjustmentRepo_);
|
|
145
|
+
query = this.buildQuery_({ id: id }, config);
|
|
146
|
+
return [4 /*yield*/, lineItemAdjustmentRepo.findOne(query)];
|
|
147
|
+
case 1:
|
|
148
|
+
lineItemAdjustment = _a.sent();
|
|
149
|
+
if (!lineItemAdjustment) {
|
|
150
|
+
throw new medusa_core_utils_1.MedusaError(medusa_core_utils_1.MedusaError.Types.NOT_FOUND, "Line item adjustment with id: ".concat(id, " was not found"));
|
|
151
|
+
}
|
|
152
|
+
return [2 /*return*/, lineItemAdjustment];
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
});
|
|
156
|
+
};
|
|
157
|
+
/**
|
|
158
|
+
* Creates a line item adjustment
|
|
159
|
+
* @param data - the line item adjustment to create
|
|
160
|
+
* @return line item adjustment
|
|
161
|
+
*/
|
|
162
|
+
LineItemAdjustmentService.prototype.create = function (data) {
|
|
163
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
164
|
+
var _this = this;
|
|
165
|
+
return __generator(this, function (_a) {
|
|
166
|
+
switch (_a.label) {
|
|
167
|
+
case 0: return [4 /*yield*/, this.atomicPhase_(function (manager) { return __awaiter(_this, void 0, void 0, function () {
|
|
168
|
+
var lineItemAdjustmentRepo, lineItemAdjustment;
|
|
169
|
+
return __generator(this, function (_a) {
|
|
170
|
+
switch (_a.label) {
|
|
171
|
+
case 0:
|
|
172
|
+
lineItemAdjustmentRepo = manager.getCustomRepository(this.lineItemAdjustmentRepo_);
|
|
173
|
+
return [4 /*yield*/, lineItemAdjustmentRepo.create(data)];
|
|
174
|
+
case 1:
|
|
175
|
+
lineItemAdjustment = _a.sent();
|
|
176
|
+
return [4 /*yield*/, lineItemAdjustmentRepo.save(lineItemAdjustment)];
|
|
177
|
+
case 2: return [2 /*return*/, _a.sent()];
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
}); })];
|
|
181
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
});
|
|
185
|
+
};
|
|
186
|
+
/**
|
|
187
|
+
* Creates a line item adjustment
|
|
188
|
+
* @param id - the line item adjustment id to update
|
|
189
|
+
* @param data - the line item adjustment to create
|
|
190
|
+
* @return line item adjustment
|
|
191
|
+
*/
|
|
192
|
+
LineItemAdjustmentService.prototype.update = function (id, data) {
|
|
193
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
194
|
+
var _this = this;
|
|
195
|
+
return __generator(this, function (_a) {
|
|
196
|
+
switch (_a.label) {
|
|
197
|
+
case 0: return [4 /*yield*/, this.atomicPhase_(function (manager) { return __awaiter(_this, void 0, void 0, function () {
|
|
198
|
+
var lineItemAdjustmentRepo, lineItemAdjustment, metadata, rest, _a, _b, _c, key, value, result;
|
|
199
|
+
var e_1, _d;
|
|
200
|
+
return __generator(this, function (_e) {
|
|
201
|
+
switch (_e.label) {
|
|
202
|
+
case 0:
|
|
203
|
+
lineItemAdjustmentRepo = manager.getCustomRepository(this.lineItemAdjustmentRepo_);
|
|
204
|
+
return [4 /*yield*/, this.retrieve(id)];
|
|
205
|
+
case 1:
|
|
206
|
+
lineItemAdjustment = _e.sent();
|
|
207
|
+
metadata = data.metadata, rest = __rest(data, ["metadata"]);
|
|
208
|
+
if (metadata) {
|
|
209
|
+
lineItemAdjustment.metadata = this.setMetadata_(lineItemAdjustment, metadata);
|
|
210
|
+
}
|
|
211
|
+
try {
|
|
212
|
+
for (_a = __values(Object.entries(rest)), _b = _a.next(); !_b.done; _b = _a.next()) {
|
|
213
|
+
_c = __read(_b.value, 2), key = _c[0], value = _c[1];
|
|
214
|
+
lineItemAdjustment[key] = value;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
218
|
+
finally {
|
|
219
|
+
try {
|
|
220
|
+
if (_b && !_b.done && (_d = _a.return)) _d.call(_a);
|
|
221
|
+
}
|
|
222
|
+
finally { if (e_1) throw e_1.error; }
|
|
223
|
+
}
|
|
224
|
+
return [4 /*yield*/, lineItemAdjustmentRepo.save(lineItemAdjustment)];
|
|
225
|
+
case 2:
|
|
226
|
+
result = _e.sent();
|
|
227
|
+
return [2 /*return*/, result];
|
|
228
|
+
}
|
|
229
|
+
});
|
|
230
|
+
}); })];
|
|
231
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
232
|
+
}
|
|
233
|
+
});
|
|
234
|
+
});
|
|
235
|
+
};
|
|
236
|
+
/**
|
|
237
|
+
* Lists line item adjustments
|
|
238
|
+
* @param selector - the query object for find
|
|
239
|
+
* @param config - the config to be used for find
|
|
240
|
+
* @return the result of the find operation
|
|
241
|
+
*/
|
|
242
|
+
LineItemAdjustmentService.prototype.list = function (selector, config) {
|
|
243
|
+
if (selector === void 0) { selector = {}; }
|
|
244
|
+
if (config === void 0) { config = { skip: 0, take: 20 }; }
|
|
245
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
246
|
+
var lineItemAdjustmentRepo, query;
|
|
247
|
+
return __generator(this, function (_a) {
|
|
248
|
+
switch (_a.label) {
|
|
249
|
+
case 0:
|
|
250
|
+
lineItemAdjustmentRepo = this.manager_.getCustomRepository(this.lineItemAdjustmentRepo_);
|
|
251
|
+
query = this.buildQuery_(selector, config);
|
|
252
|
+
return [4 /*yield*/, lineItemAdjustmentRepo.find(query)];
|
|
253
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
254
|
+
}
|
|
255
|
+
});
|
|
256
|
+
});
|
|
257
|
+
};
|
|
258
|
+
/**
|
|
259
|
+
* Deletes line item adjustments matching a selector
|
|
260
|
+
* @param selectorOrId - the query object for find or the line item adjustment id
|
|
261
|
+
* @return the result of the delete operation
|
|
262
|
+
*/
|
|
263
|
+
LineItemAdjustmentService.prototype.delete = function (selectorOrId) {
|
|
264
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
265
|
+
var _this = this;
|
|
266
|
+
return __generator(this, function (_a) {
|
|
267
|
+
return [2 /*return*/, this.atomicPhase_(function (manager) { return __awaiter(_this, void 0, void 0, function () {
|
|
268
|
+
var lineItemAdjustmentRepo, query, lineItemAdjustments;
|
|
269
|
+
return __generator(this, function (_a) {
|
|
270
|
+
switch (_a.label) {
|
|
271
|
+
case 0:
|
|
272
|
+
lineItemAdjustmentRepo = manager.getCustomRepository(this.lineItemAdjustmentRepo_);
|
|
273
|
+
if (!(typeof selectorOrId === "string")) return [3 /*break*/, 2];
|
|
274
|
+
return [4 /*yield*/, this.delete({ id: selectorOrId })];
|
|
275
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
276
|
+
case 2:
|
|
277
|
+
query = this.buildQuery_(selectorOrId);
|
|
278
|
+
return [4 /*yield*/, lineItemAdjustmentRepo.find(query)];
|
|
279
|
+
case 3:
|
|
280
|
+
lineItemAdjustments = _a.sent();
|
|
281
|
+
return [4 /*yield*/, lineItemAdjustmentRepo.remove(lineItemAdjustments)];
|
|
282
|
+
case 4:
|
|
283
|
+
_a.sent();
|
|
284
|
+
return [2 /*return*/, Promise.resolve()];
|
|
285
|
+
}
|
|
286
|
+
});
|
|
287
|
+
}); })];
|
|
288
|
+
});
|
|
289
|
+
});
|
|
290
|
+
};
|
|
291
|
+
/**
|
|
292
|
+
* Creates adjustment for a line item
|
|
293
|
+
* @param cart - the cart object holding discounts
|
|
294
|
+
* @param generatedLineItem - the line item for which a line item adjustment might be created
|
|
295
|
+
* @param context - the line item for which a line item adjustment might be created
|
|
296
|
+
* @return a line item adjustment or undefined if no adjustment was created
|
|
297
|
+
*/
|
|
298
|
+
LineItemAdjustmentService.prototype.generateAdjustments = function (cart, generatedLineItem, context) {
|
|
299
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
300
|
+
var _this = this;
|
|
301
|
+
return __generator(this, function (_a) {
|
|
302
|
+
return [2 /*return*/, this.atomicPhase_(function (manager) { return __awaiter(_this, void 0, void 0, function () {
|
|
303
|
+
var _a, discount, lineItemProduct, isValid, amount, adjustments;
|
|
304
|
+
var _b;
|
|
305
|
+
return __generator(this, function (_c) {
|
|
306
|
+
switch (_c.label) {
|
|
307
|
+
case 0:
|
|
308
|
+
// if lineItem should not be discounted
|
|
309
|
+
// or lineItem is a return line item
|
|
310
|
+
// or the cart does not have any discounts
|
|
311
|
+
// then do nothing
|
|
312
|
+
if (!generatedLineItem.allow_discounts ||
|
|
313
|
+
generatedLineItem.is_return ||
|
|
314
|
+
!((_b = cart === null || cart === void 0 ? void 0 : cart.discounts) === null || _b === void 0 ? void 0 : _b.length)) {
|
|
315
|
+
return [2 /*return*/, []];
|
|
316
|
+
}
|
|
317
|
+
_a = __read(cart.discounts.filter(function (d) { return d.rule.type !== "free_shipping"; }), 1), discount = _a[0];
|
|
318
|
+
// if no discount is applied to the cart then return
|
|
319
|
+
if (!discount) {
|
|
320
|
+
return [2 /*return*/, []];
|
|
321
|
+
}
|
|
322
|
+
lineItemProduct = context.variant.product_id;
|
|
323
|
+
return [4 /*yield*/, this.discountService
|
|
324
|
+
.withTransaction(manager)
|
|
325
|
+
.validateDiscountForProduct(discount.rule_id, lineItemProduct)
|
|
326
|
+
// if discount is not valid for line item, then do nothing
|
|
327
|
+
];
|
|
328
|
+
case 1:
|
|
329
|
+
isValid = _c.sent();
|
|
330
|
+
// if discount is not valid for line item, then do nothing
|
|
331
|
+
if (!isValid) {
|
|
332
|
+
return [2 /*return*/, []];
|
|
333
|
+
}
|
|
334
|
+
return [4 /*yield*/, this.discountService.calculateDiscountForLineItem(discount.id, generatedLineItem, cart)
|
|
335
|
+
// if discounted amount is 0, then do nothing
|
|
336
|
+
];
|
|
337
|
+
case 2:
|
|
338
|
+
amount = _c.sent();
|
|
339
|
+
// if discounted amount is 0, then do nothing
|
|
340
|
+
if (amount === 0) {
|
|
341
|
+
return [2 /*return*/, []];
|
|
342
|
+
}
|
|
343
|
+
adjustments = [
|
|
344
|
+
{
|
|
345
|
+
amount: amount,
|
|
346
|
+
discount_id: discount.id,
|
|
347
|
+
description: "discount",
|
|
348
|
+
},
|
|
349
|
+
];
|
|
350
|
+
return [2 /*return*/, adjustments];
|
|
351
|
+
}
|
|
352
|
+
});
|
|
353
|
+
}); })];
|
|
354
|
+
});
|
|
355
|
+
});
|
|
356
|
+
};
|
|
357
|
+
/**
|
|
358
|
+
* Creates adjustment for a line item
|
|
359
|
+
* @param cart - the cart object holding discounts
|
|
360
|
+
* @param lineItem - the line item for which a line item adjustment might be created
|
|
361
|
+
* @return a line item adjustment or undefined if no adjustment was created
|
|
362
|
+
*/
|
|
363
|
+
LineItemAdjustmentService.prototype.createAdjustmentForLineItem = function (cart, lineItem) {
|
|
364
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
365
|
+
var adjustments, createdAdjustments, adjustments_1, adjustments_1_1, adjustment, created, e_2_1;
|
|
366
|
+
var e_2, _a;
|
|
367
|
+
return __generator(this, function (_b) {
|
|
368
|
+
switch (_b.label) {
|
|
369
|
+
case 0: return [4 /*yield*/, this.generateAdjustments(cart, lineItem, {
|
|
370
|
+
variant: lineItem.variant,
|
|
371
|
+
})];
|
|
372
|
+
case 1:
|
|
373
|
+
adjustments = _b.sent();
|
|
374
|
+
createdAdjustments = [];
|
|
375
|
+
_b.label = 2;
|
|
376
|
+
case 2:
|
|
377
|
+
_b.trys.push([2, 7, 8, 9]);
|
|
378
|
+
adjustments_1 = __values(adjustments), adjustments_1_1 = adjustments_1.next();
|
|
379
|
+
_b.label = 3;
|
|
380
|
+
case 3:
|
|
381
|
+
if (!!adjustments_1_1.done) return [3 /*break*/, 6];
|
|
382
|
+
adjustment = adjustments_1_1.value;
|
|
383
|
+
return [4 /*yield*/, this.create(__assign({ item_id: lineItem.id }, adjustment))];
|
|
384
|
+
case 4:
|
|
385
|
+
created = _b.sent();
|
|
386
|
+
createdAdjustments.push(created);
|
|
387
|
+
_b.label = 5;
|
|
388
|
+
case 5:
|
|
389
|
+
adjustments_1_1 = adjustments_1.next();
|
|
390
|
+
return [3 /*break*/, 3];
|
|
391
|
+
case 6: return [3 /*break*/, 9];
|
|
392
|
+
case 7:
|
|
393
|
+
e_2_1 = _b.sent();
|
|
394
|
+
e_2 = { error: e_2_1 };
|
|
395
|
+
return [3 /*break*/, 9];
|
|
396
|
+
case 8:
|
|
397
|
+
try {
|
|
398
|
+
if (adjustments_1_1 && !adjustments_1_1.done && (_a = adjustments_1.return)) _a.call(adjustments_1);
|
|
399
|
+
}
|
|
400
|
+
finally { if (e_2) throw e_2.error; }
|
|
401
|
+
return [7 /*endfinally*/];
|
|
402
|
+
case 9: return [2 /*return*/, createdAdjustments];
|
|
403
|
+
}
|
|
404
|
+
});
|
|
405
|
+
});
|
|
406
|
+
};
|
|
407
|
+
/**
|
|
408
|
+
* Creates adjustment for a line item
|
|
409
|
+
* @param cart - the cart object holding discounts
|
|
410
|
+
* @param lineItem - the line item for which a line item adjustment might be created
|
|
411
|
+
* @return if a lineItem was given, returns a line item adjustment or undefined if no adjustment was created
|
|
412
|
+
* otherwise returns an array of line item adjustments for each line item in the cart
|
|
413
|
+
*/
|
|
414
|
+
LineItemAdjustmentService.prototype.createAdjustments = function (cart, lineItem) {
|
|
415
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
416
|
+
var _this = this;
|
|
417
|
+
return __generator(this, function (_a) {
|
|
418
|
+
switch (_a.label) {
|
|
419
|
+
case 0:
|
|
420
|
+
if (!lineItem) return [3 /*break*/, 2];
|
|
421
|
+
return [4 /*yield*/, this.createAdjustmentForLineItem(cart, lineItem)];
|
|
422
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
423
|
+
case 2:
|
|
424
|
+
if (!cart.items) {
|
|
425
|
+
return [2 /*return*/, []];
|
|
426
|
+
}
|
|
427
|
+
return [4 /*yield*/, Promise.all(cart.items.map(function (li) { return _this.createAdjustmentForLineItem(cart, li); }))];
|
|
428
|
+
case 3: return [2 /*return*/, _a.sent()];
|
|
429
|
+
}
|
|
430
|
+
});
|
|
431
|
+
});
|
|
432
|
+
};
|
|
433
|
+
return LineItemAdjustmentService;
|
|
434
|
+
}(medusa_interfaces_1.BaseService));
|
|
435
|
+
exports.default = LineItemAdjustmentService;
|
|
436
|
+
//# sourceMappingURL=line-item-adjustment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"line-item-adjustment.js","sourceRoot":"","sources":["../../src/services/line-item-adjustment.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,uDAA+C;AAC/C,uDAA+C;AAsB/C;;;GAGG;AACH;IAAwC,6CAAW;IAKjD,mCAAY,EAIqB;YAH/B,OAAO,aAAA,EACP,4BAA4B,kCAAA,EAC5B,eAAe,qBAAA;QAHjB,YAKE,iBAAO,SAIR;QAHC,KAAI,CAAC,QAAQ,GAAG,OAAO,CAAA;QACvB,KAAI,CAAC,uBAAuB,GAAG,4BAA4B,CAAA;QAC3D,KAAI,CAAC,eAAe,GAAG,eAAe,CAAA;;IACxC,CAAC;IAED,mDAAe,GAAf,UACE,kBAAiC;QAEjC,IAAI,CAAC,kBAAkB,EAAE;YACvB,OAAO,IAAI,CAAA;SACZ;QAED,IAAM,MAAM,GAAG,IAAI,yBAAyB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,CAAC,EAAE,IACjB,UAAU,EACb,EAAA;;wBAHI,OAAO,GAAG,SAGd;wBAEF,kBAAkB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;;;;;;;;;;;;;;;;4BAGlC,sBAAO,kBAAkB,EAAA;;;;KAC1B;IAED;;;;;;OAMG;IACG,qDAAiB,GAAvB,UACE,IAAU,EACV,QAAmB;;;;;;6BAEf,QAAQ,EAAR,wBAAQ;wBACH,qBAAM,IAAI,CAAC,2BAA2B,CAAC,IAAI,EAAE,QAAQ,CAAC,EAAA;4BAA7D,sBAAO,SAAsD,EAAA;;wBAG/D,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE;4BACf,sBAAO,EAAE,EAAA;yBACV;wBAEM,qBAAM,OAAO,CAAC,GAAG,CACtB,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,UAAC,EAAE,IAAK,OAAA,KAAI,CAAC,2BAA2B,CAAC,IAAI,EAAE,EAAE,CAAC,EAA1C,CAA0C,CAAC,CACnE,EAAA;4BAFD,sBAAO,SAEN,EAAA;;;;KACF;IACH,gCAAC;AAAD,CAAC,AAhRD,CAAwC,+BAAW,GAgRlD;AAED,kBAAe,yBAAyB,CAAA"}
|
|
@@ -1,49 +1,51 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { BaseService } from "medusa-interfaces";
|
|
2
|
+
import { EntityManager } from "typeorm";
|
|
3
|
+
import { LineItemRepository } from "../repositories/line-item";
|
|
4
|
+
import { LineItemTaxLineRepository } from "../repositories/line-item-tax-line";
|
|
5
|
+
import { ProductService, RegionService, ProductVariantService } from "./index";
|
|
6
|
+
import { CartRepository } from "../repositories/cart";
|
|
7
|
+
import { LineItem } from "../models/line-item";
|
|
8
|
+
import LineItemAdjustmentService from "./line-item-adjustment";
|
|
9
|
+
import { Cart } from "../models/cart";
|
|
10
|
+
declare type InjectedDependencies = {
|
|
11
|
+
manager: EntityManager;
|
|
12
|
+
lineItemRepository: typeof LineItemRepository;
|
|
13
|
+
lineItemTaxLineRepository: typeof LineItemTaxLineRepository;
|
|
14
|
+
cartRepository: typeof CartRepository;
|
|
15
|
+
productVariantService: ProductVariantService;
|
|
16
|
+
productService: ProductService;
|
|
17
|
+
regionService: RegionService;
|
|
18
|
+
lineItemAdjustmentService: LineItemAdjustmentService;
|
|
19
|
+
};
|
|
3
20
|
/**
|
|
4
21
|
* Provides layer to manipulate line items.
|
|
5
22
|
* @extends BaseService
|
|
6
23
|
*/
|
|
7
|
-
declare class LineItemService extends
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
/** @private @const {EntityManager} */
|
|
19
|
-
private manager_;
|
|
20
|
-
/** @private @const {LineItemRepository} */
|
|
21
|
-
private lineItemRepository_;
|
|
22
|
-
/** @private @const {typeof LineItemTaxLineRepository} */
|
|
23
|
-
private itemTaxLineRepo_;
|
|
24
|
-
/** @private @const {ProductVariantService} */
|
|
25
|
-
private productVariantService_;
|
|
26
|
-
/** @private @const {ProductService} */
|
|
27
|
-
private productService_;
|
|
28
|
-
/** @private @const {RegionService} */
|
|
29
|
-
private regionService_;
|
|
30
|
-
/** @private @const {CartRepository} */
|
|
31
|
-
private cartRepository_;
|
|
32
|
-
withTransaction(transactionManager: any): LineItemService;
|
|
24
|
+
declare class LineItemService extends BaseService {
|
|
25
|
+
protected readonly manager_: EntityManager;
|
|
26
|
+
protected readonly lineItemRepository_: typeof LineItemRepository;
|
|
27
|
+
protected readonly itemTaxLineRepo_: typeof LineItemTaxLineRepository;
|
|
28
|
+
protected readonly cartRepository_: typeof CartRepository;
|
|
29
|
+
protected readonly productVariantService_: ProductVariantService;
|
|
30
|
+
protected readonly productService_: ProductService;
|
|
31
|
+
protected readonly regionService_: RegionService;
|
|
32
|
+
protected readonly lineItemAdjustmentService_: LineItemAdjustmentService;
|
|
33
|
+
constructor({ manager, lineItemRepository, lineItemTaxLineRepository, productVariantService, productService, regionService, cartRepository, lineItemAdjustmentService, }: InjectedDependencies);
|
|
34
|
+
withTransaction(transactionManager: EntityManager): LineItemService;
|
|
33
35
|
list(selector: any, config?: {
|
|
34
36
|
skip: number;
|
|
35
37
|
take: number;
|
|
36
38
|
order: {
|
|
37
39
|
created_at: string;
|
|
38
40
|
};
|
|
39
|
-
}): Promise<
|
|
41
|
+
}): Promise<LineItem[]>;
|
|
40
42
|
/**
|
|
41
43
|
* Retrieves a line item by its id.
|
|
42
44
|
* @param {string} id - the id of the line item to retrieve
|
|
43
45
|
* @param {object} config - the config to be used at query building
|
|
44
|
-
* @return {LineItem} the line item
|
|
46
|
+
* @return {Promise<LineItem | never>} the line item
|
|
45
47
|
*/
|
|
46
|
-
retrieve(id: string, config?:
|
|
48
|
+
retrieve(id: string, config?: {}): Promise<LineItem | never>;
|
|
47
49
|
/**
|
|
48
50
|
* Creates return line items for a given cart based on the return items in a
|
|
49
51
|
* return.
|
|
@@ -52,24 +54,30 @@ declare class LineItemService extends LineItemService_base {
|
|
|
52
54
|
* @return {Promise<LineItem[]>} the created line items
|
|
53
55
|
*/
|
|
54
56
|
createReturnLines(returnId: string, cartId: string): Promise<LineItem[]>;
|
|
55
|
-
generate(variantId:
|
|
57
|
+
generate(variantId: string, regionId: string, quantity: number, context?: {
|
|
58
|
+
unit_price?: number;
|
|
59
|
+
metadata?: Record<string, unknown>;
|
|
60
|
+
customer_id?: string;
|
|
61
|
+
cart?: Cart;
|
|
62
|
+
}): Promise<LineItem>;
|
|
56
63
|
/**
|
|
57
64
|
* Create a line item
|
|
58
|
-
* @param {LineItem}
|
|
59
|
-
* @return {LineItem} the created line item
|
|
65
|
+
* @param {Partial<LineItem>} data - the line item object to create
|
|
66
|
+
* @return {Promise<LineItem>} the created line item
|
|
60
67
|
*/
|
|
61
|
-
create(
|
|
68
|
+
create(data: Partial<LineItem>): Promise<LineItem>;
|
|
62
69
|
/**
|
|
63
70
|
* Updates a line item
|
|
64
71
|
* @param {string} id - the id of the line item to update
|
|
65
|
-
* @param {
|
|
66
|
-
* @return {LineItem} the update line item
|
|
72
|
+
* @param {Partial<LineItem>} data - the properties to update on line item
|
|
73
|
+
* @return {Promise<LineItem>} the update line item
|
|
67
74
|
*/
|
|
68
|
-
update(id: string,
|
|
75
|
+
update(id: string, data: Partial<LineItem>): Promise<LineItem>;
|
|
69
76
|
/**
|
|
70
77
|
* Deletes a line item.
|
|
71
78
|
* @param {string} id - the id of the line item to delete
|
|
72
|
-
* @return {Promise} the result of the delete operation
|
|
79
|
+
* @return {Promise<LineItem | undefined>} the result of the delete operation
|
|
73
80
|
*/
|
|
74
|
-
delete(id: string): Promise<
|
|
81
|
+
delete(id: string): Promise<LineItem | undefined>;
|
|
75
82
|
}
|
|
83
|
+
export default LineItemService;
|