@medusajs/medusa 1.2.2-dev.56 → 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/list-customer-groups.js +2 -2
- package/dist/api/routes/admin/customer-groups/list-customer-groups.js.map +1 -1
- package/dist/api/routes/admin/discounts/create-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/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/index.d.ts +7 -0
- package/dist/api/routes/admin/price-lists/index.js +3 -0
- package/dist/api/routes/admin/price-lists/index.js.map +1 -1
- package/dist/api/routes/admin/price-lists/list-price-list-products.d.ts +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/update-price-list.d.ts +2 -2
- package/dist/api/routes/admin/price-lists/update-price-list.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-variant.js +11 -7
- 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/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 +2 -1
- package/dist/api/routes/store/products/list-products.js +21 -8
- 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/shipping-options/list-options.js.map +1 -1
- package/dist/api/routes/store/swaps/create-swap.js +7 -3
- package/dist/api/routes/store/swaps/create-swap.js.map +1 -1
- package/dist/api/routes/store/variants/get-variant.js +17 -5
- package/dist/api/routes/store/variants/get-variant.js.map +1 -1
- package/dist/api/routes/store/variants/list-variants.d.ts +2 -1
- package/dist/api/routes/store/variants/list-variants.js +38 -9
- package/dist/api/routes/store/variants/list-variants.js.map +1 -1
- package/dist/commands/develop.js +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 -59
- package/dist/index.js +3 -62
- 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/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/{api/routes/admin/discounts/remove-valid-product.js → migrations/1648641130007-tax_line_constraints.js} +39 -44
- 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/{api/routes/admin/discounts/add-valid-product.js → migrations/1649775522087-add_batch_job_model.js} +39 -44
- 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.js +3 -1
- 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.js +4 -1
- package/dist/models/money-amount.js.map +1 -1
- package/dist/models/price-list.js +6 -2
- package/dist/models/price-list.js.map +1 -1
- 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 -1
- package/dist/repositories/customer.js +7 -9
- 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 +1 -0
- package/dist/repositories/money-amount.js +49 -2
- package/dist/repositories/money-amount.js.map +1 -1
- package/dist/repositories/product.d.ts +2 -0
- package/dist/repositories/product.js +35 -17
- 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 +4 -2
- package/dist/services/customer.js.map +1 -1
- package/dist/services/discount.d.ts +50 -58
- package/dist/services/discount.js +363 -152
- 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/product-variant.d.ts +26 -9
- package/dist/services/product-variant.js +222 -76
- package/dist/services/product-variant.js.map +1 -1
- package/dist/services/product.d.ts +22 -4
- package/dist/services/product.js +236 -48
- 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/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-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 +6 -0
- 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/store/carts/update-payment-method.d.ts +0 -38
- package/dist/api/routes/store/carts/update-payment-method.js +0 -122
- 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/yarn-error.log +0 -6769
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (_) try {
|
|
18
|
+
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;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
+
};
|
|
41
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
+
var dotenv_1 = __importDefault(require("dotenv"));
|
|
43
|
+
var typeorm_1 = require("typeorm");
|
|
44
|
+
var logger_1 = __importDefault(require("../loaders/logger"));
|
|
45
|
+
var discount_condition_1 = require("../models/discount-condition");
|
|
46
|
+
var discount_condition_product_1 = require("../models/discount-condition-product");
|
|
47
|
+
var discount_rule_1 = require("../models/discount-rule");
|
|
48
|
+
dotenv_1.default.config();
|
|
49
|
+
var typeormConfig = {
|
|
50
|
+
type: process.env.TYPEORM_CONNECTION,
|
|
51
|
+
url: process.env.TYPEORM_URL,
|
|
52
|
+
username: process.env.TYPEORM_USERNAME,
|
|
53
|
+
password: process.env.TYPEORM_PASSWORD,
|
|
54
|
+
database: process.env.TYPEORM_DATABASE,
|
|
55
|
+
migrations: [process.env.TYPEORM_MIGRATIONS],
|
|
56
|
+
entities: [process.env.TYPEORM_ENTITIES],
|
|
57
|
+
logging: true,
|
|
58
|
+
};
|
|
59
|
+
var migrate = function (_a) {
|
|
60
|
+
var typeormConfig = _a.typeormConfig;
|
|
61
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
62
|
+
var connection, BATCH_SIZE, noDanglingProductsValidation;
|
|
63
|
+
var _this = this;
|
|
64
|
+
return __generator(this, function (_b) {
|
|
65
|
+
switch (_b.label) {
|
|
66
|
+
case 0: return [4 /*yield*/, (0, typeorm_1.createConnection)(typeormConfig)];
|
|
67
|
+
case 1:
|
|
68
|
+
connection = _b.sent();
|
|
69
|
+
BATCH_SIZE = 1000;
|
|
70
|
+
return [4 /*yield*/, connection.transaction(function (manager) { return __awaiter(_this, void 0, void 0, function () {
|
|
71
|
+
var discountRuleCount, offset, discountRules, discountRuleProductCount, getConditionProductsResult;
|
|
72
|
+
return __generator(this, function (_a) {
|
|
73
|
+
switch (_a.label) {
|
|
74
|
+
case 0: return [4 /*yield*/, manager
|
|
75
|
+
.createQueryBuilder()
|
|
76
|
+
.from(discount_rule_1.DiscountRule, "dr")
|
|
77
|
+
.getCount()];
|
|
78
|
+
case 1:
|
|
79
|
+
discountRuleCount = _a.sent();
|
|
80
|
+
offset = 0;
|
|
81
|
+
_a.label = 2;
|
|
82
|
+
case 2:
|
|
83
|
+
if (!(offset < discountRuleCount)) return [3 /*break*/, 5];
|
|
84
|
+
return [4 /*yield*/, manager
|
|
85
|
+
.createQueryBuilder()
|
|
86
|
+
.from(discount_rule_1.DiscountRule, "dr")
|
|
87
|
+
.select("dr.id")
|
|
88
|
+
.innerJoin("discount_rule_products", "drp", "dr.id = drp.discount_rule_id")
|
|
89
|
+
.distinct(true)
|
|
90
|
+
.limit(BATCH_SIZE)
|
|
91
|
+
.offset(offset)
|
|
92
|
+
.getRawMany()];
|
|
93
|
+
case 3:
|
|
94
|
+
discountRules = _a.sent();
|
|
95
|
+
return [4 /*yield*/, manager
|
|
96
|
+
.createQueryBuilder()
|
|
97
|
+
.insert()
|
|
98
|
+
.into(discount_condition_1.DiscountCondition)
|
|
99
|
+
.values(discountRules.map(function (dr) {
|
|
100
|
+
return Object.assign(new discount_condition_1.DiscountCondition(), {
|
|
101
|
+
type: discount_condition_1.DiscountConditionType.PRODUCTS,
|
|
102
|
+
operator: discount_condition_1.DiscountConditionOperator.IN,
|
|
103
|
+
discount_rule_id: dr.dr_id,
|
|
104
|
+
});
|
|
105
|
+
}))
|
|
106
|
+
.orIgnore()
|
|
107
|
+
.execute()];
|
|
108
|
+
case 4:
|
|
109
|
+
_a.sent();
|
|
110
|
+
offset += BATCH_SIZE;
|
|
111
|
+
return [3 /*break*/, 2];
|
|
112
|
+
case 5: return [4 /*yield*/, manager.query("SELECT COUNT(*) FROM discount_rule_products")];
|
|
113
|
+
case 6:
|
|
114
|
+
discountRuleProductCount = _a.sent();
|
|
115
|
+
offset = 0;
|
|
116
|
+
_a.label = 7;
|
|
117
|
+
case 7:
|
|
118
|
+
if (!(offset < parseInt(discountRuleProductCount[0].count))) return [3 /*break*/, 10];
|
|
119
|
+
return [4 /*yield*/, manager
|
|
120
|
+
.createQueryBuilder()
|
|
121
|
+
.from(discount_rule_1.DiscountRule, "dr")
|
|
122
|
+
.innerJoin("discount_rule_products", "drp", "dr.id = drp.discount_rule_id")
|
|
123
|
+
.innerJoin("discount_condition", "dc", "dr.id = dc.discount_rule_id")
|
|
124
|
+
.select("dc.id as cond_id, drp.product_id")
|
|
125
|
+
.limit(BATCH_SIZE)
|
|
126
|
+
.offset(offset)
|
|
127
|
+
.getRawMany()];
|
|
128
|
+
case 8:
|
|
129
|
+
getConditionProductsResult = _a.sent();
|
|
130
|
+
return [4 /*yield*/, manager
|
|
131
|
+
.createQueryBuilder()
|
|
132
|
+
.insert()
|
|
133
|
+
.into(discount_condition_product_1.DiscountConditionProduct)
|
|
134
|
+
.values(getConditionProductsResult.map(function (dr) { return ({
|
|
135
|
+
condition_id: dr.cond_id,
|
|
136
|
+
product_id: dr.product_id,
|
|
137
|
+
}); }))
|
|
138
|
+
.orIgnore()
|
|
139
|
+
.execute()];
|
|
140
|
+
case 9:
|
|
141
|
+
_a.sent();
|
|
142
|
+
offset += BATCH_SIZE;
|
|
143
|
+
return [3 /*break*/, 7];
|
|
144
|
+
case 10: return [2 /*return*/];
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
}); })
|
|
148
|
+
// Validate results
|
|
149
|
+
];
|
|
150
|
+
case 2:
|
|
151
|
+
_b.sent();
|
|
152
|
+
return [4 /*yield*/, connection.manager
|
|
153
|
+
.query("SELECT drp.discount_rule_id, drp.product_id, dcp.product_id FROM \"discount_rule_products\" drp\n LEFT JOIN discount_condition dc ON dc.discount_rule_id = drp.discount_rule_id\n LEFT JOIN discount_condition_product dcp ON dcp.condition_id = dc.id AND dcp.product_id = drp.product_id\n WHERE dcp.product_id IS NULL")];
|
|
154
|
+
case 3:
|
|
155
|
+
noDanglingProductsValidation = _b.sent();
|
|
156
|
+
if (noDanglingProductsValidation &&
|
|
157
|
+
(noDanglingProductsValidation === null || noDanglingProductsValidation === void 0 ? void 0 : noDanglingProductsValidation.length) === 0) {
|
|
158
|
+
logger_1.default.info("Discount entities have been successfully migrated");
|
|
159
|
+
process.exit();
|
|
160
|
+
}
|
|
161
|
+
else {
|
|
162
|
+
logger_1.default.error("Discount entities could not be migrated");
|
|
163
|
+
process.exit(1);
|
|
164
|
+
}
|
|
165
|
+
return [2 /*return*/];
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
});
|
|
169
|
+
};
|
|
170
|
+
migrate({ typeormConfig: typeormConfig })
|
|
171
|
+
.then(function () {
|
|
172
|
+
logger_1.default.info("Database migration completed successfully");
|
|
173
|
+
process.exit();
|
|
174
|
+
})
|
|
175
|
+
.catch(function (err) { return console.log(err); });
|
|
176
|
+
exports.default = migrate;
|
|
177
|
+
//# sourceMappingURL=discount-rule-migration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discount-rule-migration.js","sourceRoot":"","sources":["../../src/scripts/discount-rule-migration.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kDAA2B;AAC3B,mCAA0C;AAC1C,6DAAsC;AACtC,mEAIqC;AACrC,mFAA+E;AAC/E,yDAAsD;AACtD,gBAAM,CAAC,MAAM,EAAE,CAAA;AAEf,IAAM,aAAa,GAAG;IACpB,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,kBAAkB;IACpC,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,WAAW;IAC5B,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,gBAAgB;IACtC,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,gBAAgB;IACtC,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,gBAAgB;IACtC,UAAU,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,kBAA4B,CAAC;IACtD,QAAQ,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC;IACxC,OAAO,EAAE,IAAI;CACd,CAAA;AAED,IAAM,OAAO,GAAG,UAAgB,EAAiB;QAAf,aAAa,mBAAA;;;;;;wBAC1B,qBAAM,IAAA,0BAAgB,EAAC,aAAa,CAAC,EAAA;;oBAAlD,UAAU,GAAG,SAAqC;oBAElD,UAAU,GAAG,IAAI,CAAA;oBAEvB,qBAAM,UAAU,CAAC,WAAW,CAAC,UAAO,OAAO;;;;4CACf,qBAAM,OAAO;6CACpC,kBAAkB,EAAE;6CACpB,IAAI,CAAC,4BAAY,EAAE,IAAI,CAAC;6CACxB,QAAQ,EAAE,EAAA;;wCAHP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C,IAAI,EAAE,CAAA;AAChB,CAAC,CAAC;KACD,KAAK,CAAC,UAAC,GAAG,IAAK,OAAA,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,EAAhB,CAAgB,CAAC,CAAA;AAEnC,kBAAe,OAAO,CAAA"}
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
+
function step(op) {
|
|
27
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
+
while (_) try {
|
|
29
|
+
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;
|
|
30
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
+
switch (op[0]) {
|
|
32
|
+
case 0: case 1: t = op; break;
|
|
33
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
+
default:
|
|
37
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
+
if (t[2]) _.ops.pop();
|
|
42
|
+
_.trys.pop(); continue;
|
|
43
|
+
}
|
|
44
|
+
op = body.call(thisArg, _);
|
|
45
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
50
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
51
|
+
};
|
|
52
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
53
|
+
var dotenv_1 = __importDefault(require("dotenv"));
|
|
54
|
+
var typeorm_1 = require("typeorm");
|
|
55
|
+
var logger_1 = __importDefault(require("../loaders/logger"));
|
|
56
|
+
var line_item_1 = require("../models/line-item");
|
|
57
|
+
var line_item_adjustment_1 = require("../models/line-item-adjustment");
|
|
58
|
+
dotenv_1.default.config();
|
|
59
|
+
var typeormConfig = {
|
|
60
|
+
type: process.env.TYPEORM_CONNECTION,
|
|
61
|
+
url: process.env.TYPEORM_URL,
|
|
62
|
+
username: process.env.TYPEORM_USERNAME,
|
|
63
|
+
password: process.env.TYPEORM_PASSWORD,
|
|
64
|
+
database: process.env.TYPEORM_DATABASE,
|
|
65
|
+
migrations: [process.env.TYPEORM_MIGRATIONS],
|
|
66
|
+
entities: [process.env.TYPEORM_ENTITIES],
|
|
67
|
+
logging: true,
|
|
68
|
+
};
|
|
69
|
+
var migrate = function (_a) {
|
|
70
|
+
var typeormConfig = _a.typeormConfig;
|
|
71
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
72
|
+
var connection, BATCH_SIZE;
|
|
73
|
+
var _this = this;
|
|
74
|
+
return __generator(this, function (_b) {
|
|
75
|
+
switch (_b.label) {
|
|
76
|
+
case 0: return [4 /*yield*/, (0, typeorm_1.createConnection)(typeormConfig)];
|
|
77
|
+
case 1:
|
|
78
|
+
connection = _b.sent();
|
|
79
|
+
BATCH_SIZE = 1000;
|
|
80
|
+
return [4 /*yield*/, connection.transaction(function (manager) { return __awaiter(_this, void 0, void 0, function () {
|
|
81
|
+
var getDiscountableLineItems, getLineItemAllocations, totalAdjustments, offset, lineItemAdjustments;
|
|
82
|
+
return __generator(this, function (_a) {
|
|
83
|
+
switch (_a.label) {
|
|
84
|
+
case 0:
|
|
85
|
+
getDiscountableLineItems = function (qb) {
|
|
86
|
+
return qb
|
|
87
|
+
.from(line_item_1.LineItem, "li")
|
|
88
|
+
.select([
|
|
89
|
+
"li.order_id as order_id",
|
|
90
|
+
"SUM(li.quantity * li.unit_price)::bigint AS discountable_subtotal",
|
|
91
|
+
])
|
|
92
|
+
.where("li.allow_discounts = true")
|
|
93
|
+
.groupBy("li.order_id");
|
|
94
|
+
};
|
|
95
|
+
getLineItemAllocations = function (qb) {
|
|
96
|
+
return qb
|
|
97
|
+
.from(line_item_1.LineItem, "li")
|
|
98
|
+
.select([
|
|
99
|
+
"disc.id AS discount_id",
|
|
100
|
+
"dr.allocation",
|
|
101
|
+
"dr.type",
|
|
102
|
+
"dr.value",
|
|
103
|
+
"li.*",
|
|
104
|
+
"li.order_id",
|
|
105
|
+
"ods.discountable_subtotal",
|
|
106
|
+
"li.quantity * li.unit_price AS li_subtotal",
|
|
107
|
+
"COALESCE(ROUND(CASE\n WHEN dr.type = 'percentage' THEN li.quantity*li.unit_price * (dr.value::float / 100)\n WHEN dr.type = 'fixed' THEN li.quantity*li.unit_price * (LEAST(COALESCE(dr.value, 0), ods.discountable_subtotal)::float / ods.discountable_subtotal)\n ELSE 0\n END), 0) AS discount_total",
|
|
108
|
+
])
|
|
109
|
+
.leftJoin("order", "o", "o.id = li.order_id")
|
|
110
|
+
.leftJoin("order_discounts", "od", "o.id = od.order_id")
|
|
111
|
+
.leftJoin("discount", "disc", "od.discount_id = disc.id")
|
|
112
|
+
.leftJoin("discount_rule", "dr", "dr.id = disc.rule_id")
|
|
113
|
+
.leftJoinAndSelect(getDiscountableLineItems, "ods", "ods.order_id = li.order_id")
|
|
114
|
+
.where("dr.type != :type", { type: "free_shipping" });
|
|
115
|
+
};
|
|
116
|
+
return [4 /*yield*/, manager
|
|
117
|
+
.createQueryBuilder()
|
|
118
|
+
.from(getLineItemAllocations, "lia")
|
|
119
|
+
.select("COUNT(*)")
|
|
120
|
+
.getRawOne()
|
|
121
|
+
.then(function (result) { return parseInt(result.count, 10); })];
|
|
122
|
+
case 1:
|
|
123
|
+
totalAdjustments = _a.sent();
|
|
124
|
+
offset = 0;
|
|
125
|
+
_a.label = 2;
|
|
126
|
+
case 2:
|
|
127
|
+
if (!(offset < totalAdjustments)) return [3 /*break*/, 5];
|
|
128
|
+
return [4 /*yield*/, manager
|
|
129
|
+
.createQueryBuilder()
|
|
130
|
+
.from(getLineItemAllocations, "lia")
|
|
131
|
+
.select([
|
|
132
|
+
"lia.id AS item_id",
|
|
133
|
+
"lia.discount_id",
|
|
134
|
+
"lia.discount_total AS amount",
|
|
135
|
+
"'discount' AS description",
|
|
136
|
+
])
|
|
137
|
+
.limit(BATCH_SIZE)
|
|
138
|
+
.offset(offset)
|
|
139
|
+
.getRawMany()];
|
|
140
|
+
case 3:
|
|
141
|
+
lineItemAdjustments = _a.sent();
|
|
142
|
+
return [4 /*yield*/, manager
|
|
143
|
+
.createQueryBuilder()
|
|
144
|
+
.insert()
|
|
145
|
+
.into(line_item_adjustment_1.LineItemAdjustment)
|
|
146
|
+
.values(lineItemAdjustments.map(function (lia) {
|
|
147
|
+
return Object.assign(new line_item_adjustment_1.LineItemAdjustment(), __assign({}, lia));
|
|
148
|
+
}))
|
|
149
|
+
.orIgnore()
|
|
150
|
+
.execute()];
|
|
151
|
+
case 4:
|
|
152
|
+
_a.sent();
|
|
153
|
+
offset += BATCH_SIZE;
|
|
154
|
+
return [3 /*break*/, 2];
|
|
155
|
+
case 5: return [2 /*return*/];
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
}); })];
|
|
159
|
+
case 2:
|
|
160
|
+
_b.sent();
|
|
161
|
+
return [2 /*return*/];
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
});
|
|
165
|
+
};
|
|
166
|
+
migrate({ typeormConfig: typeormConfig })
|
|
167
|
+
.then(function () {
|
|
168
|
+
logger_1.default.info("Database migration completed successfully");
|
|
169
|
+
process.exit();
|
|
170
|
+
})
|
|
171
|
+
.catch(function (err) { return console.log(err); });
|
|
172
|
+
exports.default = migrate;
|
|
173
|
+
//# sourceMappingURL=line-item-adjustment-migration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"line-item-adjustment-migration.js","sourceRoot":"","sources":["../../src/scripts/line-item-adjustment-migration.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kDAA2B;AAC3B,mCAA8D;AAC9D,6DAAsC;AACtC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CAAC,MAAM,CAAC,IAAI,yCAAkB,EAAE,eACjC,GAAG,EACN;4CAFF,CAEE,CACH,CACF;iDACA,QAAQ,EAAE;iDACV,OAAO,EAAE,EAAA;;wCAZZ,SAYY,CAAA;wCACZ,MAAM,IAAI,UAAU,CAAA;;;;;6BAEvB,CAAC,EAAA;;oBA9EF,SA8EE,CAAA;;;;;CACH,CAAA;AAED,OAAO,CAAC,EAAE,aAAa,eAAA,EAAE,CAAC;KACvB,IAAI,CAAC;IACJ,gBAAM,CAAC,IAAI,CAAC,2CAA2C,CAAC,CAAA;IACxD,OAAO,CAAC,IAAI,EAAE,CAAA;AAChB,CAAC,CAAC;KACD,KAAK,CAAC,UAAC,GAAG,IAAK,OAAA,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,EAAhB,CAAgB,CAAC,CAAA;AAEnC,kBAAe,OAAO,CAAA"}
|
package/dist/services/cart.d.ts
CHANGED
|
@@ -1,37 +1,41 @@
|
|
|
1
|
-
import { EntityManager } from "typeorm";
|
|
2
1
|
import { BaseService } from "medusa-interfaces";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { AddressRepository } from "../repositories/address";
|
|
6
|
-
import { PaymentSessionRepository } from "../repositories/payment-session";
|
|
2
|
+
import { EntityManager } from "typeorm";
|
|
3
|
+
import { IPriceSelectionStrategy } from "../interfaces/price-selection-strategy";
|
|
7
4
|
import { Address } from "../models/address";
|
|
8
5
|
import { Cart } from "../models/cart";
|
|
6
|
+
import { CustomShippingOption } from "../models/custom-shipping-option";
|
|
9
7
|
import { Customer } from "../models/customer";
|
|
10
8
|
import { LineItem } from "../models/line-item";
|
|
11
9
|
import { ShippingMethod } from "../models/shipping-method";
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
10
|
+
import { AddressRepository } from "../repositories/address";
|
|
11
|
+
import { CartRepository } from "../repositories/cart";
|
|
12
|
+
import { PaymentSessionRepository } from "../repositories/payment-session";
|
|
13
|
+
import { ShippingMethodRepository } from "../repositories/shipping-method";
|
|
14
|
+
import { CartCreateProps, CartUpdateProps, FilterableCartProps, LineItemUpdate } from "../types/cart";
|
|
15
|
+
import { FindConfig, TotalField } from "../types/common";
|
|
16
|
+
import CustomerService from "./customer";
|
|
17
|
+
import DiscountService from "./discount";
|
|
15
18
|
import EventBusService from "./event-bus";
|
|
16
|
-
import
|
|
17
|
-
import ProductService from "./product";
|
|
18
|
-
import RegionService from "./region";
|
|
19
|
+
import GiftCardService from "./gift-card";
|
|
19
20
|
import LineItemService from "./line-item";
|
|
20
21
|
import PaymentProviderService from "./payment-provider";
|
|
22
|
+
import ProductService from "./product";
|
|
23
|
+
import ProductVariantService from "./product-variant";
|
|
24
|
+
import RegionService from "./region";
|
|
21
25
|
import ShippingOptionService from "./shipping-option";
|
|
22
|
-
import CustomerService from "./customer";
|
|
23
26
|
import TaxProviderService from "./tax-provider";
|
|
24
|
-
import DiscountService from "./discount";
|
|
25
|
-
import GiftCardService from "./gift-card";
|
|
26
27
|
import TotalsService from "./totals";
|
|
27
28
|
import InventoryService from "./inventory";
|
|
28
29
|
import CustomShippingOptionService from "./custom-shipping-option";
|
|
29
|
-
|
|
30
|
+
import LineItemAdjustmentService from "./line-item-adjustment";
|
|
31
|
+
import { LineItemRepository } from "../repositories/line-item";
|
|
32
|
+
declare type InjectedDependencies = {
|
|
30
33
|
manager: EntityManager;
|
|
31
34
|
cartRepository: typeof CartRepository;
|
|
32
35
|
shippingMethodRepository: typeof ShippingMethodRepository;
|
|
33
36
|
addressRepository: typeof AddressRepository;
|
|
34
37
|
paymentSessionRepository: typeof PaymentSessionRepository;
|
|
38
|
+
lineItemRepository: typeof LineItemRepository;
|
|
35
39
|
eventBusService: EventBusService;
|
|
36
40
|
taxProviderService: TaxProviderService;
|
|
37
41
|
paymentProviderService: PaymentProviderService;
|
|
@@ -46,6 +50,8 @@ declare type CartConstructorProps = {
|
|
|
46
50
|
totalsService: TotalsService;
|
|
47
51
|
inventoryService: InventoryService;
|
|
48
52
|
customShippingOptionService: CustomShippingOptionService;
|
|
53
|
+
lineItemAdjustmentService: LineItemAdjustmentService;
|
|
54
|
+
priceSelectionStrategy: IPriceSelectionStrategy;
|
|
49
55
|
};
|
|
50
56
|
declare type TotalsConfig = {
|
|
51
57
|
force_taxes?: boolean;
|
|
@@ -56,31 +62,34 @@ declare class CartService extends BaseService {
|
|
|
56
62
|
CREATED: string;
|
|
57
63
|
UPDATED: string;
|
|
58
64
|
};
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
65
|
+
protected readonly manager_: EntityManager;
|
|
66
|
+
protected readonly shippingMethodRepository_: typeof ShippingMethodRepository;
|
|
67
|
+
protected readonly cartRepository_: typeof CartRepository;
|
|
68
|
+
protected readonly addressRepository_: typeof AddressRepository;
|
|
69
|
+
protected readonly paymentSessionRepository_: typeof PaymentSessionRepository;
|
|
70
|
+
protected readonly lineItemRepository_: typeof LineItemRepository;
|
|
71
|
+
protected readonly eventBus_: EventBusService;
|
|
72
|
+
protected readonly productVariantService_: ProductVariantService;
|
|
73
|
+
protected readonly productService_: ProductService;
|
|
74
|
+
protected readonly regionService_: RegionService;
|
|
75
|
+
protected readonly lineItemService_: LineItemService;
|
|
76
|
+
protected readonly paymentProviderService_: PaymentProviderService;
|
|
77
|
+
protected readonly customerService_: CustomerService;
|
|
78
|
+
protected readonly shippingOptionService_: ShippingOptionService;
|
|
79
|
+
protected readonly discountService_: DiscountService;
|
|
80
|
+
protected readonly giftCardService_: GiftCardService;
|
|
81
|
+
protected readonly taxProviderService_: TaxProviderService;
|
|
82
|
+
protected readonly totalsService_: TotalsService;
|
|
83
|
+
protected readonly inventoryService_: InventoryService;
|
|
84
|
+
protected readonly customShippingOptionService_: CustomShippingOptionService;
|
|
85
|
+
protected readonly priceSelectionStrategy_: IPriceSelectionStrategy;
|
|
86
|
+
protected readonly lineItemAdjustmentService_: LineItemAdjustmentService;
|
|
87
|
+
constructor({ manager, cartRepository, shippingMethodRepository, lineItemRepository, eventBusService, paymentProviderService, productService, productVariantService, taxProviderService, regionService, lineItemService, shippingOptionService, customerService, discountService, giftCardService, totalsService, addressRepository, paymentSessionRepository, inventoryService, customShippingOptionService, lineItemAdjustmentService, priceSelectionStrategy, }: InjectedDependencies);
|
|
79
88
|
withTransaction(transactionManager: EntityManager): CartService;
|
|
80
|
-
transformQueryForTotals_(config: FindConfig<Cart>): FindConfig<Cart> & {
|
|
89
|
+
protected transformQueryForTotals_(config: FindConfig<Cart>): FindConfig<Cart> & {
|
|
81
90
|
totalsToSelect: TotalField[];
|
|
82
91
|
};
|
|
83
|
-
decorateTotals_(cart: Cart, totalsToSelect: TotalField[], options?: TotalsConfig): Promise<Cart>;
|
|
92
|
+
protected decorateTotals_(cart: Cart, totalsToSelect: TotalField[], options?: TotalsConfig): Promise<Cart>;
|
|
84
93
|
/**
|
|
85
94
|
* @param selector - the query object for find
|
|
86
95
|
* @param config - config object
|
|
@@ -116,7 +125,7 @@ declare class CartService extends BaseService {
|
|
|
116
125
|
* @param lineItem - the line item
|
|
117
126
|
* @return boolean representing wheter shipping method is validated
|
|
118
127
|
*/
|
|
119
|
-
validateLineItemShipping_(shippingMethods: ShippingMethod[], lineItem: LineItem): boolean;
|
|
128
|
+
protected validateLineItemShipping_(shippingMethods: ShippingMethod[], lineItem: LineItem): boolean;
|
|
120
129
|
/**
|
|
121
130
|
* Adds a line item to the cart.
|
|
122
131
|
* @param cartId - the id of the cart that we will add to
|
|
@@ -142,20 +151,20 @@ declare class CartService extends BaseService {
|
|
|
142
151
|
* @return void
|
|
143
152
|
*/
|
|
144
153
|
adjustFreeShipping_(cart: Cart, shouldAdd: boolean): Promise<void>;
|
|
145
|
-
update(cartId: string,
|
|
154
|
+
update(cartId: string, data: CartUpdateProps): Promise<Cart>;
|
|
146
155
|
/**
|
|
147
156
|
* Sets the customer id of a cart
|
|
148
157
|
* @param cart - the cart to add email to
|
|
149
158
|
* @param customerId - the customer to add to cart
|
|
150
159
|
* @return the result of the update operation
|
|
151
160
|
*/
|
|
152
|
-
updateCustomerId_(cart: Cart, customerId: string): Promise<void>;
|
|
161
|
+
protected updateCustomerId_(cart: Cart, customerId: string): Promise<void>;
|
|
153
162
|
/**
|
|
154
163
|
* Creates or fetches a user based on an email.
|
|
155
164
|
* @param email - the email to use
|
|
156
165
|
* @return the resultign customer object
|
|
157
166
|
*/
|
|
158
|
-
createOrFetchUserFromEmail_(email: string): Promise<Customer>;
|
|
167
|
+
protected createOrFetchUserFromEmail_(email: string): Promise<Customer>;
|
|
159
168
|
/**
|
|
160
169
|
* Updates the cart's billing address.
|
|
161
170
|
* @param cart - the cart to update
|
|
@@ -163,7 +172,7 @@ declare class CartService extends BaseService {
|
|
|
163
172
|
* @param addrRepo - the repository to use for address updates
|
|
164
173
|
* @return the result of the update operation
|
|
165
174
|
*/
|
|
166
|
-
updateBillingAddress_(cart: Cart, addressOrId: Partial<Address> | string, addrRepo: AddressRepository): Promise<void>;
|
|
175
|
+
protected updateBillingAddress_(cart: Cart, addressOrId: Partial<Address> | string, addrRepo: AddressRepository): Promise<void>;
|
|
167
176
|
/**
|
|
168
177
|
* Updates the cart's shipping address.
|
|
169
178
|
* @param cart - the cart to update
|
|
@@ -171,8 +180,8 @@ declare class CartService extends BaseService {
|
|
|
171
180
|
* @param addrRepo - the repository to use for address updates
|
|
172
181
|
* @return the result of the update operation
|
|
173
182
|
*/
|
|
174
|
-
updateShippingAddress_(cart: Cart, addressOrId: Partial<Address> | string, addrRepo: AddressRepository): Promise<void>;
|
|
175
|
-
applyGiftCard_(cart: Cart, code: string): Promise<void>;
|
|
183
|
+
protected updateShippingAddress_(cart: Cart, addressOrId: Partial<Address> | string, addrRepo: AddressRepository): Promise<void>;
|
|
184
|
+
protected applyGiftCard_(cart: Cart, code: string): Promise<void>;
|
|
176
185
|
/**
|
|
177
186
|
* Updates the cart's discounts.
|
|
178
187
|
* If discount besides free shipping is already applied, this
|
|
@@ -209,7 +218,7 @@ declare class CartService extends BaseService {
|
|
|
209
218
|
* this could be IP address or similar for fraud handling.
|
|
210
219
|
* @return the resulting cart
|
|
211
220
|
*/
|
|
212
|
-
authorizePayment(cartId: string, context?: Record<string,
|
|
221
|
+
authorizePayment(cartId: string, context?: Record<string, unknown>): Promise<Cart>;
|
|
213
222
|
/**
|
|
214
223
|
* Sets a payment method for a cart.
|
|
215
224
|
* @param cartId - the id of the cart to add payment method to
|
|
@@ -254,7 +263,7 @@ declare class CartService extends BaseService {
|
|
|
254
263
|
* @param data - the fulmillment data for the method
|
|
255
264
|
* @return the result of the update operation
|
|
256
265
|
*/
|
|
257
|
-
addShippingMethod(cartId: string, optionId: string, data?: Record<string,
|
|
266
|
+
addShippingMethod(cartId: string, optionId: string, data?: Record<string, unknown>): Promise<Cart>;
|
|
258
267
|
/**
|
|
259
268
|
* Finds the cart's custom shipping options based on the passed option id.
|
|
260
269
|
* throws if custom options is not empty and no shipping option corresponds to optionId
|
|
@@ -263,6 +272,7 @@ declare class CartService extends BaseService {
|
|
|
263
272
|
* @return custom shipping option
|
|
264
273
|
*/
|
|
265
274
|
findCustomShippingOption(cartCustomShippingOptions: CustomShippingOption[], optionId: string): CustomShippingOption | undefined;
|
|
275
|
+
protected updateUnitPrices_(cart: Cart, regionId?: string, customer_id?: string): Promise<void>;
|
|
266
276
|
/**
|
|
267
277
|
* Set's the region of a cart.
|
|
268
278
|
* @param cart - the cart to set region on
|
|
@@ -270,7 +280,7 @@ declare class CartService extends BaseService {
|
|
|
270
280
|
* @param countryCode - the country code to set the country to
|
|
271
281
|
* @return the result of the update operation
|
|
272
282
|
*/
|
|
273
|
-
setRegion_(cart: Cart, regionId: string, countryCode: string | null): Promise<void>;
|
|
283
|
+
protected setRegion_(cart: Cart, regionId: string, countryCode: string | null): Promise<void>;
|
|
274
284
|
/**
|
|
275
285
|
* Deletes a cart from the database. Completed carts cannot be deleted.
|
|
276
286
|
* @param cartId - the id of the cart to delete
|
|
@@ -288,6 +298,7 @@ declare class CartService extends BaseService {
|
|
|
288
298
|
*/
|
|
289
299
|
setMetadata(cartId: string, key: string, value: string | number): Promise<Cart>;
|
|
290
300
|
createTaxLines(id: string): Promise<Cart>;
|
|
301
|
+
protected refreshAdjustments_(cart: Cart): Promise<void>;
|
|
291
302
|
/**
|
|
292
303
|
* Dedicated method to delete metadata for a cart.
|
|
293
304
|
* @param cartId - the cart to delete metadata from.
|