@medusajs/medusa 1.3.2 → 1.3.3
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/api/middlewares/feature-flag-enabled.js +57 -0
- 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/discounts/add-valid-product.d.ts +23 -0
- package/dist/api/routes/admin/discounts/add-valid-product.js +82 -0
- package/dist/api/routes/admin/discounts/add-valid-product.js.map +1 -0
- package/dist/api/routes/admin/discounts/remove-valid-product.d.ts +23 -0
- package/dist/api/routes/admin/discounts/remove-valid-product.js +82 -0
- package/dist/api/routes/admin/discounts/remove-valid-product.js.map +1 -0
- 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/get-variants.d.ts +24 -0
- package/dist/api/routes/admin/products/get-variants.js +76 -0
- package/dist/api/routes/admin/products/get-variants.js.map +1 -0
- 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-method.d.ts +38 -0
- package/dist/api/routes/store/carts/update-payment-method.js +122 -0
- package/dist/api/routes/store/carts/update-payment-method.js.map +1 -0
- 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/config/index.d.ts +14 -0
- package/dist/config/index.js +40 -0
- package/dist/config/index.js.map +1 -0
- 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/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 +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/1649775522087-add_batch_job_model.js +4 -4
- package/dist/migrations/1649775522087-add_batch_job_model.js.map +1 -1
- 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
|
@@ -85,246 +85,237 @@ var __values = (this && this.__values) || function(o) {
|
|
|
85
85
|
};
|
|
86
86
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
87
87
|
var medusa_core_utils_1 = require("medusa-core-utils");
|
|
88
|
-
var
|
|
88
|
+
var interfaces_1 = require("../interfaces");
|
|
89
|
+
var utils_1 = require("../utils");
|
|
89
90
|
var ClaimItemService = /** @class */ (function (_super) {
|
|
90
91
|
__extends(ClaimItemService, _super);
|
|
91
92
|
function ClaimItemService(_a) {
|
|
92
93
|
var manager = _a.manager, claimItemRepository = _a.claimItemRepository, claimTagRepository = _a.claimTagRepository, claimImageRepository = _a.claimImageRepository, lineItemService = _a.lineItemService, eventBusService = _a.eventBusService;
|
|
93
|
-
var _this =
|
|
94
|
-
|
|
94
|
+
var _this =
|
|
95
|
+
// eslint-disable-next-line prefer-rest-params
|
|
96
|
+
_super.call(this, arguments[0]) || this;
|
|
95
97
|
_this.manager_ = manager;
|
|
96
|
-
/** @private @constant {ClaimRepository} */
|
|
97
98
|
_this.claimItemRepository_ = claimItemRepository;
|
|
98
99
|
_this.claimTagRepository_ = claimTagRepository;
|
|
99
100
|
_this.claimImageRepository_ = claimImageRepository;
|
|
100
|
-
/** @private @constant {LineItemService} */
|
|
101
101
|
_this.lineItemService_ = lineItemService;
|
|
102
|
-
/** @private @constant {EventBus} */
|
|
103
102
|
_this.eventBus_ = eventBusService;
|
|
104
103
|
return _this;
|
|
105
104
|
}
|
|
106
|
-
ClaimItemService.prototype.withTransaction = function (manager) {
|
|
107
|
-
if (!manager) {
|
|
108
|
-
return this;
|
|
109
|
-
}
|
|
110
|
-
var cloned = new ClaimItemService({
|
|
111
|
-
manager: manager,
|
|
112
|
-
claimItemRepository: this.claimItemRepository_,
|
|
113
|
-
claimTagRepository: this.claimTagRepository_,
|
|
114
|
-
claimImageRepository: this.claimImageRepository_,
|
|
115
|
-
lineItemService: this.lineItemService_,
|
|
116
|
-
eventBusService: this.eventBus_,
|
|
117
|
-
});
|
|
118
|
-
cloned.transactionManager_ = manager;
|
|
119
|
-
return cloned;
|
|
120
|
-
};
|
|
121
105
|
ClaimItemService.prototype.create = function (data) {
|
|
122
|
-
|
|
123
|
-
return this.atomicPhase_(function (manager) { return __awaiter(_this, void 0, void 0, function () {
|
|
124
|
-
var ciRepo, item_id, reason, quantity, tags, images, rest, lineItem, tagsToAdd, claimTagRepo_1, imagesToAdd, claimImgRepo_1, created, result;
|
|
106
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
125
107
|
var _this = this;
|
|
126
108
|
return __generator(this, function (_a) {
|
|
127
109
|
switch (_a.label) {
|
|
128
|
-
case 0:
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
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
|
-
|
|
110
|
+
case 0: return [4 /*yield*/, this.atomicPhase_(function (manager) { return __awaiter(_this, void 0, void 0, function () {
|
|
111
|
+
var ciRepo, item_id, reason, quantity, tags, images, rest, lineItem, tagsToAdd, claimTagRepo_1, imagesToAdd, claimImgRepo_1, toCreate, created, result;
|
|
112
|
+
var _this = this;
|
|
113
|
+
return __generator(this, function (_a) {
|
|
114
|
+
switch (_a.label) {
|
|
115
|
+
case 0:
|
|
116
|
+
ciRepo = manager.getCustomRepository(this.claimItemRepository_);
|
|
117
|
+
item_id = data.item_id, reason = data.reason, quantity = data.quantity, tags = data.tags, images = data.images, rest = __rest(data, ["item_id", "reason", "quantity", "tags", "images"]);
|
|
118
|
+
if (reason !== "missing_item" &&
|
|
119
|
+
reason !== "wrong_item" &&
|
|
120
|
+
reason !== "production_failure" &&
|
|
121
|
+
reason !== "other") {
|
|
122
|
+
throw new medusa_core_utils_1.MedusaError(medusa_core_utils_1.MedusaError.Types.INVALID_DATA, "Claim Item reason must be one of \"missing_item\", \"wrong_item\", \"production_failure\" or \"other\".");
|
|
123
|
+
}
|
|
124
|
+
return [4 /*yield*/, this.lineItemService_
|
|
125
|
+
.withTransaction(manager)
|
|
126
|
+
.retrieve(item_id)];
|
|
127
|
+
case 1:
|
|
128
|
+
lineItem = _a.sent();
|
|
129
|
+
if (lineItem.fulfilled_quantity < quantity) {
|
|
130
|
+
throw new medusa_core_utils_1.MedusaError(medusa_core_utils_1.MedusaError.Types.NOT_ALLOWED, "Cannot claim more of an item than has been fulfilled.");
|
|
131
|
+
}
|
|
132
|
+
tagsToAdd = [];
|
|
133
|
+
if (!(tags && tags.length)) return [3 /*break*/, 3];
|
|
134
|
+
claimTagRepo_1 = manager.getCustomRepository(this.claimTagRepository_);
|
|
135
|
+
return [4 /*yield*/, Promise.all(tags.map(function (t) { return __awaiter(_this, void 0, void 0, function () {
|
|
136
|
+
var normalized, existing;
|
|
137
|
+
return __generator(this, function (_a) {
|
|
138
|
+
switch (_a.label) {
|
|
139
|
+
case 0:
|
|
140
|
+
normalized = t.trim().toLowerCase();
|
|
141
|
+
return [4 /*yield*/, claimTagRepo_1.findOne({
|
|
142
|
+
where: { value: normalized },
|
|
143
|
+
})];
|
|
144
|
+
case 1:
|
|
145
|
+
existing = _a.sent();
|
|
146
|
+
if (existing) {
|
|
147
|
+
return [2 /*return*/, existing];
|
|
148
|
+
}
|
|
149
|
+
return [2 /*return*/, claimTagRepo_1.create({ value: normalized })];
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
}); }))];
|
|
153
|
+
case 2:
|
|
154
|
+
tagsToAdd = _a.sent();
|
|
155
|
+
_a.label = 3;
|
|
156
|
+
case 3:
|
|
157
|
+
imagesToAdd = [];
|
|
158
|
+
if (images && images.length) {
|
|
159
|
+
claimImgRepo_1 = manager.getCustomRepository(this.claimImageRepository_);
|
|
160
|
+
imagesToAdd = images.map(function (url) {
|
|
161
|
+
return claimImgRepo_1.create({ url: url });
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
toCreate = __assign(__assign({}, rest), { variant_id: lineItem.variant_id, tags: tagsToAdd, images: imagesToAdd, item_id: item_id, reason: reason, quantity: quantity });
|
|
165
|
+
created = ciRepo.create(toCreate);
|
|
166
|
+
return [4 /*yield*/, ciRepo.save(created)];
|
|
167
|
+
case 4:
|
|
168
|
+
result = _a.sent();
|
|
169
|
+
return [4 /*yield*/, this.eventBus_
|
|
170
|
+
.withTransaction(manager)
|
|
171
|
+
.emit(ClaimItemService.Events.CREATED, {
|
|
172
|
+
id: result.id,
|
|
173
|
+
})];
|
|
174
|
+
case 5:
|
|
175
|
+
_a.sent();
|
|
176
|
+
return [2 /*return*/, result];
|
|
177
|
+
}
|
|
175
178
|
});
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
return [4 /*yield*/, ciRepo.save(created)];
|
|
179
|
-
case 4:
|
|
180
|
-
result = _a.sent();
|
|
181
|
-
return [4 /*yield*/, this.eventBus_
|
|
182
|
-
.withTransaction(manager)
|
|
183
|
-
.emit(ClaimItemService.Events.CREATED, {
|
|
184
|
-
id: result.id,
|
|
185
|
-
})];
|
|
186
|
-
case 5:
|
|
187
|
-
_a.sent();
|
|
188
|
-
return [2 /*return*/, result];
|
|
179
|
+
}); })];
|
|
180
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
189
181
|
}
|
|
190
182
|
});
|
|
191
|
-
});
|
|
183
|
+
});
|
|
192
184
|
};
|
|
193
185
|
ClaimItemService.prototype.update = function (id, data) {
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
186
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
187
|
+
var _this = this;
|
|
188
|
+
return __generator(this, function (_a) {
|
|
189
|
+
return [2 /*return*/, this.atomicPhase_(function (manager) { return __awaiter(_this, void 0, void 0, function () {
|
|
190
|
+
var ciRepo, item, tags, images, reason, note, metadata, claimTagRepo, tags_1, tags_1_1, t, normalized, existing, e_1_1, claimImgRepo, ids, _a, _b, i, e_2_1, images_1, images_1_1, i;
|
|
191
|
+
var e_1, _c, e_2, _d, e_3, _e;
|
|
192
|
+
return __generator(this, function (_f) {
|
|
193
|
+
switch (_f.label) {
|
|
194
|
+
case 0:
|
|
195
|
+
ciRepo = manager.getCustomRepository(this.claimItemRepository_);
|
|
196
|
+
return [4 /*yield*/, this.retrieve(id, { relations: ["images", "tags"] })];
|
|
197
|
+
case 1:
|
|
198
|
+
item = _f.sent();
|
|
199
|
+
tags = data.tags, images = data.images, reason = data.reason, note = data.note, metadata = data.metadata;
|
|
200
|
+
if (note) {
|
|
201
|
+
item.note = note;
|
|
202
|
+
}
|
|
203
|
+
if (reason) {
|
|
204
|
+
item.reason = reason;
|
|
205
|
+
}
|
|
206
|
+
if (metadata) {
|
|
207
|
+
item.metadata = (0, utils_1.setMetadata)(item, metadata);
|
|
208
|
+
}
|
|
209
|
+
if (!tags) return [3 /*break*/, 10];
|
|
210
|
+
item.tags = [];
|
|
211
|
+
claimTagRepo = manager.getCustomRepository(this.claimTagRepository_);
|
|
212
|
+
_f.label = 2;
|
|
213
|
+
case 2:
|
|
214
|
+
_f.trys.push([2, 8, 9, 10]);
|
|
215
|
+
tags_1 = __values(tags), tags_1_1 = tags_1.next();
|
|
216
|
+
_f.label = 3;
|
|
217
|
+
case 3:
|
|
218
|
+
if (!!tags_1_1.done) return [3 /*break*/, 7];
|
|
219
|
+
t = tags_1_1.value;
|
|
220
|
+
if (!t.id) return [3 /*break*/, 4];
|
|
221
|
+
item.tags.push(t);
|
|
222
|
+
return [3 /*break*/, 6];
|
|
223
|
+
case 4:
|
|
224
|
+
normalized = t.value.trim().toLowerCase();
|
|
225
|
+
return [4 /*yield*/, claimTagRepo.findOne({
|
|
226
|
+
where: { value: normalized },
|
|
227
|
+
})];
|
|
228
|
+
case 5:
|
|
229
|
+
existing = _f.sent();
|
|
230
|
+
if (existing) {
|
|
231
|
+
item.tags.push(existing);
|
|
232
|
+
}
|
|
233
|
+
else {
|
|
234
|
+
item.tags.push(claimTagRepo.create({ value: normalized }));
|
|
235
|
+
}
|
|
236
|
+
_f.label = 6;
|
|
237
|
+
case 6:
|
|
238
|
+
tags_1_1 = tags_1.next();
|
|
239
|
+
return [3 /*break*/, 3];
|
|
240
|
+
case 7: return [3 /*break*/, 10];
|
|
241
|
+
case 8:
|
|
242
|
+
e_1_1 = _f.sent();
|
|
243
|
+
e_1 = { error: e_1_1 };
|
|
244
|
+
return [3 /*break*/, 10];
|
|
245
|
+
case 9:
|
|
246
|
+
try {
|
|
247
|
+
if (tags_1_1 && !tags_1_1.done && (_c = tags_1.return)) _c.call(tags_1);
|
|
248
|
+
}
|
|
249
|
+
finally { if (e_1) throw e_1.error; }
|
|
250
|
+
return [7 /*endfinally*/];
|
|
251
|
+
case 10:
|
|
252
|
+
if (!images) return [3 /*break*/, 19];
|
|
253
|
+
claimImgRepo = manager.getCustomRepository(this.claimImageRepository_);
|
|
254
|
+
ids = images.map(function (i) { return i.id; });
|
|
255
|
+
_f.label = 11;
|
|
256
|
+
case 11:
|
|
257
|
+
_f.trys.push([11, 16, 17, 18]);
|
|
258
|
+
_a = __values(item.images), _b = _a.next();
|
|
259
|
+
_f.label = 12;
|
|
260
|
+
case 12:
|
|
261
|
+
if (!!_b.done) return [3 /*break*/, 15];
|
|
262
|
+
i = _b.value;
|
|
263
|
+
if (!!ids.includes(i.id)) return [3 /*break*/, 14];
|
|
264
|
+
return [4 /*yield*/, claimImgRepo.remove(i)];
|
|
265
|
+
case 13:
|
|
266
|
+
_f.sent();
|
|
267
|
+
_f.label = 14;
|
|
268
|
+
case 14:
|
|
269
|
+
_b = _a.next();
|
|
270
|
+
return [3 /*break*/, 12];
|
|
271
|
+
case 15: return [3 /*break*/, 18];
|
|
272
|
+
case 16:
|
|
273
|
+
e_2_1 = _f.sent();
|
|
274
|
+
e_2 = { error: e_2_1 };
|
|
275
|
+
return [3 /*break*/, 18];
|
|
276
|
+
case 17:
|
|
277
|
+
try {
|
|
278
|
+
if (_b && !_b.done && (_d = _a.return)) _d.call(_a);
|
|
279
|
+
}
|
|
280
|
+
finally { if (e_2) throw e_2.error; }
|
|
281
|
+
return [7 /*endfinally*/];
|
|
282
|
+
case 18:
|
|
283
|
+
item.images = [];
|
|
284
|
+
try {
|
|
285
|
+
for (images_1 = __values(images), images_1_1 = images_1.next(); !images_1_1.done; images_1_1 = images_1.next()) {
|
|
286
|
+
i = images_1_1.value;
|
|
287
|
+
if (i.id) {
|
|
288
|
+
item.images.push(i);
|
|
289
|
+
}
|
|
290
|
+
else {
|
|
291
|
+
item.images.push(claimImgRepo.create({ url: i.url }));
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
296
|
+
finally {
|
|
297
|
+
try {
|
|
298
|
+
if (images_1_1 && !images_1_1.done && (_e = images_1.return)) _e.call(images_1);
|
|
299
|
+
}
|
|
300
|
+
finally { if (e_3) throw e_3.error; }
|
|
301
|
+
}
|
|
302
|
+
_f.label = 19;
|
|
303
|
+
case 19: return [4 /*yield*/, ciRepo.save(item)];
|
|
304
|
+
case 20:
|
|
305
|
+
_f.sent();
|
|
306
|
+
return [4 /*yield*/, this.eventBus_
|
|
307
|
+
.withTransaction(manager)
|
|
308
|
+
.emit(ClaimItemService.Events.UPDATED, {
|
|
309
|
+
id: item.id,
|
|
310
|
+
})];
|
|
311
|
+
case 21:
|
|
312
|
+
_f.sent();
|
|
313
|
+
return [2 /*return*/, item];
|
|
305
314
|
}
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
_f.label = 19;
|
|
309
|
-
case 19: return [4 /*yield*/, ciRepo.save(item)];
|
|
310
|
-
case 20:
|
|
311
|
-
_f.sent();
|
|
312
|
-
return [4 /*yield*/, this.eventBus_
|
|
313
|
-
.withTransaction(manager)
|
|
314
|
-
.emit(ClaimItemService.Events.UPDATED, {
|
|
315
|
-
id: item.id,
|
|
316
|
-
})];
|
|
317
|
-
case 21:
|
|
318
|
-
_f.sent();
|
|
319
|
-
return [2 /*return*/, item];
|
|
320
|
-
}
|
|
315
|
+
});
|
|
316
|
+
}); })];
|
|
321
317
|
});
|
|
322
|
-
});
|
|
323
|
-
};
|
|
324
|
-
ClaimItemService.prototype.cancel = function (id) {
|
|
325
|
-
return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
326
|
-
return [2 /*return*/];
|
|
327
|
-
}); });
|
|
318
|
+
});
|
|
328
319
|
};
|
|
329
320
|
/**
|
|
330
321
|
* @param {Object} selector - the query object for find
|
|
@@ -332,12 +323,16 @@ var ClaimItemService = /** @class */ (function (_super) {
|
|
|
332
323
|
* @return {Promise} the result of the find operation
|
|
333
324
|
*/
|
|
334
325
|
ClaimItemService.prototype.list = function (selector, config) {
|
|
335
|
-
if (config === void 0) { config = {
|
|
326
|
+
if (config === void 0) { config = {
|
|
327
|
+
skip: 0,
|
|
328
|
+
take: 50,
|
|
329
|
+
order: { created_at: "DESC" },
|
|
330
|
+
}; }
|
|
336
331
|
return __awaiter(this, void 0, void 0, function () {
|
|
337
332
|
var ciRepo, query;
|
|
338
333
|
return __generator(this, function (_a) {
|
|
339
334
|
ciRepo = this.manager_.getCustomRepository(this.claimItemRepository_);
|
|
340
|
-
query =
|
|
335
|
+
query = (0, utils_1.buildQuery)(selector, config);
|
|
341
336
|
return [2 /*return*/, ciRepo.find(query)];
|
|
342
337
|
});
|
|
343
338
|
});
|
|
@@ -351,13 +346,12 @@ var ClaimItemService = /** @class */ (function (_super) {
|
|
|
351
346
|
ClaimItemService.prototype.retrieve = function (id, config) {
|
|
352
347
|
if (config === void 0) { config = {}; }
|
|
353
348
|
return __awaiter(this, void 0, void 0, function () {
|
|
354
|
-
var claimItemRepo,
|
|
349
|
+
var claimItemRepo, query, item;
|
|
355
350
|
return __generator(this, function (_a) {
|
|
356
351
|
switch (_a.label) {
|
|
357
352
|
case 0:
|
|
358
353
|
claimItemRepo = this.manager_.getCustomRepository(this.claimItemRepository_);
|
|
359
|
-
|
|
360
|
-
query = this.buildQuery_({ id: validatedId }, config);
|
|
354
|
+
query = (0, utils_1.buildQuery)({ id: id }, config);
|
|
361
355
|
return [4 /*yield*/, claimItemRepo.findOne(query)];
|
|
362
356
|
case 1:
|
|
363
357
|
item = _a.sent();
|
|
@@ -369,36 +363,12 @@ var ClaimItemService = /** @class */ (function (_super) {
|
|
|
369
363
|
});
|
|
370
364
|
});
|
|
371
365
|
};
|
|
372
|
-
/**
|
|
373
|
-
* Dedicated method to delete metadata for an order.
|
|
374
|
-
* @param {string} orderId - the order to delete metadata from.
|
|
375
|
-
* @param {string} key - key for metadata field
|
|
376
|
-
* @return {Promise} resolves to the updated result.
|
|
377
|
-
*/
|
|
378
|
-
ClaimItemService.prototype.deleteMetadata = function (orderId, key) {
|
|
379
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
380
|
-
var validatedId, keyPath;
|
|
381
|
-
var _a;
|
|
382
|
-
return __generator(this, function (_b) {
|
|
383
|
-
validatedId = this.validateId_(orderId);
|
|
384
|
-
if (typeof key !== "string") {
|
|
385
|
-
throw new medusa_core_utils_1.MedusaError(medusa_core_utils_1.MedusaError.Types.INVALID_ARGUMENT, "Key type is invalid. Metadata keys must be strings");
|
|
386
|
-
}
|
|
387
|
-
keyPath = "metadata.".concat(key);
|
|
388
|
-
return [2 /*return*/, this.orderModel_
|
|
389
|
-
.updateOne({ _id: validatedId }, { $unset: (_a = {}, _a[keyPath] = "", _a) })
|
|
390
|
-
.catch(function (err) {
|
|
391
|
-
throw new medusa_core_utils_1.MedusaError(medusa_core_utils_1.MedusaError.Types.DB_ERROR, err.message);
|
|
392
|
-
})];
|
|
393
|
-
});
|
|
394
|
-
});
|
|
395
|
-
};
|
|
396
366
|
ClaimItemService.Events = {
|
|
397
367
|
CREATED: "claim_item.created",
|
|
398
368
|
UPDATED: "claim_item.updated",
|
|
399
369
|
CANCELED: "claim_item.canceled",
|
|
400
370
|
};
|
|
401
371
|
return ClaimItemService;
|
|
402
|
-
}(
|
|
372
|
+
}(interfaces_1.TransactionBaseService));
|
|
403
373
|
exports.default = ClaimItemService;
|
|
404
374
|
//# sourceMappingURL=claim-item.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"claim-item.js","sourceRoot":"","sources":["../../src/services/claim-item.
|
|
1
|
+
{"version":3,"file":"claim-item.js","sourceRoot":"","sources":["../../src/services/claim-item.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uDAA+C;AAE/C,4CAAqE;AAOrE,kCAAkD;AAIlD;IAA+B,oCAA6B;IAgB1D,0BAAY,EAOX;YANC,OAAO,aAAA,EACP,mBAAmB,yBAAA,EACnB,kBAAkB,wBAAA,EAClB,oBAAoB,0BAAA,EACpB,eAAe,qBAAA,EACf,eAAe,qB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