@medusajs/medusa 1.2.2-dev.53 → 1.3.1-alpha.63
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +98 -0
- package/dist/api/index.d.ts +1 -0
- package/dist/api/index.js +1 -0
- package/dist/api/index.js.map +1 -1
- package/dist/api/middlewares/authenticate-customer.d.ts +2 -1
- package/dist/api/middlewares/authenticate-customer.js +1 -2
- package/dist/api/middlewares/authenticate-customer.js.map +1 -1
- package/dist/api/middlewares/authenticate.d.ts +2 -1
- package/dist/api/middlewares/authenticate.js.map +1 -1
- package/dist/api/middlewares/await-middleware.d.ts +3 -1
- package/dist/api/middlewares/await-middleware.js +2 -31
- package/dist/api/middlewares/await-middleware.js.map +1 -1
- package/dist/api/middlewares/batch-job/can-access-batch-job.d.ts +1 -0
- package/dist/api/middlewares/batch-job/can-access-batch-job.js +70 -0
- package/dist/api/middlewares/batch-job/can-access-batch-job.js.map +1 -0
- package/dist/api/middlewares/batch-job/get-requested-batch-job.d.ts +1 -0
- package/dist/api/middlewares/batch-job/get-requested-batch-job.js +67 -0
- package/dist/api/middlewares/batch-job/get-requested-batch-job.js.map +1 -0
- package/dist/api/middlewares/error-handler.d.ts +3 -1
- package/dist/api/middlewares/error-handler.js +4 -4
- package/dist/api/middlewares/error-handler.js.map +1 -1
- package/dist/api/middlewares/index.d.ts +12 -10
- package/dist/api/middlewares/index.js +9 -0
- package/dist/api/middlewares/index.js.map +1 -1
- package/dist/api/middlewares/normalized-query.d.ts +6 -1
- package/dist/api/middlewares/normalized-query.js +5 -2
- package/dist/api/middlewares/normalized-query.js.map +1 -1
- package/dist/api/middlewares/transform-body.d.ts +4 -0
- package/dist/api/middlewares/transform-body.js +66 -0
- package/dist/api/middlewares/transform-body.js.map +1 -0
- package/dist/api/middlewares/transform-query.d.ts +6 -0
- package/dist/api/middlewares/transform-query.js +86 -0
- package/dist/api/middlewares/transform-query.js.map +1 -0
- package/dist/api/routes/admin/auth/create-session.js +5 -5
- package/dist/api/routes/admin/auth/create-session.js.map +1 -1
- package/dist/api/routes/admin/batch/index.d.ts +13 -0
- package/dist/api/routes/admin/batch/index.js +50 -0
- package/dist/api/routes/admin/batch/index.js.map +1 -0
- package/dist/api/routes/admin/batch/list-batch-jobs.d.ts +48 -0
- package/dist/api/routes/admin/batch/list-batch-jobs.js +220 -0
- package/dist/api/routes/admin/batch/list-batch-jobs.js.map +1 -0
- package/dist/api/routes/admin/customer-groups/list-customer-groups.js +2 -2
- package/dist/api/routes/admin/customer-groups/list-customer-groups.js.map +1 -1
- package/dist/api/routes/admin/discounts/create-condition.d.ts +58 -0
- package/dist/api/routes/admin/discounts/create-condition.js +186 -0
- package/dist/api/routes/admin/discounts/create-condition.js.map +1 -0
- package/dist/api/routes/admin/discounts/create-discount.d.ts +14 -4
- package/dist/api/routes/admin/discounts/create-discount.js +72 -16
- package/dist/api/routes/admin/discounts/create-discount.js.map +1 -1
- package/dist/api/routes/admin/discounts/create-dynamic-code.d.ts +1 -0
- package/dist/api/routes/admin/discounts/create-dynamic-code.js +4 -1
- package/dist/api/routes/admin/discounts/create-dynamic-code.js.map +1 -1
- package/dist/api/routes/admin/discounts/delete-condition.d.ts +36 -0
- package/dist/api/routes/admin/discounts/delete-condition.js +151 -0
- package/dist/api/routes/admin/discounts/delete-condition.js.map +1 -0
- package/dist/api/routes/admin/discounts/delete-dynamic-code.js +3 -1
- package/dist/api/routes/admin/discounts/delete-dynamic-code.js.map +1 -1
- package/dist/api/routes/admin/discounts/get-condition.d.ts +31 -0
- package/dist/api/routes/admin/discounts/get-condition.js +125 -0
- package/dist/api/routes/admin/discounts/get-condition.js.map +1 -0
- package/dist/api/routes/admin/discounts/get-discount-by-code.d.ts +4 -0
- package/dist/api/routes/admin/discounts/get-discount-by-code.js +40 -6
- package/dist/api/routes/admin/discounts/get-discount-by-code.js.map +1 -1
- package/dist/api/routes/admin/discounts/get-discount.d.ts +7 -0
- package/dist/api/routes/admin/discounts/get-discount.js +43 -9
- package/dist/api/routes/admin/discounts/get-discount.js.map +1 -1
- package/dist/api/routes/admin/discounts/index.d.ts +11 -3
- package/dist/api/routes/admin/discounts/index.js +13 -7
- package/dist/api/routes/admin/discounts/index.js.map +1 -1
- package/dist/api/routes/admin/discounts/list-discounts.d.ts +2 -6
- package/dist/api/routes/admin/discounts/list-discounts.js +15 -28
- package/dist/api/routes/admin/discounts/list-discounts.js.map +1 -1
- package/dist/api/routes/admin/discounts/update-condition.d.ts +55 -0
- package/dist/api/routes/admin/discounts/update-condition.js +184 -0
- package/dist/api/routes/admin/discounts/update-condition.js.map +1 -0
- package/dist/api/routes/admin/discounts/update-discount.d.ts +18 -12
- package/dist/api/routes/admin/discounts/update-discount.js +79 -33
- package/dist/api/routes/admin/discounts/update-discount.js.map +1 -1
- package/dist/api/routes/admin/draft-orders/create-draft-order.d.ts +3 -3
- package/dist/api/routes/admin/draft-orders/create-draft-order.js.map +1 -1
- package/dist/api/routes/admin/draft-orders/create-line-item.d.ts +1 -1
- package/dist/api/routes/admin/draft-orders/create-line-item.js.map +1 -1
- package/dist/api/routes/admin/draft-orders/index.d.ts +1 -1
- package/dist/api/routes/admin/draft-orders/index.js +7 -1
- package/dist/api/routes/admin/draft-orders/index.js.map +1 -1
- package/dist/api/routes/admin/draft-orders/list-draft-orders.js +7 -6
- package/dist/api/routes/admin/draft-orders/list-draft-orders.js.map +1 -1
- package/dist/api/routes/admin/draft-orders/register-payment.js +0 -1
- package/dist/api/routes/admin/draft-orders/register-payment.js.map +1 -1
- package/dist/api/routes/admin/draft-orders/update-line-item.d.ts +1 -1
- package/dist/api/routes/admin/draft-orders/update-line-item.js.map +1 -1
- package/dist/api/routes/admin/index.js +23 -19
- package/dist/api/routes/admin/index.js.map +1 -1
- package/dist/api/routes/admin/notifications/index.js.map +1 -1
- package/dist/api/routes/admin/notifications/list-notifications.js.map +1 -1
- package/dist/api/routes/admin/notifications/resend-notification.js.map +1 -1
- package/dist/api/routes/admin/orders/add-shipping-method.d.ts +1 -1
- package/dist/api/routes/admin/orders/add-shipping-method.js.map +1 -1
- package/dist/api/routes/admin/orders/create-claim.d.ts +4 -14
- package/dist/api/routes/admin/orders/create-claim.js +9 -14
- package/dist/api/routes/admin/orders/create-claim.js.map +1 -1
- package/dist/api/routes/admin/orders/create-order.js.map +1 -1
- package/dist/api/routes/admin/orders/create-swap.js +7 -3
- package/dist/api/routes/admin/orders/create-swap.js.map +1 -1
- package/dist/api/routes/admin/orders/fulfill-claim.d.ts +1 -1
- package/dist/api/routes/admin/orders/fulfill-claim.js.map +1 -1
- package/dist/api/routes/admin/orders/index.d.ts +1 -1
- package/dist/api/routes/admin/orders/index.js +1 -3
- package/dist/api/routes/admin/orders/index.js.map +1 -1
- package/dist/api/routes/admin/orders/list-orders.js.map +1 -1
- package/dist/api/routes/admin/orders/update-claim.d.ts +1 -1
- package/dist/api/routes/admin/orders/update-claim.js.map +1 -1
- package/dist/api/routes/admin/orders/update-order.js.map +1 -1
- package/dist/api/routes/admin/price-lists/add-prices-batch.d.ts +70 -0
- package/dist/api/routes/admin/price-lists/add-prices-batch.js +158 -0
- package/dist/api/routes/admin/price-lists/add-prices-batch.js.map +1 -0
- package/dist/api/routes/admin/price-lists/create-price-list.d.ts +88 -0
- package/dist/api/routes/admin/price-lists/create-price-list.js +190 -0
- package/dist/api/routes/admin/price-lists/create-price-list.js.map +1 -0
- package/dist/api/routes/admin/price-lists/delete-price-list.d.ts +28 -0
- package/dist/api/routes/admin/price-lists/delete-price-list.js +84 -0
- package/dist/api/routes/admin/price-lists/delete-price-list.js.map +1 -0
- package/dist/api/routes/admin/price-lists/delete-prices-batch.d.ts +43 -0
- package/dist/api/routes/admin/price-lists/delete-prices-batch.js +118 -0
- package/dist/api/routes/admin/price-lists/delete-prices-batch.js.map +1 -0
- package/dist/api/routes/admin/price-lists/delete-product-prices.d.ts +32 -0
- package/dist/api/routes/admin/price-lists/delete-product-prices.js +105 -0
- package/dist/api/routes/admin/price-lists/delete-product-prices.js.map +1 -0
- package/dist/api/routes/admin/price-lists/delete-variant-prices.d.ts +32 -0
- package/dist/api/routes/admin/price-lists/delete-variant-prices.js +105 -0
- package/dist/api/routes/admin/price-lists/delete-variant-prices.js.map +1 -0
- package/dist/api/routes/admin/price-lists/get-price-list.d.ts +22 -0
- package/dist/api/routes/admin/price-lists/get-price-list.js +78 -0
- package/dist/api/routes/admin/price-lists/get-price-list.js.map +1 -0
- package/dist/api/routes/admin/price-lists/index.d.ts +30 -0
- package/dist/api/routes/admin/price-lists/index.js +76 -0
- package/dist/api/routes/admin/price-lists/index.js.map +1 -0
- package/dist/api/routes/admin/price-lists/list-price-list-products.d.ts +75 -0
- package/dist/api/routes/admin/price-lists/list-price-list-products.js +255 -0
- package/dist/api/routes/admin/price-lists/list-price-list-products.js.map +1 -0
- package/dist/api/routes/admin/price-lists/list-price-lists.d.ts +39 -0
- package/dist/api/routes/admin/price-lists/list-price-lists.js +165 -0
- package/dist/api/routes/admin/price-lists/list-price-lists.js.map +1 -0
- package/dist/api/routes/admin/price-lists/update-price-list.d.ts +92 -0
- package/dist/api/routes/admin/price-lists/update-price-list.js +211 -0
- package/dist/api/routes/admin/price-lists/update-price-list.js.map +1 -0
- package/dist/api/routes/admin/product-tags/list-product-tags.d.ts +2 -1
- package/dist/api/routes/admin/product-tags/list-product-tags.js +6 -3
- package/dist/api/routes/admin/product-tags/list-product-tags.js.map +1 -1
- package/dist/api/routes/admin/product-types/list-product-types.d.ts +2 -1
- package/dist/api/routes/admin/product-types/list-product-types.js +6 -3
- package/dist/api/routes/admin/product-types/list-product-types.js.map +1 -1
- package/dist/api/routes/admin/products/create-product.d.ts +2 -7
- package/dist/api/routes/admin/products/create-product.js +2 -24
- package/dist/api/routes/admin/products/create-product.js.map +1 -1
- package/dist/api/routes/admin/products/create-variant.d.ts +7 -9
- package/dist/api/routes/admin/products/create-variant.js +7 -26
- package/dist/api/routes/admin/products/create-variant.js.map +1 -1
- package/dist/api/routes/admin/products/index.d.ts +3 -2
- package/dist/api/routes/admin/products/index.js +8 -3
- package/dist/api/routes/admin/products/index.js.map +1 -1
- package/dist/api/routes/admin/products/list-products.d.ts +2 -1
- package/dist/api/routes/admin/products/list-products.js +31 -65
- package/dist/api/routes/admin/products/list-products.js.map +1 -1
- package/dist/api/routes/admin/products/list-variants.d.ts +35 -0
- package/dist/api/routes/admin/products/list-variants.js +173 -0
- package/dist/api/routes/admin/products/list-variants.js.map +1 -0
- package/dist/api/routes/admin/products/update-product.d.ts +2 -7
- package/dist/api/routes/admin/products/update-product.js +2 -24
- package/dist/api/routes/admin/products/update-product.js.map +1 -1
- package/dist/api/routes/admin/products/update-variant.d.ts +10 -9
- package/dist/api/routes/admin/products/update-variant.js +21 -33
- package/dist/api/routes/admin/products/update-variant.js.map +1 -1
- package/dist/api/routes/admin/regions/index.d.ts +1 -1
- package/dist/api/routes/admin/shipping-options/list-shipping-options.d.ts +2 -2
- package/dist/api/routes/admin/shipping-options/list-shipping-options.js +2 -2
- package/dist/api/routes/admin/shipping-options/list-shipping-options.js.map +1 -1
- package/dist/api/routes/admin/store/get-store.js +4 -2
- package/dist/api/routes/admin/store/get-store.js.map +1 -1
- package/dist/api/routes/admin/store/update-store.d.ts +1 -0
- package/dist/api/routes/admin/store/update-store.js +5 -0
- package/dist/api/routes/admin/store/update-store.js.map +1 -1
- package/dist/api/routes/admin/swaps/index.js +3 -0
- package/dist/api/routes/admin/swaps/index.js.map +1 -1
- package/dist/api/routes/admin/tax-rates/list-tax-rates.js.map +1 -1
- package/dist/api/routes/admin/tax-rates/utils/get-query-config.d.ts +1 -1
- package/dist/api/routes/admin/tax-rates/utils/get-query-config.js +4 -2
- package/dist/api/routes/admin/tax-rates/utils/get-query-config.js.map +1 -1
- package/dist/api/routes/admin/uploads/index.d.ts +1 -1
- package/dist/api/routes/admin/users/update-user.d.ts +1 -1
- package/dist/api/routes/admin/users/update-user.js.map +1 -1
- package/dist/api/routes/store/auth/create-session.js +4 -5
- package/dist/api/routes/store/auth/create-session.js.map +1 -1
- package/dist/api/routes/store/carts/create-cart.js +8 -5
- package/dist/api/routes/store/carts/create-cart.js.map +1 -1
- package/dist/api/routes/store/carts/create-line-item.d.ts +1 -1
- package/dist/api/routes/store/carts/create-line-item.js +9 -6
- package/dist/api/routes/store/carts/create-line-item.js.map +1 -1
- package/dist/api/routes/store/carts/index.d.ts +0 -1
- package/dist/api/routes/store/carts/index.js +1 -3
- package/dist/api/routes/store/carts/index.js.map +1 -1
- package/dist/api/routes/store/carts/update-cart.js +8 -8
- package/dist/api/routes/store/carts/update-cart.js.map +1 -1
- package/dist/api/routes/store/collections/list-collections.d.ts +3 -0
- package/dist/api/routes/store/collections/list-collections.js +33 -16
- package/dist/api/routes/store/collections/list-collections.js.map +1 -1
- package/dist/api/routes/store/customers/create-customer.js +3 -4
- package/dist/api/routes/store/customers/create-customer.js.map +1 -1
- package/dist/api/routes/store/customers/get-payment-methods.js +6 -7
- package/dist/api/routes/store/customers/get-payment-methods.js.map +1 -1
- package/dist/api/routes/store/orders/index.js +0 -2
- package/dist/api/routes/store/orders/index.js.map +1 -1
- package/dist/api/routes/store/products/get-product.js +17 -5
- package/dist/api/routes/store/products/get-product.js.map +1 -1
- package/dist/api/routes/store/products/index.d.ts +2 -2
- package/dist/api/routes/store/products/list-products.d.ts +2 -2
- package/dist/api/routes/store/products/list-products.js +21 -14
- package/dist/api/routes/store/products/list-products.js.map +1 -1
- package/dist/api/routes/store/products/search.d.ts +1 -1
- package/dist/api/routes/store/products/search.js.map +1 -1
- package/dist/api/routes/store/regions/list-regions.d.ts +3 -0
- package/dist/api/routes/store/regions/list-regions.js +22 -7
- package/dist/api/routes/store/regions/list-regions.js.map +1 -1
- package/dist/api/routes/store/shipping-options/list-options.js.map +1 -1
- package/dist/api/routes/store/swaps/create-swap.js +7 -3
- package/dist/api/routes/store/swaps/create-swap.js.map +1 -1
- package/dist/api/routes/store/variants/get-variant.js +17 -5
- package/dist/api/routes/store/variants/get-variant.js.map +1 -1
- package/dist/api/routes/store/variants/list-variants.d.ts +2 -1
- package/dist/api/routes/store/variants/list-variants.js +38 -9
- package/dist/api/routes/store/variants/list-variants.js.map +1 -1
- package/dist/commands/develop.js +2 -2
- package/dist/commands/develop.js.map +1 -1
- package/dist/commands/migrate.js +17 -6
- package/dist/commands/migrate.js.map +1 -1
- package/dist/commands/start.js +6 -0
- package/dist/commands/start.js.map +1 -1
- package/dist/controllers/customers/index.d.ts +1 -1
- package/dist/controllers/customers/list-customers.d.ts +1 -1
- package/dist/controllers/customers/list-customers.js +34 -37
- package/dist/controllers/customers/list-customers.js.map +1 -1
- package/dist/controllers/products/admin-list-products.d.ts +16 -0
- package/dist/controllers/products/admin-list-products.js +103 -0
- package/dist/controllers/products/admin-list-products.js.map +1 -0
- package/dist/helpers/test-request.js +26 -17
- package/dist/helpers/test-request.js.map +1 -1
- package/dist/index.d.ts +4 -58
- package/dist/index.js +4 -61
- package/dist/index.js.map +1 -1
- package/dist/interfaces/base-service.d.ts +66 -0
- package/dist/interfaces/base-service.js +377 -0
- package/dist/interfaces/base-service.js.map +1 -0
- package/dist/interfaces/batch-job-strategy.d.ts +28 -0
- package/dist/interfaces/batch-job-strategy.js +75 -0
- package/dist/interfaces/batch-job-strategy.js.map +1 -0
- package/dist/interfaces/file-service.d.ts +62 -0
- package/dist/interfaces/file-service.js +32 -0
- package/dist/interfaces/file-service.js.map +1 -0
- package/dist/interfaces/index.d.ts +4 -0
- package/dist/interfaces/index.js +4 -0
- package/dist/interfaces/index.js.map +1 -1
- package/dist/interfaces/models/base-entity.d.ts +8 -0
- package/dist/interfaces/models/base-entity.js +36 -0
- package/dist/interfaces/models/base-entity.js.map +1 -0
- package/dist/interfaces/models/soft-deletable-entity.d.ts +4 -0
- package/dist/interfaces/models/soft-deletable-entity.js +43 -0
- package/dist/interfaces/models/soft-deletable-entity.js.map +1 -0
- package/dist/interfaces/price-selection-strategy.d.ts +50 -0
- package/dist/interfaces/price-selection-strategy.js +34 -0
- package/dist/interfaces/price-selection-strategy.js.map +1 -0
- package/dist/interfaces/tax-service.d.ts +6 -0
- package/dist/interfaces/tax-service.js +31 -0
- package/dist/interfaces/tax-service.js.map +1 -1
- package/dist/interfaces/transaction-base-service.d.ts +23 -0
- package/dist/interfaces/transaction-base-service.js +200 -0
- package/dist/interfaces/transaction-base-service.js.map +1 -0
- package/dist/loaders/api.d.ts +9 -5
- package/dist/loaders/api.js +2 -6
- package/dist/loaders/api.js.map +1 -1
- package/dist/loaders/config.d.ts +3 -0
- package/dist/loaders/config.js +47 -0
- package/dist/loaders/config.js.map +1 -0
- package/dist/loaders/database.d.ts +8 -4
- package/dist/loaders/database.js.map +1 -1
- package/dist/loaders/defaults.d.ts +4 -3
- package/dist/loaders/defaults.js +39 -31
- package/dist/loaders/defaults.js.map +1 -1
- package/dist/loaders/express.d.ts +7 -4
- package/dist/loaders/express.js +7 -5
- package/dist/loaders/express.js.map +1 -1
- package/dist/loaders/index.d.ts +13 -8
- package/dist/loaders/index.js +29 -54
- package/dist/loaders/index.js.map +1 -1
- package/dist/loaders/logger.d.ts +1 -0
- package/dist/loaders/logger.js.map +1 -1
- package/dist/loaders/models.d.ts +8 -3
- package/dist/loaders/models.js +19 -17
- package/dist/loaders/models.js.map +1 -1
- package/dist/loaders/passport.d.ts +7 -4
- package/dist/loaders/passport.js +23 -21
- package/dist/loaders/passport.js.map +1 -1
- package/dist/loaders/plugins.d.ts +38 -10
- package/dist/loaders/plugins.js +43 -30
- package/dist/loaders/plugins.js.map +1 -1
- package/dist/loaders/redis.d.ts +8 -5
- package/dist/loaders/redis.js +3 -3
- package/dist/loaders/redis.js.map +1 -1
- package/dist/loaders/repositories.d.ts +7 -3
- package/dist/loaders/repositories.js +1 -1
- package/dist/loaders/repositories.js.map +1 -1
- package/dist/loaders/search-index.d.ts +4 -3
- package/dist/loaders/search-index.js.map +1 -1
- package/dist/loaders/services.d.ts +10 -5
- package/dist/loaders/services.js.map +1 -1
- package/dist/loaders/strategies.d.ts +1 -1
- package/dist/loaders/subscribers.d.ts +7 -3
- package/dist/loaders/subscribers.js.map +1 -1
- package/dist/migrations/1646324713514-discount_conditions.d.ts +6 -0
- package/dist/migrations/1646324713514-discount_conditions.js +335 -0
- package/dist/migrations/1646324713514-discount_conditions.js.map +1 -0
- package/dist/migrations/1646915480108-update_money_amount_add_price_list.d.ts +6 -0
- package/dist/migrations/1646915480108-update_money_amount_add_price_list.js +143 -0
- package/dist/migrations/1646915480108-update_money_amount_add_price_list.js.map +1 -0
- package/dist/migrations/1648600574750-add_line_item_adjustments.d.ts +6 -0
- package/dist/migrations/1648600574750-add_line_item_adjustments.js +101 -0
- package/dist/migrations/1648600574750-add_line_item_adjustments.js.map +1 -0
- package/dist/migrations/1648641130007-tax_line_constraints.d.ts +6 -0
- package/dist/migrations/1648641130007-tax_line_constraints.js +77 -0
- package/dist/migrations/1648641130007-tax_line_constraints.js.map +1 -0
- package/dist/migrations/1649775522087-add_batch_job_model.d.ts +6 -0
- package/dist/migrations/1649775522087-add_batch_job_model.js +77 -0
- package/dist/migrations/1649775522087-add_batch_job_model.js.map +1 -0
- package/dist/models/address.d.ts +3 -6
- package/dist/models/address.js +23 -24
- package/dist/models/address.js.map +1 -1
- package/dist/models/batch-job.d.ts +55 -0
- package/dist/models/batch-job.js +118 -0
- package/dist/models/batch-job.js.map +1 -0
- package/dist/models/cart.d.ts +5 -8
- package/dist/models/cart.js +35 -36
- package/dist/models/cart.js.map +1 -1
- package/dist/models/claim-image.d.ts +3 -6
- package/dist/models/claim-image.js +22 -23
- package/dist/models/claim-image.js.map +1 -1
- package/dist/models/claim-item.d.ts +3 -6
- package/dist/models/claim-item.js +25 -24
- package/dist/models/claim-item.js.map +1 -1
- package/dist/models/claim-order.d.ts +4 -4
- package/dist/models/claim-order.js +28 -13
- package/dist/models/claim-order.js.map +1 -1
- package/dist/models/claim-tag.d.ts +3 -6
- package/dist/models/claim-tag.js +22 -23
- package/dist/models/claim-tag.js.map +1 -1
- package/dist/models/country.d.ts +1 -1
- package/dist/models/country.js +1 -1
- package/dist/models/country.js.map +1 -1
- package/dist/models/custom-shipping-option.d.ts +3 -6
- package/dist/models/custom-shipping-option.js +23 -24
- package/dist/models/custom-shipping-option.js.map +1 -1
- package/dist/models/customer-group.d.ts +6 -7
- package/dist/models/customer-group.js +30 -36
- package/dist/models/customer-group.js.map +1 -1
- package/dist/models/customer.d.ts +3 -6
- package/dist/models/customer.js +23 -25
- package/dist/models/customer.js.map +1 -1
- package/dist/models/discount-condition-customer-group.d.ts +39 -0
- package/dist/models/discount-condition-customer-group.js +84 -0
- package/dist/models/discount-condition-customer-group.js.map +1 -0
- package/dist/models/discount-condition-product-collection.d.ts +39 -0
- package/dist/models/discount-condition-product-collection.js +84 -0
- package/dist/models/discount-condition-product-collection.js.map +1 -0
- package/dist/models/discount-condition-product-tag.d.ts +39 -0
- package/dist/models/discount-condition-product-tag.js +84 -0
- package/dist/models/discount-condition-product-tag.js.map +1 -0
- package/dist/models/discount-condition-product-type.d.ts +39 -0
- package/dist/models/discount-condition-product-type.js +84 -0
- package/dist/models/discount-condition-product-type.js.map +1 -0
- package/dist/models/discount-condition-product.d.ts +39 -0
- package/dist/models/discount-condition-product.js +84 -0
- package/dist/models/discount-condition-product.js.map +1 -0
- package/dist/models/discount-condition.d.ts +65 -0
- package/dist/models/discount-condition.js +209 -0
- package/dist/models/discount-condition.js.map +1 -0
- package/dist/models/discount-rule.d.ts +8 -11
- package/dist/models/discount-rule.js +28 -38
- package/dist/models/discount-rule.js.map +1 -1
- package/dist/models/discount.d.ts +7 -10
- package/dist/models/discount.js +30 -30
- package/dist/models/discount.js.map +1 -1
- package/dist/models/draft-order.d.ts +4 -7
- package/dist/models/draft-order.js +25 -22
- package/dist/models/draft-order.js.map +1 -1
- package/dist/models/fulfillment-item.js.map +1 -1
- package/dist/models/fulfillment-provider.js.map +1 -1
- package/dist/models/fulfillment.d.ts +5 -7
- package/dist/models/fulfillment.js +29 -21
- package/dist/models/fulfillment.js.map +1 -1
- package/dist/models/gift-card-transaction.js +2 -5
- package/dist/models/gift-card-transaction.js.map +1 -1
- package/dist/models/gift-card.d.ts +3 -6
- package/dist/models/gift-card.js +22 -23
- package/dist/models/gift-card.js.map +1 -1
- package/dist/models/idempotency-key.d.ts +2 -2
- package/dist/models/idempotency-key.js +2 -3
- package/dist/models/idempotency-key.js.map +1 -1
- package/dist/models/image.d.ts +3 -6
- package/dist/models/image.js +22 -23
- package/dist/models/image.js.map +1 -1
- package/dist/models/index.d.ts +67 -0
- package/dist/models/index.js +80 -0
- package/dist/models/index.js.map +1 -0
- package/dist/models/invite.d.ts +3 -6
- package/dist/models/invite.js +22 -24
- package/dist/models/invite.js.map +1 -1
- package/dist/models/line-item-adjustment.d.ts +13 -0
- package/dist/models/line-item-adjustment.js +76 -0
- package/dist/models/line-item-adjustment.js.map +1 -0
- package/dist/models/line-item-tax-line.js +4 -6
- package/dist/models/line-item-tax-line.js.map +1 -1
- package/dist/models/line-item.d.ts +5 -5
- package/dist/models/line-item.js +29 -19
- package/dist/models/line-item.js.map +1 -1
- package/dist/models/money-amount.d.ts +12 -8
- package/dist/models/money-amount.js +47 -30
- package/dist/models/money-amount.js.map +1 -1
- package/dist/models/note.d.ts +3 -6
- package/dist/models/note.js +22 -23
- package/dist/models/note.js.map +1 -1
- package/dist/models/notification.d.ts +3 -5
- package/dist/models/notification.js +22 -19
- package/dist/models/notification.js.map +1 -1
- package/dist/models/oauth.d.ts +1 -1
- package/dist/models/oauth.js +2 -5
- package/dist/models/oauth.js.map +1 -1
- package/dist/models/order.d.ts +3 -5
- package/dist/models/order.js +25 -21
- package/dist/models/order.js.map +1 -1
- package/dist/models/payment-provider.js.map +1 -1
- package/dist/models/payment-session.d.ts +3 -5
- package/dist/models/payment-session.js +22 -19
- package/dist/models/payment-session.js.map +1 -1
- package/dist/models/payment.d.ts +4 -6
- package/dist/models/payment.js +22 -19
- package/dist/models/payment.js.map +1 -1
- package/dist/models/price-list.d.ts +54 -0
- package/dist/models/price-list.js +144 -0
- package/dist/models/price-list.js.map +1 -0
- package/dist/models/product-collection.d.ts +4 -7
- package/dist/models/product-collection.js +25 -24
- package/dist/models/product-collection.js.map +1 -1
- package/dist/models/product-option-value.d.ts +3 -6
- package/dist/models/product-option-value.js +24 -26
- package/dist/models/product-option-value.js.map +1 -1
- package/dist/models/product-option.d.ts +3 -6
- package/dist/models/product-option.js +23 -24
- package/dist/models/product-option.js.map +1 -1
- package/dist/models/product-tag.d.ts +3 -6
- package/dist/models/product-tag.js +22 -23
- package/dist/models/product-tag.js.map +1 -1
- package/dist/models/product-tax-rate.d.ts +1 -1
- package/dist/models/product-tax-rate.js.map +1 -1
- package/dist/models/product-type-tax-rate.d.ts +1 -1
- package/dist/models/product-type-tax-rate.js.map +1 -1
- package/dist/models/product-type.d.ts +3 -6
- package/dist/models/product-type.js +22 -23
- package/dist/models/product-type.js.map +1 -1
- package/dist/models/product-variant.d.ts +3 -6
- package/dist/models/product-variant.js +30 -26
- package/dist/models/product-variant.js.map +1 -1
- package/dist/models/product.d.ts +3 -6
- package/dist/models/product.js +25 -22
- package/dist/models/product.js.map +1 -1
- package/dist/models/refund.d.ts +3 -5
- package/dist/models/refund.js +22 -17
- package/dist/models/refund.js.map +1 -1
- package/dist/models/region.d.ts +3 -6
- package/dist/models/region.js +23 -24
- package/dist/models/region.js.map +1 -1
- package/dist/models/return-item.d.ts +1 -1
- package/dist/models/return-item.js.map +1 -1
- package/dist/models/return-reason.d.ts +3 -6
- package/dist/models/return-reason.js +24 -25
- package/dist/models/return-reason.js.map +1 -1
- package/dist/models/return.d.ts +5 -7
- package/dist/models/return.js +29 -21
- package/dist/models/return.js.map +1 -1
- package/dist/models/shipping-method-tax-line.js +4 -6
- package/dist/models/shipping-method-tax-line.js.map +1 -1
- package/dist/models/shipping-method.d.ts +2 -2
- package/dist/models/shipping-method.js +3 -6
- package/dist/models/shipping-method.js.map +1 -1
- package/dist/models/shipping-option-requirement.js +2 -5
- package/dist/models/shipping-option-requirement.js.map +1 -1
- package/dist/models/shipping-option.d.ts +5 -8
- package/dist/models/shipping-option.js +26 -25
- package/dist/models/shipping-option.js.map +1 -1
- package/dist/models/shipping-profile.d.ts +3 -6
- package/dist/models/shipping-profile.js +22 -23
- package/dist/models/shipping-profile.js.map +1 -1
- package/dist/models/shipping-tax-rate.d.ts +1 -1
- package/dist/models/shipping-tax-rate.js.map +1 -1
- package/dist/models/staged-job.d.ts +1 -1
- package/dist/models/staged-job.js +2 -3
- package/dist/models/staged-job.js.map +1 -1
- package/dist/models/store.d.ts +3 -5
- package/dist/models/store.js +22 -17
- package/dist/models/store.js.map +1 -1
- package/dist/models/swap.d.ts +9 -12
- package/dist/models/swap.js +55 -52
- package/dist/models/swap.js.map +1 -1
- package/dist/models/tax-line.d.ts +3 -5
- package/dist/models/tax-line.js +20 -14
- package/dist/models/tax-line.js.map +1 -1
- package/dist/models/tax-rate.d.ts +3 -5
- package/dist/models/tax-rate.js +22 -19
- package/dist/models/tax-rate.js.map +1 -1
- package/dist/models/tracking-link.d.ts +3 -6
- package/dist/models/tracking-link.js +26 -27
- package/dist/models/tracking-link.js.map +1 -1
- package/dist/models/user.d.ts +3 -6
- package/dist/models/user.js +22 -23
- package/dist/models/user.js.map +1 -1
- package/dist/repositories/batch-job.d.ts +4 -0
- package/dist/repositories/batch-job.js +38 -0
- package/dist/repositories/batch-job.js.map +1 -0
- package/dist/repositories/cart.d.ts +2 -2
- package/dist/repositories/cart.js.map +1 -1
- package/dist/repositories/customer.d.ts +1 -1
- package/dist/repositories/customer.js +7 -9
- package/dist/repositories/customer.js.map +1 -1
- package/dist/repositories/discount-condition.d.ts +38 -0
- package/dist/repositories/discount-condition.js +398 -0
- package/dist/repositories/discount-condition.js.map +1 -0
- package/dist/repositories/line-item-adjustment.d.ts +4 -0
- package/dist/repositories/line-item-adjustment.js +38 -0
- package/dist/repositories/line-item-adjustment.js.map +1 -0
- package/dist/repositories/line-item-tax-line.d.ts +2 -0
- package/dist/repositories/line-item-tax-line.js +80 -0
- package/dist/repositories/line-item-tax-line.js.map +1 -1
- package/dist/repositories/line-item.js +1 -0
- package/dist/repositories/line-item.js.map +1 -1
- package/dist/repositories/money-amount.d.ts +8 -2
- package/dist/repositories/money-amount.js +177 -2
- package/dist/repositories/money-amount.js.map +1 -1
- package/dist/repositories/order.d.ts +1 -1
- package/dist/repositories/price-list.d.ts +11 -0
- package/dist/repositories/price-list.js +247 -0
- package/dist/repositories/price-list.js.map +1 -0
- package/dist/repositories/product.d.ts +5 -1
- package/dist/repositories/product.js +96 -18
- package/dist/repositories/product.js.map +1 -1
- package/dist/repositories/shipping-method-tax-line.d.ts +2 -0
- package/dist/repositories/shipping-method-tax-line.js +80 -0
- package/dist/repositories/shipping-method-tax-line.js.map +1 -1
- package/dist/scripts/discount-rule-migration.d.ts +4 -0
- package/dist/scripts/discount-rule-migration.js +189 -0
- package/dist/scripts/discount-rule-migration.js.map +1 -0
- package/dist/scripts/line-item-adjustment-migration.d.ts +4 -0
- package/dist/scripts/line-item-adjustment-migration.js +173 -0
- package/dist/scripts/line-item-adjustment-migration.js.map +1 -0
- package/dist/services/batch-job.d.ts +24 -0
- package/dist/services/batch-job.js +126 -0
- package/dist/services/batch-job.js.map +1 -0
- package/dist/services/cart.d.ts +66 -55
- package/dist/services/cart.js +1315 -1405
- package/dist/services/cart.js.map +1 -1
- package/dist/services/claim-item.d.ts +23 -27
- package/dist/services/claim-item.js +217 -247
- package/dist/services/claim-item.js.map +1 -1
- package/dist/services/claim.d.ts +89 -71
- package/dist/services/claim.js +915 -840
- package/dist/services/claim.js.map +1 -1
- package/dist/services/customer.d.ts +0 -7
- package/dist/services/customer.js +8 -35
- package/dist/services/customer.js.map +1 -1
- package/dist/services/discount-condition.d.ts +31 -0
- package/dist/services/discount-condition.js +232 -0
- package/dist/services/discount-condition.js.map +1 -0
- package/dist/services/discount.d.ts +50 -59
- package/dist/services/discount.js +274 -176
- package/dist/services/discount.js.map +1 -1
- package/dist/services/draft-order.d.ts +69 -66
- package/dist/services/draft-order.js +375 -352
- package/dist/services/draft-order.js.map +1 -1
- package/dist/services/event-bus.d.ts +72 -56
- package/dist/services/event-bus.js +122 -99
- package/dist/services/event-bus.js.map +1 -1
- package/dist/services/file.d.ts +14 -0
- package/dist/services/file.js +43 -0
- package/dist/services/file.js.map +1 -0
- package/dist/services/fulfillment-provider.js +23 -17
- package/dist/services/fulfillment-provider.js.map +1 -1
- package/dist/services/invite.d.ts +4 -2
- package/dist/services/invite.js +11 -9
- package/dist/services/invite.js.map +1 -1
- package/dist/services/line-item-adjustment.d.ts +87 -0
- package/dist/services/line-item-adjustment.js +434 -0
- package/dist/services/line-item-adjustment.js.map +1 -0
- package/dist/services/line-item.d.ts +48 -40
- package/dist/services/line-item.js +226 -193
- package/dist/services/line-item.js.map +1 -1
- package/dist/services/order.d.ts +0 -13
- package/dist/services/order.js +4 -30
- package/dist/services/order.js.map +1 -1
- package/dist/services/payment-provider.js +23 -17
- package/dist/services/payment-provider.js.map +1 -1
- package/dist/services/price-list.d.ts +107 -0
- package/dist/services/price-list.js +740 -0
- package/dist/services/price-list.js.map +1 -0
- package/dist/services/pricing.d.ts +87 -0
- package/dist/services/pricing.js +443 -0
- package/dist/services/pricing.js.map +1 -0
- package/dist/services/product-tag.d.ts +2 -2
- package/dist/services/product-tag.js +15 -2
- package/dist/services/product-tag.js.map +1 -1
- package/dist/services/product-type.d.ts +1 -1
- package/dist/services/product-type.js +14 -1
- package/dist/services/product-type.js.map +1 -1
- package/dist/services/product-variant.d.ts +40 -16
- package/dist/services/product-variant.js +259 -109
- package/dist/services/product-variant.js.map +1 -1
- package/dist/services/product.d.ts +22 -11
- package/dist/services/product.js +251 -87
- package/dist/services/product.js.map +1 -1
- package/dist/services/region.js +12 -8
- package/dist/services/region.js.map +1 -1
- package/dist/services/return.js +2 -1
- package/dist/services/return.js.map +1 -1
- package/dist/services/shipping-option.d.ts +44 -109
- package/dist/services/shipping-option.js +309 -353
- package/dist/services/shipping-option.js.map +1 -1
- package/dist/services/store.d.ts +36 -45
- package/dist/services/store.js +207 -217
- package/dist/services/store.js.map +1 -1
- package/dist/services/swap.d.ts +4 -1
- package/dist/services/swap.js +29 -16
- package/dist/services/swap.js.map +1 -1
- package/dist/services/system-tax.d.ts +2 -3
- package/dist/services/system-tax.js +2 -2
- package/dist/services/system-tax.js.map +1 -1
- package/dist/services/tax-provider.d.ts +2 -0
- package/dist/services/tax-provider.js +96 -7
- package/dist/services/tax-provider.js.map +1 -1
- package/dist/services/tax-rate.d.ts +3 -3
- package/dist/services/tax-rate.js +1 -1
- package/dist/services/tax-rate.js.map +1 -1
- package/dist/services/totals.d.ts +9 -8
- package/dist/services/totals.js +41 -88
- package/dist/services/totals.js.map +1 -1
- package/dist/strategies/cart-completion.js.map +1 -1
- package/dist/strategies/price-selection.d.ts +13 -0
- package/dist/strategies/price-selection.js +185 -0
- package/dist/strategies/price-selection.js.map +1 -0
- package/dist/subscribers/order.js +1 -7
- package/dist/subscribers/order.js.map +1 -1
- package/dist/types/batch-job.d.ts +15 -0
- package/dist/types/batch-job.js +63 -0
- package/dist/types/batch-job.js.map +1 -0
- package/dist/types/cart.d.ts +2 -2
- package/dist/types/claim.d.ts +67 -0
- package/dist/types/claim.js +3 -0
- package/dist/types/claim.js.map +1 -0
- package/dist/types/common.d.ts +53 -13
- package/dist/types/common.js +1 -0
- package/dist/types/common.js.map +1 -1
- package/dist/types/discount.d.ts +68 -1
- package/dist/types/discount.js +129 -5
- package/dist/types/discount.js.map +1 -1
- package/dist/types/global.d.ts +53 -0
- package/dist/types/global.js +3 -0
- package/dist/types/global.js.map +1 -0
- package/dist/types/line-item-adjustment.d.ts +9 -0
- package/dist/types/line-item-adjustment.js +50 -0
- package/dist/types/line-item-adjustment.js.map +1 -0
- package/dist/types/note.d.ts +1 -1
- package/dist/types/price-list.d.ts +73 -0
- package/dist/types/price-list.js +157 -0
- package/dist/types/price-list.js.map +1 -0
- package/dist/types/price-selection.d.ts +5 -0
- package/dist/types/price-selection.js +35 -0
- package/dist/types/price-selection.js.map +1 -0
- package/dist/types/pricing.d.ts +25 -0
- package/dist/types/pricing.js +3 -0
- package/dist/types/pricing.js.map +1 -0
- package/dist/types/product-variant.d.ts +24 -1
- package/dist/types/product-variant.js +65 -1
- package/dist/types/product-variant.js.map +1 -1
- package/dist/types/product.d.ts +18 -0
- package/dist/types/product.js +104 -5
- package/dist/types/product.js.map +1 -1
- package/dist/types/shipping-options.d.ts +56 -0
- package/dist/types/shipping-options.js +3 -0
- package/dist/types/shipping-options.js.map +1 -0
- package/dist/types/store.d.ts +9 -0
- package/dist/types/store.js +3 -0
- package/dist/types/store.js.map +1 -0
- package/dist/types/tax-service.d.ts +2 -2
- package/dist/types/user.d.ts +2 -2
- package/dist/types/validators/exactly-one.d.ts +6 -0
- package/dist/types/validators/exactly-one.js +37 -0
- package/dist/types/validators/exactly-one.js.map +1 -0
- package/dist/utils/build-query.d.ts +8 -0
- package/dist/utils/build-query.js +114 -0
- package/dist/utils/build-query.js.map +1 -0
- package/dist/utils/countries.d.ts +3 -2
- package/dist/utils/countries.js.map +1 -1
- package/dist/utils/currencies.d.ts +10 -1899
- package/dist/utils/currencies.js.map +1 -1
- package/dist/utils/date-helpers.d.ts +2 -0
- package/dist/utils/date-helpers.js +15 -0
- package/dist/utils/date-helpers.js.map +1 -0
- package/dist/utils/format-registration-name.d.ts +4 -4
- package/dist/utils/format-registration-name.js +7 -10
- package/dist/utils/format-registration-name.js.map +1 -1
- package/dist/utils/generate-entity-id.d.ts +6 -0
- package/dist/utils/generate-entity-id.js +19 -0
- package/dist/utils/generate-entity-id.js.map +1 -0
- package/dist/utils/get-query-config.d.ts +9 -0
- package/dist/utils/get-query-config.js +133 -0
- package/dist/utils/get-query-config.js.map +1 -0
- package/dist/utils/index.d.ts +4 -0
- package/dist/utils/index.js +17 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/set-metadata.d.ts +9 -0
- package/dist/utils/set-metadata.js +72 -0
- package/dist/utils/set-metadata.js.map +1 -0
- package/dist/utils/sleep.d.ts +1 -0
- package/dist/utils/sleep.js +50 -0
- package/dist/utils/sleep.js.map +1 -0
- package/dist/utils/validate-id.d.ts +4 -0
- package/dist/utils/validate-id.js +47 -0
- package/dist/utils/validate-id.js.map +1 -0
- package/jest.config.js +6 -0
- package/package.json +11 -9
- package/tsconfig.spec.json +10 -0
- package/yarn-error.log +23292 -1023
|
@@ -0,0 +1,740 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
var __assign = (this && this.__assign) || function () {
|
|
18
|
+
__assign = Object.assign || function(t) {
|
|
19
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
20
|
+
s = arguments[i];
|
|
21
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
22
|
+
t[p] = s[p];
|
|
23
|
+
}
|
|
24
|
+
return t;
|
|
25
|
+
};
|
|
26
|
+
return __assign.apply(this, arguments);
|
|
27
|
+
};
|
|
28
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
29
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
30
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
31
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
32
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
33
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
34
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
38
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
39
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
40
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
41
|
+
function step(op) {
|
|
42
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
43
|
+
while (_) try {
|
|
44
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
45
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
46
|
+
switch (op[0]) {
|
|
47
|
+
case 0: case 1: t = op; break;
|
|
48
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
49
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
50
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
51
|
+
default:
|
|
52
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
53
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
54
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
55
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
56
|
+
if (t[2]) _.ops.pop();
|
|
57
|
+
_.trys.pop(); continue;
|
|
58
|
+
}
|
|
59
|
+
op = body.call(thisArg, _);
|
|
60
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
61
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
65
|
+
var t = {};
|
|
66
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
67
|
+
t[p] = s[p];
|
|
68
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
69
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
70
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
71
|
+
t[p[i]] = s[p[i]];
|
|
72
|
+
}
|
|
73
|
+
return t;
|
|
74
|
+
};
|
|
75
|
+
var __values = (this && this.__values) || function(o) {
|
|
76
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
77
|
+
if (m) return m.call(o);
|
|
78
|
+
if (o && typeof o.length === "number") return {
|
|
79
|
+
next: function () {
|
|
80
|
+
if (o && i >= o.length) o = void 0;
|
|
81
|
+
return { value: o && o[i++], done: !o };
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
85
|
+
};
|
|
86
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
87
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
88
|
+
if (!m) return o;
|
|
89
|
+
var i = m.call(o), r, ar = [], e;
|
|
90
|
+
try {
|
|
91
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
92
|
+
}
|
|
93
|
+
catch (error) { e = { error: error }; }
|
|
94
|
+
finally {
|
|
95
|
+
try {
|
|
96
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
97
|
+
}
|
|
98
|
+
finally { if (e) throw e.error; }
|
|
99
|
+
}
|
|
100
|
+
return ar;
|
|
101
|
+
};
|
|
102
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
103
|
+
var medusa_core_utils_1 = require("medusa-core-utils");
|
|
104
|
+
var exception_formatter_1 = require("../utils/exception-formatter");
|
|
105
|
+
var interfaces_1 = require("../interfaces");
|
|
106
|
+
var utils_1 = require("../utils");
|
|
107
|
+
/**
|
|
108
|
+
* Provides layer to manipulate product tags.
|
|
109
|
+
* @extends BaseService
|
|
110
|
+
*/
|
|
111
|
+
var PriceListService = /** @class */ (function (_super) {
|
|
112
|
+
__extends(PriceListService, _super);
|
|
113
|
+
function PriceListService(_a) {
|
|
114
|
+
var manager = _a.manager, customerGroupService = _a.customerGroupService, regionService = _a.regionService, productService = _a.productService, productVariantService = _a.productVariantService, priceListRepository = _a.priceListRepository, moneyAmountRepository = _a.moneyAmountRepository;
|
|
115
|
+
var _this =
|
|
116
|
+
// eslint-disable-next-line prefer-rest-params
|
|
117
|
+
_super.call(this, arguments[0]) || this;
|
|
118
|
+
_this.manager_ = manager;
|
|
119
|
+
_this.customerGroupService_ = customerGroupService;
|
|
120
|
+
_this.productService_ = productService;
|
|
121
|
+
_this.variantService_ = productVariantService;
|
|
122
|
+
_this.regionService_ = regionService;
|
|
123
|
+
_this.priceListRepo_ = priceListRepository;
|
|
124
|
+
_this.moneyAmountRepo_ = moneyAmountRepository;
|
|
125
|
+
return _this;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Retrieves a product tag by id.
|
|
129
|
+
* @param {string} priceListId - the id of the product tag to retrieve
|
|
130
|
+
* @param {Object} config - the config to retrieve the tag by
|
|
131
|
+
* @return {Promise<PriceList>} the collection.
|
|
132
|
+
*/
|
|
133
|
+
PriceListService.prototype.retrieve = function (priceListId, config) {
|
|
134
|
+
if (config === void 0) { config = {}; }
|
|
135
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
136
|
+
var priceListRepo, query, priceList;
|
|
137
|
+
return __generator(this, function (_a) {
|
|
138
|
+
switch (_a.label) {
|
|
139
|
+
case 0:
|
|
140
|
+
priceListRepo = this.manager_.getCustomRepository(this.priceListRepo_);
|
|
141
|
+
query = (0, utils_1.buildQuery)({ id: priceListId }, config);
|
|
142
|
+
return [4 /*yield*/, priceListRepo.findOne(query)];
|
|
143
|
+
case 1:
|
|
144
|
+
priceList = _a.sent();
|
|
145
|
+
if (!priceList) {
|
|
146
|
+
throw new medusa_core_utils_1.MedusaError(medusa_core_utils_1.MedusaError.Types.NOT_FOUND, "Price list with id: ".concat(priceListId, " was not found"));
|
|
147
|
+
}
|
|
148
|
+
return [2 /*return*/, priceList];
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
});
|
|
152
|
+
};
|
|
153
|
+
/**
|
|
154
|
+
* Creates a Price List
|
|
155
|
+
* @param {CreatePriceListInput} priceListObject - the Price List to create
|
|
156
|
+
* @return {Promise<PriceList>} created Price List
|
|
157
|
+
*/
|
|
158
|
+
PriceListService.prototype.create = function (priceListObject) {
|
|
159
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
160
|
+
var _this = this;
|
|
161
|
+
return __generator(this, function (_a) {
|
|
162
|
+
switch (_a.label) {
|
|
163
|
+
case 0: return [4 /*yield*/, this.atomicPhase_(function (manager) { return __awaiter(_this, void 0, void 0, function () {
|
|
164
|
+
var priceListRepo, moneyAmountRepo, prices, customer_groups, rest, entity, priceList, result, error_1;
|
|
165
|
+
return __generator(this, function (_a) {
|
|
166
|
+
switch (_a.label) {
|
|
167
|
+
case 0:
|
|
168
|
+
priceListRepo = manager.getCustomRepository(this.priceListRepo_);
|
|
169
|
+
moneyAmountRepo = manager.getCustomRepository(this.moneyAmountRepo_);
|
|
170
|
+
prices = priceListObject.prices, customer_groups = priceListObject.customer_groups, rest = __rest(priceListObject, ["prices", "customer_groups"]);
|
|
171
|
+
_a.label = 1;
|
|
172
|
+
case 1:
|
|
173
|
+
_a.trys.push([1, 8, , 9]);
|
|
174
|
+
entity = priceListRepo.create(rest);
|
|
175
|
+
return [4 /*yield*/, priceListRepo.save(entity)];
|
|
176
|
+
case 2:
|
|
177
|
+
priceList = _a.sent();
|
|
178
|
+
if (!prices) return [3 /*break*/, 4];
|
|
179
|
+
return [4 /*yield*/, moneyAmountRepo.addPriceListPrices(priceList.id, prices)];
|
|
180
|
+
case 3:
|
|
181
|
+
_a.sent();
|
|
182
|
+
_a.label = 4;
|
|
183
|
+
case 4:
|
|
184
|
+
if (!customer_groups) return [3 /*break*/, 6];
|
|
185
|
+
return [4 /*yield*/, this.upsertCustomerGroups_(priceList.id, customer_groups)];
|
|
186
|
+
case 5:
|
|
187
|
+
_a.sent();
|
|
188
|
+
_a.label = 6;
|
|
189
|
+
case 6: return [4 /*yield*/, this.retrieve(priceList.id, {
|
|
190
|
+
relations: ["prices", "customer_groups"],
|
|
191
|
+
})];
|
|
192
|
+
case 7:
|
|
193
|
+
result = _a.sent();
|
|
194
|
+
return [2 /*return*/, result];
|
|
195
|
+
case 8:
|
|
196
|
+
error_1 = _a.sent();
|
|
197
|
+
throw (0, exception_formatter_1.formatException)(error_1);
|
|
198
|
+
case 9: return [2 /*return*/];
|
|
199
|
+
}
|
|
200
|
+
});
|
|
201
|
+
}); })];
|
|
202
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
});
|
|
206
|
+
};
|
|
207
|
+
/**
|
|
208
|
+
* Updates a Price List
|
|
209
|
+
* @param {string} id - the id of the Product List to update
|
|
210
|
+
* @param {UpdatePriceListInput} update - the update to apply
|
|
211
|
+
* @returns {Promise<PriceList>} updated Price List
|
|
212
|
+
*/
|
|
213
|
+
PriceListService.prototype.update = function (id, update) {
|
|
214
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
215
|
+
var _this = this;
|
|
216
|
+
return __generator(this, function (_a) {
|
|
217
|
+
switch (_a.label) {
|
|
218
|
+
case 0: return [4 /*yield*/, this.atomicPhase_(function (manager) { return __awaiter(_this, void 0, void 0, function () {
|
|
219
|
+
var priceListRepo, moneyAmountRepo, priceList, prices, customer_groups, rest, prices_, _a, _b, _c, key, value;
|
|
220
|
+
var e_1, _d;
|
|
221
|
+
return __generator(this, function (_e) {
|
|
222
|
+
switch (_e.label) {
|
|
223
|
+
case 0:
|
|
224
|
+
priceListRepo = manager.getCustomRepository(this.priceListRepo_);
|
|
225
|
+
moneyAmountRepo = manager.getCustomRepository(this.moneyAmountRepo_);
|
|
226
|
+
return [4 /*yield*/, this.retrieve(id, { select: ["id"] })];
|
|
227
|
+
case 1:
|
|
228
|
+
priceList = _e.sent();
|
|
229
|
+
prices = update.prices, customer_groups = update.customer_groups, rest = __rest(update, ["prices", "customer_groups"]);
|
|
230
|
+
if (!prices) return [3 /*break*/, 4];
|
|
231
|
+
return [4 /*yield*/, this.addCurrencyFromRegion(prices)];
|
|
232
|
+
case 2:
|
|
233
|
+
prices_ = _e.sent();
|
|
234
|
+
return [4 /*yield*/, moneyAmountRepo.updatePriceListPrices(id, prices_)];
|
|
235
|
+
case 3:
|
|
236
|
+
_e.sent();
|
|
237
|
+
_e.label = 4;
|
|
238
|
+
case 4:
|
|
239
|
+
if (!customer_groups) return [3 /*break*/, 6];
|
|
240
|
+
return [4 /*yield*/, this.upsertCustomerGroups_(id, customer_groups)];
|
|
241
|
+
case 5:
|
|
242
|
+
_e.sent();
|
|
243
|
+
_e.label = 6;
|
|
244
|
+
case 6:
|
|
245
|
+
try {
|
|
246
|
+
for (_a = __values(Object.entries(rest)), _b = _a.next(); !_b.done; _b = _a.next()) {
|
|
247
|
+
_c = __read(_b.value, 2), key = _c[0], value = _c[1];
|
|
248
|
+
if (typeof value === "undefined") {
|
|
249
|
+
continue;
|
|
250
|
+
}
|
|
251
|
+
priceList[key] = value;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
255
|
+
finally {
|
|
256
|
+
try {
|
|
257
|
+
if (_b && !_b.done && (_d = _a.return)) _d.call(_a);
|
|
258
|
+
}
|
|
259
|
+
finally { if (e_1) throw e_1.error; }
|
|
260
|
+
}
|
|
261
|
+
return [4 /*yield*/, priceListRepo.save(priceList)];
|
|
262
|
+
case 7:
|
|
263
|
+
_e.sent();
|
|
264
|
+
return [4 /*yield*/, this.retrieve(id, {
|
|
265
|
+
relations: ["prices", "customer_groups"],
|
|
266
|
+
})];
|
|
267
|
+
case 8: return [2 /*return*/, _e.sent()];
|
|
268
|
+
}
|
|
269
|
+
});
|
|
270
|
+
}); })];
|
|
271
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
272
|
+
}
|
|
273
|
+
});
|
|
274
|
+
});
|
|
275
|
+
};
|
|
276
|
+
/**
|
|
277
|
+
* Adds prices to a price list in bulk, optionally replacing all existing prices
|
|
278
|
+
* @param id - id of the price list
|
|
279
|
+
* @param prices - prices to add
|
|
280
|
+
* @param replace - whether to replace existing prices
|
|
281
|
+
* @returns {Promise<PriceList>} updated Price List
|
|
282
|
+
*/
|
|
283
|
+
PriceListService.prototype.addPrices = function (id, prices, replace) {
|
|
284
|
+
if (replace === void 0) { replace = false; }
|
|
285
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
286
|
+
var _this = this;
|
|
287
|
+
return __generator(this, function (_a) {
|
|
288
|
+
switch (_a.label) {
|
|
289
|
+
case 0: return [4 /*yield*/, this.atomicPhase_(function (manager) { return __awaiter(_this, void 0, void 0, function () {
|
|
290
|
+
var moneyAmountRepo, priceList, prices_;
|
|
291
|
+
return __generator(this, function (_a) {
|
|
292
|
+
switch (_a.label) {
|
|
293
|
+
case 0:
|
|
294
|
+
moneyAmountRepo = manager.getCustomRepository(this.moneyAmountRepo_);
|
|
295
|
+
return [4 /*yield*/, this.retrieve(id, { select: ["id"] })];
|
|
296
|
+
case 1:
|
|
297
|
+
priceList = _a.sent();
|
|
298
|
+
return [4 /*yield*/, this.addCurrencyFromRegion(prices)];
|
|
299
|
+
case 2:
|
|
300
|
+
prices_ = _a.sent();
|
|
301
|
+
return [4 /*yield*/, moneyAmountRepo.addPriceListPrices(priceList.id, prices_, replace)];
|
|
302
|
+
case 3:
|
|
303
|
+
_a.sent();
|
|
304
|
+
return [4 /*yield*/, this.retrieve(priceList.id, {
|
|
305
|
+
relations: ["prices"],
|
|
306
|
+
})];
|
|
307
|
+
case 4: return [2 /*return*/, _a.sent()];
|
|
308
|
+
}
|
|
309
|
+
});
|
|
310
|
+
}); })];
|
|
311
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
312
|
+
}
|
|
313
|
+
});
|
|
314
|
+
});
|
|
315
|
+
};
|
|
316
|
+
/**
|
|
317
|
+
* Removes prices from a price list and deletes the removed prices in bulk
|
|
318
|
+
* @param id - id of the price list
|
|
319
|
+
* @param priceIds - ids of the prices to delete
|
|
320
|
+
* @returns {Promise<void>} updated Price List
|
|
321
|
+
*/
|
|
322
|
+
PriceListService.prototype.deletePrices = function (id, priceIds) {
|
|
323
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
324
|
+
var _this = this;
|
|
325
|
+
return __generator(this, function (_a) {
|
|
326
|
+
switch (_a.label) {
|
|
327
|
+
case 0: return [4 /*yield*/, this.atomicPhase_(function (manager) { return __awaiter(_this, void 0, void 0, function () {
|
|
328
|
+
var moneyAmountRepo, priceList;
|
|
329
|
+
return __generator(this, function (_a) {
|
|
330
|
+
switch (_a.label) {
|
|
331
|
+
case 0:
|
|
332
|
+
moneyAmountRepo = manager.getCustomRepository(this.moneyAmountRepo_);
|
|
333
|
+
return [4 /*yield*/, this.retrieve(id, { select: ["id"] })];
|
|
334
|
+
case 1:
|
|
335
|
+
priceList = _a.sent();
|
|
336
|
+
return [4 /*yield*/, moneyAmountRepo.deletePriceListPrices(priceList.id, priceIds)];
|
|
337
|
+
case 2:
|
|
338
|
+
_a.sent();
|
|
339
|
+
return [2 /*return*/];
|
|
340
|
+
}
|
|
341
|
+
});
|
|
342
|
+
}); })];
|
|
343
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
344
|
+
}
|
|
345
|
+
});
|
|
346
|
+
});
|
|
347
|
+
};
|
|
348
|
+
/**
|
|
349
|
+
* Deletes a Price List
|
|
350
|
+
* Will never fail due to delete being idempotent.
|
|
351
|
+
* @param id - id of the price list
|
|
352
|
+
* @returns {Promise<void>} empty promise
|
|
353
|
+
*/
|
|
354
|
+
PriceListService.prototype.delete = function (id) {
|
|
355
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
356
|
+
var _this = this;
|
|
357
|
+
return __generator(this, function (_a) {
|
|
358
|
+
switch (_a.label) {
|
|
359
|
+
case 0: return [4 /*yield*/, this.atomicPhase_(function (manager) { return __awaiter(_this, void 0, void 0, function () {
|
|
360
|
+
var priceListRepo, priceList;
|
|
361
|
+
return __generator(this, function (_a) {
|
|
362
|
+
switch (_a.label) {
|
|
363
|
+
case 0:
|
|
364
|
+
priceListRepo = manager.getCustomRepository(this.priceListRepo_);
|
|
365
|
+
return [4 /*yield*/, priceListRepo.findOne({ where: { id: id } })];
|
|
366
|
+
case 1:
|
|
367
|
+
priceList = _a.sent();
|
|
368
|
+
if (!priceList) {
|
|
369
|
+
return [2 /*return*/, Promise.resolve()];
|
|
370
|
+
}
|
|
371
|
+
return [4 /*yield*/, priceListRepo.remove(priceList)];
|
|
372
|
+
case 2:
|
|
373
|
+
_a.sent();
|
|
374
|
+
return [2 /*return*/];
|
|
375
|
+
}
|
|
376
|
+
});
|
|
377
|
+
}); })];
|
|
378
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
379
|
+
}
|
|
380
|
+
});
|
|
381
|
+
});
|
|
382
|
+
};
|
|
383
|
+
/**
|
|
384
|
+
* Lists Price Lists
|
|
385
|
+
* @param {Object} selector - the query object for find
|
|
386
|
+
* @param {Object} config - the config to be used for find
|
|
387
|
+
* @return {Promise<PriceList[]>} the result of the find operation
|
|
388
|
+
*/
|
|
389
|
+
PriceListService.prototype.list = function (selector, config) {
|
|
390
|
+
if (selector === void 0) { selector = {}; }
|
|
391
|
+
if (config === void 0) { config = { skip: 0, take: 20 }; }
|
|
392
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
393
|
+
var _this = this;
|
|
394
|
+
return __generator(this, function (_a) {
|
|
395
|
+
switch (_a.label) {
|
|
396
|
+
case 0: return [4 /*yield*/, this.atomicPhase_(function (manager) { return __awaiter(_this, void 0, void 0, function () {
|
|
397
|
+
var priceListRepo, q, priceListSelector, query, groups, _a, priceLists;
|
|
398
|
+
return __generator(this, function (_b) {
|
|
399
|
+
switch (_b.label) {
|
|
400
|
+
case 0:
|
|
401
|
+
priceListRepo = manager.getCustomRepository(this.priceListRepo_);
|
|
402
|
+
q = selector.q, priceListSelector = __rest(selector, ["q"]);
|
|
403
|
+
query = (0, utils_1.buildQuery)(priceListSelector, config);
|
|
404
|
+
groups = query.where.customer_groups;
|
|
405
|
+
query.where.customer_groups = undefined;
|
|
406
|
+
return [4 /*yield*/, priceListRepo.listAndCount(query, groups)];
|
|
407
|
+
case 1:
|
|
408
|
+
_a = __read.apply(void 0, [_b.sent(), 1]), priceLists = _a[0];
|
|
409
|
+
return [2 /*return*/, priceLists];
|
|
410
|
+
}
|
|
411
|
+
});
|
|
412
|
+
}); })];
|
|
413
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
414
|
+
}
|
|
415
|
+
});
|
|
416
|
+
});
|
|
417
|
+
};
|
|
418
|
+
/**
|
|
419
|
+
* Lists Price Lists and adds count
|
|
420
|
+
* @param {Object} selector - the query object for find
|
|
421
|
+
* @param {Object} config - the config to be used for find
|
|
422
|
+
* @return {Promise} the result of the find operation
|
|
423
|
+
*/
|
|
424
|
+
PriceListService.prototype.listAndCount = function (selector, config) {
|
|
425
|
+
if (selector === void 0) { selector = {}; }
|
|
426
|
+
if (config === void 0) { config = {
|
|
427
|
+
skip: 0,
|
|
428
|
+
take: 20,
|
|
429
|
+
}; }
|
|
430
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
431
|
+
var _this = this;
|
|
432
|
+
return __generator(this, function (_a) {
|
|
433
|
+
switch (_a.label) {
|
|
434
|
+
case 0: return [4 /*yield*/, this.atomicPhase_(function (manager) { return __awaiter(_this, void 0, void 0, function () {
|
|
435
|
+
var priceListRepo, q, priceListSelector, _a, relations, query, groups;
|
|
436
|
+
return __generator(this, function (_b) {
|
|
437
|
+
switch (_b.label) {
|
|
438
|
+
case 0:
|
|
439
|
+
priceListRepo = manager.getCustomRepository(this.priceListRepo_);
|
|
440
|
+
q = selector.q, priceListSelector = __rest(selector, ["q"]);
|
|
441
|
+
_a = (0, utils_1.buildQuery)(priceListSelector, config), relations = _a.relations, query = __rest(_a, ["relations"]);
|
|
442
|
+
groups = query.where.customer_groups;
|
|
443
|
+
delete query.where.customer_groups;
|
|
444
|
+
if (!q) return [3 /*break*/, 2];
|
|
445
|
+
return [4 /*yield*/, priceListRepo.getFreeTextSearchResultsAndCount(q, query, groups, relations)];
|
|
446
|
+
case 1: return [2 /*return*/, _b.sent()];
|
|
447
|
+
case 2: return [4 /*yield*/, priceListRepo.listAndCount(__assign(__assign({}, query), { relations: relations }), groups)];
|
|
448
|
+
case 3: return [2 /*return*/, _b.sent()];
|
|
449
|
+
}
|
|
450
|
+
});
|
|
451
|
+
}); })];
|
|
452
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
453
|
+
}
|
|
454
|
+
});
|
|
455
|
+
});
|
|
456
|
+
};
|
|
457
|
+
PriceListService.prototype.upsertCustomerGroups_ = function (priceListId, customerGroups) {
|
|
458
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
459
|
+
var priceListRepo, priceList, groups, customerGroups_1, customerGroups_1_1, cg, customerGroup, e_2_1;
|
|
460
|
+
var e_2, _a;
|
|
461
|
+
return __generator(this, function (_b) {
|
|
462
|
+
switch (_b.label) {
|
|
463
|
+
case 0:
|
|
464
|
+
priceListRepo = this.manager_.getCustomRepository(this.priceListRepo_);
|
|
465
|
+
return [4 /*yield*/, this.retrieve(priceListId, { select: ["id"] })];
|
|
466
|
+
case 1:
|
|
467
|
+
priceList = _b.sent();
|
|
468
|
+
groups = [];
|
|
469
|
+
_b.label = 2;
|
|
470
|
+
case 2:
|
|
471
|
+
_b.trys.push([2, 7, 8, 9]);
|
|
472
|
+
customerGroups_1 = __values(customerGroups), customerGroups_1_1 = customerGroups_1.next();
|
|
473
|
+
_b.label = 3;
|
|
474
|
+
case 3:
|
|
475
|
+
if (!!customerGroups_1_1.done) return [3 /*break*/, 6];
|
|
476
|
+
cg = customerGroups_1_1.value;
|
|
477
|
+
return [4 /*yield*/, this.customerGroupService_.retrieve(cg.id)];
|
|
478
|
+
case 4:
|
|
479
|
+
customerGroup = _b.sent();
|
|
480
|
+
groups.push(customerGroup);
|
|
481
|
+
_b.label = 5;
|
|
482
|
+
case 5:
|
|
483
|
+
customerGroups_1_1 = customerGroups_1.next();
|
|
484
|
+
return [3 /*break*/, 3];
|
|
485
|
+
case 6: return [3 /*break*/, 9];
|
|
486
|
+
case 7:
|
|
487
|
+
e_2_1 = _b.sent();
|
|
488
|
+
e_2 = { error: e_2_1 };
|
|
489
|
+
return [3 /*break*/, 9];
|
|
490
|
+
case 8:
|
|
491
|
+
try {
|
|
492
|
+
if (customerGroups_1_1 && !customerGroups_1_1.done && (_a = customerGroups_1.return)) _a.call(customerGroups_1);
|
|
493
|
+
}
|
|
494
|
+
finally { if (e_2) throw e_2.error; }
|
|
495
|
+
return [7 /*endfinally*/];
|
|
496
|
+
case 9:
|
|
497
|
+
priceList.customer_groups = groups;
|
|
498
|
+
return [4 /*yield*/, priceListRepo.save(priceList)];
|
|
499
|
+
case 10:
|
|
500
|
+
_b.sent();
|
|
501
|
+
return [2 /*return*/];
|
|
502
|
+
}
|
|
503
|
+
});
|
|
504
|
+
});
|
|
505
|
+
};
|
|
506
|
+
PriceListService.prototype.listProducts = function (priceListId, selector, config, requiresPriceList) {
|
|
507
|
+
if (selector === void 0) { selector = {}; }
|
|
508
|
+
if (config === void 0) { config = {
|
|
509
|
+
relations: [],
|
|
510
|
+
skip: 0,
|
|
511
|
+
take: 20,
|
|
512
|
+
}; }
|
|
513
|
+
if (requiresPriceList === void 0) { requiresPriceList = false; }
|
|
514
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
515
|
+
var _this = this;
|
|
516
|
+
return __generator(this, function (_a) {
|
|
517
|
+
switch (_a.label) {
|
|
518
|
+
case 0: return [4 /*yield*/, this.atomicPhase_(function (manager) { return __awaiter(_this, void 0, void 0, function () {
|
|
519
|
+
var _a, products, count, moneyAmountRepo, productsWithPrices;
|
|
520
|
+
var _this = this;
|
|
521
|
+
return __generator(this, function (_b) {
|
|
522
|
+
switch (_b.label) {
|
|
523
|
+
case 0: return [4 /*yield*/, this.productService_.listAndCount(selector, config)];
|
|
524
|
+
case 1:
|
|
525
|
+
_a = __read.apply(void 0, [_b.sent(), 2]), products = _a[0], count = _a[1];
|
|
526
|
+
moneyAmountRepo = manager.getCustomRepository(this.moneyAmountRepo_);
|
|
527
|
+
return [4 /*yield*/, Promise.all(products.map(function (p) { return __awaiter(_this, void 0, void 0, function () {
|
|
528
|
+
var _a;
|
|
529
|
+
var _this = this;
|
|
530
|
+
var _b;
|
|
531
|
+
return __generator(this, function (_c) {
|
|
532
|
+
switch (_c.label) {
|
|
533
|
+
case 0:
|
|
534
|
+
if (!((_b = p.variants) === null || _b === void 0 ? void 0 : _b.length)) return [3 /*break*/, 2];
|
|
535
|
+
_a = p;
|
|
536
|
+
return [4 /*yield*/, Promise.all(p.variants.map(function (v) { return __awaiter(_this, void 0, void 0, function () {
|
|
537
|
+
var _a, prices;
|
|
538
|
+
return __generator(this, function (_b) {
|
|
539
|
+
switch (_b.label) {
|
|
540
|
+
case 0: return [4 /*yield*/, moneyAmountRepo.findManyForVariantInPriceList(v.id, priceListId, requiresPriceList)];
|
|
541
|
+
case 1:
|
|
542
|
+
_a = __read.apply(void 0, [_b.sent(), 1]), prices = _a[0];
|
|
543
|
+
return [2 /*return*/, __assign(__assign({}, v), { prices: prices })];
|
|
544
|
+
}
|
|
545
|
+
});
|
|
546
|
+
}); }))];
|
|
547
|
+
case 1:
|
|
548
|
+
_a.variants = _c.sent();
|
|
549
|
+
_c.label = 2;
|
|
550
|
+
case 2: return [2 /*return*/, p];
|
|
551
|
+
}
|
|
552
|
+
});
|
|
553
|
+
}); }))];
|
|
554
|
+
case 2:
|
|
555
|
+
productsWithPrices = _b.sent();
|
|
556
|
+
return [2 /*return*/, [productsWithPrices, count]];
|
|
557
|
+
}
|
|
558
|
+
});
|
|
559
|
+
}); })];
|
|
560
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
561
|
+
}
|
|
562
|
+
});
|
|
563
|
+
});
|
|
564
|
+
};
|
|
565
|
+
PriceListService.prototype.listVariants = function (priceListId, selector, config, requiresPriceList) {
|
|
566
|
+
if (selector === void 0) { selector = {}; }
|
|
567
|
+
if (config === void 0) { config = {
|
|
568
|
+
relations: [],
|
|
569
|
+
skip: 0,
|
|
570
|
+
take: 20,
|
|
571
|
+
}; }
|
|
572
|
+
if (requiresPriceList === void 0) { requiresPriceList = false; }
|
|
573
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
574
|
+
var _this = this;
|
|
575
|
+
return __generator(this, function (_a) {
|
|
576
|
+
switch (_a.label) {
|
|
577
|
+
case 0: return [4 /*yield*/, this.atomicPhase_(function (manager) { return __awaiter(_this, void 0, void 0, function () {
|
|
578
|
+
var _a, variants, count, moneyAmountRepo, variantsWithPrices;
|
|
579
|
+
var _this = this;
|
|
580
|
+
return __generator(this, function (_b) {
|
|
581
|
+
switch (_b.label) {
|
|
582
|
+
case 0: return [4 /*yield*/, this.variantService_.listAndCount(selector, config)];
|
|
583
|
+
case 1:
|
|
584
|
+
_a = __read.apply(void 0, [_b.sent(), 2]), variants = _a[0], count = _a[1];
|
|
585
|
+
moneyAmountRepo = manager.getCustomRepository(this.moneyAmountRepo_);
|
|
586
|
+
return [4 /*yield*/, Promise.all(variants.map(function (variant) { return __awaiter(_this, void 0, void 0, function () {
|
|
587
|
+
var _a, prices;
|
|
588
|
+
return __generator(this, function (_b) {
|
|
589
|
+
switch (_b.label) {
|
|
590
|
+
case 0: return [4 /*yield*/, moneyAmountRepo.findManyForVariantInPriceList(variant.id, priceListId, requiresPriceList)];
|
|
591
|
+
case 1:
|
|
592
|
+
_a = __read.apply(void 0, [_b.sent(), 1]), prices = _a[0];
|
|
593
|
+
variant.prices = prices;
|
|
594
|
+
return [2 /*return*/, variant];
|
|
595
|
+
}
|
|
596
|
+
});
|
|
597
|
+
}); }))];
|
|
598
|
+
case 2:
|
|
599
|
+
variantsWithPrices = _b.sent();
|
|
600
|
+
return [2 /*return*/, [variantsWithPrices, count]];
|
|
601
|
+
}
|
|
602
|
+
});
|
|
603
|
+
}); })];
|
|
604
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
605
|
+
}
|
|
606
|
+
});
|
|
607
|
+
});
|
|
608
|
+
};
|
|
609
|
+
PriceListService.prototype.deleteProductPrices = function (priceListId, productIds) {
|
|
610
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
611
|
+
var _this = this;
|
|
612
|
+
return __generator(this, function (_a) {
|
|
613
|
+
switch (_a.label) {
|
|
614
|
+
case 0: return [4 /*yield*/, this.atomicPhase_(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
615
|
+
var _a, products, count, priceIds;
|
|
616
|
+
return __generator(this, function (_b) {
|
|
617
|
+
switch (_b.label) {
|
|
618
|
+
case 0: return [4 /*yield*/, this.listProducts(priceListId, {
|
|
619
|
+
id: productIds,
|
|
620
|
+
}, {
|
|
621
|
+
relations: ["variants"],
|
|
622
|
+
}, true)];
|
|
623
|
+
case 1:
|
|
624
|
+
_a = __read.apply(void 0, [_b.sent(), 2]), products = _a[0], count = _a[1];
|
|
625
|
+
if (count === 0) {
|
|
626
|
+
return [2 /*return*/, [[], count]];
|
|
627
|
+
}
|
|
628
|
+
priceIds = products
|
|
629
|
+
.map(function (_a) {
|
|
630
|
+
var variants = _a.variants;
|
|
631
|
+
return variants
|
|
632
|
+
.map(function (variant) { return variant.prices.map(function (price) { return price.id; }); })
|
|
633
|
+
.flat();
|
|
634
|
+
})
|
|
635
|
+
.flat();
|
|
636
|
+
if (!priceIds.length) {
|
|
637
|
+
return [2 /*return*/, [[], 0]];
|
|
638
|
+
}
|
|
639
|
+
return [4 /*yield*/, this.deletePrices(priceListId, priceIds)];
|
|
640
|
+
case 2:
|
|
641
|
+
_b.sent();
|
|
642
|
+
return [2 /*return*/, [priceIds, priceIds.length]];
|
|
643
|
+
}
|
|
644
|
+
});
|
|
645
|
+
}); })];
|
|
646
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
647
|
+
}
|
|
648
|
+
});
|
|
649
|
+
});
|
|
650
|
+
};
|
|
651
|
+
PriceListService.prototype.deleteVariantPrices = function (priceListId, variantIds) {
|
|
652
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
653
|
+
var _this = this;
|
|
654
|
+
return __generator(this, function (_a) {
|
|
655
|
+
switch (_a.label) {
|
|
656
|
+
case 0: return [4 /*yield*/, this.atomicPhase_(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
657
|
+
var _a, variants, count, priceIds;
|
|
658
|
+
return __generator(this, function (_b) {
|
|
659
|
+
switch (_b.label) {
|
|
660
|
+
case 0: return [4 /*yield*/, this.listVariants(priceListId, {
|
|
661
|
+
id: variantIds,
|
|
662
|
+
}, {}, true)];
|
|
663
|
+
case 1:
|
|
664
|
+
_a = __read.apply(void 0, [_b.sent(), 2]), variants = _a[0], count = _a[1];
|
|
665
|
+
if (count === 0) {
|
|
666
|
+
return [2 /*return*/, [[], count]];
|
|
667
|
+
}
|
|
668
|
+
priceIds = variants
|
|
669
|
+
.map(function (variant) { return variant.prices.map(function (price) { return price.id; }); })
|
|
670
|
+
.flat();
|
|
671
|
+
if (!priceIds.length) {
|
|
672
|
+
return [2 /*return*/, [[], 0]];
|
|
673
|
+
}
|
|
674
|
+
return [4 /*yield*/, this.deletePrices(priceListId, priceIds)];
|
|
675
|
+
case 2:
|
|
676
|
+
_b.sent();
|
|
677
|
+
return [2 /*return*/, [priceIds, priceIds.length]];
|
|
678
|
+
}
|
|
679
|
+
});
|
|
680
|
+
}); })];
|
|
681
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
682
|
+
}
|
|
683
|
+
});
|
|
684
|
+
});
|
|
685
|
+
};
|
|
686
|
+
/**
|
|
687
|
+
* Add `currency_code` to an MA record if `region_id`is passed.
|
|
688
|
+
* @param prices - a list of PriceListPrice(Create/Update)Input records
|
|
689
|
+
* @return {Promise} updated `prices` list
|
|
690
|
+
*/
|
|
691
|
+
PriceListService.prototype.addCurrencyFromRegion = function (prices) {
|
|
692
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
693
|
+
var prices_, prices_1, prices_1_1, p, region, e_3_1;
|
|
694
|
+
var e_3, _a;
|
|
695
|
+
return __generator(this, function (_b) {
|
|
696
|
+
switch (_b.label) {
|
|
697
|
+
case 0:
|
|
698
|
+
prices_ = [];
|
|
699
|
+
_b.label = 1;
|
|
700
|
+
case 1:
|
|
701
|
+
_b.trys.push([1, 7, 8, 9]);
|
|
702
|
+
prices_1 = __values(prices), prices_1_1 = prices_1.next();
|
|
703
|
+
_b.label = 2;
|
|
704
|
+
case 2:
|
|
705
|
+
if (!!prices_1_1.done) return [3 /*break*/, 6];
|
|
706
|
+
p = prices_1_1.value;
|
|
707
|
+
if (!p.region_id) return [3 /*break*/, 4];
|
|
708
|
+
return [4 /*yield*/, this.regionService_
|
|
709
|
+
.withTransaction(this.manager_)
|
|
710
|
+
.retrieve(p.region_id)];
|
|
711
|
+
case 3:
|
|
712
|
+
region = _b.sent();
|
|
713
|
+
p.currency_code = region.currency_code;
|
|
714
|
+
_b.label = 4;
|
|
715
|
+
case 4:
|
|
716
|
+
prices_.push(p);
|
|
717
|
+
_b.label = 5;
|
|
718
|
+
case 5:
|
|
719
|
+
prices_1_1 = prices_1.next();
|
|
720
|
+
return [3 /*break*/, 2];
|
|
721
|
+
case 6: return [3 /*break*/, 9];
|
|
722
|
+
case 7:
|
|
723
|
+
e_3_1 = _b.sent();
|
|
724
|
+
e_3 = { error: e_3_1 };
|
|
725
|
+
return [3 /*break*/, 9];
|
|
726
|
+
case 8:
|
|
727
|
+
try {
|
|
728
|
+
if (prices_1_1 && !prices_1_1.done && (_a = prices_1.return)) _a.call(prices_1);
|
|
729
|
+
}
|
|
730
|
+
finally { if (e_3) throw e_3.error; }
|
|
731
|
+
return [7 /*endfinally*/];
|
|
732
|
+
case 9: return [2 /*return*/, prices_];
|
|
733
|
+
}
|
|
734
|
+
});
|
|
735
|
+
});
|
|
736
|
+
};
|
|
737
|
+
return PriceListService;
|
|
738
|
+
}(interfaces_1.TransactionBaseService));
|
|
739
|
+
exports.default = PriceListService;
|
|
740
|
+
//# sourceMappingURL=price-list.js.map
|