@medusajs/medusa 1.3.2 → 1.3.3-alpha.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +43 -0
- package/dist/api/index.d.ts +15 -14
- package/dist/api/index.js +15 -14
- package/dist/api/index.js.map +1 -1
- package/dist/api/middlewares/authenticate-customer.d.ts +2 -1
- package/dist/api/middlewares/authenticate-customer.js +1 -2
- package/dist/api/middlewares/authenticate-customer.js.map +1 -1
- package/dist/api/middlewares/authenticate.d.ts +2 -1
- package/dist/api/middlewares/authenticate.js.map +1 -1
- package/dist/api/middlewares/await-middleware.d.ts +3 -1
- package/dist/api/middlewares/await-middleware.js +2 -31
- package/dist/api/middlewares/await-middleware.js.map +1 -1
- package/dist/api/middlewares/error-handler.d.ts +3 -1
- package/dist/api/middlewares/error-handler.js.map +1 -1
- package/dist/api/middlewares/feature-flag-enabled.d.ts +2 -0
- package/dist/{services/transaction.js → api/middlewares/feature-flag-enabled.js} +18 -35
- package/dist/api/middlewares/feature-flag-enabled.js.map +1 -0
- package/dist/api/middlewares/index.d.ts +10 -10
- package/dist/api/middlewares/index.js +5 -1
- package/dist/api/middlewares/index.js.map +1 -1
- package/dist/api/middlewares/normalized-query.d.ts +6 -1
- package/dist/api/middlewares/normalized-query.js +5 -2
- package/dist/api/middlewares/normalized-query.js.map +1 -1
- package/dist/api/middlewares/transform-body.d.ts +4 -0
- package/dist/api/middlewares/transform-body.js +66 -0
- package/dist/api/middlewares/transform-body.js.map +1 -0
- package/dist/api/middlewares/transform-query.d.ts +6 -0
- package/dist/api/middlewares/transform-query.js +86 -0
- package/dist/api/middlewares/transform-query.js.map +1 -0
- package/dist/api/routes/admin/batch/cancel-batch-job.d.ts +22 -0
- package/dist/api/routes/admin/batch/cancel-batch-job.js +74 -0
- package/dist/api/routes/admin/batch/cancel-batch-job.js.map +1 -0
- package/dist/api/routes/admin/batch/confirm-batch-job.d.ts +22 -0
- package/dist/api/routes/admin/batch/confirm-batch-job.js +74 -0
- package/dist/api/routes/admin/batch/confirm-batch-job.js.map +1 -0
- package/dist/api/routes/admin/batch/create-batch-job.d.ts +30 -0
- package/dist/api/routes/admin/batch/create-batch-job.js +125 -0
- package/dist/api/routes/admin/batch/create-batch-job.js.map +1 -0
- package/dist/api/routes/admin/batch/get-batch-job.d.ts +22 -0
- package/dist/api/routes/admin/batch/get-batch-job.js +67 -0
- package/dist/api/routes/admin/batch/get-batch-job.js.map +1 -0
- package/dist/api/routes/admin/batch/index.d.ts +4 -0
- package/dist/api/routes/admin/batch/index.js +36 -7
- package/dist/api/routes/admin/batch/index.js.map +1 -1
- package/dist/api/routes/admin/batch/list-batch-jobs.d.ts +15 -7
- package/dist/api/routes/admin/batch/list-batch-jobs.js +61 -46
- package/dist/api/routes/admin/batch/list-batch-jobs.js.map +1 -1
- package/dist/api/routes/admin/collections/add-products.d.ts +2 -1
- package/dist/api/routes/admin/collections/add-products.js +4 -7
- package/dist/api/routes/admin/collections/add-products.js.map +1 -1
- package/dist/api/routes/admin/collections/create-collection.d.ts +2 -1
- package/dist/api/routes/admin/collections/create-collection.js +6 -8
- package/dist/api/routes/admin/collections/create-collection.js.map +1 -1
- package/dist/api/routes/admin/collections/delete-collection.d.ts +2 -1
- package/dist/api/routes/admin/collections/delete-collection.js.map +1 -1
- package/dist/api/routes/admin/collections/get-collection.d.ts +2 -1
- package/dist/api/routes/admin/collections/get-collection.js +4 -5
- package/dist/api/routes/admin/collections/get-collection.js.map +1 -1
- package/dist/api/routes/admin/collections/index.js +32 -12
- package/dist/api/routes/admin/collections/index.js.map +1 -1
- package/dist/api/routes/admin/collections/list-collections.d.ts +2 -1
- package/dist/api/routes/admin/collections/list-collections.js +9 -19
- package/dist/api/routes/admin/collections/list-collections.js.map +1 -1
- package/dist/api/routes/admin/collections/remove-products.d.ts +2 -1
- package/dist/api/routes/admin/collections/remove-products.js +5 -8
- package/dist/api/routes/admin/collections/remove-products.js.map +1 -1
- package/dist/api/routes/admin/collections/update-collection.d.ts +2 -1
- package/dist/api/routes/admin/collections/update-collection.js +5 -8
- package/dist/api/routes/admin/collections/update-collection.js.map +1 -1
- package/dist/api/routes/admin/customer-groups/add-customers-batch.d.ts +2 -1
- package/dist/api/routes/admin/customer-groups/add-customers-batch.js.map +1 -1
- package/dist/api/routes/admin/customer-groups/create-customer-group.d.ts +2 -1
- package/dist/api/routes/admin/customer-groups/create-customer-group.js.map +1 -1
- package/dist/api/routes/admin/customer-groups/delete-customer-group.d.ts +2 -1
- package/dist/api/routes/admin/customer-groups/delete-customer-group.js.map +1 -1
- package/dist/api/routes/admin/customer-groups/delete-customers-batch.d.ts +2 -1
- package/dist/api/routes/admin/customer-groups/delete-customers-batch.js.map +1 -1
- package/dist/api/routes/admin/customer-groups/get-customer-group-customers.d.ts +2 -1
- package/dist/api/routes/admin/customer-groups/get-customer-group-customers.js.map +1 -1
- package/dist/api/routes/admin/customer-groups/get-customer-group.d.ts +2 -1
- package/dist/api/routes/admin/customer-groups/get-customer-group.js +3 -17
- package/dist/api/routes/admin/customer-groups/get-customer-group.js.map +1 -1
- package/dist/api/routes/admin/customer-groups/index.js +29 -11
- package/dist/api/routes/admin/customer-groups/index.js.map +1 -1
- package/dist/api/routes/admin/customer-groups/list-customer-groups.d.ts +2 -1
- package/dist/api/routes/admin/customer-groups/list-customer-groups.js +10 -45
- package/dist/api/routes/admin/customer-groups/list-customer-groups.js.map +1 -1
- package/dist/api/routes/admin/customer-groups/update-customer-group.d.ts +2 -1
- package/dist/api/routes/admin/customer-groups/update-customer-group.js.map +1 -1
- package/dist/api/routes/admin/customers/create-customer.d.ts +1 -1
- package/dist/api/routes/admin/customers/create-customer.js.map +1 -1
- package/dist/api/routes/admin/customers/update-customer.d.ts +1 -1
- package/dist/api/routes/admin/customers/update-customer.js.map +1 -1
- package/dist/api/routes/admin/draft-orders/index.d.ts +1 -1
- package/dist/api/routes/admin/draft-orders/index.js +1 -0
- package/dist/api/routes/admin/draft-orders/index.js.map +1 -1
- package/dist/api/routes/admin/draft-orders/list-draft-orders.js +7 -6
- package/dist/api/routes/admin/draft-orders/list-draft-orders.js.map +1 -1
- package/dist/api/routes/admin/gift-cards/create-gift-card.d.ts +2 -2
- package/dist/api/routes/admin/gift-cards/create-gift-card.js +0 -1
- package/dist/api/routes/admin/gift-cards/create-gift-card.js.map +1 -1
- package/dist/api/routes/admin/gift-cards/index.d.ts +1 -1
- package/dist/api/routes/admin/gift-cards/index.js +19 -5
- package/dist/api/routes/admin/gift-cards/index.js.map +1 -1
- package/dist/api/routes/admin/gift-cards/list-gift-cards.js +24 -18
- package/dist/api/routes/admin/gift-cards/list-gift-cards.js.map +1 -1
- package/dist/api/routes/admin/gift-cards/update-gift-card.d.ts +1 -1
- package/dist/api/routes/admin/gift-cards/update-gift-card.js.map +1 -1
- package/dist/api/routes/admin/orders/create-claim.d.ts +4 -14
- package/dist/api/routes/admin/orders/create-claim.js +3 -14
- package/dist/api/routes/admin/orders/create-claim.js.map +1 -1
- package/dist/api/routes/admin/orders/fulfill-claim.d.ts +1 -1
- package/dist/api/routes/admin/orders/fulfill-claim.js.map +1 -1
- package/dist/api/routes/admin/orders/update-claim.d.ts +1 -1
- package/dist/api/routes/admin/orders/update-claim.js.map +1 -1
- package/dist/api/routes/admin/price-lists/create-price-list.d.ts +2 -1
- package/dist/api/routes/admin/price-lists/create-price-list.js +4 -7
- package/dist/api/routes/admin/price-lists/create-price-list.js.map +1 -1
- package/dist/api/routes/admin/price-lists/index.js +26 -7
- package/dist/api/routes/admin/price-lists/index.js.map +1 -1
- package/dist/api/routes/admin/price-lists/list-price-list-products.d.ts +3 -7
- package/dist/api/routes/admin/price-lists/list-price-list-products.js +21 -59
- package/dist/api/routes/admin/price-lists/list-price-list-products.js.map +1 -1
- package/dist/api/routes/admin/price-lists/list-price-lists.d.ts +2 -1
- package/dist/api/routes/admin/price-lists/list-price-lists.js +8 -40
- package/dist/api/routes/admin/price-lists/list-price-lists.js.map +1 -1
- package/dist/api/routes/admin/products/add-option.js +26 -6
- package/dist/api/routes/admin/products/add-option.js.map +1 -1
- package/dist/api/routes/admin/products/create-product.d.ts +3 -3
- package/dist/api/routes/admin/products/create-product.js +13 -9
- package/dist/api/routes/admin/products/create-product.js.map +1 -1
- package/dist/api/routes/admin/products/delete-variant.js +26 -6
- package/dist/api/routes/admin/products/delete-variant.js.map +1 -1
- package/dist/api/routes/admin/products/get-product.js +24 -4
- package/dist/api/routes/admin/products/get-product.js.map +1 -1
- package/dist/api/routes/admin/products/index.d.ts +3 -2
- package/dist/api/routes/admin/products/index.js +1 -4
- package/dist/api/routes/admin/products/index.js.map +1 -1
- package/dist/api/routes/admin/products/list-products.d.ts +1 -6
- package/dist/api/routes/admin/products/list-products.js +3 -9
- package/dist/api/routes/admin/products/list-products.js.map +1 -1
- package/dist/api/routes/admin/products/update-product.d.ts +3 -3
- package/dist/api/routes/admin/products/update-product.js +28 -7
- package/dist/api/routes/admin/products/update-product.js.map +1 -1
- package/dist/api/routes/admin/products/update-variant.js +27 -10
- package/dist/api/routes/admin/products/update-variant.js.map +1 -1
- package/dist/api/routes/admin/shipping-options/list-shipping-options.js +6 -2
- package/dist/api/routes/admin/shipping-options/list-shipping-options.js.map +1 -1
- package/dist/api/routes/admin/store/get-store.js +4 -2
- package/dist/api/routes/admin/store/get-store.js.map +1 -1
- package/dist/api/routes/admin/store/update-store.d.ts +1 -0
- package/dist/api/routes/admin/store/update-store.js +5 -0
- package/dist/api/routes/admin/store/update-store.js.map +1 -1
- package/dist/api/routes/admin/uploads/create-upload.d.ts +1 -1
- package/dist/api/routes/admin/uploads/create-upload.js +5 -5
- package/dist/api/routes/admin/uploads/create-upload.js.map +1 -1
- package/dist/api/routes/admin/uploads/delete-upload.d.ts +4 -1
- package/dist/api/routes/admin/uploads/delete-upload.js +29 -11
- package/dist/api/routes/admin/uploads/delete-upload.js.map +1 -1
- package/dist/api/routes/admin/uploads/get-download-url.d.ts +28 -0
- package/dist/api/routes/admin/uploads/get-download-url.js +99 -0
- package/dist/api/routes/admin/uploads/get-download-url.js.map +1 -0
- package/dist/api/routes/admin/uploads/index.d.ts +10 -3
- package/dist/api/routes/admin/uploads/index.js +19 -4
- package/dist/api/routes/admin/uploads/index.js.map +1 -1
- package/dist/api/routes/store/carts/add-shipping-method.js +6 -2
- package/dist/api/routes/store/carts/add-shipping-method.js.map +1 -1
- package/dist/api/routes/store/carts/calculate-taxes.js +9 -2
- package/dist/api/routes/store/carts/calculate-taxes.js.map +1 -1
- package/dist/api/routes/store/carts/create-cart.js +6 -2
- package/dist/api/routes/store/carts/create-cart.js.map +1 -1
- package/dist/api/routes/store/carts/create-line-item.js +6 -2
- package/dist/api/routes/store/carts/create-line-item.js.map +1 -1
- package/dist/api/routes/store/carts/create-payment-sessions.js +6 -2
- package/dist/api/routes/store/carts/create-payment-sessions.js.map +1 -1
- package/dist/api/routes/store/carts/decorate-line-items-with-totals.d.ts +5 -0
- package/dist/api/routes/store/carts/decorate-line-items-with-totals.js +71 -0
- package/dist/api/routes/store/carts/decorate-line-items-with-totals.js.map +1 -0
- package/dist/api/routes/store/carts/delete-discount.js +6 -2
- package/dist/api/routes/store/carts/delete-discount.js.map +1 -1
- package/dist/api/routes/store/carts/delete-line-item.js +6 -2
- package/dist/api/routes/store/carts/delete-line-item.js.map +1 -1
- package/dist/api/routes/store/carts/delete-payment-session.js +6 -2
- package/dist/api/routes/store/carts/delete-payment-session.js.map +1 -1
- package/dist/api/routes/store/carts/get-cart.js +6 -2
- package/dist/api/routes/store/carts/get-cart.js.map +1 -1
- package/dist/api/routes/store/carts/refresh-payment-session.js +6 -2
- package/dist/api/routes/store/carts/refresh-payment-session.js.map +1 -1
- package/dist/api/routes/store/carts/set-payment-session.js +6 -2
- package/dist/api/routes/store/carts/set-payment-session.js.map +1 -1
- package/dist/api/routes/store/carts/update-cart.js +6 -2
- package/dist/api/routes/store/carts/update-cart.js.map +1 -1
- package/dist/api/routes/store/carts/update-line-item.js +6 -2
- package/dist/api/routes/store/carts/update-line-item.js.map +1 -1
- package/dist/api/routes/store/carts/update-payment-session.js +6 -2
- package/dist/api/routes/store/carts/update-payment-session.js.map +1 -1
- package/dist/api/routes/store/customers/get-payment-methods.js +6 -7
- package/dist/api/routes/store/customers/get-payment-methods.js.map +1 -1
- package/dist/api/routes/store/customers/index.d.ts +1 -1
- package/dist/api/routes/store/customers/index.js.map +1 -1
- package/dist/api/routes/store/customers/update-address.js +1 -1
- package/dist/api/routes/store/customers/update-address.js.map +1 -1
- package/dist/api/routes/store/customers/update-customer.d.ts +1 -1
- package/dist/api/routes/store/customers/update-customer.js.map +1 -1
- package/dist/api/routes/store/gift-cards/index.d.ts +1 -1
- package/dist/api/routes/store/gift-cards/index.js +6 -1
- package/dist/api/routes/store/gift-cards/index.js.map +1 -1
- package/dist/api/routes/store/products/get-product.js +51 -12
- package/dist/api/routes/store/products/get-product.js.map +1 -1
- package/dist/api/routes/store/products/list-products.js +30 -7
- package/dist/api/routes/store/products/list-products.js.map +1 -1
- package/dist/api/routes/store/shipping-options/list-options.js +6 -2
- package/dist/api/routes/store/shipping-options/list-options.js.map +1 -1
- package/dist/api/routes/store/shipping-options/list-shipping-options.js +8 -2
- package/dist/api/routes/store/shipping-options/list-shipping-options.js.map +1 -1
- package/dist/api/routes/store/variants/get-variant.js +51 -12
- package/dist/api/routes/store/variants/get-variant.js.map +1 -1
- package/dist/api/routes/store/variants/list-variants.js +29 -6
- package/dist/api/routes/store/variants/list-variants.js.map +1 -1
- package/dist/commands/migrate.js +29 -14
- package/dist/commands/migrate.js.map +1 -1
- package/dist/commands/seed.js +14 -10
- package/dist/commands/seed.js.map +1 -1
- package/dist/commands/start.js +1 -1
- package/dist/commands/utils/get-migrations.d.ts +2 -1
- package/dist/commands/utils/get-migrations.js +95 -36
- package/dist/commands/utils/get-migrations.js.map +1 -1
- package/dist/controllers/products/admin-list-products.js +16 -8
- package/dist/controllers/products/admin-list-products.js.map +1 -1
- package/dist/helpers/test-request.js +21 -15
- package/dist/helpers/test-request.js.map +1 -1
- package/dist/interfaces/abstract-parser.d.ts +25 -0
- package/dist/interfaces/abstract-parser.js +14 -0
- package/dist/interfaces/abstract-parser.js.map +1 -0
- package/dist/interfaces/batch-job-strategy.d.ts +34 -0
- package/dist/interfaces/batch-job-strategy.js +182 -0
- package/dist/interfaces/batch-job-strategy.js.map +1 -0
- package/dist/interfaces/csv-parser.d.ts +46 -0
- package/dist/interfaces/csv-parser.js +15 -0
- package/dist/interfaces/csv-parser.js.map +1 -0
- package/dist/interfaces/file-service.d.ts +66 -0
- package/dist/interfaces/file-service.js +32 -0
- package/dist/interfaces/file-service.js.map +1 -0
- package/dist/interfaces/index.d.ts +2 -0
- package/dist/interfaces/index.js +2 -0
- package/dist/interfaces/index.js.map +1 -1
- package/dist/loaders/config.js +3 -2
- package/dist/loaders/config.js.map +1 -1
- package/dist/loaders/feature-flags/index.d.ts +6 -0
- package/dist/loaders/feature-flags/index.js +71 -0
- package/dist/loaders/feature-flags/index.js.map +1 -0
- package/dist/loaders/index.d.ts +1 -1
- package/dist/loaders/index.js +8 -5
- package/dist/loaders/index.js.map +1 -1
- package/dist/loaders/plugins.d.ts +4 -3
- package/dist/loaders/plugins.js +71 -34
- package/dist/loaders/plugins.js.map +1 -1
- package/dist/loaders/redis.d.ts +1 -1
- package/dist/loaders/redis.js.map +1 -1
- package/dist/loaders/search-index.js +1 -0
- package/dist/loaders/search-index.js.map +1 -1
- package/dist/loaders/strategies.d.ts +2 -2
- package/dist/loaders/strategies.js +21 -7
- package/dist/loaders/strategies.js.map +1 -1
- package/dist/migrations/1657267320181-extended_batch_job.d.ts +6 -0
- package/dist/migrations/1657267320181-extended_batch_job.js +137 -0
- package/dist/migrations/1657267320181-extended_batch_job.js.map +1 -0
- package/dist/models/batch-job.d.ts +45 -4
- package/dist/models/batch-job.js +94 -7
- package/dist/models/batch-job.js.map +1 -1
- package/dist/models/customer.d.ts +1 -1
- package/dist/models/customer.js +1 -1
- package/dist/models/customer.js.map +1 -1
- package/dist/models/draft-order.d.ts +1 -2
- package/dist/models/draft-order.js +2 -2
- package/dist/models/draft-order.js.map +1 -1
- package/dist/models/line-item.d.ts +9 -2
- package/dist/models/line-item.js +2 -2
- package/dist/models/line-item.js.map +1 -1
- package/dist/models/product.d.ts +17 -17
- package/dist/models/product.js +34 -34
- package/dist/models/product.js.map +1 -1
- package/dist/models/shipping-method.d.ts +1 -1
- package/dist/models/shipping-method.js +1 -1
- package/dist/models/shipping-method.js.map +1 -1
- package/dist/models/shipping-option.d.ts +1 -1
- package/dist/models/shipping-option.js +1 -1
- package/dist/models/shipping-option.js.map +1 -1
- package/dist/repositories/customer.d.ts +2 -1
- package/dist/repositories/customer.js +18 -7
- package/dist/repositories/customer.js.map +1 -1
- package/dist/repositories/gift-card.d.ts +5 -1
- package/dist/repositories/gift-card.js +124 -29
- package/dist/repositories/gift-card.js.map +1 -1
- package/dist/repositories/image.d.ts +1 -0
- package/dist/repositories/image.js +100 -0
- package/dist/repositories/image.js.map +1 -1
- package/dist/repositories/price-list.js.map +1 -1
- package/dist/repositories/product-tag.d.ts +6 -0
- package/dist/repositories/product-tag.js +113 -0
- package/dist/repositories/product-tag.js.map +1 -1
- package/dist/repositories/product-type.d.ts +5 -0
- package/dist/repositories/product-type.js +64 -0
- package/dist/repositories/product-type.js.map +1 -1
- package/dist/repositories/product-variant.js +4 -5
- package/dist/repositories/product-variant.js.map +1 -1
- package/dist/repositories/product.d.ts +14 -17
- package/dist/repositories/product.js +64 -2
- package/dist/repositories/product.js.map +1 -1
- package/dist/repositories/tax-rate.d.ts +1 -1
- package/dist/repositories/tax-rate.js +2 -9
- package/dist/repositories/tax-rate.js.map +1 -1
- package/dist/services/auth.d.ts +16 -7
- package/dist/services/auth.js +130 -93
- package/dist/services/auth.js.map +1 -1
- package/dist/services/batch-job.d.ts +30 -5
- package/dist/services/batch-job.js +437 -2
- package/dist/services/batch-job.js.map +1 -1
- package/dist/services/cart.js +34 -13
- package/dist/services/cart.js.map +1 -1
- package/dist/services/claim-item.d.ts +23 -27
- package/dist/services/claim-item.js +217 -247
- package/dist/services/claim-item.js.map +1 -1
- package/dist/services/claim.d.ts +89 -71
- package/dist/services/claim.js +911 -879
- package/dist/services/claim.js.map +1 -1
- package/dist/services/csv-parser.d.ts +17 -0
- package/dist/services/csv-parser.js +319 -0
- package/dist/services/csv-parser.js.map +1 -0
- package/dist/services/custom-shipping-option.d.ts +30 -32
- package/dist/services/custom-shipping-option.js +78 -74
- package/dist/services/custom-shipping-option.js.map +1 -1
- package/dist/services/customer.d.ts +48 -50
- package/dist/services/customer.js +465 -428
- package/dist/services/customer.js.map +1 -1
- package/dist/services/discount-condition.d.ts +13 -13
- package/dist/services/discount-condition.js +5 -16
- package/dist/services/discount-condition.js.map +1 -1
- package/dist/services/discount.d.ts +22 -16
- package/dist/services/discount.js +530 -484
- package/dist/services/discount.js.map +1 -1
- package/dist/services/draft-order.d.ts +69 -66
- package/dist/services/draft-order.js +375 -353
- package/dist/services/draft-order.js.map +1 -1
- package/dist/services/event-bus.d.ts +72 -56
- package/dist/services/event-bus.js +122 -99
- package/dist/services/event-bus.js.map +1 -1
- package/dist/services/file.d.ts +14 -0
- package/dist/services/file.js +43 -0
- package/dist/services/file.js.map +1 -0
- package/dist/services/fulfillment.d.ts +63 -64
- package/dist/services/fulfillment.js +200 -194
- package/dist/services/fulfillment.js.map +1 -1
- package/dist/services/gift-card.d.ts +54 -45
- package/dist/services/gift-card.js +239 -221
- package/dist/services/gift-card.js.map +1 -1
- package/dist/services/idempotency-key.d.ts +1 -5
- package/dist/services/idempotency-key.js +2 -5
- package/dist/services/idempotency-key.js.map +1 -1
- package/dist/services/index.d.ts +11 -9
- package/dist/services/index.js +23 -19
- package/dist/services/index.js.map +1 -1
- package/dist/services/line-item.d.ts +3 -2
- package/dist/services/line-item.js +9 -7
- package/dist/services/line-item.js.map +1 -1
- package/dist/services/price-list.d.ts +4 -1
- package/dist/services/price-list.js +7 -4
- package/dist/services/price-list.js.map +1 -1
- package/dist/services/pricing.d.ts +101 -0
- package/dist/services/pricing.js +588 -0
- package/dist/services/pricing.js.map +1 -0
- package/dist/services/product-variant.d.ts +0 -11
- package/dist/services/product-variant.js +28 -138
- package/dist/services/product-variant.js.map +1 -1
- package/dist/services/product.d.ts +107 -145
- package/dist/services/product.js +708 -1036
- package/dist/services/product.js.map +1 -1
- package/dist/services/region.js +4 -4
- package/dist/services/region.js.map +1 -1
- package/dist/services/shipping-option.d.ts +43 -108
- package/dist/services/shipping-option.js +305 -352
- package/dist/services/shipping-option.js.map +1 -1
- package/dist/services/shipping-profile.d.ts +2 -2
- package/dist/services/shipping-profile.js +1 -1
- package/dist/services/store.d.ts +36 -45
- package/dist/services/store.js +207 -217
- package/dist/services/store.js.map +1 -1
- package/dist/services/strategy-resolver.d.ts +13 -0
- package/dist/services/strategy-resolver.js +40 -0
- package/dist/services/strategy-resolver.js.map +1 -0
- package/dist/services/tax-provider.d.ts +7 -3
- package/dist/services/tax-provider.js +6 -6
- package/dist/services/tax-provider.js.map +1 -1
- package/dist/services/tax-rate.d.ts +1 -1
- package/dist/services/tax-rate.js +2 -2
- package/dist/services/tax-rate.js.map +1 -1
- package/dist/services/totals.js.map +1 -1
- package/dist/services/user.d.ts +8 -9
- package/dist/services/user.js +216 -168
- package/dist/services/user.js.map +1 -1
- package/dist/strategies/__fixtures__/order-export-data.d.ts +3 -0
- package/dist/strategies/__fixtures__/order-export-data.js +70 -0
- package/dist/strategies/__fixtures__/order-export-data.js.map +1 -0
- package/dist/strategies/__fixtures__/product-export-data.d.ts +319 -0
- package/dist/strategies/__fixtures__/product-export-data.js +401 -0
- package/dist/strategies/__fixtures__/product-export-data.js.map +1 -0
- package/dist/strategies/batch-jobs/order/export.d.ts +36 -0
- package/dist/strategies/batch-jobs/order/export.js +351 -0
- package/dist/strategies/batch-jobs/order/export.js.map +1 -0
- package/dist/strategies/batch-jobs/order/index.d.ts +29 -0
- package/dist/strategies/batch-jobs/order/index.js +115 -0
- package/dist/strategies/batch-jobs/order/index.js.map +1 -0
- package/dist/strategies/batch-jobs/product/export.d.ts +36 -0
- package/dist/strategies/batch-jobs/product/export.js +546 -0
- package/dist/strategies/batch-jobs/product/export.js.map +1 -0
- package/dist/strategies/batch-jobs/product/index.d.ts +45 -0
- package/dist/strategies/batch-jobs/product/index.js +272 -0
- package/dist/strategies/batch-jobs/product/index.js.map +1 -0
- package/dist/subscribers/batch-job.d.ts +17 -0
- package/dist/subscribers/batch-job.js +96 -0
- package/dist/subscribers/batch-job.js.map +1 -0
- package/dist/types/batch-job.d.ts +23 -2
- package/dist/types/batch-job.js +4 -1
- package/dist/types/batch-job.js.map +1 -1
- package/dist/types/claim.d.ts +67 -0
- package/dist/types/claim.js +3 -0
- package/dist/types/claim.js.map +1 -0
- package/dist/types/common.d.ts +27 -3
- package/dist/types/common.js.map +1 -1
- package/dist/types/customers.d.ts +24 -0
- package/dist/types/customers.js.map +1 -1
- package/dist/types/discount.d.ts +2 -1
- package/dist/types/discount.js.map +1 -1
- package/dist/types/feature-flags.d.ts +9 -0
- package/dist/types/feature-flags.js +3 -0
- package/dist/types/feature-flags.js.map +1 -0
- package/dist/types/fulfillment.d.ts +27 -0
- package/dist/types/fulfillment.js +3 -0
- package/dist/types/fulfillment.js.map +1 -0
- package/dist/types/gift-card.d.ts +21 -0
- package/dist/types/gift-card.js +3 -0
- package/dist/types/gift-card.js.map +1 -0
- package/dist/types/global.d.ts +12 -1
- package/dist/types/price-list.d.ts +9 -0
- package/dist/types/pricing.d.ts +30 -0
- package/dist/types/pricing.js +3 -0
- package/dist/types/pricing.js.map +1 -0
- package/dist/types/product-variant.d.ts +4 -3
- package/dist/types/product-variant.js.map +1 -1
- package/dist/types/product.d.ts +110 -8
- package/dist/types/product.js +8 -11
- package/dist/types/product.js.map +1 -1
- package/dist/types/shipping-options.d.ts +62 -0
- package/dist/types/shipping-options.js +3 -0
- package/dist/types/shipping-options.js.map +1 -0
- package/dist/types/store.d.ts +9 -0
- package/dist/types/store.js +3 -0
- package/dist/types/store.js.map +1 -0
- package/dist/utils/build-query.d.ts +7 -7
- package/dist/utils/build-query.js +9 -5
- package/dist/utils/build-query.js.map +1 -1
- package/dist/utils/countries.d.ts +3 -2
- package/dist/utils/countries.js.map +1 -1
- package/dist/utils/currencies.d.ts +10 -1899
- package/dist/utils/currencies.js.map +1 -1
- package/dist/utils/db-aware-column.js +2 -2
- package/dist/utils/db-aware-column.js.map +1 -1
- package/dist/utils/feature-flag-decorators.d.ts +4 -0
- package/dist/utils/feature-flag-decorators.js +52 -0
- package/dist/utils/feature-flag-decorators.js.map +1 -0
- package/dist/utils/flag-router.d.ts +7 -0
- package/dist/utils/flag-router.js +19 -0
- package/dist/utils/flag-router.js.map +1 -0
- package/dist/utils/format-registration-name.d.ts +4 -4
- package/dist/utils/format-registration-name.js +7 -10
- package/dist/utils/format-registration-name.js.map +1 -1
- package/dist/utils/get-query-config.d.ts +4 -6
- package/dist/utils/get-query-config.js +46 -1
- package/dist/utils/get-query-config.js.map +1 -1
- package/dist/utils/omit-relation-if-exists.d.ts +7 -0
- package/dist/utils/omit-relation-if-exists.js +16 -0
- package/dist/utils/omit-relation-if-exists.js.map +1 -0
- package/dist/utils/set-metadata.d.ts +6 -6
- package/dist/utils/set-metadata.js +5 -5
- package/dist/utils/set-metadata.js.map +1 -1
- package/dist/utils/sleep.d.ts +1 -0
- package/dist/utils/sleep.js +50 -0
- package/dist/utils/sleep.js.map +1 -0
- package/package.json +6 -4
- package/yarn-error.log +29038 -0
- package/dist/scripts/mongo-sql-migration.d.ts +0 -2
- package/dist/scripts/mongo-sql-migration.js +0 -1603
- package/dist/scripts/mongo-sql-migration.js.map +0 -1
- package/dist/services/transaction.d.ts +0 -6
- package/dist/services/transaction.js.map +0 -1
|
@@ -72,109 +72,83 @@ var __values = (this && this.__values) || function(o) {
|
|
|
72
72
|
};
|
|
73
73
|
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
74
74
|
};
|
|
75
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
76
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
77
|
-
if (!m) return o;
|
|
78
|
-
var i = m.call(o), r, ar = [], e;
|
|
79
|
-
try {
|
|
80
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
81
|
-
}
|
|
82
|
-
catch (error) { e = { error: error }; }
|
|
83
|
-
finally {
|
|
84
|
-
try {
|
|
85
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
86
|
-
}
|
|
87
|
-
finally { if (e) throw e.error; }
|
|
88
|
-
}
|
|
89
|
-
return ar;
|
|
90
|
-
};
|
|
91
75
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
92
76
|
var medusa_core_utils_1 = require("medusa-core-utils");
|
|
93
|
-
var
|
|
77
|
+
var interfaces_1 = require("../interfaces");
|
|
78
|
+
var utils_1 = require("../utils");
|
|
94
79
|
/**
|
|
95
80
|
* Provides layer to manipulate profiles.
|
|
96
|
-
* @extends BaseService
|
|
97
81
|
*/
|
|
98
82
|
var ShippingOptionService = /** @class */ (function (_super) {
|
|
99
83
|
__extends(ShippingOptionService, _super);
|
|
100
84
|
function ShippingOptionService(_a) {
|
|
101
85
|
var manager = _a.manager, shippingOptionRepository = _a.shippingOptionRepository, shippingOptionRequirementRepository = _a.shippingOptionRequirementRepository, shippingMethodRepository = _a.shippingMethodRepository, fulfillmentProviderService = _a.fulfillmentProviderService, regionService = _a.regionService;
|
|
102
|
-
var _this =
|
|
103
|
-
|
|
86
|
+
var _this =
|
|
87
|
+
// eslint-disable-next-line prefer-rest-params
|
|
88
|
+
_super.call(this, arguments[0]) || this;
|
|
104
89
|
_this.manager_ = manager;
|
|
105
|
-
/** @private @const {ShippingOptionRepository} */
|
|
106
90
|
_this.optionRepository_ = shippingOptionRepository;
|
|
107
|
-
/** @private @const {ShippingMethodRepository} */
|
|
108
91
|
_this.methodRepository_ = shippingMethodRepository;
|
|
109
|
-
/** @private @const {ShippingOptionRequirementRepository} */
|
|
110
92
|
_this.requirementRepository_ = shippingOptionRequirementRepository;
|
|
111
|
-
/** @private @const {ProductService} */
|
|
112
93
|
_this.providerService_ = fulfillmentProviderService;
|
|
113
|
-
/** @private @const {RegionService} */
|
|
114
94
|
_this.regionService_ = regionService;
|
|
115
95
|
return _this;
|
|
116
96
|
}
|
|
117
|
-
ShippingOptionService.prototype.withTransaction = function (transactionManager) {
|
|
118
|
-
if (!transactionManager) {
|
|
119
|
-
return this;
|
|
120
|
-
}
|
|
121
|
-
var cloned = new ShippingOptionService({
|
|
122
|
-
manager: transactionManager,
|
|
123
|
-
shippingOptionRepository: this.optionRepository_,
|
|
124
|
-
shippingMethodRepository: this.methodRepository_,
|
|
125
|
-
shippingOptionRequirementRepository: this.requirementRepository_,
|
|
126
|
-
fulfillmentProviderService: this.providerService_,
|
|
127
|
-
regionService: this.regionService_,
|
|
128
|
-
});
|
|
129
|
-
cloned.transactionManager_ = transactionManager;
|
|
130
|
-
return cloned;
|
|
131
|
-
};
|
|
132
97
|
/**
|
|
133
98
|
* Validates a requirement
|
|
134
|
-
* @param {
|
|
99
|
+
* @param {ShippingOptionRequirement} requirement - the requirement to validate
|
|
135
100
|
* @param {string} optionId - the id to validate the requirement
|
|
136
|
-
* @return {
|
|
101
|
+
* @return {ShippingOptionRequirement} a validated shipping requirement
|
|
137
102
|
*/
|
|
138
103
|
ShippingOptionService.prototype.validateRequirement_ = function (requirement, optionId) {
|
|
104
|
+
if (optionId === void 0) { optionId = undefined; }
|
|
139
105
|
return __awaiter(this, void 0, void 0, function () {
|
|
140
|
-
var
|
|
106
|
+
var _this = this;
|
|
141
107
|
return __generator(this, function (_a) {
|
|
142
108
|
switch (_a.label) {
|
|
143
|
-
case 0:
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
109
|
+
case 0: return [4 /*yield*/, this.atomicPhase_(function (manager) { return __awaiter(_this, void 0, void 0, function () {
|
|
110
|
+
var reqRepo, existingReq, req, created;
|
|
111
|
+
return __generator(this, function (_a) {
|
|
112
|
+
switch (_a.label) {
|
|
113
|
+
case 0:
|
|
114
|
+
if (!requirement.type) {
|
|
115
|
+
throw new medusa_core_utils_1.MedusaError(medusa_core_utils_1.MedusaError.Types.INVALID_DATA, "A Shipping Requirement must have a type field");
|
|
116
|
+
}
|
|
117
|
+
if (requirement.type !== "min_subtotal" &&
|
|
118
|
+
requirement.type !== "max_subtotal") {
|
|
119
|
+
throw new medusa_core_utils_1.MedusaError(medusa_core_utils_1.MedusaError.Types.INVALID_DATA, "Requirement type must be one of min_subtotal, max_subtotal");
|
|
120
|
+
}
|
|
121
|
+
reqRepo = manager.getCustomRepository(this.requirementRepository_);
|
|
122
|
+
return [4 /*yield*/, reqRepo.findOne({
|
|
123
|
+
where: { id: requirement.id },
|
|
124
|
+
})];
|
|
125
|
+
case 1:
|
|
126
|
+
existingReq = _a.sent();
|
|
127
|
+
if (!existingReq && requirement.id) {
|
|
128
|
+
throw new medusa_core_utils_1.MedusaError(medusa_core_utils_1.MedusaError.Types.INVALID_DATA, "ID does not exist");
|
|
129
|
+
}
|
|
130
|
+
// If no option id is provided, we are currently in the process of creating
|
|
131
|
+
// a new shipping option. Therefore, simply return the requirement, such
|
|
132
|
+
// that the cascading will take care of the creation of the requirement.
|
|
133
|
+
if (!optionId) {
|
|
134
|
+
return [2 /*return*/, requirement];
|
|
135
|
+
}
|
|
136
|
+
if (!existingReq) return [3 /*break*/, 3];
|
|
137
|
+
return [4 /*yield*/, reqRepo.save(__assign(__assign({}, existingReq), requirement))];
|
|
138
|
+
case 2:
|
|
139
|
+
req = _a.sent();
|
|
140
|
+
return [3 /*break*/, 5];
|
|
141
|
+
case 3:
|
|
142
|
+
created = reqRepo.create(__assign(__assign({}, requirement), { shipping_option_id: optionId }));
|
|
143
|
+
return [4 /*yield*/, reqRepo.save(created)];
|
|
144
|
+
case 4:
|
|
145
|
+
req = _a.sent();
|
|
146
|
+
_a.label = 5;
|
|
147
|
+
case 5: return [2 /*return*/, req];
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
}); })];
|
|
151
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
178
152
|
}
|
|
179
153
|
});
|
|
180
154
|
});
|
|
@@ -187,11 +161,19 @@ var ShippingOptionService = /** @class */ (function (_super) {
|
|
|
187
161
|
ShippingOptionService.prototype.list = function (selector, config) {
|
|
188
162
|
if (config === void 0) { config = { skip: 0, take: 50 }; }
|
|
189
163
|
return __awaiter(this, void 0, void 0, function () {
|
|
190
|
-
var
|
|
164
|
+
var _this = this;
|
|
191
165
|
return __generator(this, function (_a) {
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
166
|
+
switch (_a.label) {
|
|
167
|
+
case 0: return [4 /*yield*/, this.atomicPhase_(function (transactionManager) { return __awaiter(_this, void 0, void 0, function () {
|
|
168
|
+
var optRepo, query;
|
|
169
|
+
return __generator(this, function (_a) {
|
|
170
|
+
optRepo = transactionManager.getCustomRepository(this.optionRepository_);
|
|
171
|
+
query = (0, utils_1.buildQuery)(selector, config);
|
|
172
|
+
return [2 /*return*/, optRepo.find(query)];
|
|
173
|
+
});
|
|
174
|
+
}); })];
|
|
175
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
176
|
+
}
|
|
195
177
|
});
|
|
196
178
|
});
|
|
197
179
|
};
|
|
@@ -203,13 +185,21 @@ var ShippingOptionService = /** @class */ (function (_super) {
|
|
|
203
185
|
ShippingOptionService.prototype.listAndCount = function (selector, config) {
|
|
204
186
|
if (config === void 0) { config = { skip: 0, take: 50 }; }
|
|
205
187
|
return __awaiter(this, void 0, void 0, function () {
|
|
206
|
-
var
|
|
188
|
+
var _this = this;
|
|
207
189
|
return __generator(this, function (_a) {
|
|
208
190
|
switch (_a.label) {
|
|
209
|
-
case 0:
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
191
|
+
case 0: return [4 /*yield*/, this.atomicPhase_(function (transactionManager) { return __awaiter(_this, void 0, void 0, function () {
|
|
192
|
+
var optRepo, query;
|
|
193
|
+
return __generator(this, function (_a) {
|
|
194
|
+
switch (_a.label) {
|
|
195
|
+
case 0:
|
|
196
|
+
optRepo = transactionManager.getCustomRepository(this.optionRepository_);
|
|
197
|
+
query = (0, utils_1.buildQuery)(selector, config);
|
|
198
|
+
return [4 /*yield*/, optRepo.findAndCount(query)];
|
|
199
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
}); })];
|
|
213
203
|
case 1: return [2 /*return*/, _a.sent()];
|
|
214
204
|
}
|
|
215
205
|
});
|
|
@@ -225,28 +215,35 @@ var ShippingOptionService = /** @class */ (function (_super) {
|
|
|
225
215
|
ShippingOptionService.prototype.retrieve = function (optionId, options) {
|
|
226
216
|
if (options === void 0) { options = {}; }
|
|
227
217
|
return __awaiter(this, void 0, void 0, function () {
|
|
228
|
-
var
|
|
218
|
+
var _this = this;
|
|
229
219
|
return __generator(this, function (_a) {
|
|
230
220
|
switch (_a.label) {
|
|
231
|
-
case 0:
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
221
|
+
case 0: return [4 /*yield*/, this.atomicPhase_(function (transactionManager) { return __awaiter(_this, void 0, void 0, function () {
|
|
222
|
+
var soRepo, query, option;
|
|
223
|
+
return __generator(this, function (_a) {
|
|
224
|
+
switch (_a.label) {
|
|
225
|
+
case 0:
|
|
226
|
+
soRepo = transactionManager.getCustomRepository(this.optionRepository_);
|
|
227
|
+
query = {
|
|
228
|
+
where: { id: optionId },
|
|
229
|
+
};
|
|
230
|
+
if (options.select) {
|
|
231
|
+
query.select = options.select;
|
|
232
|
+
}
|
|
233
|
+
if (options.relations) {
|
|
234
|
+
query.relations = options.relations;
|
|
235
|
+
}
|
|
236
|
+
return [4 /*yield*/, soRepo.findOne(query)];
|
|
237
|
+
case 1:
|
|
238
|
+
option = _a.sent();
|
|
239
|
+
if (!option) {
|
|
240
|
+
throw new medusa_core_utils_1.MedusaError(medusa_core_utils_1.MedusaError.Types.NOT_FOUND, "Shipping Option with ".concat(optionId, " was not found"));
|
|
241
|
+
}
|
|
242
|
+
return [2 /*return*/, option];
|
|
243
|
+
}
|
|
244
|
+
});
|
|
245
|
+
}); })];
|
|
246
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
250
247
|
}
|
|
251
248
|
});
|
|
252
249
|
});
|
|
@@ -262,52 +259,70 @@ var ShippingOptionService = /** @class */ (function (_super) {
|
|
|
262
259
|
return __awaiter(this, void 0, void 0, function () {
|
|
263
260
|
var _this = this;
|
|
264
261
|
return __generator(this, function (_a) {
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
method
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
262
|
+
switch (_a.label) {
|
|
263
|
+
case 0: return [4 /*yield*/, this.atomicPhase_(function (manager) { return __awaiter(_this, void 0, void 0, function () {
|
|
264
|
+
var methodRepo, method, _a, _b, key;
|
|
265
|
+
var e_1, _c;
|
|
266
|
+
return __generator(this, function (_d) {
|
|
267
|
+
switch (_d.label) {
|
|
268
|
+
case 0:
|
|
269
|
+
methodRepo = manager.getCustomRepository(this.methodRepository_);
|
|
270
|
+
return [4 /*yield*/, methodRepo.findOne({ where: { id: id } })];
|
|
271
|
+
case 1:
|
|
272
|
+
method = _d.sent();
|
|
273
|
+
if (!method) {
|
|
274
|
+
return [2 /*return*/, undefined];
|
|
275
|
+
}
|
|
276
|
+
try {
|
|
277
|
+
for (_a = __values(Object.keys(update).filter(function (k) { return typeof update[k] !== "undefined"; })), _b = _a.next(); !_b.done; _b = _a.next()) {
|
|
278
|
+
key = _b.value;
|
|
279
|
+
method[key] = update[key];
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
283
|
+
finally {
|
|
284
|
+
try {
|
|
285
|
+
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
|
|
286
|
+
}
|
|
287
|
+
finally { if (e_1) throw e_1.error; }
|
|
288
|
+
}
|
|
289
|
+
return [2 /*return*/, methodRepo.save(method)];
|
|
290
|
+
}
|
|
291
|
+
});
|
|
292
|
+
}); })];
|
|
293
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
294
|
+
}
|
|
290
295
|
});
|
|
291
296
|
});
|
|
292
297
|
};
|
|
293
298
|
/**
|
|
294
299
|
* Removes a given shipping method
|
|
295
300
|
* @param {ShippingMethod | Array<ShippingMethod>} shippingMethods - the shipping method to remove
|
|
301
|
+
* @returns removed shipping methods
|
|
296
302
|
*/
|
|
297
303
|
ShippingOptionService.prototype.deleteShippingMethods = function (shippingMethods) {
|
|
298
304
|
return __awaiter(this, void 0, void 0, function () {
|
|
305
|
+
var removeEntities;
|
|
299
306
|
var _this = this;
|
|
300
307
|
return __generator(this, function (_a) {
|
|
301
|
-
|
|
302
|
-
|
|
308
|
+
switch (_a.label) {
|
|
309
|
+
case 0:
|
|
310
|
+
removeEntities = Array.isArray(shippingMethods)
|
|
311
|
+
? shippingMethods
|
|
312
|
+
: [shippingMethods];
|
|
313
|
+
return [4 /*yield*/, this.atomicPhase_(function (manager) { return __awaiter(_this, void 0, void 0, function () {
|
|
314
|
+
var methodRepo;
|
|
315
|
+
return __generator(this, function (_a) {
|
|
316
|
+
switch (_a.label) {
|
|
317
|
+
case 0:
|
|
318
|
+
methodRepo = manager.getCustomRepository(this.methodRepository_);
|
|
319
|
+
return [4 /*yield*/, methodRepo.remove(removeEntities)];
|
|
320
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
321
|
+
}
|
|
322
|
+
});
|
|
323
|
+
}); })];
|
|
324
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
303
325
|
}
|
|
304
|
-
return [2 /*return*/, this.atomicPhase_(function (manager) { return __awaiter(_this, void 0, void 0, function () {
|
|
305
|
-
var methodRepo;
|
|
306
|
-
return __generator(this, function (_a) {
|
|
307
|
-
methodRepo = manager.getCustomRepository(this.methodRepository_);
|
|
308
|
-
return [2 /*return*/, methodRepo.remove(shippingMethods)];
|
|
309
|
-
});
|
|
310
|
-
}); })];
|
|
311
326
|
});
|
|
312
327
|
});
|
|
313
328
|
};
|
|
@@ -322,69 +337,69 @@ var ShippingOptionService = /** @class */ (function (_super) {
|
|
|
322
337
|
return __awaiter(this, void 0, void 0, function () {
|
|
323
338
|
var _this = this;
|
|
324
339
|
return __generator(this, function (_a) {
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
case 1:
|
|
333
|
-
option = _a.sent();
|
|
334
|
-
methodRepo = manager.getCustomRepository(this.methodRepository_);
|
|
335
|
-
if ("cart" in config) {
|
|
336
|
-
this.validateCartOption(option, config.cart || {});
|
|
337
|
-
}
|
|
338
|
-
return [4 /*yield*/, this.providerService_.validateFulfillmentData(option, data, config.cart || {})];
|
|
339
|
-
case 2:
|
|
340
|
-
validatedData = _a.sent();
|
|
341
|
-
if (!(typeof config.price === "number")) return [3 /*break*/, 3];
|
|
342
|
-
methodPrice = config.price;
|
|
343
|
-
return [3 /*break*/, 5];
|
|
344
|
-
case 3: return [4 /*yield*/, this.getPrice_(option, validatedData, config.cart)];
|
|
345
|
-
case 4:
|
|
346
|
-
methodPrice = _a.sent();
|
|
347
|
-
_a.label = 5;
|
|
348
|
-
case 5:
|
|
349
|
-
toCreate = {
|
|
350
|
-
shipping_option_id: option.id,
|
|
351
|
-
data: validatedData,
|
|
352
|
-
price: methodPrice,
|
|
353
|
-
};
|
|
354
|
-
if (config.order) {
|
|
355
|
-
toCreate.order_id = config.order.id;
|
|
356
|
-
}
|
|
357
|
-
if (config.cart) {
|
|
358
|
-
toCreate.cart_id = config.cart.id;
|
|
359
|
-
}
|
|
360
|
-
if (config.cart_id) {
|
|
361
|
-
toCreate.cart_id = config.cart_id;
|
|
362
|
-
}
|
|
363
|
-
if (config.return_id) {
|
|
364
|
-
toCreate.return_id = config.return_id;
|
|
365
|
-
}
|
|
366
|
-
if (config.order_id) {
|
|
367
|
-
toCreate.order_id = config.order_id;
|
|
368
|
-
}
|
|
369
|
-
if (config.claim_order_id) {
|
|
370
|
-
toCreate.claim_order_id = config.claim_order_id;
|
|
371
|
-
}
|
|
372
|
-
if (config.draft_order_id) {
|
|
373
|
-
toCreate.draft_order_id = config.draft_order_id;
|
|
374
|
-
}
|
|
375
|
-
return [4 /*yield*/, methodRepo.create(toCreate)];
|
|
376
|
-
case 6:
|
|
377
|
-
method = _a.sent();
|
|
378
|
-
return [4 /*yield*/, methodRepo.save(method)];
|
|
379
|
-
case 7:
|
|
380
|
-
created = _a.sent();
|
|
381
|
-
return [2 /*return*/, methodRepo.findOne({
|
|
382
|
-
where: { id: created.id },
|
|
383
|
-
relations: ["shipping_option"],
|
|
340
|
+
switch (_a.label) {
|
|
341
|
+
case 0: return [4 /*yield*/, this.atomicPhase_(function (manager) { return __awaiter(_this, void 0, void 0, function () {
|
|
342
|
+
var option, methodRepo, validatedData, methodPrice, toCreate, method, created;
|
|
343
|
+
return __generator(this, function (_a) {
|
|
344
|
+
switch (_a.label) {
|
|
345
|
+
case 0: return [4 /*yield*/, this.retrieve(optionId, {
|
|
346
|
+
relations: ["requirements"],
|
|
384
347
|
})];
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
348
|
+
case 1:
|
|
349
|
+
option = _a.sent();
|
|
350
|
+
methodRepo = manager.getCustomRepository(this.methodRepository_);
|
|
351
|
+
if (typeof config.cart !== "undefined") {
|
|
352
|
+
this.validateCartOption(option, config.cart);
|
|
353
|
+
}
|
|
354
|
+
return [4 /*yield*/, this.providerService_.validateFulfillmentData(option, data, config.cart || {})];
|
|
355
|
+
case 2:
|
|
356
|
+
validatedData = _a.sent();
|
|
357
|
+
if (!(typeof config.price === "number")) return [3 /*break*/, 3];
|
|
358
|
+
methodPrice = config.price;
|
|
359
|
+
return [3 /*break*/, 5];
|
|
360
|
+
case 3: return [4 /*yield*/, this.getPrice_(option, validatedData, config.cart)];
|
|
361
|
+
case 4:
|
|
362
|
+
methodPrice = _a.sent();
|
|
363
|
+
_a.label = 5;
|
|
364
|
+
case 5:
|
|
365
|
+
toCreate = {
|
|
366
|
+
shipping_option_id: option.id,
|
|
367
|
+
data: validatedData,
|
|
368
|
+
price: methodPrice,
|
|
369
|
+
};
|
|
370
|
+
if (config.order) {
|
|
371
|
+
toCreate.order_id = config.order.id;
|
|
372
|
+
}
|
|
373
|
+
if (config.cart) {
|
|
374
|
+
toCreate.cart_id = config.cart.id;
|
|
375
|
+
}
|
|
376
|
+
if (config.cart_id) {
|
|
377
|
+
toCreate.cart_id = config.cart_id;
|
|
378
|
+
}
|
|
379
|
+
if (config.return_id) {
|
|
380
|
+
toCreate.return_id = config.return_id;
|
|
381
|
+
}
|
|
382
|
+
if (config.order_id) {
|
|
383
|
+
toCreate.order_id = config.order_id;
|
|
384
|
+
}
|
|
385
|
+
if (config.claim_order_id) {
|
|
386
|
+
toCreate.claim_order_id = config.claim_order_id;
|
|
387
|
+
}
|
|
388
|
+
return [4 /*yield*/, methodRepo.create(toCreate)];
|
|
389
|
+
case 6:
|
|
390
|
+
method = _a.sent();
|
|
391
|
+
return [4 /*yield*/, methodRepo.save(method)];
|
|
392
|
+
case 7:
|
|
393
|
+
created = _a.sent();
|
|
394
|
+
return [2 /*return*/, methodRepo.findOne({
|
|
395
|
+
where: { id: created.id },
|
|
396
|
+
relations: ["shipping_option"],
|
|
397
|
+
})];
|
|
398
|
+
}
|
|
399
|
+
});
|
|
400
|
+
}); })];
|
|
401
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
402
|
+
}
|
|
388
403
|
});
|
|
389
404
|
});
|
|
390
405
|
};
|
|
@@ -431,22 +446,23 @@ var ShippingOptionService = /** @class */ (function (_super) {
|
|
|
431
446
|
var _this = this;
|
|
432
447
|
return __generator(this, function (_a) {
|
|
433
448
|
return [2 /*return*/, this.atomicPhase_(function (manager) { return __awaiter(_this, void 0, void 0, function () {
|
|
434
|
-
var optionRepo, option, region, _a, isValid, acc, _loop_1, this_1, _b, _c, r,
|
|
435
|
-
var
|
|
436
|
-
|
|
437
|
-
|
|
449
|
+
var optionRepo, option, region, _a, isValid, acc, _loop_1, this_1, _b, _c, r, e_2_1, result;
|
|
450
|
+
var e_2, _d;
|
|
451
|
+
var _e;
|
|
452
|
+
return __generator(this, function (_f) {
|
|
453
|
+
switch (_f.label) {
|
|
438
454
|
case 0:
|
|
439
455
|
optionRepo = manager.getCustomRepository(this.optionRepository_);
|
|
440
456
|
return [4 /*yield*/, optionRepo.create(data)];
|
|
441
457
|
case 1:
|
|
442
|
-
option =
|
|
458
|
+
option = _f.sent();
|
|
443
459
|
return [4 /*yield*/, this.regionService_
|
|
444
460
|
.withTransaction(manager)
|
|
445
461
|
.retrieve(option.region_id, {
|
|
446
462
|
relations: ["fulfillment_providers"],
|
|
447
463
|
})];
|
|
448
464
|
case 2:
|
|
449
|
-
region =
|
|
465
|
+
region = _f.sent();
|
|
450
466
|
if (!region.fulfillment_providers.find(function (_a) {
|
|
451
467
|
var id = _a.id;
|
|
452
468
|
return id === option.provider_id;
|
|
@@ -456,23 +472,24 @@ var ShippingOptionService = /** @class */ (function (_super) {
|
|
|
456
472
|
_a = option;
|
|
457
473
|
return [4 /*yield*/, this.validatePriceType_(data.price_type, option)];
|
|
458
474
|
case 3:
|
|
459
|
-
_a.price_type =
|
|
460
|
-
option.amount =
|
|
475
|
+
_a.price_type = _f.sent();
|
|
476
|
+
option.amount =
|
|
477
|
+
data.price_type === "calculated" ? null : (_e = data.amount) !== null && _e !== void 0 ? _e : null;
|
|
461
478
|
return [4 /*yield*/, this.providerService_.validateOption(option)];
|
|
462
479
|
case 4:
|
|
463
|
-
isValid =
|
|
480
|
+
isValid = _f.sent();
|
|
464
481
|
if (!isValid) {
|
|
465
482
|
throw new medusa_core_utils_1.MedusaError(medusa_core_utils_1.MedusaError.Types.INVALID_DATA, "The fulfillment provider cannot validate the shipping option");
|
|
466
483
|
}
|
|
467
|
-
if (!(
|
|
484
|
+
if (!(typeof data.requirements !== "undefined")) return [3 /*break*/, 12];
|
|
468
485
|
acc = [];
|
|
469
486
|
_loop_1 = function (r) {
|
|
470
487
|
var validated;
|
|
471
|
-
return __generator(this, function (
|
|
472
|
-
switch (
|
|
488
|
+
return __generator(this, function (_g) {
|
|
489
|
+
switch (_g.label) {
|
|
473
490
|
case 0: return [4 /*yield*/, this_1.validateRequirement_(r)];
|
|
474
491
|
case 1:
|
|
475
|
-
validated =
|
|
492
|
+
validated = _g.sent();
|
|
476
493
|
if (acc.find(function (raw) { return raw.type === validated.type; })) {
|
|
477
494
|
throw new medusa_core_utils_1.MedusaError(medusa_core_utils_1.MedusaError.Types.INVALID_DATA, "Only one requirement of each type is allowed");
|
|
478
495
|
}
|
|
@@ -489,35 +506,35 @@ var ShippingOptionService = /** @class */ (function (_super) {
|
|
|
489
506
|
});
|
|
490
507
|
};
|
|
491
508
|
this_1 = this;
|
|
492
|
-
|
|
509
|
+
_f.label = 5;
|
|
493
510
|
case 5:
|
|
494
|
-
|
|
511
|
+
_f.trys.push([5, 10, 11, 12]);
|
|
495
512
|
_b = __values(data.requirements), _c = _b.next();
|
|
496
|
-
|
|
513
|
+
_f.label = 6;
|
|
497
514
|
case 6:
|
|
498
515
|
if (!!_c.done) return [3 /*break*/, 9];
|
|
499
516
|
r = _c.value;
|
|
500
517
|
return [5 /*yield**/, _loop_1(r)];
|
|
501
518
|
case 7:
|
|
502
|
-
|
|
503
|
-
|
|
519
|
+
_f.sent();
|
|
520
|
+
_f.label = 8;
|
|
504
521
|
case 8:
|
|
505
522
|
_c = _b.next();
|
|
506
523
|
return [3 /*break*/, 6];
|
|
507
524
|
case 9: return [3 /*break*/, 12];
|
|
508
525
|
case 10:
|
|
509
|
-
|
|
510
|
-
|
|
526
|
+
e_2_1 = _f.sent();
|
|
527
|
+
e_2 = { error: e_2_1 };
|
|
511
528
|
return [3 /*break*/, 12];
|
|
512
529
|
case 11:
|
|
513
530
|
try {
|
|
514
531
|
if (_c && !_c.done && (_d = _b.return)) _d.call(_b);
|
|
515
532
|
}
|
|
516
|
-
finally { if (
|
|
533
|
+
finally { if (e_2) throw e_2.error; }
|
|
517
534
|
return [7 /*endfinally*/];
|
|
518
535
|
case 12: return [4 /*yield*/, optionRepo.save(option)];
|
|
519
536
|
case 13:
|
|
520
|
-
result =
|
|
537
|
+
result = _f.sent();
|
|
521
538
|
return [2 /*return*/, result];
|
|
522
539
|
}
|
|
523
540
|
});
|
|
@@ -525,16 +542,11 @@ var ShippingOptionService = /** @class */ (function (_super) {
|
|
|
525
542
|
});
|
|
526
543
|
});
|
|
527
544
|
};
|
|
528
|
-
/**
|
|
529
|
-
* @typedef ShippingOptionPrice
|
|
530
|
-
* @property {string} type - one of flat_rate, calculated
|
|
531
|
-
* @property {number} value - the value if available
|
|
532
|
-
*/
|
|
533
545
|
/**
|
|
534
546
|
* Validates a shipping option price
|
|
535
|
-
* @param {
|
|
547
|
+
* @param {ShippingOptionPriceType} priceType - the price to validate
|
|
536
548
|
* @param {ShippingOption} option - the option to validate against
|
|
537
|
-
* @return {Promise<
|
|
549
|
+
* @return {Promise<ShippingOptionPriceType>} the validated price
|
|
538
550
|
*/
|
|
539
551
|
ShippingOptionService.prototype.validatePriceType_ = function (priceType, option) {
|
|
540
552
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -573,8 +585,8 @@ var ShippingOptionService = /** @class */ (function (_super) {
|
|
|
573
585
|
var _this = this;
|
|
574
586
|
return __generator(this, function (_a) {
|
|
575
587
|
return [2 /*return*/, this.atomicPhase_(function (manager) { return __awaiter(_this, void 0, void 0, function () {
|
|
576
|
-
var option, _a, acc, _loop_2, this_2, _b, _c, r,
|
|
577
|
-
var
|
|
588
|
+
var option, _a, acc, _loop_2, this_2, _b, _c, r, e_3_1, accReqs_1, toRemove, _d, optionRepo;
|
|
589
|
+
var e_3, _e;
|
|
578
590
|
var _this = this;
|
|
579
591
|
return __generator(this, function (_f) {
|
|
580
592
|
switch (_f.label) {
|
|
@@ -583,9 +595,9 @@ var ShippingOptionService = /** @class */ (function (_super) {
|
|
|
583
595
|
})];
|
|
584
596
|
case 1:
|
|
585
597
|
option = _f.sent();
|
|
586
|
-
if (!(
|
|
598
|
+
if (!(typeof update.metadata !== "undefined")) return [3 /*break*/, 3];
|
|
587
599
|
_a = option;
|
|
588
|
-
return [4 /*yield*/,
|
|
600
|
+
return [4 /*yield*/, (0, utils_1.setMetadata)(option, update.metadata)];
|
|
589
601
|
case 2:
|
|
590
602
|
_a.metadata = _f.sent();
|
|
591
603
|
_f.label = 3;
|
|
@@ -593,10 +605,10 @@ var ShippingOptionService = /** @class */ (function (_super) {
|
|
|
593
605
|
if (update.region_id || update.provider_id || update.data) {
|
|
594
606
|
throw new medusa_core_utils_1.MedusaError(medusa_core_utils_1.MedusaError.Types.NOT_ALLOWED, "Region and Provider cannot be updated after creation");
|
|
595
607
|
}
|
|
596
|
-
if (
|
|
608
|
+
if (typeof update.is_return !== "undefined") {
|
|
597
609
|
throw new medusa_core_utils_1.MedusaError(medusa_core_utils_1.MedusaError.Types.NOT_ALLOWED, "is_return cannot be changed after creation");
|
|
598
610
|
}
|
|
599
|
-
if (!(
|
|
611
|
+
if (!(typeof update.requirements !== "undefined")) return [3 /*break*/, 14];
|
|
600
612
|
acc = [];
|
|
601
613
|
_loop_2 = function (r) {
|
|
602
614
|
var validated;
|
|
@@ -638,14 +650,14 @@ var ShippingOptionService = /** @class */ (function (_super) {
|
|
|
638
650
|
return [3 /*break*/, 5];
|
|
639
651
|
case 8: return [3 /*break*/, 11];
|
|
640
652
|
case 9:
|
|
641
|
-
|
|
642
|
-
|
|
653
|
+
e_3_1 = _f.sent();
|
|
654
|
+
e_3 = { error: e_3_1 };
|
|
643
655
|
return [3 /*break*/, 11];
|
|
644
656
|
case 10:
|
|
645
657
|
try {
|
|
646
658
|
if (_c && !_c.done && (_e = _b.return)) _e.call(_b);
|
|
647
659
|
}
|
|
648
|
-
finally { if (
|
|
660
|
+
finally { if (e_3) throw e_3.error; }
|
|
649
661
|
return [7 /*endfinally*/];
|
|
650
662
|
case 11:
|
|
651
663
|
if (!option.requirements) return [3 /*break*/, 13];
|
|
@@ -668,7 +680,7 @@ var ShippingOptionService = /** @class */ (function (_super) {
|
|
|
668
680
|
option.requirements = acc;
|
|
669
681
|
_f.label = 14;
|
|
670
682
|
case 14:
|
|
671
|
-
if (!(
|
|
683
|
+
if (!(typeof update.price_type !== "undefined")) return [3 /*break*/, 16];
|
|
672
684
|
_d = option;
|
|
673
685
|
return [4 /*yield*/, this.validatePriceType_(update.price_type, option)];
|
|
674
686
|
case 15:
|
|
@@ -678,20 +690,19 @@ var ShippingOptionService = /** @class */ (function (_super) {
|
|
|
678
690
|
}
|
|
679
691
|
_f.label = 16;
|
|
680
692
|
case 16:
|
|
681
|
-
if (
|
|
693
|
+
if (typeof update.amount !== "undefined" &&
|
|
694
|
+
option.price_type !== "calculated") {
|
|
682
695
|
option.amount = update.amount;
|
|
683
696
|
}
|
|
684
|
-
if (
|
|
697
|
+
if (typeof update.name !== "undefined") {
|
|
685
698
|
option.name = update.name;
|
|
686
699
|
}
|
|
687
|
-
if (
|
|
700
|
+
if (typeof update.admin_only !== "undefined") {
|
|
688
701
|
option.admin_only = update.admin_only;
|
|
689
702
|
}
|
|
690
703
|
optionRepo = manager.getCustomRepository(this.optionRepository_);
|
|
691
704
|
return [4 /*yield*/, optionRepo.save(option)];
|
|
692
|
-
case 17:
|
|
693
|
-
result = _f.sent();
|
|
694
|
-
return [2 /*return*/, result];
|
|
705
|
+
case 17: return [2 /*return*/, _f.sent()];
|
|
695
706
|
}
|
|
696
707
|
});
|
|
697
708
|
}); })];
|
|
@@ -706,35 +717,38 @@ var ShippingOptionService = /** @class */ (function (_super) {
|
|
|
706
717
|
*/
|
|
707
718
|
ShippingOptionService.prototype.delete = function (optionId) {
|
|
708
719
|
return __awaiter(this, void 0, void 0, function () {
|
|
709
|
-
var
|
|
720
|
+
var _this = this;
|
|
710
721
|
return __generator(this, function (_a) {
|
|
711
722
|
switch (_a.label) {
|
|
712
|
-
case 0:
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
723
|
+
case 0: return [4 /*yield*/, this.atomicPhase_(function (manager) { return __awaiter(_this, void 0, void 0, function () {
|
|
724
|
+
var option, optionRepo, error_1;
|
|
725
|
+
return __generator(this, function (_a) {
|
|
726
|
+
switch (_a.label) {
|
|
727
|
+
case 0:
|
|
728
|
+
_a.trys.push([0, 2, , 3]);
|
|
729
|
+
return [4 /*yield*/, this.retrieve(optionId)];
|
|
730
|
+
case 1:
|
|
731
|
+
option = _a.sent();
|
|
732
|
+
optionRepo = manager.getCustomRepository(this.optionRepository_);
|
|
733
|
+
return [2 /*return*/, optionRepo.softRemove(option)];
|
|
734
|
+
case 2:
|
|
735
|
+
error_1 = _a.sent();
|
|
736
|
+
// Delete is idempotent, but we return a promise to allow then-chaining
|
|
737
|
+
return [2 /*return*/];
|
|
738
|
+
case 3: return [2 /*return*/];
|
|
739
|
+
}
|
|
740
|
+
});
|
|
741
|
+
}); })];
|
|
742
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
724
743
|
}
|
|
725
744
|
});
|
|
726
745
|
});
|
|
727
746
|
};
|
|
728
|
-
/**
|
|
729
|
-
* @typedef ShippingRequirement
|
|
730
|
-
* @property {string} type - one of max_subtotal, min_subtotal
|
|
731
|
-
* @property {number} amount - the value to match against
|
|
732
|
-
*/
|
|
733
747
|
/**
|
|
734
748
|
* Adds a requirement to a shipping option. Only 1 requirement of each type
|
|
735
749
|
* is allowed.
|
|
736
750
|
* @param {string} optionId - the option to add the requirement to.
|
|
737
|
-
* @param {
|
|
751
|
+
* @param {ShippingOptionRequirement} requirement - the requirement for the option.
|
|
738
752
|
* @return {Promise} the result of update
|
|
739
753
|
*/
|
|
740
754
|
ShippingOptionService.prototype.addRequirement = function (optionId, requirement) {
|
|
@@ -773,93 +787,32 @@ var ShippingOptionService = /** @class */ (function (_super) {
|
|
|
773
787
|
ShippingOptionService.prototype.removeRequirement = function (requirementId) {
|
|
774
788
|
return __awaiter(this, void 0, void 0, function () {
|
|
775
789
|
var _this = this;
|
|
776
|
-
return __generator(this, function (_a) {
|
|
777
|
-
return [2 /*return*/, this.atomicPhase_(function (manager) { return __awaiter(_this, void 0, void 0, function () {
|
|
778
|
-
var reqRepo, requirement, result, error_2;
|
|
779
|
-
return __generator(this, function (_a) {
|
|
780
|
-
switch (_a.label) {
|
|
781
|
-
case 0:
|
|
782
|
-
_a.trys.push([0, 3, , 4]);
|
|
783
|
-
reqRepo = manager.getCustomRepository(this.requirementRepository_);
|
|
784
|
-
return [4 /*yield*/, reqRepo.findOne({
|
|
785
|
-
where: { id: requirementId },
|
|
786
|
-
})];
|
|
787
|
-
case 1:
|
|
788
|
-
requirement = _a.sent();
|
|
789
|
-
return [4 /*yield*/, reqRepo.softRemove(requirement)];
|
|
790
|
-
case 2:
|
|
791
|
-
result = _a.sent();
|
|
792
|
-
return [2 /*return*/, result];
|
|
793
|
-
case 3:
|
|
794
|
-
error_2 = _a.sent();
|
|
795
|
-
// Delete is idempotent, but we return a promise to allow then-chaining
|
|
796
|
-
return [2 /*return*/, Promise.resolve()];
|
|
797
|
-
case 4: return [2 /*return*/];
|
|
798
|
-
}
|
|
799
|
-
});
|
|
800
|
-
}); })];
|
|
801
|
-
});
|
|
802
|
-
});
|
|
803
|
-
};
|
|
804
|
-
/**
|
|
805
|
-
* Decorates a shipping option.
|
|
806
|
-
* @param {ShippingOption} optionId - the shipping option to decorate using optionId.
|
|
807
|
-
* @param {string[]} fields - the fields to include.
|
|
808
|
-
* @param {string[]} expandFields - fields to expand.
|
|
809
|
-
* @return {ShippingOption} the decorated ShippingOption.
|
|
810
|
-
*/
|
|
811
|
-
ShippingOptionService.prototype.decorate = function (optionId, fields, expandFields) {
|
|
812
|
-
if (fields === void 0) { fields = []; }
|
|
813
|
-
if (expandFields === void 0) { expandFields = []; }
|
|
814
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
815
|
-
var requiredFields, option;
|
|
816
790
|
return __generator(this, function (_a) {
|
|
817
791
|
switch (_a.label) {
|
|
818
|
-
case 0:
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
var e_3, _d;
|
|
842
|
-
return __generator(this, function (_e) {
|
|
843
|
-
existing = option.metadata || {};
|
|
844
|
-
newData = {};
|
|
845
|
-
try {
|
|
846
|
-
for (_a = __values(Object.entries(metadata)), _b = _a.next(); !_b.done; _b = _a.next()) {
|
|
847
|
-
_c = __read(_b.value, 2), key = _c[0], value = _c[1];
|
|
848
|
-
if (typeof key !== "string") {
|
|
849
|
-
throw new medusa_core_utils_1.MedusaError(medusa_core_utils_1.MedusaError.Types.INVALID_ARGUMENT, "Key type is invalid. Metadata keys must be strings");
|
|
850
|
-
}
|
|
851
|
-
newData[key] = value;
|
|
852
|
-
}
|
|
853
|
-
}
|
|
854
|
-
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
855
|
-
finally {
|
|
856
|
-
try {
|
|
857
|
-
if (_b && !_b.done && (_d = _a.return)) _d.call(_a);
|
|
858
|
-
}
|
|
859
|
-
finally { if (e_3) throw e_3.error; }
|
|
792
|
+
case 0: return [4 /*yield*/, this.atomicPhase_(function (manager) { return __awaiter(_this, void 0, void 0, function () {
|
|
793
|
+
var reqRepo, requirement;
|
|
794
|
+
return __generator(this, function (_a) {
|
|
795
|
+
switch (_a.label) {
|
|
796
|
+
case 0:
|
|
797
|
+
reqRepo = manager.getCustomRepository(this.requirementRepository_);
|
|
798
|
+
return [4 /*yield*/, reqRepo.findOne({
|
|
799
|
+
where: { id: requirementId },
|
|
800
|
+
})
|
|
801
|
+
// Delete is idempotent, but we return a promise to allow then-chaining
|
|
802
|
+
];
|
|
803
|
+
case 1:
|
|
804
|
+
requirement = _a.sent();
|
|
805
|
+
// Delete is idempotent, but we return a promise to allow then-chaining
|
|
806
|
+
if (typeof requirement === "undefined") {
|
|
807
|
+
return [2 /*return*/, Promise.resolve()];
|
|
808
|
+
}
|
|
809
|
+
return [4 /*yield*/, reqRepo.softRemove(requirement)];
|
|
810
|
+
case 2: return [2 /*return*/, _a.sent()];
|
|
811
|
+
}
|
|
812
|
+
});
|
|
813
|
+
}); })];
|
|
814
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
860
815
|
}
|
|
861
|
-
updated = __assign(__assign({}, existing), newData);
|
|
862
|
-
return [2 /*return*/, updated];
|
|
863
816
|
});
|
|
864
817
|
});
|
|
865
818
|
};
|
|
@@ -885,6 +838,6 @@ var ShippingOptionService = /** @class */ (function (_super) {
|
|
|
885
838
|
});
|
|
886
839
|
};
|
|
887
840
|
return ShippingOptionService;
|
|
888
|
-
}(
|
|
841
|
+
}(interfaces_1.TransactionBaseService));
|
|
889
842
|
exports.default = ShippingOptionService;
|
|
890
843
|
//# sourceMappingURL=shipping-option.js.map
|