@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,469 @@
|
|
|
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 __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
18
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
19
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
20
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
21
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
22
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
23
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
27
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
28
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
29
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
30
|
+
function step(op) {
|
|
31
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
32
|
+
while (_) try {
|
|
33
|
+
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;
|
|
34
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
35
|
+
switch (op[0]) {
|
|
36
|
+
case 0: case 1: t = op; break;
|
|
37
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
38
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
39
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
40
|
+
default:
|
|
41
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
42
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
43
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
44
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
45
|
+
if (t[2]) _.ops.pop();
|
|
46
|
+
_.trys.pop(); continue;
|
|
47
|
+
}
|
|
48
|
+
op = body.call(thisArg, _);
|
|
49
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
50
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
54
|
+
var t = {};
|
|
55
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
56
|
+
t[p] = s[p];
|
|
57
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
58
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
59
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
60
|
+
t[p[i]] = s[p[i]];
|
|
61
|
+
}
|
|
62
|
+
return t;
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
92
|
+
var medusa_core_utils_1 = require("medusa-core-utils");
|
|
93
|
+
var medusa_interfaces_1 = require("medusa-interfaces");
|
|
94
|
+
var exception_formatter_1 = require("../utils/exception-formatter");
|
|
95
|
+
/**
|
|
96
|
+
* Provides layer to manipulate product tags.
|
|
97
|
+
* @extends BaseService
|
|
98
|
+
*/
|
|
99
|
+
var PriceListService = /** @class */ (function (_super) {
|
|
100
|
+
__extends(PriceListService, _super);
|
|
101
|
+
function PriceListService(_a) {
|
|
102
|
+
var manager = _a.manager, customerGroupService = _a.customerGroupService, priceListRepository = _a.priceListRepository, moneyAmountRepository = _a.moneyAmountRepository;
|
|
103
|
+
var _this = _super.call(this) || this;
|
|
104
|
+
_this.manager_ = manager;
|
|
105
|
+
_this.customerGroupService_ = customerGroupService;
|
|
106
|
+
_this.priceListRepo_ = priceListRepository;
|
|
107
|
+
_this.moneyAmountRepo_ = moneyAmountRepository;
|
|
108
|
+
return _this;
|
|
109
|
+
}
|
|
110
|
+
PriceListService.prototype.withTransaction = function (transactionManager) {
|
|
111
|
+
if (!transactionManager) {
|
|
112
|
+
return this;
|
|
113
|
+
}
|
|
114
|
+
var cloned = new PriceListService({
|
|
115
|
+
manager: transactionManager,
|
|
116
|
+
customerGroupService: this.customerGroupService_,
|
|
117
|
+
priceListRepository: this.priceListRepo_,
|
|
118
|
+
moneyAmountRepository: this.moneyAmountRepo_,
|
|
119
|
+
});
|
|
120
|
+
cloned.transactionManager_ = transactionManager;
|
|
121
|
+
return cloned;
|
|
122
|
+
};
|
|
123
|
+
/**
|
|
124
|
+
* Retrieves a product tag by id.
|
|
125
|
+
* @param {string} priceListId - the id of the product tag to retrieve
|
|
126
|
+
* @param {Object} config - the config to retrieve the tag by
|
|
127
|
+
* @return {Promise<PriceList>} the collection.
|
|
128
|
+
*/
|
|
129
|
+
PriceListService.prototype.retrieve = function (priceListId, config) {
|
|
130
|
+
if (config === void 0) { config = {}; }
|
|
131
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
132
|
+
var priceListRepo, query, priceList;
|
|
133
|
+
return __generator(this, function (_a) {
|
|
134
|
+
switch (_a.label) {
|
|
135
|
+
case 0:
|
|
136
|
+
priceListRepo = this.manager_.getCustomRepository(this.priceListRepo_);
|
|
137
|
+
query = this.buildQuery_({ id: priceListId }, config);
|
|
138
|
+
return [4 /*yield*/, priceListRepo.findOne(query)];
|
|
139
|
+
case 1:
|
|
140
|
+
priceList = _a.sent();
|
|
141
|
+
if (!priceList) {
|
|
142
|
+
throw new medusa_core_utils_1.MedusaError(medusa_core_utils_1.MedusaError.Types.NOT_FOUND, "Price list with id: ".concat(priceListId, " was not found"));
|
|
143
|
+
}
|
|
144
|
+
return [2 /*return*/, priceList];
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
});
|
|
148
|
+
};
|
|
149
|
+
/**
|
|
150
|
+
* Creates a Price List
|
|
151
|
+
* @param {CreatePriceListInput} priceListObject - the Price List to create
|
|
152
|
+
* @return {Promise<PriceList>} created Price List
|
|
153
|
+
*/
|
|
154
|
+
PriceListService.prototype.create = function (priceListObject) {
|
|
155
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
156
|
+
var _this = this;
|
|
157
|
+
return __generator(this, function (_a) {
|
|
158
|
+
switch (_a.label) {
|
|
159
|
+
case 0: return [4 /*yield*/, this.atomicPhase_(function (manager) { return __awaiter(_this, void 0, void 0, function () {
|
|
160
|
+
var priceListRepo, moneyAmountRepo, prices, customer_groups, rest, entity, priceList, result, error_1;
|
|
161
|
+
return __generator(this, function (_a) {
|
|
162
|
+
switch (_a.label) {
|
|
163
|
+
case 0:
|
|
164
|
+
priceListRepo = manager.getCustomRepository(this.priceListRepo_);
|
|
165
|
+
moneyAmountRepo = manager.getCustomRepository(this.moneyAmountRepo_);
|
|
166
|
+
prices = priceListObject.prices, customer_groups = priceListObject.customer_groups, rest = __rest(priceListObject, ["prices", "customer_groups"]);
|
|
167
|
+
_a.label = 1;
|
|
168
|
+
case 1:
|
|
169
|
+
_a.trys.push([1, 8, , 9]);
|
|
170
|
+
entity = priceListRepo.create(rest);
|
|
171
|
+
return [4 /*yield*/, priceListRepo.save(entity)];
|
|
172
|
+
case 2:
|
|
173
|
+
priceList = _a.sent();
|
|
174
|
+
if (!prices) return [3 /*break*/, 4];
|
|
175
|
+
return [4 /*yield*/, moneyAmountRepo.addPriceListPrices(priceList.id, prices)];
|
|
176
|
+
case 3:
|
|
177
|
+
_a.sent();
|
|
178
|
+
_a.label = 4;
|
|
179
|
+
case 4:
|
|
180
|
+
if (!customer_groups) return [3 /*break*/, 6];
|
|
181
|
+
return [4 /*yield*/, this.upsertCustomerGroups_(priceList.id, customer_groups)];
|
|
182
|
+
case 5:
|
|
183
|
+
_a.sent();
|
|
184
|
+
_a.label = 6;
|
|
185
|
+
case 6: return [4 /*yield*/, this.retrieve(priceList.id, {
|
|
186
|
+
relations: ["prices", "customer_groups"],
|
|
187
|
+
})];
|
|
188
|
+
case 7:
|
|
189
|
+
result = _a.sent();
|
|
190
|
+
return [2 /*return*/, result];
|
|
191
|
+
case 8:
|
|
192
|
+
error_1 = _a.sent();
|
|
193
|
+
throw (0, exception_formatter_1.formatException)(error_1);
|
|
194
|
+
case 9: return [2 /*return*/];
|
|
195
|
+
}
|
|
196
|
+
});
|
|
197
|
+
}); })];
|
|
198
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
199
|
+
}
|
|
200
|
+
});
|
|
201
|
+
});
|
|
202
|
+
};
|
|
203
|
+
/**
|
|
204
|
+
* Updates a Price List
|
|
205
|
+
* @param {string} id - the id of the Product List to update
|
|
206
|
+
* @param {UpdatePriceListInput} update - the update to apply
|
|
207
|
+
* @returns {Promise<PriceList>} updated Price List
|
|
208
|
+
*/
|
|
209
|
+
PriceListService.prototype.update = function (id, update) {
|
|
210
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
211
|
+
var _this = this;
|
|
212
|
+
return __generator(this, function (_a) {
|
|
213
|
+
switch (_a.label) {
|
|
214
|
+
case 0: return [4 /*yield*/, this.atomicPhase_(function (manager) { return __awaiter(_this, void 0, void 0, function () {
|
|
215
|
+
var priceListRepo, moneyAmountRepo, priceList, prices, customer_groups, rest, _a, _b, _c, key, value, result;
|
|
216
|
+
var e_1, _d;
|
|
217
|
+
return __generator(this, function (_e) {
|
|
218
|
+
switch (_e.label) {
|
|
219
|
+
case 0:
|
|
220
|
+
priceListRepo = manager.getCustomRepository(this.priceListRepo_);
|
|
221
|
+
moneyAmountRepo = manager.getCustomRepository(this.moneyAmountRepo_);
|
|
222
|
+
return [4 /*yield*/, this.retrieve(id, { select: ["id"] })];
|
|
223
|
+
case 1:
|
|
224
|
+
priceList = _e.sent();
|
|
225
|
+
prices = update.prices, customer_groups = update.customer_groups, rest = __rest(update, ["prices", "customer_groups"]);
|
|
226
|
+
try {
|
|
227
|
+
for (_a = __values(Object.entries(rest)), _b = _a.next(); !_b.done; _b = _a.next()) {
|
|
228
|
+
_c = __read(_b.value, 2), key = _c[0], value = _c[1];
|
|
229
|
+
priceList[key] = value;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
233
|
+
finally {
|
|
234
|
+
try {
|
|
235
|
+
if (_b && !_b.done && (_d = _a.return)) _d.call(_a);
|
|
236
|
+
}
|
|
237
|
+
finally { if (e_1) throw e_1.error; }
|
|
238
|
+
}
|
|
239
|
+
return [4 /*yield*/, priceListRepo.save(priceList)];
|
|
240
|
+
case 2:
|
|
241
|
+
_e.sent();
|
|
242
|
+
if (!prices) return [3 /*break*/, 4];
|
|
243
|
+
return [4 /*yield*/, moneyAmountRepo.updatePriceListPrices(id, prices)];
|
|
244
|
+
case 3:
|
|
245
|
+
_e.sent();
|
|
246
|
+
_e.label = 4;
|
|
247
|
+
case 4:
|
|
248
|
+
if (!customer_groups) return [3 /*break*/, 6];
|
|
249
|
+
return [4 /*yield*/, this.upsertCustomerGroups_(id, customer_groups)];
|
|
250
|
+
case 5:
|
|
251
|
+
_e.sent();
|
|
252
|
+
_e.label = 6;
|
|
253
|
+
case 6: return [4 /*yield*/, this.retrieve(id, {
|
|
254
|
+
relations: ["prices", "customer_groups"],
|
|
255
|
+
})];
|
|
256
|
+
case 7:
|
|
257
|
+
result = _e.sent();
|
|
258
|
+
return [2 /*return*/, result];
|
|
259
|
+
}
|
|
260
|
+
});
|
|
261
|
+
}); })];
|
|
262
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
263
|
+
}
|
|
264
|
+
});
|
|
265
|
+
});
|
|
266
|
+
};
|
|
267
|
+
/**
|
|
268
|
+
* Adds prices to a price list in bulk, optionally replacing all existing prices
|
|
269
|
+
* @param id - id of the price list
|
|
270
|
+
* @param prices - prices to add
|
|
271
|
+
* @param replace - whether to replace existing prices
|
|
272
|
+
* @returns {Promise<PriceList>} updated Price List
|
|
273
|
+
*/
|
|
274
|
+
PriceListService.prototype.addPrices = function (id, prices, replace) {
|
|
275
|
+
if (replace === void 0) { replace = false; }
|
|
276
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
277
|
+
var _this = this;
|
|
278
|
+
return __generator(this, function (_a) {
|
|
279
|
+
switch (_a.label) {
|
|
280
|
+
case 0: return [4 /*yield*/, this.atomicPhase_(function (manager) { return __awaiter(_this, void 0, void 0, function () {
|
|
281
|
+
var moneyAmountRepo, priceList, result;
|
|
282
|
+
return __generator(this, function (_a) {
|
|
283
|
+
switch (_a.label) {
|
|
284
|
+
case 0:
|
|
285
|
+
moneyAmountRepo = manager.getCustomRepository(this.moneyAmountRepo_);
|
|
286
|
+
return [4 /*yield*/, this.retrieve(id, { select: ["id"] })];
|
|
287
|
+
case 1:
|
|
288
|
+
priceList = _a.sent();
|
|
289
|
+
return [4 /*yield*/, moneyAmountRepo.addPriceListPrices(priceList.id, prices, replace)];
|
|
290
|
+
case 2:
|
|
291
|
+
_a.sent();
|
|
292
|
+
return [4 /*yield*/, this.retrieve(priceList.id, {
|
|
293
|
+
relations: ["prices"],
|
|
294
|
+
})];
|
|
295
|
+
case 3:
|
|
296
|
+
result = _a.sent();
|
|
297
|
+
return [2 /*return*/, result];
|
|
298
|
+
}
|
|
299
|
+
});
|
|
300
|
+
}); })];
|
|
301
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
302
|
+
}
|
|
303
|
+
});
|
|
304
|
+
});
|
|
305
|
+
};
|
|
306
|
+
/**
|
|
307
|
+
* Removes prices from a price list and deletes the removed prices in bulk
|
|
308
|
+
* @param id - id of the price list
|
|
309
|
+
* @param priceIds - ids of the prices to delete
|
|
310
|
+
* @returns {Promise<void>} updated Price List
|
|
311
|
+
*/
|
|
312
|
+
PriceListService.prototype.deletePrices = function (id, priceIds) {
|
|
313
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
314
|
+
var _this = this;
|
|
315
|
+
return __generator(this, function (_a) {
|
|
316
|
+
switch (_a.label) {
|
|
317
|
+
case 0: return [4 /*yield*/, this.atomicPhase_(function (manager) { return __awaiter(_this, void 0, void 0, function () {
|
|
318
|
+
var moneyAmountRepo, priceList;
|
|
319
|
+
return __generator(this, function (_a) {
|
|
320
|
+
switch (_a.label) {
|
|
321
|
+
case 0:
|
|
322
|
+
moneyAmountRepo = manager.getCustomRepository(this.moneyAmountRepo_);
|
|
323
|
+
return [4 /*yield*/, this.retrieve(id, { select: ["id"] })];
|
|
324
|
+
case 1:
|
|
325
|
+
priceList = _a.sent();
|
|
326
|
+
return [4 /*yield*/, moneyAmountRepo.deletePriceListPrices(priceList.id, priceIds)];
|
|
327
|
+
case 2:
|
|
328
|
+
_a.sent();
|
|
329
|
+
return [2 /*return*/, Promise.resolve()];
|
|
330
|
+
}
|
|
331
|
+
});
|
|
332
|
+
}); })];
|
|
333
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
334
|
+
}
|
|
335
|
+
});
|
|
336
|
+
});
|
|
337
|
+
};
|
|
338
|
+
/**
|
|
339
|
+
* Deletes a Price List
|
|
340
|
+
* Will never fail due to delete being idempotent.
|
|
341
|
+
* @param id - id of the price list
|
|
342
|
+
* @returns {Promise<void>} empty promise
|
|
343
|
+
*/
|
|
344
|
+
PriceListService.prototype.delete = function (id) {
|
|
345
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
346
|
+
var _this = this;
|
|
347
|
+
return __generator(this, function (_a) {
|
|
348
|
+
switch (_a.label) {
|
|
349
|
+
case 0: return [4 /*yield*/, this.atomicPhase_(function (manager) { return __awaiter(_this, void 0, void 0, function () {
|
|
350
|
+
var priceListRepo, priceList;
|
|
351
|
+
return __generator(this, function (_a) {
|
|
352
|
+
switch (_a.label) {
|
|
353
|
+
case 0:
|
|
354
|
+
priceListRepo = manager.getCustomRepository(this.priceListRepo_);
|
|
355
|
+
return [4 /*yield*/, priceListRepo.findOne({ where: { id: id } })];
|
|
356
|
+
case 1:
|
|
357
|
+
priceList = _a.sent();
|
|
358
|
+
if (!priceList) {
|
|
359
|
+
return [2 /*return*/, Promise.resolve()];
|
|
360
|
+
}
|
|
361
|
+
return [4 /*yield*/, priceListRepo.delete(priceList)];
|
|
362
|
+
case 2:
|
|
363
|
+
_a.sent();
|
|
364
|
+
return [2 /*return*/, Promise.resolve()];
|
|
365
|
+
}
|
|
366
|
+
});
|
|
367
|
+
}); })];
|
|
368
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
369
|
+
}
|
|
370
|
+
});
|
|
371
|
+
});
|
|
372
|
+
};
|
|
373
|
+
/**
|
|
374
|
+
* Lists Price Lists
|
|
375
|
+
* @param {Object} selector - the query object for find
|
|
376
|
+
* @param {Object} config - the config to be used for find
|
|
377
|
+
* @return {Promise<PriceList[]>} the result of the find operation
|
|
378
|
+
*/
|
|
379
|
+
PriceListService.prototype.list = function (selector, config) {
|
|
380
|
+
if (selector === void 0) { selector = {}; }
|
|
381
|
+
if (config === void 0) { config = { skip: 0, take: 20 }; }
|
|
382
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
383
|
+
var priceListRepo, query;
|
|
384
|
+
return __generator(this, function (_a) {
|
|
385
|
+
switch (_a.label) {
|
|
386
|
+
case 0:
|
|
387
|
+
priceListRepo = this.manager_.getCustomRepository(this.priceListRepo_);
|
|
388
|
+
query = this.buildQuery_(selector, config);
|
|
389
|
+
return [4 /*yield*/, priceListRepo.find(query)];
|
|
390
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
391
|
+
}
|
|
392
|
+
});
|
|
393
|
+
});
|
|
394
|
+
};
|
|
395
|
+
/**
|
|
396
|
+
* Lists Price Lists and adds count
|
|
397
|
+
* @param {Object} selector - the query object for find
|
|
398
|
+
* @param {Object} config - the config to be used for find
|
|
399
|
+
* @return {Promise} the result of the find operation
|
|
400
|
+
*/
|
|
401
|
+
PriceListService.prototype.listAndCount = function (selector, config) {
|
|
402
|
+
if (selector === void 0) { selector = {}; }
|
|
403
|
+
if (config === void 0) { config = { skip: 0, take: 20 }; }
|
|
404
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
405
|
+
var priceListRepo, query;
|
|
406
|
+
return __generator(this, function (_a) {
|
|
407
|
+
switch (_a.label) {
|
|
408
|
+
case 0:
|
|
409
|
+
priceListRepo = this.manager_.getCustomRepository(this.priceListRepo_);
|
|
410
|
+
query = this.buildQuery_(selector, config);
|
|
411
|
+
return [4 /*yield*/, priceListRepo.findAndCount(query)];
|
|
412
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
413
|
+
}
|
|
414
|
+
});
|
|
415
|
+
});
|
|
416
|
+
};
|
|
417
|
+
PriceListService.prototype.upsertCustomerGroups_ = function (priceListId, customerGroups) {
|
|
418
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
419
|
+
var priceListRepo, priceList, groups, customerGroups_1, customerGroups_1_1, cg, customerGroup, e_2_1;
|
|
420
|
+
var e_2, _a;
|
|
421
|
+
return __generator(this, function (_b) {
|
|
422
|
+
switch (_b.label) {
|
|
423
|
+
case 0:
|
|
424
|
+
priceListRepo = this.manager_.getCustomRepository(this.priceListRepo_);
|
|
425
|
+
return [4 /*yield*/, this.retrieve(priceListId, { select: ["id"] })];
|
|
426
|
+
case 1:
|
|
427
|
+
priceList = _b.sent();
|
|
428
|
+
groups = [];
|
|
429
|
+
_b.label = 2;
|
|
430
|
+
case 2:
|
|
431
|
+
_b.trys.push([2, 7, 8, 9]);
|
|
432
|
+
customerGroups_1 = __values(customerGroups), customerGroups_1_1 = customerGroups_1.next();
|
|
433
|
+
_b.label = 3;
|
|
434
|
+
case 3:
|
|
435
|
+
if (!!customerGroups_1_1.done) return [3 /*break*/, 6];
|
|
436
|
+
cg = customerGroups_1_1.value;
|
|
437
|
+
return [4 /*yield*/, this.customerGroupService_.retrieve(cg.id)];
|
|
438
|
+
case 4:
|
|
439
|
+
customerGroup = _b.sent();
|
|
440
|
+
groups.push(customerGroup);
|
|
441
|
+
_b.label = 5;
|
|
442
|
+
case 5:
|
|
443
|
+
customerGroups_1_1 = customerGroups_1.next();
|
|
444
|
+
return [3 /*break*/, 3];
|
|
445
|
+
case 6: return [3 /*break*/, 9];
|
|
446
|
+
case 7:
|
|
447
|
+
e_2_1 = _b.sent();
|
|
448
|
+
e_2 = { error: e_2_1 };
|
|
449
|
+
return [3 /*break*/, 9];
|
|
450
|
+
case 8:
|
|
451
|
+
try {
|
|
452
|
+
if (customerGroups_1_1 && !customerGroups_1_1.done && (_a = customerGroups_1.return)) _a.call(customerGroups_1);
|
|
453
|
+
}
|
|
454
|
+
finally { if (e_2) throw e_2.error; }
|
|
455
|
+
return [7 /*endfinally*/];
|
|
456
|
+
case 9:
|
|
457
|
+
priceList.customer_groups = groups;
|
|
458
|
+
return [4 /*yield*/, priceListRepo.save(priceList)];
|
|
459
|
+
case 10:
|
|
460
|
+
_b.sent();
|
|
461
|
+
return [2 /*return*/];
|
|
462
|
+
}
|
|
463
|
+
});
|
|
464
|
+
});
|
|
465
|
+
};
|
|
466
|
+
return PriceListService;
|
|
467
|
+
}(medusa_interfaces_1.BaseService));
|
|
468
|
+
exports.default = PriceListService;
|
|
469
|
+
//# sourceMappingURL=price-list.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"price-list.js","sourceRoot":"","sources":["../../src/services/price-list.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uDAA+C;AAC/C,uDAA+C;AAc/C,oEAA8D;AAS9D;;;GAGG;AACH;IAA+B,oCAAW;IAMxC,0BAAY,EAKgB;YAJ1B,OAAO,aAAA,EACP,oBAAoB,0BAAA,EACpB,mBAAmB,yBAAA,EACnB,qBAAqB,2BAAA;QAJvB,YAME,iBAAO,SAKR;QAJC,KAAI,CAAC,QAAQ,GAAG,OAAO,CAAA;QACvB,KAAI,CAAC,qBAAqB,GAAG,oBAAoB,CAAA;QACjD,KAAI,CAAC,cAAc,GAAG,mBAAmB,CAAA;QACzC,KAAI,CAAC,gBAAgB,GAAG,qBAAqB,CAAA;;IAC/C,CAAC;IAED,0CAAe,GAAf,UAAgB,kBAAiC;QAC/C,IAAI,CAAC,kBAAkB,EAAE;YACvB,OAAO,IAAI,CAAA;SACZ;QAED,IAAM,MAAM,GAAG,IAAI,gBAAgB,CAAC;YAClC,OAAO,EAAE,kBAAkB;YAC3B,oBAAoB,EAAE,IAAI,CAAC,qBAAqB;YAChD,mBAAmB,EAAE,IAAI,CAAC,cAAc;YACxC,qBAAqB,EAAE,IAAI,CAAC,gBAAgB;SAC7C,CAAC,CAAA;QAEF,MAAM,CAAC,mBAAmB,GAAG,kBAAkB,CAAA;QAE/C,OAAO,MAAM,CAAA;IACf,CAAC;IAED;;;;;OAKG;IACG,mCAAQ,GAAd,UACE,WAAmB,EACnB,MAAkC;QAAlC,uBAAA,EAAA,WAAkC;;;;;;wBAE5B,aAAa,GAAG,IAAI,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AAC,EAAA;;wBAAnC,SAAmC,CAAA;;;;;KACpC;IACH,uBAAC;AAAD,CAAC,AA1PD,CAA+B,+BAAW,GA0PzC;AAED,kBAAe,gBAAgB,CAAA"}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { BaseService } from "medusa-interfaces";
|
|
2
2
|
import { EntityManager, SelectQueryBuilder } from "typeorm";
|
|
3
|
+
import { PriceSelectionContext } from "../interfaces/price-selection-strategy";
|
|
3
4
|
import { MoneyAmount } from "../models/money-amount";
|
|
4
5
|
import { Product } from "../models/product";
|
|
5
6
|
import { ProductOptionValue } from "../models/product-option-value";
|
|
6
7
|
import { ProductVariant } from "../models/product-variant";
|
|
7
8
|
import { FindWithRelationsOptions, ProductVariantRepository } from "../repositories/product-variant";
|
|
8
9
|
import { FindConfig } from "../types/common";
|
|
9
|
-
import { CreateProductVariantInput, FilterableProductVariantProps, ProductVariantPrice, UpdateProductVariantInput } from "../types/product-variant";
|
|
10
|
+
import { CreateProductVariantInput, FilterableProductVariantProps, GetRegionPriceContext, ProductVariantPrice, UpdateProductVariantInput } from "../types/product-variant";
|
|
10
11
|
/**
|
|
11
12
|
* Provides layer to manipulate product variants.
|
|
12
13
|
* @extends BaseService
|
|
@@ -22,9 +23,11 @@ declare class ProductVariantService extends BaseService {
|
|
|
22
23
|
private productRepository_;
|
|
23
24
|
private eventBus_;
|
|
24
25
|
private regionService_;
|
|
26
|
+
private priceSelectionStrategy_;
|
|
25
27
|
private moneyAmountRepository_;
|
|
26
28
|
private productOptionValueRepository_;
|
|
27
|
-
|
|
29
|
+
private cartRepository_;
|
|
30
|
+
constructor({ manager, productVariantRepository, productRepository, eventBusService, regionService, moneyAmountRepository, productOptionValueRepository, cartRepository, priceSelectionStrategy, }: {
|
|
28
31
|
manager: any;
|
|
29
32
|
productVariantRepository: any;
|
|
30
33
|
productRepository: any;
|
|
@@ -32,6 +35,8 @@ declare class ProductVariantService extends BaseService {
|
|
|
32
35
|
regionService: any;
|
|
33
36
|
moneyAmountRepository: any;
|
|
34
37
|
productOptionValueRepository: any;
|
|
38
|
+
cartRepository: any;
|
|
39
|
+
priceSelectionStrategy: any;
|
|
35
40
|
});
|
|
36
41
|
withTransaction(transactionManager: EntityManager): ProductVariantService;
|
|
37
42
|
/**
|
|
@@ -40,14 +45,14 @@ declare class ProductVariantService extends BaseService {
|
|
|
40
45
|
* @param {FindConfig<ProductVariant>} config - query config object for variant retrieval.
|
|
41
46
|
* @return {Promise<Product>} the product document.
|
|
42
47
|
*/
|
|
43
|
-
retrieve(variantId: string, config?: FindConfig<ProductVariant>): Promise<ProductVariant>;
|
|
48
|
+
retrieve(variantId: string, config?: FindConfig<ProductVariant> & PriceSelectionContext): Promise<ProductVariant>;
|
|
44
49
|
/**
|
|
45
50
|
* Gets a product variant by id.
|
|
46
51
|
* @param {string} sku - The unique stock keeping unit used to identify the product variant.
|
|
47
52
|
* @param {FindConfig<ProductVariant>} config - query config object for variant retrieval.
|
|
48
53
|
* @return {Promise<Product>} the product document.
|
|
49
54
|
*/
|
|
50
|
-
retrieveBySKU(sku: string, config?: FindConfig<ProductVariant>): Promise<ProductVariant>;
|
|
55
|
+
retrieveBySKU(sku: string, config?: FindConfig<ProductVariant> & PriceSelectionContext): Promise<ProductVariant>;
|
|
51
56
|
/**
|
|
52
57
|
* Creates an unpublished product variant. Will validate against parent product
|
|
53
58
|
* to ensure that the variant can in fact be created.
|
|
@@ -62,33 +67,41 @@ declare class ProductVariantService extends BaseService {
|
|
|
62
67
|
* The function will throw, if price updates are attempted.
|
|
63
68
|
* @param {string | ProductVariant} variantOrVariantId - variant or id of a variant.
|
|
64
69
|
* @param {object} update - an object with the update values.
|
|
70
|
+
* @param {object} config - an object with the config values for returning the variant.
|
|
65
71
|
* @return {Promise} resolves to the update result.
|
|
66
72
|
*/
|
|
67
73
|
update(variantOrVariantId: string | Partial<ProductVariant>, update: UpdateProductVariantInput): Promise<ProductVariant>;
|
|
68
|
-
updateVariantPrices(variantId: string, prices: ProductVariantPrice[]): Promise<void>;
|
|
69
74
|
/**
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
* @param
|
|
73
|
-
* @
|
|
75
|
+
* Updates a variant's prices.
|
|
76
|
+
* Deletes any prices that are not in the update object, and is not associated with a price list.
|
|
77
|
+
* @param variantId - the id of variant variant
|
|
78
|
+
* @param prices - the update prices
|
|
79
|
+
* @returns {Promise<void>} empty promise
|
|
74
80
|
*/
|
|
75
|
-
|
|
81
|
+
updateVariantPrices(variantId: string, prices: ProductVariantPrice[]): Promise<void>;
|
|
76
82
|
/**
|
|
77
83
|
* Gets the price specific to a region. If no region specific money amount
|
|
78
84
|
* exists the function will try to use a currency price. If no default
|
|
79
85
|
* currency price exists the function will throw an error.
|
|
80
86
|
* @param {string} variantId - the id of the variant to get price from
|
|
81
|
-
* @param {
|
|
87
|
+
* @param {GetRegionPriceContext} context - context for getting region price
|
|
82
88
|
* @return {number} the price specific to the region
|
|
83
89
|
*/
|
|
84
|
-
getRegionPrice(variantId: string,
|
|
90
|
+
getRegionPrice(variantId: string, context: GetRegionPriceContext): Promise<number>;
|
|
85
91
|
/**
|
|
86
|
-
* Sets the price of a specific region
|
|
92
|
+
* Sets the default price of a specific region
|
|
87
93
|
* @param {string} variantId - the id of the variant to update
|
|
88
94
|
* @param {string} price - the price for the variant.
|
|
89
95
|
* @return {Promise} the result of the update operation
|
|
90
96
|
*/
|
|
91
97
|
setRegionPrice(variantId: string, price: ProductVariantPrice): Promise<MoneyAmount>;
|
|
98
|
+
/**
|
|
99
|
+
* Sets the default price for the given currency.
|
|
100
|
+
* @param {string} variantId - the id of the variant to set prices for
|
|
101
|
+
* @param {ProductVariantPrice} price - the price for the variant
|
|
102
|
+
* @return {Promise} the result of the update operation
|
|
103
|
+
*/
|
|
104
|
+
setCurrencyPrice(variantId: string, price: ProductVariantPrice): Promise<MoneyAmount>;
|
|
92
105
|
/**
|
|
93
106
|
* Updates variant's option value.
|
|
94
107
|
* Option value must be of type string or number.
|
|
@@ -123,13 +136,13 @@ declare class ProductVariantService extends BaseService {
|
|
|
123
136
|
* @param {FindConfig<ProductVariant>} config - query config object for variant retrieval
|
|
124
137
|
* @return {Promise} the result of the find operation
|
|
125
138
|
*/
|
|
126
|
-
listAndCount(selector: FilterableProductVariantProps, config?: FindConfig<ProductVariant>): Promise<[ProductVariant[], number]>;
|
|
139
|
+
listAndCount(selector: FilterableProductVariantProps, config?: FindConfig<ProductVariant> & PriceSelectionContext): Promise<[ProductVariant[], number]>;
|
|
127
140
|
/**
|
|
128
141
|
* @param {FilterableProductVariantProps} selector - the query object for find
|
|
129
142
|
* @param {FindConfig<ProductVariant>} config - query config object for variant retrieval
|
|
130
143
|
* @return {Promise} the result of the find operation
|
|
131
144
|
*/
|
|
132
|
-
list(selector: FilterableProductVariantProps, config?: FindConfig<ProductVariant>): Promise<ProductVariant[]>;
|
|
145
|
+
list(selector: FilterableProductVariantProps, config?: FindConfig<ProductVariant> & PriceSelectionContext): Promise<ProductVariant[]>;
|
|
133
146
|
/**
|
|
134
147
|
* Deletes variant.
|
|
135
148
|
* Will never fail due to delete being idempotent.
|
|
@@ -144,7 +157,7 @@ declare class ProductVariantService extends BaseService {
|
|
|
144
157
|
* @param {Object} metadata - the metadata to set
|
|
145
158
|
* @return {Object} updated metadata object
|
|
146
159
|
*/
|
|
147
|
-
setMetadata_(variant: ProductVariant, metadata: object): Record<string,
|
|
160
|
+
setMetadata_(variant: ProductVariant, metadata: object): Record<string, unknown>;
|
|
148
161
|
/**
|
|
149
162
|
* Creates a query object to be used for list queries.
|
|
150
163
|
* @param {object} selector - the selector to create the query from
|
|
@@ -167,5 +180,16 @@ declare class ProductVariantService extends BaseService {
|
|
|
167
180
|
* count of products that matches the query as the second element.
|
|
168
181
|
*/
|
|
169
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[]>;
|
|
170
194
|
}
|
|
171
195
|
export default ProductVariantService;
|