From 5ea32aaa44a47b143c46f895032478334b7379ca Mon Sep 17 00:00:00 2001 From: Adrien de Peretti Date: Fri, 26 Sep 2025 09:19:46 +0200 Subject: [PATCH] fix(): Cart workflow price calculation for different items but same variant (#13511) RESOLVES CORE-1204 **What** - Fix wrong price tier when multiple items are targetting the same variant - fix type import from the wrong package **Notes** If you are struggling navigating the changes, you can focus on the following files: ``` integration-tests/http/__tests__/cart/store/cart.spec.ts integration-tests/modules/__tests__/cart/store/cart.workflows.spec.ts packages/core/core-flows/src/cart/steps/get-promotion-codes-to-apply.ts packages/core/core-flows/src/cart/steps/get-variant-price-sets.ts packages/core/core-flows/src/cart/workflows/add-to-cart.ts packages/core/core-flows/src/cart/workflows/create-carts.ts packages/core/core-flows/src/cart/workflows/get-variants-and-items-with-prices.ts packages/core/core-flows/src/cart/workflows/refresh-cart-items.ts packages/core/core-flows/src/order/workflows/add-line-items.ts packages/core/core-flows/src/order/workflows/create-order.ts ``` --- .changeset/shiny-cups-work.md | 5 + .../http/__tests__/cart/store/cart.spec.ts | 150 ++++++++++++ .../cart/store/cart.workflows.spec.ts | 16 +- .../src/api-key/steps/delete-api-keys.ts | 2 +- .../link-sales-channels-to-publishable-key.ts | 6 +- .../steps/validate-sales-channel-exists.ts | 2 +- .../src/api-key/workflows/create-api-keys.ts | 2 +- .../link-sales-channels-to-publishable-key.ts | 10 +- .../src/auth/steps/set-auth-app-metadata.ts | 16 +- .../generate-reset-password-token.ts | 2 +- .../steps/compensate-payment-if-needed.ts | 2 +- .../src/cart/steps/confirm-inventory.ts | 5 +- .../core-flows/src/cart/steps/create-carts.ts | 5 +- .../src/cart/steps/find-or-create-customer.ts | 5 +- .../get-actions-to-compute-from-promotions.ts | 5 +- .../steps/get-promotion-codes-to-apply.ts | 4 +- .../src/cart/steps/get-variant-price-sets.ts | 11 +- .../steps/remove-line-item-adjustments.ts | 2 +- .../remove-shipping-method-adjustments.ts | 2 +- .../steps/remove-shipping-method-from-cart.ts | 9 +- .../src/cart/steps/reserve-inventory.ts | 2 +- .../src/cart/steps/update-cart-promotions.ts | 2 +- .../src/cart/steps/validate-cart-payments.ts | 2 +- .../steps/validate-cart-shipping-options.ts | 20 +- .../src/cart/steps/validate-cart.ts | 10 +- .../src/cart/steps/validate-sales-channel.ts | 2 +- .../steps/validate-shipping-methods-data.ts | 14 +- .../src/cart/steps/validate-shipping.ts | 2 +- .../src/cart/steps/validate-variant-prices.ts | 4 +- .../prepare-confirm-inventory-input.spec.ts | 2 +- .../src/cart/workflows/add-to-cart.ts | 166 +++++++------ .../workflows/confirm-variant-inventory.ts | 4 +- .../src/cart/workflows/create-carts.ts | 135 +++-------- .../get-variants-and-items-with-prices.ts | 226 ++++++++++++++++++ ...-shipping-options-for-cart-with-pricing.ts | 2 +- .../list-shipping-options-for-cart.ts | 58 +++-- .../src/cart/workflows/refresh-cart-items.ts | 112 +-------- ...refund-payment-recreate-payment-session.ts | 5 +- .../src/common/steps/create-remote-links.ts | 2 +- .../src/common/steps/dismiss-remote-links.ts | 2 +- .../src/common/steps/update-remote-links.ts | 2 +- .../src/common/workflows/batch-links.ts | 15 +- .../src/common/workflows/create-links.ts | 12 +- .../src/common/workflows/dismiss-links.ts | 12 +- .../src/common/workflows/update-links.ts | 12 +- .../steps/delete-customer-groups.ts | 2 +- .../link-customer-groups-customer.ts | 18 +- .../link-customers-customer-group.ts | 18 +- .../src/customer/steps/delete-addresses.ts | 2 +- .../src/customer/steps/delete-customers.ts | 2 +- .../workflows/create-customer-account.ts | 14 +- .../customer/workflows/create-customers.ts | 17 +- ...reate-draft-order-line-item-adjustments.ts | 4 +- ...draft-order-shipping-method-adjustments.ts | 4 +- .../draft-order/steps/delete-draft-order.ts | 2 +- .../get-draft-order-promotion-context.ts | 10 +- ...emove-draft-order-line-item-adjustments.ts | 4 +- ...draft-order-shipping-method-adjustments.ts | 4 +- .../restore-draft-order-shipping-methods.ts | 27 ++- .../steps/update-draft-order-promotions.ts | 6 +- .../update-draft-order-shipping-metod.ts | 7 +- .../steps/validate-draft-order-change.ts | 10 +- ...validate-draft-order-remove-action-item.ts | 12 +- ...date-draft-order-shipping-method-action.ts | 10 +- ...validate-draft-order-update-action-item.ts | 12 +- .../draft-order/steps/validate-draft-order.ts | 10 +- .../steps/validate-promo-codes-to-add.ts | 22 +- .../steps/validate-promo-codes-to-remove.ts | 22 +- .../src/draft-order/utils/validation.ts | 2 +- .../workflows/add-draft-order-items.ts | 6 +- .../workflows/add-draft-order-promotions.ts | 14 +- .../add-draft-order-shipping-methods.ts | 2 +- .../workflows/begin-draft-order-edit.ts | 14 +- .../workflows/cancel-draft-order-edit.ts | 2 +- .../workflows/confirm-draft-order-edit.ts | 6 +- .../workflows/convert-draft-order.ts | 10 +- .../workflows/delete-draft-order.ts | 2 +- .../refresh-draft-order-adjustments.ts | 2 +- .../remove-draft-order-action-item.ts | 2 +- ...move-draft-order-action-shipping-method.ts | 2 +- .../remove-draft-order-promotions.ts | 14 +- .../remove-draft-order-shipping-method.ts | 2 +- .../workflows/request-draft-order-edit.ts | 10 +- .../update-draft-order-action-item.ts | 2 +- ...date-draft-order-action-shipping-method.ts | 2 +- .../workflows/update-draft-order-item.ts | 2 +- .../update-draft-order-shipping-method.ts | 6 +- .../workflows/update-draft-order.ts | 22 +- .../core-flows/src/file/steps/delete-files.ts | 4 +- .../core-flows/src/file/steps/upload-files.ts | 8 +- .../src/file/workflows/upload-files.ts | 18 +- .../fulfillment/steps/cancel-fulfillment.ts | 2 +- .../steps/delete-fulfillment-sets.ts | 2 +- .../fulfillment/steps/delete-service-zones.ts | 2 +- .../steps/delete-shipping-options.ts | 2 +- .../steps/set-shipping-options-price-sets.ts | 2 +- .../steps/validate-fulfillment-providers.ts | 5 +- .../fulfillment/steps/validate-shipment.ts | 2 +- .../steps/validate-shipping-option-prices.ts | 10 +- .../calculate-shipping-options-prices.ts | 16 +- .../workflows/create-service-zones.ts | 13 +- .../fulfillment/workflows/create-shipment.ts | 10 +- .../workflows/create-shipping-options.ts | 40 ++-- .../workflows/create-shipping-profiles.ts | 10 +- .../workflows/delete-shipping-options.ts | 10 +- .../mark-fulfillment-as-delivered.ts | 20 +- .../workflows/update-fulfillment.ts | 12 +- .../workflows/update-service-zones.ts | 13 +- .../workflows/update-shipping-options.ts | 21 +- .../workflows/update-shipping-profiles.ts | 13 +- .../steps/adjust-inventory-levels.ts | 2 +- .../inventory/steps/create-inventory-items.ts | 8 +- .../steps/create-inventory-levels.ts | 8 +- .../inventory/steps/delete-inventory-items.ts | 2 +- .../steps/delete-inventory-levels.ts | 2 +- .../inventory/steps/update-inventory-items.ts | 8 +- .../steps/update-inventory-levels.ts | 8 +- .../steps/validate-inventory-locations.ts | 7 +- .../workflows/batch-inventory-item-levels.ts | 22 +- .../workflows/bulk-create-delete-levels.ts | 5 +- .../workflows/create-inventory-items.ts | 10 +- .../workflows/create-inventory-levels.ts | 13 +- .../workflows/update-inventory-items.ts | 13 +- .../workflows/update-inventory-levels.ts | 13 +- .../src/invite/steps/create-invites.ts | 7 +- .../src/invite/steps/delete-invites.ts | 2 +- .../src/invite/steps/refresh-invite-tokens.ts | 2 +- .../src/invite/steps/validate-token.ts | 2 +- .../src/invite/workflows/accept-invite.ts | 12 +- .../src/invite/workflows/create-invites.ts | 10 +- .../src/invite/workflows/delete-invites.ts | 10 +- .../invite/workflows/refresh-invite-tokens.ts | 12 +- .../src/line-item/steps/delete-line-items.ts | 2 +- .../notification/steps/notify-on-failure.ts | 4 +- .../notification/steps/send-notifications.ts | 2 +- .../src/order/steps/add-order-transaction.ts | 2 +- .../src/order/steps/archive-orders.ts | 2 +- .../src/order/steps/cancel-orders.ts | 2 +- .../src/order/steps/claim/delete-claims.ts | 2 +- .../src/order/steps/complete-orders.ts | 2 +- .../src/order/steps/confirm-order-changes.ts | 2 +- .../src/order/steps/create-line-items.ts | 4 +- .../src/order/steps/create-orders.ts | 7 +- .../src/order/steps/delete-line-items.ts | 2 +- .../steps/delete-order-change-actions.ts | 2 +- .../src/order/steps/delete-order-changes.ts | 2 +- .../steps/delete-order-shipping-methods.ts | 2 +- .../order/steps/exchange/delete-exchanges.ts | 2 +- .../src/order/steps/preview-order-change.ts | 2 +- .../src/order/steps/return/delete-returns.ts | 2 +- .../src/order/steps/return/update-returns.ts | 2 +- .../src/order/utils/aggregate-status.ts | 2 +- .../src/order/utils/build-reservations-map.ts | 2 +- .../order/utils/prepare-shipping-method.ts | 2 +- .../src/order/workflows/add-line-items.ts | 133 ++--------- .../src/order/workflows/archive-orders.ts | 12 +- .../order/workflows/cancel-order-change.ts | 10 +- .../src/order/workflows/complete-orders.ts | 16 +- ...eate-or-update-order-payment-collection.ts | 2 +- .../order/workflows/create-order-change.ts | 13 +- .../workflows/create-order-credit-lines.ts | 5 +- .../src/order/workflows/create-order.ts | 144 +++++------ .../order/workflows/decline-order-change.ts | 8 +- .../delete-order-payment-collection.ts | 16 +- .../workflows/exchange/refresh-shipping.ts | 2 +- .../src/order/workflows/get-order-detail.ts | 14 +- .../src/order/workflows/get-orders-list.ts | 26 +- .../list-shipping-options-for-order.ts | 2 +- .../mark-payment-collection-as-paid.ts | 2 +- .../order-edit/cancel-begin-order-edit.ts | 2 +- .../create-order-refund-credit-lines.ts | 2 +- .../payments/refund-captured-payments.ts | 2 +- .../workflows/return/cancel-receive-return.ts | 22 +- .../workflows/return/cancel-request-return.ts | 24 +- .../return/receive-complete-return.ts | 25 +- .../workflows/return/refresh-shipping.ts | 2 +- .../transfer/accept-order-transfer.ts | 2 +- .../transfer/request-order-transfer.ts | 22 +- .../src/order/workflows/update-order.ts | 4 +- .../src/order/workflows/update-tax-lines.ts | 2 +- .../steps/cancel-payment.ts | 2 +- .../steps/delete-refund-reasons.ts | 2 +- .../workflows/cancel-payment-collection.ts | 2 +- .../src/payment/steps/cancel-payment.ts | 2 +- .../src/payment/workflows/capture-payment.ts | 2 +- .../src/payment/workflows/process-payment.ts | 2 +- .../src/payment/workflows/refund-payment.ts | 6 +- .../src/payment/workflows/refund-payments.ts | 2 +- .../price-list/steps/delete-price-lists.ts | 2 +- .../get-existing-price-lists-price-ids.ts | 5 +- .../steps/remove-price-list-prices.ts | 2 +- .../workflows/update-price-lists.ts | 10 +- .../pricing/steps/delete-price-preferences.ts | 2 +- .../src/pricing/steps/update-price-sets.ts | 19 +- .../workflows/create-price-preferences.ts | 19 +- .../workflows/update-price-preferences.ts | 10 +- .../steps/delete-product-categories.ts | 2 +- .../product/helpers/normalize-for-import.ts | 4 +- .../src/product/steps/create-collections.ts | 5 +- .../product/steps/create-product-options.ts | 7 +- .../src/product/steps/create-product-tags.ts | 5 +- .../src/product/steps/create-product-types.ts | 5 +- .../product/steps/create-product-variants.ts | 7 +- .../src/product/steps/create-products.ts | 7 +- .../src/product/steps/delete-collections.ts | 2 +- .../product/steps/delete-product-options.ts | 2 +- .../src/product/steps/delete-product-tags.ts | 2 +- .../src/product/steps/delete-product-types.ts | 2 +- .../product/steps/delete-product-variants.ts | 2 +- .../src/product/steps/delete-products.ts | 2 +- .../src/product/steps/get-products.ts | 2 +- .../steps/normalize-products-to-chunks.ts | 2 +- .../src/product/steps/normalize-products.ts | 2 +- .../src/product/steps/update-collections.ts | 7 +- .../product/steps/update-product-options.ts | 7 +- .../src/product/steps/update-product-tags.ts | 7 +- .../src/product/steps/update-product-types.ts | 7 +- .../product/steps/update-product-variants.ts | 19 +- .../src/product/steps/update-products.ts | 5 +- .../batch-link-products-collection.ts | 10 +- .../workflows/batch-products-in-category.ts | 12 +- .../product/workflows/create-collections.ts | 18 +- .../workflows/create-product-options.ts | 16 +- .../product/workflows/create-product-tags.ts | 18 +- .../product/workflows/create-product-types.ts | 18 +- .../src/product/workflows/export-products.ts | 22 +- .../workflows/import-products-as-chunks.ts | 4 +- .../src/product/workflows/import-products.ts | 4 +- .../product/workflows/update-collections.ts | 18 +- .../workflows/update-product-options.ts | 16 +- .../product/workflows/update-product-tags.ts | 18 +- .../product/workflows/update-product-types.ts | 18 +- .../src/promotion/steps/delete-campaigns.ts | 2 +- .../steps/delete-promotion-rules-workflow.ts | 2 +- .../src/promotion/steps/delete-promotions.ts | 2 +- .../add-or-remove-campaign-promotions.ts | 18 +- .../promotion/workflows/create-campaigns.ts | 17 +- .../promotion/workflows/create-promotions.ts | 17 +- .../workflows/delete-promotion-rules.ts | 10 +- .../promotion/workflows/update-campaigns.ts | 17 +- .../src/region/steps/delete-regions.ts | 2 +- .../src/region/workflows/create-regions.ts | 10 +- .../src/region/workflows/update-regions.ts | 10 +- .../reservation/steps/create-reservations.ts | 2 +- .../delete-reservations-by-line-items.ts | 2 +- .../reservation/steps/delete-reservations.ts | 2 +- .../reservation/steps/update-reservations.ts | 10 +- .../workflows/create-reservations.ts | 12 +- .../workflows/update-reservations.ts | 12 +- .../steps/delete-return-reasons.ts | 4 +- .../steps/delete-sales-channels.ts | 2 +- .../link-products-to-sales-channel.ts | 16 +- .../steps/create-shipping-option-types.ts | 20 +- .../steps/delete-shipping-option-types.ts | 12 +- .../steps/update-shipping-option-types.ts | 22 +- .../workflows/create-shipping-option-types.ts | 50 ++-- .../workflows/update-shipping-option-types.ts | 33 ++- .../steps/delete-shipping-profile.ts | 2 +- .../create-location-fulfillment-set.ts | 10 +- .../workflows/create-stock-locations.ts | 10 +- .../link-sales-channels-to-stock-location.ts | 18 +- .../src/store/steps/create-stores.ts | 7 +- .../src/store/steps/delete-stores.ts | 2 +- .../src/store/workflows/create-stores.ts | 10 +- .../src/store/workflows/update-stores.ts | 10 +- .../src/tax/steps/create-tax-rates.ts | 7 +- .../src/tax/steps/delete-tax-rate-rules.ts | 2 +- .../src/tax/steps/delete-tax-rates.ts | 2 +- .../src/tax/steps/delete-tax-regions.ts | 2 +- .../tax/workflows/create-tax-rate-rules.ts | 13 +- .../src/tax/workflows/create-tax-rates.ts | 16 +- .../src/tax/workflows/create-tax-regions.ts | 13 +- .../src/tax/workflows/set-tax-rate-rules.ts | 13 +- .../src/tax/workflows/update-tax-regions.ts | 5 +- .../core-flows/src/user/steps/create-users.ts | 9 +- .../core-flows/src/user/steps/delete-users.ts | 2 +- .../core-flows/src/user/steps/update-users.ts | 7 +- .../src/user/workflows/create-user-account.ts | 14 +- .../src/user/workflows/create-users.ts | 16 +- .../src/user/workflows/delete-users.ts | 2 +- .../src/user/workflows/update-users.ts | 10 +- 281 files changed, 1864 insertions(+), 1466 deletions(-) create mode 100644 .changeset/shiny-cups-work.md create mode 100644 packages/core/core-flows/src/cart/workflows/get-variants-and-items-with-prices.ts diff --git a/.changeset/shiny-cups-work.md b/.changeset/shiny-cups-work.md new file mode 100644 index 0000000000..19a50b1983 --- /dev/null +++ b/.changeset/shiny-cups-work.md @@ -0,0 +1,5 @@ +--- +"@medusajs/core-flows": patch +--- + +fix(): Cart workflow price calculation for different items but same variant diff --git a/integration-tests/http/__tests__/cart/store/cart.spec.ts b/integration-tests/http/__tests__/cart/store/cart.spec.ts index 3305d18a20..fe8f731a76 100644 --- a/integration-tests/http/__tests__/cart/store/cart.spec.ts +++ b/integration-tests/http/__tests__/cart/store/cart.spec.ts @@ -285,6 +285,156 @@ medusaIntegrationTestRunner({ ) }) + it("should successfully create a cart with a line items for the same variant with different quantities and calculate prices based on the correct quantity", async () => { + const productData = { + title: "Medusa T-Shirt based quantity", + handle: "t-shirt-with-quantity-prices", + status: ProductStatus.PUBLISHED, + options: [ + { + title: "Size", + values: ["S"], + }, + ], + variants: [ + { + title: "S", + sku: "SHIRT-S-BLACK-w-quantity-prices", + options: { + Size: "S", + }, + manage_inventory: false, + prices: [ + { + amount: 1500, + currency_code: "usd", + min_quantity: 1, + max_quantity: 4, + }, + { + amount: 1000, + currency_code: "usd", + min_quantity: 5, + max_quantity: 10, + }, + ], + }, + ], + } + + const newProduct = await api.post( + `/admin/products`, + productData, + adminHeaders + ) + + const variantId = newProduct.data.product.variants[0].id + + const newCart = ( + await api.post( + `/store/carts`, + { + currency_code: "usd", + sales_channel_id: salesChannel.id, + region_id: region.id, + shipping_address: shippingAddressData, + items: [{ variant_id: variantId, quantity: 6 }], + }, + storeHeaders + ) + ).data.cart + + expect(newCart).toEqual( + expect.objectContaining({ + item_subtotal: 5714.285714285715, + item_tax_total: 285.7142857142857, + item_total: 6000, + items: [ + expect.objectContaining({ + quantity: 6, + title: "Medusa T-Shirt based quantity", + unit_price: 1000, + updated_at: expect.any(String), + variant_barcode: null, + variant_id: expect.any(String), + variant_sku: "SHIRT-S-BLACK-w-quantity-prices", + variant_title: "S", + }), + ], + original_item_subtotal: 5714.285714285715, + original_item_tax_total: 285.7142857142857, + original_item_total: 6000, + original_shipping_subtotal: 0, + original_shipping_tax_total: 0, + original_shipping_total: 0, + original_tax_total: 285.7142857142857, + original_total: 6000, + shipping_subtotal: 0, + shipping_tax_total: 0, + shipping_total: 0, + subtotal: 5714.285714285715, + tax_total: 285.7142857142857, + total: 6000, + }) + ) + + const updatedCart = ( + await api.post( + `/store/carts/${newCart.id}/line-items`, + { + variant_id: variantId, + quantity: 1, + metadata: { custom: true }, + }, + storeHeaders + ) + ).data.cart + + expect(updatedCart).toEqual( + expect.objectContaining({ + item_subtotal: 7142.857142857143, + item_tax_total: 357.14285714285717, + item_total: 7500, + items: expect.arrayContaining([ + expect.objectContaining({ + quantity: 6, + title: "Medusa T-Shirt based quantity", + unit_price: 1000, + updated_at: expect.any(String), + variant_barcode: null, + variant_id: expect.any(String), + variant_sku: "SHIRT-S-BLACK-w-quantity-prices", + variant_title: "S", + }), + expect.objectContaining({ + quantity: 1, + title: "Medusa T-Shirt based quantity", + unit_price: 1500, + updated_at: expect.any(String), + variant_barcode: null, + variant_id: expect.any(String), + variant_sku: "SHIRT-S-BLACK-w-quantity-prices", + variant_title: "S", + }), + ]), + original_item_subtotal: 7142.857142857143, + original_item_tax_total: 357.14285714285717, + original_item_total: 7500, + original_shipping_subtotal: 0, + original_shipping_tax_total: 0, + original_shipping_total: 0, + original_tax_total: 357.14285714285717, + original_total: 7500, + shipping_subtotal: 0, + shipping_tax_total: 0, + shipping_total: 0, + subtotal: 7142.857142857143, + tax_total: 357.14285714285717, + total: 7500, + }) + ) + }) + describe("with sale price lists", () => { let priceList diff --git a/integration-tests/modules/__tests__/cart/store/cart.workflows.spec.ts b/integration-tests/modules/__tests__/cart/store/cart.workflows.spec.ts index a36e052ed7..7eeb408a19 100644 --- a/integration-tests/modules/__tests__/cart/store/cart.workflows.spec.ts +++ b/integration-tests/modules/__tests__/cart/store/cart.workflows.spec.ts @@ -1881,7 +1881,7 @@ medusaIntegrationTestRunner({ expect(errors).toEqual([ { - action: "get-variant-price-sets", + action: "get-variant-items-with-prices-workflow-as-step", handlerType: "invoke", error: expect.objectContaining({ message: expect.stringContaining( @@ -4307,18 +4307,20 @@ medusaIntegrationTestRunner({ }) } - const { result: result1 } = await listShippingOptionsForCartWorkflow( - appContainer - ).run({ input: { cart_id: cart.id } }) + const { result: result1 } = + await listShippingOptionsForCartWorkflow(appContainer).run({ + input: { cart_id: cart.id }, + }) expect(result1).toHaveLength(1) expect(result1[0].name).toEqual(shippingOption.name) setShippingOptionsContextHook = undefined - const { result: result2 } = await listShippingOptionsForCartWorkflow( - appContainer - ).run({ input: { cart_id: cart.id } }) + const { result: result2 } = + await listShippingOptionsForCartWorkflow(appContainer).run({ + input: { cart_id: cart.id }, + }) expect(result2).toHaveLength(0) }) diff --git a/packages/core/core-flows/src/api-key/steps/delete-api-keys.ts b/packages/core/core-flows/src/api-key/steps/delete-api-keys.ts index 4a52247f93..925eca9cc8 100644 --- a/packages/core/core-flows/src/api-key/steps/delete-api-keys.ts +++ b/packages/core/core-flows/src/api-key/steps/delete-api-keys.ts @@ -1,4 +1,4 @@ -import { IApiKeyModuleService } from "@medusajs/framework/types" +import type { IApiKeyModuleService } from "@medusajs/framework/types" import { Modules } from "@medusajs/framework/utils" import { StepResponse, createStep } from "@medusajs/framework/workflows-sdk" diff --git a/packages/core/core-flows/src/api-key/steps/link-sales-channels-to-publishable-key.ts b/packages/core/core-flows/src/api-key/steps/link-sales-channels-to-publishable-key.ts index d86b6a5902..768f22b543 100644 --- a/packages/core/core-flows/src/api-key/steps/link-sales-channels-to-publishable-key.ts +++ b/packages/core/core-flows/src/api-key/steps/link-sales-channels-to-publishable-key.ts @@ -1,4 +1,4 @@ -import { LinkWorkflowInput } from "@medusajs/framework/types" +import type { LinkWorkflowInput } from "@medusajs/framework/types" import { ContainerRegistrationKeys, Modules, @@ -8,7 +8,7 @@ import { StepResponse, createStep } from "@medusajs/framework/workflows-sdk" /** * The data to manage the sales channels of a publishable API key. - * + * * @property id - The ID of the publishable API key. * @property add - The sales channel IDs to add to the publishable API key. * @property remove - The sales channel IDs to remove from the publishable API key. @@ -18,7 +18,7 @@ export type LinkSalesChannelsToApiKeyStepInput = LinkWorkflowInput export const linkSalesChannelsToApiKeyStepId = "link-sales-channels-to-api-key" /** * This step manages the sales channels of a publishable API key. - * + * * @example * const data = linkSalesChannelsToApiKeyStep({ * id: "apk_123", diff --git a/packages/core/core-flows/src/api-key/steps/validate-sales-channel-exists.ts b/packages/core/core-flows/src/api-key/steps/validate-sales-channel-exists.ts index d5f41df018..3e06e2d4b4 100644 --- a/packages/core/core-flows/src/api-key/steps/validate-sales-channel-exists.ts +++ b/packages/core/core-flows/src/api-key/steps/validate-sales-channel-exists.ts @@ -1,4 +1,4 @@ -import { ISalesChannelModuleService } from "@medusajs/framework/types" +import type { ISalesChannelModuleService } from "@medusajs/framework/types" import { MedusaError, Modules, diff --git a/packages/core/core-flows/src/api-key/workflows/create-api-keys.ts b/packages/core/core-flows/src/api-key/workflows/create-api-keys.ts index cd91d2c00a..e35169b5c5 100644 --- a/packages/core/core-flows/src/api-key/workflows/create-api-keys.ts +++ b/packages/core/core-flows/src/api-key/workflows/create-api-keys.ts @@ -1,4 +1,4 @@ -import { ApiKeyDTO, CreateApiKeyDTO } from "@medusajs/framework/types" +import type { ApiKeyDTO, CreateApiKeyDTO } from "@medusajs/framework/types" import { WorkflowData, WorkflowResponse, diff --git a/packages/core/core-flows/src/api-key/workflows/link-sales-channels-to-publishable-key.ts b/packages/core/core-flows/src/api-key/workflows/link-sales-channels-to-publishable-key.ts index 7e8a388a4f..b37acc3edb 100644 --- a/packages/core/core-flows/src/api-key/workflows/link-sales-channels-to-publishable-key.ts +++ b/packages/core/core-flows/src/api-key/workflows/link-sales-channels-to-publishable-key.ts @@ -1,4 +1,4 @@ -import { LinkWorkflowInput } from "@medusajs/framework/types" +import type { LinkWorkflowInput } from "@medusajs/framework/types" import { WorkflowData, createWorkflow } from "@medusajs/framework/workflows-sdk" import { linkSalesChannelsToApiKeyStep, @@ -7,7 +7,7 @@ import { /** * The data to manage the sales channels of a publishable API key. - * + * * @property id - The ID of the publishable API key. * @property add - The sales channel IDs to add to the publishable API key. * @property remove - The sales channel IDs to remove from the publishable API key. @@ -19,10 +19,10 @@ export const linkSalesChannelsToApiKeyWorkflowId = /** * This workflow manages the sales channels of a publishable API key. It's used by the * [Manage Sales Channels API Route](https://docs.medusajs.com/api/admin#api-keys_postapikeysidsaleschannels). - * + * * You can use this workflow within your customizations or your own custom workflows, allowing you to * manage the sales channels of a publishable API key within your custom flows. - * + * * @example * const { result } = await linkSalesChannelsToApiKeyWorkflow(container) * .run({ @@ -32,7 +32,7 @@ export const linkSalesChannelsToApiKeyWorkflowId = * remove: ["sc_321"] * } * }) - * + * * @summary * Manage the sales channels of a publishable API key. */ diff --git a/packages/core/core-flows/src/auth/steps/set-auth-app-metadata.ts b/packages/core/core-flows/src/auth/steps/set-auth-app-metadata.ts index 2720c36eeb..3e7f213b9a 100644 --- a/packages/core/core-flows/src/auth/steps/set-auth-app-metadata.ts +++ b/packages/core/core-flows/src/auth/steps/set-auth-app-metadata.ts @@ -1,6 +1,6 @@ import { createStep, StepResponse } from "@medusajs/framework/workflows-sdk" -import { IAuthModuleService } from "@medusajs/framework/types" +import type { IAuthModuleService } from "@medusajs/framework/types" import { isDefined, Modules } from "@medusajs/framework/utils" export type SetAuthAppMetadataStepInput = { @@ -14,16 +14,16 @@ export const setAuthAppMetadataStepId = "set-auth-app-metadata" * This step sets the `app_metadata` property of an auth identity. This is useful to * associate a user (whether it's an admin user or customer) with an auth identity * that allows them to authenticate into Medusa. - * - * You can learn more about auth identites in + * + * You can learn more about auth identites in * [this documentation](https://docs.medusajs.com/resources/commerce-modules/auth/auth-identity-and-actor-types). - * + * * To use this for a custom actor type, check out [this guide](https://docs.medusajs.com/resources/commerce-modules/auth/create-actor-type) * that explains how to create a custom `manager` actor type and manage its users. - * + * * @example * To associate an auth identity with an actor type (user, customer, or other actor types): - * + * * ```ts * const data = setAuthAppMetadataStep({ * authIdentityId: "au_1234", @@ -31,9 +31,9 @@ export const setAuthAppMetadataStepId = "set-auth-app-metadata" * value: "user_123" * }) * ``` - * + * * To remove the association with an actor type, such as when deleting the user: - * + * * ```ts * const data = setAuthAppMetadataStep({ * authIdentityId: "au_1234", diff --git a/packages/core/core-flows/src/auth/workflows/generate-reset-password-token.ts b/packages/core/core-flows/src/auth/workflows/generate-reset-password-token.ts index 10b922a007..fffd2e6c54 100644 --- a/packages/core/core-flows/src/auth/workflows/generate-reset-password-token.ts +++ b/packages/core/core-flows/src/auth/workflows/generate-reset-password-token.ts @@ -9,7 +9,7 @@ import { WorkflowResponse, } from "@medusajs/framework/workflows-sdk" import { emitEventStep, useRemoteQueryStep } from "../../common" -import { ProjectConfigOptions } from "@medusajs/framework/types" +import type { ProjectConfigOptions } from "@medusajs/framework/types" /** * This workflow generates a reset password token for a user. It's used by the diff --git a/packages/core/core-flows/src/cart/steps/compensate-payment-if-needed.ts b/packages/core/core-flows/src/cart/steps/compensate-payment-if-needed.ts index b7cf549679..b850972e7f 100644 --- a/packages/core/core-flows/src/cart/steps/compensate-payment-if-needed.ts +++ b/packages/core/core-flows/src/cart/steps/compensate-payment-if-needed.ts @@ -1,4 +1,4 @@ -import { Logger } from "@medusajs/framework/types" +import type { Logger } from "@medusajs/framework/types" import { ContainerRegistrationKeys } from "@medusajs/framework/utils" import { createStep, StepResponse } from "@medusajs/framework/workflows-sdk" import { refundPaymentAndRecreatePaymentSessionWorkflow } from "../workflows/refund-payment-recreate-payment-session" diff --git a/packages/core/core-flows/src/cart/steps/confirm-inventory.ts b/packages/core/core-flows/src/cart/steps/confirm-inventory.ts index 9b21f093f1..9dc91cb600 100644 --- a/packages/core/core-flows/src/cart/steps/confirm-inventory.ts +++ b/packages/core/core-flows/src/cart/steps/confirm-inventory.ts @@ -1,4 +1,7 @@ -import { BigNumberInput, IInventoryService } from "@medusajs/framework/types" +import type { + BigNumberInput, + IInventoryService, +} from "@medusajs/framework/types" import { MathBN, MedusaError, diff --git a/packages/core/core-flows/src/cart/steps/create-carts.ts b/packages/core/core-flows/src/cart/steps/create-carts.ts index c66331b010..54f37feec7 100644 --- a/packages/core/core-flows/src/cart/steps/create-carts.ts +++ b/packages/core/core-flows/src/cart/steps/create-carts.ts @@ -1,4 +1,7 @@ -import { CreateCartDTO, ICartModuleService } from "@medusajs/framework/types" +import type { + CreateCartDTO, + ICartModuleService, +} from "@medusajs/framework/types" import { Modules } from "@medusajs/framework/utils" import { StepResponse, createStep } from "@medusajs/framework/workflows-sdk" diff --git a/packages/core/core-flows/src/cart/steps/find-or-create-customer.ts b/packages/core/core-flows/src/cart/steps/find-or-create-customer.ts index cc075d89e7..81ed2fccdc 100644 --- a/packages/core/core-flows/src/cart/steps/find-or-create-customer.ts +++ b/packages/core/core-flows/src/cart/steps/find-or-create-customer.ts @@ -1,4 +1,7 @@ -import { CustomerDTO, ICustomerModuleService } from "@medusajs/framework/types" +import type { + CustomerDTO, + ICustomerModuleService, +} from "@medusajs/framework/types" import { isDefined, Modules, validateEmail } from "@medusajs/framework/utils" import { createStep, StepResponse } from "@medusajs/framework/workflows-sdk" diff --git a/packages/core/core-flows/src/cart/steps/get-actions-to-compute-from-promotions.ts b/packages/core/core-flows/src/cart/steps/get-actions-to-compute-from-promotions.ts index 927f9ee069..1ef5c69c52 100644 --- a/packages/core/core-flows/src/cart/steps/get-actions-to-compute-from-promotions.ts +++ b/packages/core/core-flows/src/cart/steps/get-actions-to-compute-from-promotions.ts @@ -1,4 +1,7 @@ -import { CartDTO, IPromotionModuleService } from "@medusajs/framework/types" +import type { + CartDTO, + IPromotionModuleService, +} from "@medusajs/framework/types" import { Modules } from "@medusajs/framework/utils" import { StepResponse, createStep } from "@medusajs/framework/workflows-sdk" diff --git a/packages/core/core-flows/src/cart/steps/get-promotion-codes-to-apply.ts b/packages/core/core-flows/src/cart/steps/get-promotion-codes-to-apply.ts index e84402abd3..882de39e65 100644 --- a/packages/core/core-flows/src/cart/steps/get-promotion-codes-to-apply.ts +++ b/packages/core/core-flows/src/cart/steps/get-promotion-codes-to-apply.ts @@ -1,4 +1,4 @@ -import { IPromotionModuleService } from "@medusajs/framework/types" +import type { IPromotionModuleService } from "@medusajs/framework/types" import { MedusaError, Modules, @@ -79,7 +79,7 @@ export const getPromotionCodesToApply = createStep( const adjustmentCodes: string[] = [] items.concat(shipping_methods).forEach((object) => { object.adjustments?.forEach((adjustment) => { - if (adjustment.code && !adjustmentCodes.includes(adjustment.code)) { + if (adjustment.code) { adjustmentCodes.push(adjustment.code) } }) diff --git a/packages/core/core-flows/src/cart/steps/get-variant-price-sets.ts b/packages/core/core-flows/src/cart/steps/get-variant-price-sets.ts index b576afc6b9..edcc68f780 100644 --- a/packages/core/core-flows/src/cart/steps/get-variant-price-sets.ts +++ b/packages/core/core-flows/src/cart/steps/get-variant-price-sets.ts @@ -34,6 +34,10 @@ export interface GetVariantPriceSetsStepBulkInput { * The variants to get price sets for. */ data: { + /** + * The ID of the item. + */ + id?: string /** * The ID of the variant to get the price set for. */ @@ -51,6 +55,10 @@ interface VariantPriceSetData { } interface PriceCalculationItem { + /** + * The ID of the item. In case of variants we wont have an item id + */ + id?: string variantId: string priceSetId: string context?: Record @@ -124,7 +132,7 @@ async function processVariantPriceSets( for (const item of groupItems) { const calculatedPriceSet = priceSetMap.get(item.priceSetId) if (calculatedPriceSet) { - result[item.variantId] = calculatedPriceSet + result[item.id ?? item.variantId] = calculatedPriceSet } } } @@ -196,6 +204,7 @@ function createCalculationItemsFromBulkData( const priceSetId = variantToPriceSetId.get(item.variantId) if (priceSetId) { calculationItems.push({ + id: item.id, variantId: item.variantId, priceSetId, context: item.context, diff --git a/packages/core/core-flows/src/cart/steps/remove-line-item-adjustments.ts b/packages/core/core-flows/src/cart/steps/remove-line-item-adjustments.ts index 8d9dc54b40..c15941081d 100644 --- a/packages/core/core-flows/src/cart/steps/remove-line-item-adjustments.ts +++ b/packages/core/core-flows/src/cart/steps/remove-line-item-adjustments.ts @@ -1,4 +1,4 @@ -import { ICartModuleService } from "@medusajs/framework/types" +import type { ICartModuleService } from "@medusajs/framework/types" import { Modules } from "@medusajs/framework/utils" import { StepResponse, createStep } from "@medusajs/framework/workflows-sdk" diff --git a/packages/core/core-flows/src/cart/steps/remove-shipping-method-adjustments.ts b/packages/core/core-flows/src/cart/steps/remove-shipping-method-adjustments.ts index 1f6a7886d1..b3901038ab 100644 --- a/packages/core/core-flows/src/cart/steps/remove-shipping-method-adjustments.ts +++ b/packages/core/core-flows/src/cart/steps/remove-shipping-method-adjustments.ts @@ -1,4 +1,4 @@ -import { ICartModuleService } from "@medusajs/framework/types" +import type { ICartModuleService } from "@medusajs/framework/types" import { Modules } from "@medusajs/framework/utils" import { StepResponse, createStep } from "@medusajs/framework/workflows-sdk" diff --git a/packages/core/core-flows/src/cart/steps/remove-shipping-method-from-cart.ts b/packages/core/core-flows/src/cart/steps/remove-shipping-method-from-cart.ts index 96180e01ff..c4e778b42f 100644 --- a/packages/core/core-flows/src/cart/steps/remove-shipping-method-from-cart.ts +++ b/packages/core/core-flows/src/cart/steps/remove-shipping-method-from-cart.ts @@ -1,4 +1,4 @@ -import { ICartModuleService } from "@medusajs/framework/types" +import type { ICartModuleService } from "@medusajs/framework/types" import { Modules } from "@medusajs/framework/utils" import { StepResponse, createStep } from "@medusajs/framework/workflows-sdk" @@ -16,7 +16,10 @@ export interface RemoveShippingMethodFromCartStepInput { * The shipping methods removed from the cart, along with IDs of related records * that were removed. */ -export type RemoveShippingMethodFromCartStepOutput = Record | void +export type RemoveShippingMethodFromCartStepOutput = Record< + string, + string[] +> | void export const removeShippingMethodFromCartStepId = "remove-shipping-method-to-cart-step" @@ -37,7 +40,7 @@ export const removeShippingMethodFromCartStep = createStep( ) return new StepResponse( - methods as RemoveShippingMethodFromCartStepOutput, + methods as RemoveShippingMethodFromCartStepOutput, data.shipping_method_ids ) }, diff --git a/packages/core/core-flows/src/cart/steps/reserve-inventory.ts b/packages/core/core-flows/src/cart/steps/reserve-inventory.ts index 6448a9aaca..62822481b6 100644 --- a/packages/core/core-flows/src/cart/steps/reserve-inventory.ts +++ b/packages/core/core-flows/src/cart/steps/reserve-inventory.ts @@ -1,6 +1,6 @@ import { MathBN, Modules } from "@medusajs/framework/utils" import { createStep, StepResponse } from "@medusajs/framework/workflows-sdk" -import { BigNumberInput } from "@medusajs/types" +import type { BigNumberInput } from "@medusajs/framework/types" /** * The details of the items and their quantity to reserve. diff --git a/packages/core/core-flows/src/cart/steps/update-cart-promotions.ts b/packages/core/core-flows/src/cart/steps/update-cart-promotions.ts index 068d9423b5..461f830f09 100644 --- a/packages/core/core-flows/src/cart/steps/update-cart-promotions.ts +++ b/packages/core/core-flows/src/cart/steps/update-cart-promotions.ts @@ -1,4 +1,4 @@ -import { IPromotionModuleService } from "@medusajs/framework/types" +import type { IPromotionModuleService } from "@medusajs/framework/types" import { ContainerRegistrationKeys, Modules, diff --git a/packages/core/core-flows/src/cart/steps/validate-cart-payments.ts b/packages/core/core-flows/src/cart/steps/validate-cart-payments.ts index af00ba9c24..4f3e64ef22 100644 --- a/packages/core/core-flows/src/cart/steps/validate-cart-payments.ts +++ b/packages/core/core-flows/src/cart/steps/validate-cart-payments.ts @@ -1,4 +1,4 @@ -import { CartWorkflowDTO } from "@medusajs/framework/types" +import type { CartWorkflowDTO } from "@medusajs/framework/types" import { isPresent, MathBN, diff --git a/packages/core/core-flows/src/cart/steps/validate-cart-shipping-options.ts b/packages/core/core-flows/src/cart/steps/validate-cart-shipping-options.ts index e62a972f01..093e82b1bd 100644 --- a/packages/core/core-flows/src/cart/steps/validate-cart-shipping-options.ts +++ b/packages/core/core-flows/src/cart/steps/validate-cart-shipping-options.ts @@ -1,5 +1,12 @@ -import { CartDTO, IFulfillmentModuleService } from "@medusajs/framework/types" -import { arrayDifference, MedusaError, Modules, } from "@medusajs/framework/utils" +import type { + CartDTO, + IFulfillmentModuleService, +} from "@medusajs/framework/types" +import { + arrayDifference, + MedusaError, + Modules, +} from "@medusajs/framework/utils" import { createStep, StepResponse } from "@medusajs/framework/workflows-sdk" /** @@ -39,7 +46,7 @@ export const validateCartShippingOptionsStepId = /** * This step validates shipping options to ensure they can be applied on a cart. * If not valid, the step throws an error. - * + * * @example * const data = validateCartShippingOptionsStep({ * // retrieve the details of the cart from another workflow @@ -52,7 +59,12 @@ export const validateCartShippingOptionsStepId = export const validateCartShippingOptionsStep = createStep( validateCartShippingOptionsStepId, async (data: ValidateCartShippingOptionsStepInput, { container }) => { - const { option_ids: optionIds = [], cart, shippingOptionsContext, prefetched_shipping_options: prefetchedShippingOptions } = data + const { + option_ids: optionIds = [], + cart, + shippingOptionsContext, + prefetched_shipping_options: prefetchedShippingOptions, + } = data if (!optionIds.length) { return new StepResponse(void 0) diff --git a/packages/core/core-flows/src/cart/steps/validate-cart.ts b/packages/core/core-flows/src/cart/steps/validate-cart.ts index 3055fb8b12..8dec167723 100644 --- a/packages/core/core-flows/src/cart/steps/validate-cart.ts +++ b/packages/core/core-flows/src/cart/steps/validate-cart.ts @@ -1,4 +1,4 @@ -import { CartDTO, CartWorkflowDTO } from "@medusajs/framework/types" +import type { CartDTO, CartWorkflowDTO } from "@medusajs/framework/types" import { MedusaError } from "@medusajs/framework/utils" import { createStep } from "@medusajs/framework/workflows-sdk" @@ -16,13 +16,13 @@ export const validateCartStepId = "validate-cart" /** * This step validates a cart to ensure it exists and is not completed. * If not valid, the step throws an error. - * + * * :::tip - * + * * You can use the {@link retrieveCartStep} to retrieve a cart's details. - * + * * ::: - * + * * @example * const data = validateCartStep({ * // retrieve the details of the cart from another workflow diff --git a/packages/core/core-flows/src/cart/steps/validate-sales-channel.ts b/packages/core/core-flows/src/cart/steps/validate-sales-channel.ts index e35de21069..1d50f91f4f 100644 --- a/packages/core/core-flows/src/cart/steps/validate-sales-channel.ts +++ b/packages/core/core-flows/src/cart/steps/validate-sales-channel.ts @@ -1,7 +1,7 @@ import { MedusaError } from "@medusajs/framework/utils" import { createStep, StepResponse } from "@medusajs/framework/workflows-sdk" -import { SalesChannelDTO } from "@medusajs/types" +import type { SalesChannelDTO } from "@medusajs/framework/types" export const validateSalesChannelStep = createStep( "validate-sales-channel", diff --git a/packages/core/core-flows/src/cart/steps/validate-shipping-methods-data.ts b/packages/core/core-flows/src/cart/steps/validate-shipping-methods-data.ts index e5d40416b5..6bf242953c 100644 --- a/packages/core/core-flows/src/cart/steps/validate-shipping-methods-data.ts +++ b/packages/core/core-flows/src/cart/steps/validate-shipping-methods-data.ts @@ -2,7 +2,7 @@ import { Modules, promiseAll } from "@medusajs/framework/utils" import { IFulfillmentModuleService, ValidateFulfillmentDataContext, -} from "@medusajs/types" +} from "@medusajs/framework/types" import { createStep, StepResponse } from "@medusajs/workflows-sdk" /** @@ -19,7 +19,7 @@ export type ValidateShippingMethodsDataInput = { */ provider_id: string /** - * The `data` property of the shipping option that the shipping method was + * The `data` property of the shipping option that the shipping method was * created from. */ option_data: Record @@ -36,16 +36,18 @@ export type ValidateShippingMethodsDataInput = { /** * The validated data of the shipping methods. */ -export type ValidateShippingMethodsDataOutput = void | { - [x: string]: Record; -}[] +export type ValidateShippingMethodsDataOutput = + | void + | { + [x: string]: Record + }[] export const validateAndReturnShippingMethodsDataStepId = "validate-and-return-shipping-methods-data" /** * This step validates shipping options to ensure they can be applied on a cart. * The step either returns the validated data or void. - * + * * @example * const data = validateAndReturnShippingMethodsDataStep({ * id: "sm_123", diff --git a/packages/core/core-flows/src/cart/steps/validate-shipping.ts b/packages/core/core-flows/src/cart/steps/validate-shipping.ts index cae3a925a1..fd96f809ed 100644 --- a/packages/core/core-flows/src/cart/steps/validate-shipping.ts +++ b/packages/core/core-flows/src/cart/steps/validate-shipping.ts @@ -4,7 +4,7 @@ import { CartWorkflowDTO, ProductVariantDTO, ShippingOptionDTO, -} from "@medusajs/types" +} from "@medusajs/framework/types" import { createStep, StepResponse } from "@medusajs/workflows-sdk" /** diff --git a/packages/core/core-flows/src/cart/steps/validate-variant-prices.ts b/packages/core/core-flows/src/cart/steps/validate-variant-prices.ts index 8c4a6da31e..588c5baecc 100644 --- a/packages/core/core-flows/src/cart/steps/validate-variant-prices.ts +++ b/packages/core/core-flows/src/cart/steps/validate-variant-prices.ts @@ -1,4 +1,4 @@ -import { BigNumberInput } from "@medusajs/framework/types" +import type { BigNumberInput } from "@medusajs/framework/types" import { MedusaError, isPresent } from "@medusajs/framework/utils" import { createStep } from "@medusajs/framework/workflows-sdk" @@ -30,7 +30,7 @@ export const validateVariantPricesStepId = "validate-variant-prices" /** * This step validates the specified variant objects to ensure they have prices. * If not valid, the step throws an error. - * + * * @example * const data = validateVariantPricesStep({ * variants: [ diff --git a/packages/core/core-flows/src/cart/utils/__tests__/prepare-confirm-inventory-input.spec.ts b/packages/core/core-flows/src/cart/utils/__tests__/prepare-confirm-inventory-input.spec.ts index 67d40e8f41..a7db7a6878 100644 --- a/packages/core/core-flows/src/cart/utils/__tests__/prepare-confirm-inventory-input.spec.ts +++ b/packages/core/core-flows/src/cart/utils/__tests__/prepare-confirm-inventory-input.spec.ts @@ -1,4 +1,4 @@ -import { ConfirmVariantInventoryWorkflowInputDTO } from "@medusajs/framework/types" +import type { ConfirmVariantInventoryWorkflowInputDTO } from "@medusajs/framework/types" import { MedusaError } from "@medusajs/framework/utils" import { prepareConfirmInventoryInput } from "../prepare-confirm-inventory-input" diff --git a/packages/core/core-flows/src/cart/workflows/add-to-cart.ts b/packages/core/core-flows/src/cart/workflows/add-to-cart.ts index 0fab0ef6ba..8c31844951 100644 --- a/packages/core/core-flows/src/cart/workflows/add-to-cart.ts +++ b/packages/core/core-flows/src/cart/workflows/add-to-cart.ts @@ -2,12 +2,11 @@ import { AdditionalData, AddToCartWorkflowInputDTO, ConfirmVariantInventoryWorkflowInputDTO, - WithCalculatedPrice, + CreateLineItemForCartDTO, } from "@medusajs/framework/types" import { CartWorkflowEvents, deduplicate, - filterObjectByKeys, isDefined, } from "@medusajs/framework/utils" import { @@ -16,7 +15,6 @@ import { parallelize, transform, when, - WorkflowData, WorkflowResponse, } from "@medusajs/framework/workflows-sdk" import { useQueryGraphStep } from "../../common" @@ -25,12 +23,10 @@ import { acquireLockStep, releaseLockStep } from "../../locking" import { createLineItemsStep, getLineItemActionsStep, - getVariantPriceSetsStep, updateLineItemsStep, } from "../steps" import { validateCartStep } from "../steps/validate-cart" import { validateLineItemPricesStep } from "../steps/validate-line-item-prices" -import { validateVariantPricesStep } from "../steps/validate-variant-prices" import { cartFieldsForPricingContext, productVariantsFields, @@ -43,6 +39,7 @@ import { } from "../utils/prepare-line-item-data" import { pricingContextResult } from "../utils/schemas" import { confirmVariantInventoryWorkflow } from "./confirm-variant-inventory" +import { getVariantsAndItemsWithPrices } from "./get-variants-and-items-with-prices" import { refreshCartItemsWorkflow } from "./refresh-cart-items" const cartFields = ["completed_at"].concat(cartFieldsForPricingContext) @@ -119,32 +116,30 @@ export const addToCartWorkflow = createWorkflow( name: addToCartWorkflowId, idempotent: false, }, - (input: WorkflowData) => { + (input: AddToCartWorkflowInputDTO & AdditionalData) => { acquireLockStep({ key: input.cart_id, timeout: 2, ttl: 10, }) - const cartQuery = useQueryGraphStep({ + const { data: cart } = useQueryGraphStep({ entity: "cart", filters: { id: input.cart_id }, fields: cartFields, - options: { throwIfKeyNotFound: true }, + options: { throwIfKeyNotFound: true, isList: false }, }).config({ name: "get-cart" }) - const cart = transform({ cartQuery }, ({ cartQuery }) => { - return cartQuery.data[0] - }) - validateCartStep({ cart }) const validate = createHook("validate", { input, cart, }) - const variantIds = transform({ input }, (data) => { - return (data.input.items ?? []).map((i) => i.variant_id).filter(Boolean) + const variantIds = transform({ input }, (data): string[] => { + return (data.input.items ?? []) + .map((i) => i.variant_id) + .filter((v): v is string => !!v) }) const setPricingContext = createHook( @@ -162,43 +157,46 @@ export const addToCartWorkflow = createWorkflow( const setPricingContextResult = setPricingContext.getResult() - const variants = when( + const { variants: variantsData, lineItems: lineItemsData } = when( "should-calculate-prices", { variantIds }, ({ variantIds }) => { return !!variantIds.length } ).then(() => { - const pricingContext = transform( - { cart, items: input.items, setPricingContextResult }, - (data): { variantId: string; context: Record }[] => { - const baseContext = { - ...filterObjectByKeys(data.cart, cartFieldsForPricingContext), - ...(data.setPricingContextResult - ? data.setPricingContextResult - : {}), - currency_code: data.cart.currency_code, - region_id: data.cart.region_id, - region: data.cart.region, - customer_id: data.cart.customer_id, - customer: data.cart.customer, - } + const { variants: variantsData, lineItems: items } = + getVariantsAndItemsWithPrices.runAsStep({ + input: { + cart, + items: input.items, + setPricingContextResult: setPricingContextResult!, + variants: { + id: variantIds, + fields: deduplicate([ + ...productVariantsFields, + ...requiredVariantFieldsForInventoryConfirmation, + ]), + }, + }, + }) - return data.items - .filter((i) => i.variant_id) - .map((item) => { - return { - variantId: item.variant_id!, - context: { - ...baseContext, - quantity: item.quantity, - }, - } - }) - } - ) + const lineItems = transform({ items }, ({ items }) => { + return items.map((item) => { + return item.data as CreateLineItemForCartDTO + }) + }) - const { data: variantsData } = useQueryGraphStep({ + return { variants: variantsData, lineItems } + }) + + const fetchedVariants = when( + "fetch-variants", + { variantsData, variantIds }, + ({ variantsData, variantIds }) => { + return !variantsData?.length && !!variantIds.length + } + ).then(() => { + return useQueryGraphStep({ entity: "variants", fields: deduplicate([ ...productVariantsFields, @@ -207,55 +205,50 @@ export const addToCartWorkflow = createWorkflow( filters: { id: variantIds, }, - }) - - const calculatedPriceSets = getVariantPriceSetsStep({ - data: pricingContext, - }) - - const variants = transform( - { variantsData, calculatedPriceSets }, - ({ variantsData, calculatedPriceSets }) => { - return variantsData.map((variant) => { - variant.calculated_price = calculatedPriceSets[variant.id] - return variant - }) - } - ) - - validateVariantPricesStep({ variants }) - - return variants as (PrepareVariantLineItemInput & - ConfirmVariantInventoryWorkflowInputDTO["variants"][number] & - WithCalculatedPrice)[] + }).config({ name: "fetch-variants" }) }) - const lineItems = transform({ input, variants }, (data) => { - const items = (data.input.items ?? []).map((item) => { - const variant = (data.variants ?? []).find( - (v) => v.id === item.variant_id - )! + const variants = transform( + { variantsData, fetchedVariants }, + ({ variantsData, fetchedVariants }) => { + return (variantsData ?? + fetchedVariants) as unknown as PrepareVariantLineItemInput[] + } + ) - const input: PrepareLineItemDataInput = { - item, - variant: variant, - cartId: data.input.cart_id, - unitPrice: item.unit_price, - isTaxInclusive: - item.is_tax_inclusive ?? - variant?.calculated_price?.is_calculated_price_tax_inclusive, - isCustomPrice: isDefined(item?.unit_price), + const lineItems = transform( + { cart_id: input.cart_id, items: input.items, lineItemsData, variants }, + ({ cart_id, items: items_, lineItemsData, variants }) => { + if (lineItemsData?.length) { + return lineItemsData } - if (variant && !isDefined(input.unitPrice)) { - input.unitPrice = variant.calculated_price?.calculated_amount - } + const items = (items_ ?? []).map((item) => { + const variant = (variants ?? []).find( + (v) => v.id === item.variant_id + )! - return prepareLineItemData(input) - }) + const input: PrepareLineItemDataInput = { + item, + variant: variant, + cartId: cart_id, + unitPrice: item.unit_price, + isTaxInclusive: + item.is_tax_inclusive ?? + variant?.calculated_price?.is_calculated_price_tax_inclusive, + isCustomPrice: isDefined(item?.unit_price), + } - return items - }) + if (variant && !isDefined(input.unitPrice)) { + input.unitPrice = variant.calculated_price?.calculated_amount + } + + return prepareLineItemData(input) + }) + + return items + } + ) validateLineItemPricesStep({ items: lineItems }) @@ -287,7 +280,8 @@ export const addToCartWorkflow = createWorkflow( confirmVariantInventoryWorkflow.runAsStep({ input: { sales_channel_id: cart.sales_channel_id, - variants, + variants: + variants as unknown as ConfirmVariantInventoryWorkflowInputDTO["variants"], items: input.items, itemsToUpdate: itemsToConfirmInventory, }, diff --git a/packages/core/core-flows/src/cart/workflows/confirm-variant-inventory.ts b/packages/core/core-flows/src/cart/workflows/confirm-variant-inventory.ts index 6251446617..9837cc2f58 100644 --- a/packages/core/core-flows/src/cart/workflows/confirm-variant-inventory.ts +++ b/packages/core/core-flows/src/cart/workflows/confirm-variant-inventory.ts @@ -1,11 +1,11 @@ -import { ConfirmVariantInventoryWorkflowInputDTO } from "@medusajs/framework/types" +import type { ConfirmVariantInventoryWorkflowInputDTO } from "@medusajs/framework/types" import { WorkflowData, WorkflowResponse, createWorkflow, transform, } from "@medusajs/framework/workflows-sdk" -import { BigNumberInput } from "@medusajs/types" +import type { BigNumberInput } from "@medusajs/framework/types" import { confirmInventoryStep } from "../steps" import { prepareConfirmInventoryInput } from "../utils/prepare-confirm-inventory-input" diff --git a/packages/core/core-flows/src/cart/workflows/create-carts.ts b/packages/core/core-flows/src/cart/workflows/create-carts.ts index 37424dab26..e1a27a058c 100644 --- a/packages/core/core-flows/src/cart/workflows/create-carts.ts +++ b/packages/core/core-flows/src/cart/workflows/create-carts.ts @@ -1,11 +1,12 @@ import { AdditionalData, + ConfirmVariantInventoryWorkflowInputDTO, + CreateCartDTO, CreateCartWorkflowInputDTO, } from "@medusajs/framework/types" import { CartWorkflowEvents, deduplicate, - isDefined, MedusaError, } from "@medusajs/framework/utils" import { @@ -13,30 +14,22 @@ import { createWorkflow, parallelize, transform, - when, WorkflowData, WorkflowResponse, } from "@medusajs/framework/workflows-sdk" -import { useQueryGraphStep } from "../../common" import { emitEventStep } from "../../common/steps/emit-event" import { createCartsStep, findOneOrAnyRegionStep, findOrCreateCustomerStep, findSalesChannelStep, - getVariantPriceSetsStep, } from "../steps" -import { validateLineItemPricesStep } from "../steps/validate-line-item-prices" import { validateSalesChannelStep } from "../steps/validate-sales-channel" -import { validateVariantPricesStep } from "../steps/validate-variant-prices" import { productVariantsFields } from "../utils/fields" import { requiredVariantFieldsForInventoryConfirmation } from "../utils/prepare-confirm-inventory-input" -import { - prepareLineItemData, - PrepareLineItemDataInput, -} from "../utils/prepare-line-item-data" import { pricingContextResult } from "../utils/schemas" import { confirmVariantInventoryWorkflow } from "./confirm-variant-inventory" +import { getVariantsAndItemsWithPrices } from "./get-variants-and-items-with-prices" import { refreshPaymentCollectionForCartWorkflow } from "./refresh-payment-collection" import { updateCartPromotionsWorkflow } from "./update-cart-promotions" import { updateTaxLinesWorkflow } from "./update-tax-lines" @@ -119,7 +112,9 @@ export const createCartWorkflow = createWorkflow( createCartWorkflowId, (input: WorkflowData) => { const variantIds = transform({ input }, (data) => { - return (data.input.items ?? []).map((i) => i.variant_id).filter(Boolean) + return (data.input.items ?? []) + .map((i) => i.variant_id) + .filter((v): v is string => !!v) }) const [salesChannel, region, customerData] = parallelize( @@ -151,79 +146,31 @@ export const createCartWorkflow = createWorkflow( ) const setPricingContextResult = setPricingContext.getResult() - // TODO: This is on par with the context used in v1.*, but we can be more flexible. - const pricingContext = transform( - { input, region, customerData, setPricingContextResult }, - (data) => { - if (!data.region) { - throw new MedusaError(MedusaError.Types.NOT_FOUND, "No regions found") - } - - return { - ...(data.setPricingContextResult ? data.setPricingContextResult : {}), - currency_code: data.input.currency_code ?? data.region.currency_code, - region_id: data.region.id, - customer_id: data.customerData.customer?.id, - } - } - ) - - const variants = when("has-variants", { variantIds }, ({ variantIds }) => { - return !!variantIds.length - }).then(() => { - const { data: variantsData } = useQueryGraphStep({ - entity: "variants", - fields: deduplicate([ - ...productVariantsFields, - ...requiredVariantFieldsForInventoryConfirmation, - ]), - filters: { - id: variantIds, + const { variants, lineItems } = getVariantsAndItemsWithPrices.runAsStep({ + input: { + cart: { + currency_code: input.currency_code, + region, + region_id: region.id, + customer_id: customerData.customer?.id, }, - }) - - const calculatedPriceContext = transform( - { pricingContext, items: input.items }, - (data): { variantId: string; context: Record }[] => { - const baseContext = data.pricingContext - - return (data.items ?? []) - .filter((i) => i.variant_id) - .map((item) => { - return { - variantId: item.variant_id!, - context: { - ...baseContext, - quantity: item.quantity, - }, - } - }) - } - ) - - const calculatedPriceSets = getVariantPriceSetsStep({ - data: calculatedPriceContext, - }) - - const variants = transform( - { variantsData, calculatedPriceSets }, - ({ variantsData, calculatedPriceSets }) => { - return variantsData.map((variant) => { - variant.calculated_price = calculatedPriceSets[variant.id] - return variant - }) - } - ) - - validateVariantPricesStep({ variants }) - - return variants + items: input.items, + setPricingContextResult: setPricingContextResult!, + variants: { + id: variantIds, + fields: deduplicate([ + ...productVariantsFields, + ...requiredVariantFieldsForInventoryConfirmation, + ]), + }, + }, }) confirmVariantInventoryWorkflow.runAsStep({ input: { sales_channel_id: salesChannel.id, - variants: variants!, + variants: + variants as unknown as ConfirmVariantInventoryWorkflowInputDTO["variants"], items: input.items!, }, }) @@ -262,39 +209,11 @@ export const createCartWorkflow = createWorkflow( } ) - const lineItems = transform({ input, variants }, (data) => { - const items = (data.input.items ?? []).map((item) => { - const variant = (data.variants ?? []).find( - (v) => v.id === item.variant_id - )! - - const input: PrepareLineItemDataInput = { - item, - variant: variant, - unitPrice: item.unit_price, - isTaxInclusive: - item.is_tax_inclusive ?? - variant?.calculated_price?.is_calculated_price_tax_inclusive, - isCustomPrice: isDefined(item?.unit_price), - } - - if (variant && !input.unitPrice) { - input.unitPrice = variant.calculated_price?.calculated_amount - } - - return prepareLineItemData(input) - }) - - return items - }) - - validateLineItemPricesStep({ items: lineItems }) - const cartToCreate = transform({ lineItems, cartInput }, (data) => { return { ...data.cartInput, - items: data.lineItems, - } + items: data.lineItems.map((i) => i.data), + } as unknown as CreateCartDTO }) const validate = createHook("validate", { diff --git a/packages/core/core-flows/src/cart/workflows/get-variants-and-items-with-prices.ts b/packages/core/core-flows/src/cart/workflows/get-variants-and-items-with-prices.ts new file mode 100644 index 0000000000..4ab79168b4 --- /dev/null +++ b/packages/core/core-flows/src/cart/workflows/get-variants-and-items-with-prices.ts @@ -0,0 +1,226 @@ +import { + BigNumberInput, + CartDTO, + CartLineItemDTO, + CreateCartCreateLineItemDTO, + CustomerDTO, + OrderWorkflow, + RegionDTO, + UpdateLineItemDTO, + UpdateLineItemWithSelectorDTO, +} from "@medusajs/framework/types" +import { + filterObjectByKeys, + isDefined, + MedusaError, + simpleHash, +} from "@medusajs/framework/utils" +import { + createWorkflow, + transform, + WorkflowData, + WorkflowResponse, +} from "@medusajs/framework/workflows-sdk" +import { useQueryGraphStep } from "../../common" +import { getVariantPriceSetsStep } from "../steps" +import { + cartFieldsForPricingContext, + productVariantsFields, +} from "../utils/fields" +import { + prepareLineItemData, + PrepareLineItemDataInput, +} from "../utils/prepare-line-item-data" + +interface GetVariantsAndItemsWithPricesWorkflowInput { + cart: Partial & { + region?: Partial + region_id?: string + customer?: Partial + customer_id?: string + } + items?: Partial< + | CreateCartCreateLineItemDTO + | CartLineItemDTO + | OrderWorkflow.OrderAddLineItemWorkflowInput["items"][number] + >[] + setPricingContextResult: object + variants?: { + id?: string[] + fields?: string[] + } +} + +type GetVariantsAndItemsWithPricesWorkflowOutput = { + // The variant can depend on the requested fields and therefore the caller will know better + variants: (object & { + calculated_price: { + calculated_price: { + price_list_type: string + } + is_calculated_price_tax_inclusive: boolean + original_amount: BigNumberInput + calculated_amount: BigNumberInput + } + })[] + lineItems: UpdateLineItemWithSelectorDTO[] +} + +export const getVariantsAndItemsWithPricesId = + "get-variant-items-with-prices-workflow" +export const getVariantsAndItemsWithPrices = createWorkflow( + getVariantsAndItemsWithPricesId, + ( + input: WorkflowData + ): WorkflowResponse => { + const variantIds = transform( + { cart: input.cart, items: input.items, variantIds: input.variants?.id }, + (data): string[] => { + if (data.variantIds) { + return data.variantIds + } + + return Array.from( + new Set( + (data.cart.items ?? data.items ?? []).map((i) => i.variant_id) + ) + ).filter((v): v is string => !!v) + } + ) + + const cartPricingContext = transform( + { + cart: input.cart, + items: input.items, + setPricingContextResult: input.setPricingContextResult, + }, + ( + data + ): { + id: string + variantId: string + context: Record + }[] => { + const cart = data.cart + const baseContext = { + ...filterObjectByKeys(cart, cartFieldsForPricingContext), + ...(data.setPricingContextResult ? data.setPricingContextResult : {}), + currency_code: cart.currency_code ?? cart.region?.currency_code, + region_id: cart.region_id, + region: cart.region, + customer_id: cart.customer_id, + customer: cart.customer, + } + + return (data.items ?? cart.items ?? []) + .filter((i) => i.variant_id) + .map((item) => { + const idLike = + (item as CartLineItemDTO).id ?? simpleHash(JSON.stringify(item)) + return { + id: idLike, + variantId: item.variant_id!, + context: { + ...baseContext, + quantity: item.quantity, + }, + } + }) + } + ) + + const variantQueryFields = transform( + { variants: input.variants }, + (data) => { + return data.variants?.fields ?? productVariantsFields + } + ) + + const { data: variantsData } = useQueryGraphStep({ + entity: "variants", + fields: variantQueryFields, + filters: { + id: variantIds, + }, + }).config({ name: "fetch-variants" }) + + const calculatedPriceSets = getVariantPriceSetsStep({ + data: cartPricingContext, + }) + + const variantsItemsWithPrices = transform( + { + cart: input.cart, + items: input.items, + variantsData, + calculatedPriceSets, + }, + ({ + cart, + items: inputItems, + variantsData, + calculatedPriceSets, + }): GetVariantsAndItemsWithPricesWorkflowOutput => { + const priceNotFound: string[] = [] + + const items = (inputItems ?? cart.items ?? []).map((item) => { + const item_ = item as any + const idLike = + (item as CartLineItemDTO).id ?? simpleHash(JSON.stringify(item)) + let calculatedPriceSet = calculatedPriceSets[idLike] + if (!calculatedPriceSet) { + calculatedPriceSet = calculatedPriceSets[item_.variant_id!] + } + + if (!calculatedPriceSet && item_.variant_id) { + priceNotFound.push(item_.variant_id) + } + + const variant = variantsData.find((v) => v.id === item.variant_id) + + if (variant) { + variant.calculated_price = calculatedPriceSet + } + + const isCustomPrice = + item_.is_custom_price ?? isDefined(item?.unit_price) + + const input: PrepareLineItemDataInput = { + item: item_, + variant: variant, + cartId: cart.id, + unitPrice: item_.unit_price, + isTaxInclusive: + item_.is_tax_inclusive ?? + calculatedPriceSet?.is_calculated_price_tax_inclusive, + isCustomPrice: isCustomPrice, + } + + if (variant && !isCustomPrice) { + input.unitPrice = calculatedPriceSet.calculated_amount + input.isTaxInclusive = + calculatedPriceSet.is_calculated_price_tax_inclusive + } + + const preparedItem = prepareLineItemData(input) + + return { + selector: { id: (item_ as CartLineItemDTO).id }, + data: preparedItem as Partial, + } + }) + + if (priceNotFound.length > 0) { + throw new MedusaError( + MedusaError.Types.INVALID_DATA, + `Variants with IDs ${priceNotFound.join(", ")} do not have a price` + ) + } + + return { variants: variantsData, lineItems: items } + } + ) + + return new WorkflowResponse(variantsItemsWithPrices) + } +) diff --git a/packages/core/core-flows/src/cart/workflows/list-shipping-options-for-cart-with-pricing.ts b/packages/core/core-flows/src/cart/workflows/list-shipping-options-for-cart-with-pricing.ts index 312ff522a6..86ec154daf 100644 --- a/packages/core/core-flows/src/cart/workflows/list-shipping-options-for-cart-with-pricing.ts +++ b/packages/core/core-flows/src/cart/workflows/list-shipping-options-for-cart-with-pricing.ts @@ -11,7 +11,7 @@ import { AdditionalData, CalculateShippingOptionPriceDTO, ListShippingOptionsForCartWithPricingWorkflowInput, -} from "@medusajs/types" +} from "@medusajs/framework/types" import { useQueryGraphStep, validatePresenceOfStep } from "../../common" import { useRemoteQueryStep } from "../../common/steps/use-remote-query" diff --git a/packages/core/core-flows/src/cart/workflows/list-shipping-options-for-cart.ts b/packages/core/core-flows/src/cart/workflows/list-shipping-options-for-cart.ts index 10119295a1..8cb1570f57 100644 --- a/packages/core/core-flows/src/cart/workflows/list-shipping-options-for-cart.ts +++ b/packages/core/core-flows/src/cart/workflows/list-shipping-options-for-cart.ts @@ -14,9 +14,16 @@ import { cartFieldsForPricingContext } from "../utils/fields" import { AdditionalData, ListShippingOptionsForCartWorkflowInput, -} from "@medusajs/types" -import { deduplicate, filterObjectByKeys, isDefined } from "@medusajs/framework/utils" -import { pricingContextResult, shippingOptionsContextResult } from "../utils/schemas" +} from "@medusajs/framework/types" +import { + deduplicate, + filterObjectByKeys, + isDefined, +} from "@medusajs/framework/utils" +import { + pricingContextResult, + shippingOptionsContextResult, +} from "../utils/schemas" export const listShippingOptionsForCartWorkflowId = "list-shipping-options-for-cart" @@ -81,26 +88,26 @@ export const listShippingOptionsForCartWorkflowId = * Learn more about prices calculation context in the [Prices Calculation](https://docs.medusajs.com/resources/commerce-modules/pricing/price-calculation) documentation. * * ::: - * + * * @property hooks.setShippingOptionsContext - This hook is executed after the cart is retrieved and before the shipping options are queried. You can consume this hook to return any custom context useful for the shipping options retrieval. * * For example, you can consume the hook to add the customer Id to the context: - * + * * ```ts * import { listShippingOptionsForCartWithPricingWorkflow } from "@medusajs/medusa/core-flows" * import { StepResponse } from "@medusajs/workflows-sdk" - * + * * listShippingOptionsForCartWithPricingWorkflow.hooks.setShippingOptionsContext( * async ({ cart }, { container }) => { - * + * * if (cart.customer_id) { * return new StepResponse({ * customer_id: cart.customer_id, * }) * } - * + * * const query = container.resolve("query") - * + * * const { data: carts } = await query.graph({ * entity: "cart", * filters: { @@ -108,20 +115,20 @@ export const listShippingOptionsForCartWorkflowId = * }, * fields: ["customer_id"], * }) - * + * * return new StepResponse({ * customer_id: carts[0].customer_id, * }) * } * ) * ``` - * + * * The `customer_id` property will be added to the context along with other properties such as `is_return` and `enabled_in_store`. - * + * * :::note - * + * * You should also consume the `setShippingOptionsContext` hook in the {@link listShippingOptionsForCartWithPricingWorkflow} workflow to ensure that the context is consistent when listing shipping options across workflows. - * + * * ::: */ export const listShippingOptionsForCartWorkflow = createWorkflow( @@ -209,16 +216,31 @@ export const listShippingOptionsForCartWorkflow = createWorkflow( resultValidator: shippingOptionsContextResult, } ) - const setShippingOptionsContextResult = setShippingOptionsContext.getResult() + const setShippingOptionsContextResult = + setShippingOptionsContext.getResult() const queryVariables = transform( - { input, fulfillmentSetIds, cart, setPricingContextResult, setShippingOptionsContextResult }, - ({ input, fulfillmentSetIds, cart, setPricingContextResult, setShippingOptionsContextResult }) => { + { + input, + fulfillmentSetIds, + cart, + setPricingContextResult, + setShippingOptionsContextResult, + }, + ({ + input, + fulfillmentSetIds, + cart, + setPricingContextResult, + setShippingOptionsContextResult, + }) => { return { id: input.option_ids, context: { - ...(setShippingOptionsContextResult ? setShippingOptionsContextResult : {}), + ...(setShippingOptionsContextResult + ? setShippingOptionsContextResult + : {}), is_return: input.is_return ? "true" : "false", enabled_in_store: !isDefined(input.enabled_in_store) ? "true" diff --git a/packages/core/core-flows/src/cart/workflows/refresh-cart-items.ts b/packages/core/core-flows/src/cart/workflows/refresh-cart-items.ts index 74c34513f4..efcf1075f3 100644 --- a/packages/core/core-flows/src/cart/workflows/refresh-cart-items.ts +++ b/packages/core/core-flows/src/cart/workflows/refresh-cart-items.ts @@ -1,8 +1,5 @@ -import { - filterObjectByKeys, - isDefined, - PromotionActions, -} from "@medusajs/framework/utils" +import type { AdditionalData } from "@medusajs/framework/types" +import { isDefined, PromotionActions } from "@medusajs/framework/utils" import { createHook, createWorkflow, @@ -11,22 +8,13 @@ import { WorkflowData, WorkflowResponse, } from "@medusajs/framework/workflows-sdk" -import { AdditionalData, CartDTO } from "@medusajs/types" import { useQueryGraphStep } from "../../common" import { useRemoteQueryStep } from "../../common/steps/use-remote-query" import { acquireLockStep, releaseLockStep } from "../../locking" -import { getVariantPriceSetsStep, updateLineItemsStep } from "../steps" -import { validateVariantPricesStep } from "../steps/validate-variant-prices" -import { - cartFieldsForPricingContext, - cartFieldsForRefreshSteps, - productVariantsFields, -} from "../utils/fields" -import { - prepareLineItemData, - PrepareLineItemDataInput, -} from "../utils/prepare-line-item-data" +import { updateLineItemsStep } from "../steps" +import { cartFieldsForRefreshSteps } from "../utils/fields" import { pricingContextResult } from "../utils/schemas" +import { getVariantsAndItemsWithPrices } from "./get-variants-and-items-with-prices" import { refreshCartShippingMethodsWorkflow } from "./refresh-cart-shipping-methods" import { refreshPaymentCollectionForCartWorkflow } from "./refresh-payment-collection" import { updateCartPromotionsWorkflow } from "./update-cart-promotions" @@ -168,93 +156,11 @@ export const refreshCartItemsWorkflow = createWorkflow( }, }) - const variantIds = transform({ cart }, (data: { cart: CartDTO }) => { - return (data.cart.items ?? []).map((i) => i.variant_id).filter(Boolean) - }) - - const cartPricingContext = transform( - { cart, setPricingContextResult }, - (data): { variantId: string; context: Record }[] => { - const cart = data.cart - const baseContext = { - ...filterObjectByKeys(cart, cartFieldsForPricingContext), - ...(data.setPricingContextResult - ? data.setPricingContextResult - : {}), - currency_code: cart.currency_code, - region_id: cart.region_id, - region: cart.region, - customer_id: cart.customer_id, - customer: cart.customer, - } - - return cart.items - .filter((i) => i.variant_id) - .map((item) => { - return { - variantId: item.variant_id, - context: { - ...baseContext, - quantity: item.quantity, - }, - } - }) - } - ) - - const { data: variantsData } = useQueryGraphStep({ - entity: "variants", - fields: productVariantsFields, - filters: { - id: variantIds, + const { lineItems } = getVariantsAndItemsWithPrices.runAsStep({ + input: { + cart, + setPricingContextResult: setPricingContextResult!, }, - }).config({ name: "fetch-variants" }) - - const calculatedPriceSets = getVariantPriceSetsStep({ - data: cartPricingContext, - }) - - const variants = transform( - { variantsData, calculatedPriceSets }, - ({ variantsData, calculatedPriceSets }) => { - return variantsData.map((variant) => { - variant.calculated_price = calculatedPriceSets[variant.id] - return variant - }) - } - ) - - validateVariantPricesStep({ variants }) - - const lineItems = transform({ cart, variants }, ({ cart, variants }) => { - const items = cart.items.map((item) => { - const variant = (variants ?? []).find( - (v) => v.id === item.variant_id - )! - - const input: PrepareLineItemDataInput = { - item, - variant: variant, - cartId: cart.id, - unitPrice: item.unit_price, - isTaxInclusive: item.is_tax_inclusive, - } - - if (variant && !item.is_custom_price) { - input.unitPrice = variant.calculated_price?.calculated_amount - input.isTaxInclusive = - variant.calculated_price?.is_calculated_price_tax_inclusive - } - - const preparedItem = prepareLineItemData(input) - - return { - selector: { id: item.id }, - data: preparedItem, - } - }) - - return items }) updateLineItemsStep({ diff --git a/packages/core/core-flows/src/cart/workflows/refund-payment-recreate-payment-session.ts b/packages/core/core-flows/src/cart/workflows/refund-payment-recreate-payment-session.ts index 7f8810f064..d2b496a12c 100644 --- a/packages/core/core-flows/src/cart/workflows/refund-payment-recreate-payment-session.ts +++ b/packages/core/core-flows/src/cart/workflows/refund-payment-recreate-payment-session.ts @@ -1,4 +1,7 @@ -import { BigNumberInput, PaymentSessionDTO } from "@medusajs/framework/types" +import type { + BigNumberInput, + PaymentSessionDTO, +} from "@medusajs/framework/types" import { createWorkflow, WorkflowData, diff --git a/packages/core/core-flows/src/common/steps/create-remote-links.ts b/packages/core/core-flows/src/common/steps/create-remote-links.ts index 52dfe012de..bec329186c 100644 --- a/packages/core/core-flows/src/common/steps/create-remote-links.ts +++ b/packages/core/core-flows/src/common/steps/create-remote-links.ts @@ -1,5 +1,5 @@ import { Link } from "@medusajs/framework/modules-sdk" -import { LinkDefinition } from "@medusajs/framework/types" +import type { LinkDefinition } from "@medusajs/framework/types" import { ContainerRegistrationKeys } from "@medusajs/framework/utils" import { createStep, StepResponse } from "@medusajs/framework/workflows-sdk" diff --git a/packages/core/core-flows/src/common/steps/dismiss-remote-links.ts b/packages/core/core-flows/src/common/steps/dismiss-remote-links.ts index 2fbfa4ae3a..ab5c17793b 100644 --- a/packages/core/core-flows/src/common/steps/dismiss-remote-links.ts +++ b/packages/core/core-flows/src/common/steps/dismiss-remote-links.ts @@ -1,5 +1,5 @@ import { Link } from "@medusajs/framework/modules-sdk" -import { LinkDefinition } from "@medusajs/framework/types" +import type { LinkDefinition } from "@medusajs/framework/types" import { createStep, StepResponse } from "@medusajs/framework/workflows-sdk" import { ContainerRegistrationKeys } from "@medusajs/framework/utils" diff --git a/packages/core/core-flows/src/common/steps/update-remote-links.ts b/packages/core/core-flows/src/common/steps/update-remote-links.ts index 10286a2af3..d9f06e2e8c 100644 --- a/packages/core/core-flows/src/common/steps/update-remote-links.ts +++ b/packages/core/core-flows/src/common/steps/update-remote-links.ts @@ -1,5 +1,5 @@ import { Link } from "@medusajs/framework/modules-sdk" -import { LinkDefinition } from "@medusajs/framework/types" +import type { LinkDefinition } from "@medusajs/framework/types" import { ContainerRegistrationKeys, MedusaError, diff --git a/packages/core/core-flows/src/common/workflows/batch-links.ts b/packages/core/core-flows/src/common/workflows/batch-links.ts index d2ba3b8b7e..7f695b2e25 100644 --- a/packages/core/core-flows/src/common/workflows/batch-links.ts +++ b/packages/core/core-flows/src/common/workflows/batch-links.ts @@ -1,4 +1,7 @@ -import { BatchWorkflowInput, LinkDefinition } from "@medusajs/framework/types" +import type { + BatchWorkflowInput, + LinkDefinition, +} from "@medusajs/framework/types" import { WorkflowData, WorkflowResponse, @@ -12,12 +15,12 @@ import { updateRemoteLinksStep } from "../steps/update-remote-links" export const batchLinksWorkflowId = "batch-links" /** * This workflow manages one or more links to create, update, or dismiss them. - * + * * You can use this workflow within your customizations or your own custom workflows, allowing you to * manage links within your custom flows. - * + * * Learn more about links in [this documentation](https://docs.medusajs.com/learn/fundamentals/module-links/link). - * + * * @example * const { result } = await batchLinksWorkflow(container) * .run({ @@ -59,9 +62,9 @@ export const batchLinksWorkflowId = "batch-links" * ] * } * }) - * + * * @summary - * + * * Manage links between two records of linked data models. */ export const batchLinksWorkflow = createWorkflow( diff --git a/packages/core/core-flows/src/common/workflows/create-links.ts b/packages/core/core-flows/src/common/workflows/create-links.ts index d7a465992e..6a2b3fb588 100644 --- a/packages/core/core-flows/src/common/workflows/create-links.ts +++ b/packages/core/core-flows/src/common/workflows/create-links.ts @@ -1,4 +1,4 @@ -import { LinkDefinition } from "@medusajs/framework/types" +import type { LinkDefinition } from "@medusajs/framework/types" import { WorkflowData, WorkflowResponse, @@ -9,12 +9,12 @@ import { createRemoteLinkStep } from "../steps/create-remote-links" export const createLinksWorkflowId = "create-link" /** * This workflow creates one or more links between records. - * + * * You can use this workflow within your customizations or your own custom workflows, allowing you to * create links within your custom flows. - * + * * Learn more about links in [this documentation](https://docs.medusajs.com/learn/fundamentals/module-links/link). - * + * * @example * const { result } = await createLinksWorkflow(container) * .run({ @@ -30,9 +30,9 @@ export const createLinksWorkflowId = "create-link" * } * ] * }) - * + * * @summary - * + * * Create links between two records of linked data models. */ export const createLinksWorkflow = createWorkflow( diff --git a/packages/core/core-flows/src/common/workflows/dismiss-links.ts b/packages/core/core-flows/src/common/workflows/dismiss-links.ts index 58f2e5a79e..7d83cfe7cc 100644 --- a/packages/core/core-flows/src/common/workflows/dismiss-links.ts +++ b/packages/core/core-flows/src/common/workflows/dismiss-links.ts @@ -1,4 +1,4 @@ -import { LinkDefinition } from "@medusajs/framework/types" +import type { LinkDefinition } from "@medusajs/framework/types" import { WorkflowData, WorkflowResponse, @@ -9,12 +9,12 @@ import { dismissRemoteLinkStep } from "../steps/dismiss-remote-links" export const dismissLinksWorkflowId = "dismiss-link" /** * This workflow dismisses one or more links between records. - * + * * You can use this workflow within your customizations or your own custom workflows, allowing you to * dismiss links within your custom flows. - * + * * Learn more about links in [this documentation](https://docs.medusajs.com/learn/fundamentals/module-links/link). - * + * * @example * const { result } = await dismissLinksWorkflow(container) * .run({ @@ -30,9 +30,9 @@ export const dismissLinksWorkflowId = "dismiss-link" * } * ] * }) - * + * * @summary - * + * * Dismiss links between two records of linked data models. */ export const dismissLinksWorkflow = createWorkflow( diff --git a/packages/core/core-flows/src/common/workflows/update-links.ts b/packages/core/core-flows/src/common/workflows/update-links.ts index 787d9d71e2..008ddc67b5 100644 --- a/packages/core/core-flows/src/common/workflows/update-links.ts +++ b/packages/core/core-flows/src/common/workflows/update-links.ts @@ -1,4 +1,4 @@ -import { LinkDefinition } from "@medusajs/framework/types" +import type { LinkDefinition } from "@medusajs/framework/types" import { WorkflowData, WorkflowResponse, @@ -9,12 +9,12 @@ import { updateRemoteLinksStep } from "../steps/update-remote-links" export const updateLinksWorkflowId = "update-link" /** * This workflow updates one or more links between records. - * + * * You can use this workflow within your customizations or your own custom workflows, allowing you to * update links within your custom flows. - * + * * Learn more about links in [this documentation](https://docs.medusajs.com/learn/fundamentals/module-links/link). - * + * * @example * const { result } = await updateLinksWorkflow(container) * .run({ @@ -35,9 +35,9 @@ export const updateLinksWorkflowId = "update-link" * } * ] * }) - * + * * @summary - * + * * Update links between two records of linked data models. */ export const updateLinksWorkflow = createWorkflow( diff --git a/packages/core/core-flows/src/customer-group/steps/delete-customer-groups.ts b/packages/core/core-flows/src/customer-group/steps/delete-customer-groups.ts index 108dc7663f..4c109de3c2 100644 --- a/packages/core/core-flows/src/customer-group/steps/delete-customer-groups.ts +++ b/packages/core/core-flows/src/customer-group/steps/delete-customer-groups.ts @@ -1,4 +1,4 @@ -import { ICustomerModuleService } from "@medusajs/framework/types" +import type { ICustomerModuleService } from "@medusajs/framework/types" import { Modules } from "@medusajs/framework/utils" import { createStep, StepResponse } from "@medusajs/framework/workflows-sdk" diff --git a/packages/core/core-flows/src/customer-group/workflows/link-customer-groups-customer.ts b/packages/core/core-flows/src/customer-group/workflows/link-customer-groups-customer.ts index d5ff021afb..e893e730ac 100644 --- a/packages/core/core-flows/src/customer-group/workflows/link-customer-groups-customer.ts +++ b/packages/core/core-flows/src/customer-group/workflows/link-customer-groups-customer.ts @@ -1,10 +1,10 @@ -import { LinkWorkflowInput } from "@medusajs/framework/types" +import type { LinkWorkflowInput } from "@medusajs/framework/types" import { WorkflowData, createWorkflow } from "@medusajs/framework/workflows-sdk" import { linkCustomerGroupsToCustomerStep } from "../steps" /** * The data to manage the customer groups of a customer. - * + * * @property id - The ID of the customer to manage its groups. * @property add - The IDs of the customer groups to add the customer to. * @property remove - The IDs of the customer groups to remove the customer from. @@ -14,12 +14,12 @@ export type LinkCustomerGroupsToCustomerWorkflowInput = LinkWorkflowInput export const linkCustomerGroupsToCustomerWorkflowId = "link-customer-groups-to-customer" /** - * This workflow manages the customer groups a customer is in. It's used by the + * This workflow manages the customer groups a customer is in. It's used by the * [Manage Groups of Customer Admin API Route](https://docs.medusajs.com/api/admin#customers_postcustomersidcustomergroups). - * + * * You can use this workflow within your customizations or your own custom workflows, allowing you to * manage the customer groups of a customer in your custom flow. - * + * * @example * const { result } = await linkCustomerGroupsToCustomerWorkflow(container) * .run({ @@ -29,14 +29,16 @@ export const linkCustomerGroupsToCustomerWorkflowId = * remove: ["cusgrp_456"] * } * }) - * + * * @summary - * + * * Manage groups of a customer. */ export const linkCustomerGroupsToCustomerWorkflow = createWorkflow( linkCustomerGroupsToCustomerWorkflowId, - (input: WorkflowData): WorkflowData => { + ( + input: WorkflowData + ): WorkflowData => { return linkCustomerGroupsToCustomerStep(input) } ) diff --git a/packages/core/core-flows/src/customer-group/workflows/link-customers-customer-group.ts b/packages/core/core-flows/src/customer-group/workflows/link-customers-customer-group.ts index ae5068d6f2..07a5f55153 100644 --- a/packages/core/core-flows/src/customer-group/workflows/link-customers-customer-group.ts +++ b/packages/core/core-flows/src/customer-group/workflows/link-customers-customer-group.ts @@ -1,10 +1,10 @@ -import { LinkWorkflowInput } from "@medusajs/framework/types" +import type { LinkWorkflowInput } from "@medusajs/framework/types" import { WorkflowData, createWorkflow } from "@medusajs/framework/workflows-sdk" import { linkCustomersToCustomerGroupStep } from "../steps" /** * The data to manage the customers of a group. - * + * * @property id - The ID of the customer group to manage its customers. * @property add - The IDs of the customers to add to the customer group. * @property remove - The IDs of the customers to remove from the customer group. @@ -14,12 +14,12 @@ export type LinkCustomersToCustomerGroupWorkflow = LinkWorkflowInput export const linkCustomersToCustomerGroupWorkflowId = "link-customers-to-customer-group" /** - * This workflow manages the customers of a customer group. It's used by the + * This workflow manages the customers of a customer group. It's used by the * [Manage Customers of Group Admin API Route](https://docs.medusajs.com/api/admin#customer-groups_postcustomergroupsidcustomers). - * + * * You can use this workflow within your customizations or your own custom workflows, allowing you to * manage the customers of a customer group within your custom flows. - * + * * @example * const { result } = await linkCustomersToCustomerGroupWorkflow(container) * .run({ @@ -29,14 +29,16 @@ export const linkCustomersToCustomerGroupWorkflowId = * remove: ["cus_456"] * } * }) - * + * * @summary - * + * * Manage the customers of a customer group. */ export const linkCustomersToCustomerGroupWorkflow = createWorkflow( linkCustomersToCustomerGroupWorkflowId, - (input: WorkflowData): WorkflowData => { + ( + input: WorkflowData + ): WorkflowData => { return linkCustomersToCustomerGroupStep(input) } ) diff --git a/packages/core/core-flows/src/customer/steps/delete-addresses.ts b/packages/core/core-flows/src/customer/steps/delete-addresses.ts index 412dfdc7d1..622da6e7e3 100644 --- a/packages/core/core-flows/src/customer/steps/delete-addresses.ts +++ b/packages/core/core-flows/src/customer/steps/delete-addresses.ts @@ -1,4 +1,4 @@ -import { ICustomerModuleService } from "@medusajs/framework/types" +import type { ICustomerModuleService } from "@medusajs/framework/types" import { Modules } from "@medusajs/framework/utils" import { createStep, StepResponse } from "@medusajs/framework/workflows-sdk" diff --git a/packages/core/core-flows/src/customer/steps/delete-customers.ts b/packages/core/core-flows/src/customer/steps/delete-customers.ts index cdd9068330..bb11ae9873 100644 --- a/packages/core/core-flows/src/customer/steps/delete-customers.ts +++ b/packages/core/core-flows/src/customer/steps/delete-customers.ts @@ -1,4 +1,4 @@ -import { ICustomerModuleService } from "@medusajs/framework/types" +import type { ICustomerModuleService } from "@medusajs/framework/types" import { Modules } from "@medusajs/framework/utils" import { createStep, StepResponse } from "@medusajs/framework/workflows-sdk" diff --git a/packages/core/core-flows/src/customer/workflows/create-customer-account.ts b/packages/core/core-flows/src/customer/workflows/create-customer-account.ts index 8ba2696b39..d1a8ee4f11 100644 --- a/packages/core/core-flows/src/customer/workflows/create-customer-account.ts +++ b/packages/core/core-flows/src/customer/workflows/create-customer-account.ts @@ -1,4 +1,4 @@ -import { CreateCustomerDTO, CustomerDTO } from "@medusajs/framework/types" +import type { CreateCustomerDTO, CustomerDTO } from "@medusajs/framework/types" import { createWorkflow, transform, @@ -27,13 +27,13 @@ export const createCustomerAccountWorkflowId = "create-customer-account" /** * This workflow creates a customer and attaches it to an auth identity. It's used by the * [Register Customer Store API Route](https://docs.medusajs.com/api/store#customers_postcustomers). - * + * * You can create an auth identity first using the [Retrieve Registration JWT Token API Route](https://docs.medusajs.com/api/store#auth_postactor_typeauth_provider_register). * Learn more about basic authentication flows in [this documentation](https://docs.medusajs.com/resources/commerce-modules/auth/authentication-route). - * - * You can use this workflow within your customizations or your own custom workflows, allowing you to + * + * You can use this workflow within your customizations or your own custom workflows, allowing you to * register or create customer accounts within your custom flows. - * + * * @example * const { result } = await createCustomerAccountWorkflow(container) * .run({ @@ -46,9 +46,9 @@ export const createCustomerAccountWorkflowId = "create-customer-account" * } * } * }) - * + * * @summary - * + * * Create or register a customer account. */ export const createCustomerAccountWorkflow = createWorkflow( diff --git a/packages/core/core-flows/src/customer/workflows/create-customers.ts b/packages/core/core-flows/src/customer/workflows/create-customers.ts index 2fee49e3f1..11cb43fd4b 100644 --- a/packages/core/core-flows/src/customer/workflows/create-customers.ts +++ b/packages/core/core-flows/src/customer/workflows/create-customers.ts @@ -1,4 +1,7 @@ -import { AdditionalData, CreateCustomerDTO } from "@medusajs/framework/types" +import type { + AdditionalData, + CreateCustomerDTO, +} from "@medusajs/framework/types" import { CustomerWorkflowEvents } from "@medusajs/framework/utils" import { WorkflowData, @@ -23,11 +26,11 @@ export type CreateCustomersWorkflowInput = { export const createCustomersWorkflowId = "create-customers" /** * This workflow creates one or more customers. It's used by the [Create Customer Admin API Route](https://docs.medusajs.com/api/admin#customers_postcustomers). - * + * * This workflow has a hook that allows you to perform custom actions on the created customer. You can see an example in [this guide](https://docs.medusajs.com/resources/commerce-modules/customer/extend). - * + * * You can also use this workflow within your customizations or your own custom workflows, allowing you to wrap custom logic around creating customers. - * + * * @example * const { result } = await createCustomersWorkflow(container) * .run({ @@ -44,11 +47,11 @@ export const createCustomersWorkflowId = "create-customers" * } * } * }) - * + * * @summary - * + * * Create one or more customers. - * + * * @property hooks.customersCreated - This hook is executed after the customers are created. You can consume this hook to perform custom actions on the created customers. */ export const createCustomersWorkflow = createWorkflow( diff --git a/packages/core/core-flows/src/draft-order/steps/create-draft-order-line-item-adjustments.ts b/packages/core/core-flows/src/draft-order/steps/create-draft-order-line-item-adjustments.ts index 57c37fee97..7efcf0757f 100644 --- a/packages/core/core-flows/src/draft-order/steps/create-draft-order-line-item-adjustments.ts +++ b/packages/core/core-flows/src/draft-order/steps/create-draft-order-line-item-adjustments.ts @@ -3,7 +3,7 @@ import { createStep, StepResponse } from "@medusajs/framework/workflows-sdk" import { CreateLineItemAdjustmentDTO, IOrderModuleService, -} from "@medusajs/types" +} from "@medusajs/framework/types" export const createDraftOrderLineItemAdjustmentsStepId = "create-draft-order-line-item-adjustments" @@ -24,7 +24,7 @@ export interface CreateDraftOrderLineItemAdjustmentsStepInput { /** * This step creates line item adjustments for a draft order. - * + * * @example * const data = createDraftOrderLineItemAdjustmentsStep({ * order_id: "order_123", diff --git a/packages/core/core-flows/src/draft-order/steps/create-draft-order-shipping-method-adjustments.ts b/packages/core/core-flows/src/draft-order/steps/create-draft-order-shipping-method-adjustments.ts index 77f9aa24bf..437afceaa7 100644 --- a/packages/core/core-flows/src/draft-order/steps/create-draft-order-shipping-method-adjustments.ts +++ b/packages/core/core-flows/src/draft-order/steps/create-draft-order-shipping-method-adjustments.ts @@ -3,7 +3,7 @@ import { createStep, StepResponse } from "@medusajs/framework/workflows-sdk" import { CreateShippingMethodAdjustmentDTO, IOrderModuleService, -} from "@medusajs/types" +} from "@medusajs/framework/types" export const createDraftOrderShippingMethodAdjustmentsStepId = "create-draft-order-shipping-method-adjustments" @@ -20,7 +20,7 @@ export interface CreateDraftOrderShippingMethodAdjustmentsStepInput { /** * This step creates shipping method adjustments for a draft order. - * + * * @example * const data = createDraftOrderShippingMethodAdjustmentsStep({ * shippingMethodAdjustmentsToCreate: [ diff --git a/packages/core/core-flows/src/draft-order/steps/delete-draft-order.ts b/packages/core/core-flows/src/draft-order/steps/delete-draft-order.ts index 4382b9e117..fdcd252b62 100644 --- a/packages/core/core-flows/src/draft-order/steps/delete-draft-order.ts +++ b/packages/core/core-flows/src/draft-order/steps/delete-draft-order.ts @@ -1,4 +1,4 @@ -import { IOrderModuleService } from "@medusajs/framework/types" +import type { IOrderModuleService } from "@medusajs/framework/types" import { createStep } from "@medusajs/framework/workflows-sdk" import { Modules } from "@medusajs/framework/utils" diff --git a/packages/core/core-flows/src/draft-order/steps/get-draft-order-promotion-context.ts b/packages/core/core-flows/src/draft-order/steps/get-draft-order-promotion-context.ts index 9dd91b264e..aaaf6073f0 100644 --- a/packages/core/core-flows/src/draft-order/steps/get-draft-order-promotion-context.ts +++ b/packages/core/core-flows/src/draft-order/steps/get-draft-order-promotion-context.ts @@ -1,6 +1,6 @@ import { Modules } from "@medusajs/framework/utils" import { createStep, StepResponse } from "@medusajs/framework/workflows-sdk" -import { IOrderModuleService, OrderDTO } from "@medusajs/types" +import type { IOrderModuleService, OrderDTO } from "@medusajs/framework/types" /** * The details of the draft order to get the promotion context for. @@ -14,14 +14,14 @@ export interface GetDraftOrderPromotionContextStepInput { /** * This step gets the promotion context for a draft order. - * + * * :::note - * + * * You can retrieve a draft order's details using [Query](https://docs.medusajs.com/learn/fundamentals/module-links/query), * or [useQueryGraphStep](https://docs.medusajs.com/resources/references/medusa-workflows/steps/useQueryGraphStep). - * + * * ::: - * + * * @example * const data = getDraftOrderPromotionContextStep({ * order: { diff --git a/packages/core/core-flows/src/draft-order/steps/remove-draft-order-line-item-adjustments.ts b/packages/core/core-flows/src/draft-order/steps/remove-draft-order-line-item-adjustments.ts index 9083d938b0..c2d36452c6 100644 --- a/packages/core/core-flows/src/draft-order/steps/remove-draft-order-line-item-adjustments.ts +++ b/packages/core/core-flows/src/draft-order/steps/remove-draft-order-line-item-adjustments.ts @@ -1,6 +1,6 @@ import { Modules } from "@medusajs/framework/utils" import { createStep, StepResponse } from "@medusajs/framework/workflows-sdk" -import { IOrderModuleService } from "@medusajs/types" +import type { IOrderModuleService } from "@medusajs/framework/types" export const removeDraftOrderLineItemAdjustmentsStepId = "remove-draft-order-line-item-adjustments" @@ -16,7 +16,7 @@ export interface RemoveDraftOrderLineItemAdjustmentsStepInput { /** * This step removes line item adjustments from a draft order. - * + * * @example * const data = removeDraftOrderLineItemAdjustmentsStep({ * lineItemAdjustmentIdsToRemove: ["adj_123", "adj_456"], diff --git a/packages/core/core-flows/src/draft-order/steps/remove-draft-order-shipping-method-adjustments.ts b/packages/core/core-flows/src/draft-order/steps/remove-draft-order-shipping-method-adjustments.ts index 35d9084d51..bfd6203f08 100644 --- a/packages/core/core-flows/src/draft-order/steps/remove-draft-order-shipping-method-adjustments.ts +++ b/packages/core/core-flows/src/draft-order/steps/remove-draft-order-shipping-method-adjustments.ts @@ -1,6 +1,6 @@ import { Modules } from "@medusajs/framework/utils" import { StepResponse, createStep } from "@medusajs/framework/workflows-sdk" -import { IOrderModuleService } from "@medusajs/types" +import type { IOrderModuleService } from "@medusajs/framework/types" export const removeDraftOrderShippingMethodAdjustmentsStepId = "remove-draft-order-shipping-method-adjustments" @@ -17,7 +17,7 @@ export interface RemoveDraftOrderShippingMethodAdjustmentsStepInput { /** * This step removes shipping method adjustments from a draft order. - * + * * @example * const data = removeDraftOrderShippingMethodAdjustmentsStep({ * shippingMethodAdjustmentIdsToRemove: ["adj_123", "adj_456"], diff --git a/packages/core/core-flows/src/draft-order/steps/restore-draft-order-shipping-methods.ts b/packages/core/core-flows/src/draft-order/steps/restore-draft-order-shipping-methods.ts index 03dbe0dc92..01e7e0c98a 100644 --- a/packages/core/core-flows/src/draft-order/steps/restore-draft-order-shipping-methods.ts +++ b/packages/core/core-flows/src/draft-order/steps/restore-draft-order-shipping-methods.ts @@ -1,6 +1,9 @@ import { Modules } from "@medusajs/framework/utils" import { createStep, StepResponse } from "@medusajs/framework/workflows-sdk" -import { BigNumberInput, IOrderModuleService } from "@medusajs/types" +import type { + BigNumberInput, + IOrderModuleService, +} from "@medusajs/framework/types" export const restoreDraftOrderShippingMethodsStepId = "restore-draft-order-shipping-methods" @@ -49,20 +52,20 @@ export interface RestoreDraftOrderShippingMethodsStepInput { /** * This step restores the shipping methods of a draft order. * It's useful when you need to revert changes made by a canceled draft order edit. - * + * * @example * const data = restoreDraftOrderShippingMethodsStep({ * shippingMethods: [ - * { - * id: "shipping_method_123", - * before: { - * shipping_option_id: "shipping_option_123", - * amount: 10 - * }, - * after: { - * shipping_option_id: "shipping_option_123", - * amount: 10 - * } + * { + * id: "shipping_method_123", + * before: { + * shipping_option_id: "shipping_option_123", + * amount: 10 + * }, + * after: { + * shipping_option_id: "shipping_option_123", + * amount: 10 + * } * }, * ], * }) diff --git a/packages/core/core-flows/src/draft-order/steps/update-draft-order-promotions.ts b/packages/core/core-flows/src/draft-order/steps/update-draft-order-promotions.ts index fad64efe96..ea3022c018 100644 --- a/packages/core/core-flows/src/draft-order/steps/update-draft-order-promotions.ts +++ b/packages/core/core-flows/src/draft-order/steps/update-draft-order-promotions.ts @@ -4,7 +4,7 @@ import { PromotionActions, } from "@medusajs/framework/utils" import { createStep, StepResponse } from "@medusajs/framework/workflows-sdk" -import { IPromotionModuleService } from "@medusajs/types" +import type { IPromotionModuleService } from "@medusajs/framework/types" export const updateDraftOrderPromotionsStepId = "update-draft-order-promotions" @@ -22,7 +22,7 @@ export interface UpdateDraftOrderPromotionsStepInput { promo_codes: string[] /** * The action to perform on the promotions. You can either: - * + * * - Add the promotions to the draft order. * - Replace the existing promotions with the new ones. * - Remove the promotions from the draft order. @@ -32,7 +32,7 @@ export interface UpdateDraftOrderPromotionsStepInput { /** * This step updates the promotions of a draft order. - * + * * @example * const data = updateDraftOrderPromotionsStep({ * id: "order_123", diff --git a/packages/core/core-flows/src/draft-order/steps/update-draft-order-shipping-metod.ts b/packages/core/core-flows/src/draft-order/steps/update-draft-order-shipping-metod.ts index ed919b602c..4dcf5c565d 100644 --- a/packages/core/core-flows/src/draft-order/steps/update-draft-order-shipping-metod.ts +++ b/packages/core/core-flows/src/draft-order/steps/update-draft-order-shipping-metod.ts @@ -1,6 +1,9 @@ import { MedusaError, Modules } from "@medusajs/framework/utils" import { createStep, StepResponse } from "@medusajs/framework/workflows-sdk" -import { BigNumberInput, IOrderModuleService } from "@medusajs/types" +import type { + BigNumberInput, + IOrderModuleService, +} from "@medusajs/framework/types" export const updateDraftOrderShippingMethodStepId = "update-draft-order-shipping-method" @@ -33,7 +36,7 @@ export interface UpdateDraftOrderShippingMethodStepInput { /** * This step updates the shipping method of a draft order. - * + * * @example * const data = updateDraftOrderShippingMethodStep({ * order_id: "order_123", diff --git a/packages/core/core-flows/src/draft-order/steps/validate-draft-order-change.ts b/packages/core/core-flows/src/draft-order/steps/validate-draft-order-change.ts index 7c6d27e443..7c48ab8f32 100644 --- a/packages/core/core-flows/src/draft-order/steps/validate-draft-order-change.ts +++ b/packages/core/core-flows/src/draft-order/steps/validate-draft-order-change.ts @@ -1,5 +1,5 @@ import { createStep } from "@medusajs/framework/workflows-sdk" -import { OrderChangeDTO, OrderDTO } from "@medusajs/types" +import type { OrderChangeDTO, OrderDTO } from "@medusajs/framework/types" import { throwIfOrderChangeIsNotActive } from "../../order/utils/order-validation" import { throwIfNotDraftOrder } from "../utils/validation" @@ -22,14 +22,14 @@ export const validateDraftOrderChangeStepId = "validate-draft-order-change" /** * This step validates that a draft order and its change are valid. It throws an error if the * order is not a draft order or the order change is not active. - * + * * :::note - * + * * You can retrieve a draft order and its change's details using [Query](https://docs.medusajs.com/learn/fundamentals/module-links/query), * or [useQueryGraphStep](https://docs.medusajs.com/resources/references/medusa-workflows/steps/useQueryGraphStep). - * + * * ::: - * + * * @example * const data = validateDraftOrderChangeStep({ * order: { diff --git a/packages/core/core-flows/src/draft-order/steps/validate-draft-order-remove-action-item.ts b/packages/core/core-flows/src/draft-order/steps/validate-draft-order-remove-action-item.ts index 1fc6766e29..aa25bc6929 100644 --- a/packages/core/core-flows/src/draft-order/steps/validate-draft-order-remove-action-item.ts +++ b/packages/core/core-flows/src/draft-order/steps/validate-draft-order-remove-action-item.ts @@ -1,8 +1,8 @@ -import { OrderChangeActionDTO } from "@medusajs/types" +import type { OrderChangeActionDTO } from "@medusajs/framework/types" import { ChangeActionType, MedusaError } from "@medusajs/framework/utils" import { createStep } from "@medusajs/framework/workflows-sdk" -import { OrderChangeDTO, OrderWorkflow } from "@medusajs/types" +import type { OrderChangeDTO, OrderWorkflow } from "@medusajs/framework/types" /** * The details of the draft order and its change to validate. @@ -21,14 +21,14 @@ export interface ValidateDraftOrderUpdateActionItemStepInput { /** * This step validates that an item change can be removed from a draft order edit. It throws an error if the * item change is not in the draft order edit, or if the item change is not adding or updating an item. - * + * * :::note - * + * * You can retrieve a draft order change's details using [Query](https://docs.medusajs.com/learn/fundamentals/module-links/query), * or [useQueryGraphStep](https://docs.medusajs.com/resources/references/medusa-workflows/steps/useQueryGraphStep). - * + * * ::: - * + * * @example * const data = validateDraftOrderRemoveActionItemStep({ * input: { diff --git a/packages/core/core-flows/src/draft-order/steps/validate-draft-order-shipping-method-action.ts b/packages/core/core-flows/src/draft-order/steps/validate-draft-order-shipping-method-action.ts index 1a7527ca95..7d81ba3da9 100644 --- a/packages/core/core-flows/src/draft-order/steps/validate-draft-order-shipping-method-action.ts +++ b/packages/core/core-flows/src/draft-order/steps/validate-draft-order-shipping-method-action.ts @@ -4,7 +4,7 @@ import { OrderChangeActionDTO, OrderChangeDTO, OrderWorkflow, -} from "@medusajs/types" +} from "@medusajs/framework/types" /** * The details of the draft order and its change to validate. @@ -23,14 +23,14 @@ export interface ValidateDraftOrderShippingMethodActionStepInput { /** * This step validates that a shipping method change can be removed from a draft order edit. It throws an error if the * shipping method change is not in the draft order edit, or if the shipping method change is not adding a shipping method. - * + * * :::note - * + * * You can retrieve a draft order change's details using [Query](https://docs.medusajs.com/learn/fundamentals/module-links/query), * or [useQueryGraphStep](https://docs.medusajs.com/resources/references/medusa-workflows/steps/useQueryGraphStep). - * + * * ::: - * + * * @example * const data = validateDraftOrderShippingMethodActionStep({ * input: { diff --git a/packages/core/core-flows/src/draft-order/steps/validate-draft-order-update-action-item.ts b/packages/core/core-flows/src/draft-order/steps/validate-draft-order-update-action-item.ts index d0bc71bdbc..38f171d731 100644 --- a/packages/core/core-flows/src/draft-order/steps/validate-draft-order-update-action-item.ts +++ b/packages/core/core-flows/src/draft-order/steps/validate-draft-order-update-action-item.ts @@ -1,8 +1,8 @@ -import { OrderChangeActionDTO } from "@medusajs/types" +import type { OrderChangeActionDTO } from "@medusajs/framework/types" import { ChangeActionType, MedusaError } from "@medusajs/framework/utils" import { createStep } from "@medusajs/framework/workflows-sdk" -import { OrderChangeDTO, OrderWorkflow } from "@medusajs/types" +import type { OrderChangeDTO, OrderWorkflow } from "@medusajs/framework/types" /** * The details of the draft order and its change to validate. @@ -21,14 +21,14 @@ export interface ValidateDraftOrderUpdateActionItemStepInput { /** * This step validates that a new item can be updated in a draft order edit. It throws an error if the * item change is not in the draft order edit, or if the item change is not adding an item. - * + * * :::note - * + * * You can retrieve a draft order change's details using [Query](https://docs.medusajs.com/learn/fundamentals/module-links/query), * or [useQueryGraphStep](https://docs.medusajs.com/resources/references/medusa-workflows/steps/useQueryGraphStep). - * + * * ::: - * + * * @example * const data = validateDraftOrderUpdateActionItemStep({ * input: { diff --git a/packages/core/core-flows/src/draft-order/steps/validate-draft-order.ts b/packages/core/core-flows/src/draft-order/steps/validate-draft-order.ts index 355d1a4a00..3a380c9762 100644 --- a/packages/core/core-flows/src/draft-order/steps/validate-draft-order.ts +++ b/packages/core/core-flows/src/draft-order/steps/validate-draft-order.ts @@ -1,6 +1,6 @@ import { MedusaError, OrderStatus } from "@medusajs/framework/utils" import { createStep } from "@medusajs/framework/workflows-sdk" -import { OrderDTO } from "@medusajs/types" +import type { OrderDTO } from "@medusajs/framework/types" /** * The details of the draft order to validate. @@ -14,14 +14,14 @@ export interface ValidateDraftOrderStepInput { /** * This step validates that an order is a draft order. It throws an error otherwise. - * + * * :::note - * + * * You can retrieve a draft order's details using [Query](https://docs.medusajs.com/learn/fundamentals/module-links/query), * or [useQueryGraphStep](https://docs.medusajs.com/resources/references/medusa-workflows/steps/useQueryGraphStep). - * + * * ::: - * + * * @example * const data = validateDraftOrderStep({ * order: { diff --git a/packages/core/core-flows/src/draft-order/steps/validate-promo-codes-to-add.ts b/packages/core/core-flows/src/draft-order/steps/validate-promo-codes-to-add.ts index 0eba83e2a7..769ecbe4a6 100644 --- a/packages/core/core-flows/src/draft-order/steps/validate-promo-codes-to-add.ts +++ b/packages/core/core-flows/src/draft-order/steps/validate-promo-codes-to-add.ts @@ -1,5 +1,5 @@ import { createStep } from "@medusajs/framework/workflows-sdk" -import { PromotionDTO } from "@medusajs/types" +import type { PromotionDTO } from "@medusajs/framework/types" import { throwIfCodesAreInactive, throwIfCodesAreMissing, @@ -24,23 +24,23 @@ export interface ValidatePromoCodesToAddStepInput { /** * This step validates that the promo codes to add to a draft order are valid. It throws an error if the * promo codes don't exist or are inactive. - * + * * :::note - * + * * You can retrieve a promotion's details using [Query](https://docs.medusajs.com/learn/fundamentals/module-links/query), * or [useQueryGraphStep](https://docs.medusajs.com/resources/references/medusa-workflows/steps/useQueryGraphStep). - * + * * ::: - * + * * @example * const data = validatePromoCodesToAddStep({ * promo_codes: ["PROMO_123", "PROMO_456"], - * promotions: [{ - * id: "promo_123", - * code: "PROMO_123" - * }, { - * id: "promo_456", - * code: "PROMO_456" + * promotions: [{ + * id: "promo_123", + * code: "PROMO_123" + * }, { + * id: "promo_456", + * code: "PROMO_456" * }], * }) */ diff --git a/packages/core/core-flows/src/draft-order/steps/validate-promo-codes-to-remove.ts b/packages/core/core-flows/src/draft-order/steps/validate-promo-codes-to-remove.ts index 8e64e43a92..045a71775f 100644 --- a/packages/core/core-flows/src/draft-order/steps/validate-promo-codes-to-remove.ts +++ b/packages/core/core-flows/src/draft-order/steps/validate-promo-codes-to-remove.ts @@ -1,5 +1,5 @@ import { createStep } from "@medusajs/framework/workflows-sdk" -import { PromotionDTO } from "@medusajs/types" +import type { PromotionDTO } from "@medusajs/framework/types" import { throwIfCodesAreMissing } from "../utils/validation" export const validatePromoCodesToRemoveId = "validate-promo-codes-to-remove" @@ -21,23 +21,23 @@ export interface ValidatePromoCodesToRemoveStepInput { /** * This step validates that the promo codes can be removed from a draft order. It throws an error if the promo * codes don't exist. - * + * * :::note - * + * * You can retrieve a promotion's details using [Query](https://docs.medusajs.com/learn/fundamentals/module-links/query), * or [useQueryGraphStep](https://docs.medusajs.com/resources/references/medusa-workflows/steps/useQueryGraphStep). - * + * * ::: - * + * * @example * const data = validatePromoCodesToRemoveStep({ * promo_codes: ["PROMO_123", "PROMO_456"], - * promotions: [{ - * id: "promo_123", - * code: "PROMO_123" - * }, { - * id: "promo_456", - * code: "PROMO_456" + * promotions: [{ + * id: "promo_123", + * code: "PROMO_123" + * }, { + * id: "promo_456", + * code: "PROMO_456" * }], * }) */ diff --git a/packages/core/core-flows/src/draft-order/utils/validation.ts b/packages/core/core-flows/src/draft-order/utils/validation.ts index d1d8286651..904ec6af7a 100644 --- a/packages/core/core-flows/src/draft-order/utils/validation.ts +++ b/packages/core/core-flows/src/draft-order/utils/validation.ts @@ -3,7 +3,7 @@ import { OrderStatus, PromotionStatus, } from "@medusajs/framework/utils" -import { OrderDTO, PromotionDTO } from "@medusajs/types" +import type { OrderDTO, PromotionDTO } from "@medusajs/framework/types" interface ThrowIfNotDraftOrderInput { order: OrderDTO diff --git a/packages/core/core-flows/src/draft-order/workflows/add-draft-order-items.ts b/packages/core/core-flows/src/draft-order/workflows/add-draft-order-items.ts index 9c5900cc6b..592a01143f 100644 --- a/packages/core/core-flows/src/draft-order/workflows/add-draft-order-items.ts +++ b/packages/core/core-flows/src/draft-order/workflows/add-draft-order-items.ts @@ -10,7 +10,11 @@ import { WorkflowData, WorkflowResponse, } from "@medusajs/framework/workflows-sdk" -import { OrderChangeDTO, OrderDTO, OrderWorkflow } from "@medusajs/types" +import { + OrderChangeDTO, + OrderDTO, + OrderWorkflow, +} from "@medusajs/framework/types" import { useRemoteQueryStep } from "../../common" import { addOrderLineItemsWorkflow, diff --git a/packages/core/core-flows/src/draft-order/workflows/add-draft-order-promotions.ts b/packages/core/core-flows/src/draft-order/workflows/add-draft-order-promotions.ts index ce39321e1b..63948dc44a 100644 --- a/packages/core/core-flows/src/draft-order/workflows/add-draft-order-promotions.ts +++ b/packages/core/core-flows/src/draft-order/workflows/add-draft-order-promotions.ts @@ -9,7 +9,11 @@ import { WorkflowData, WorkflowResponse, } from "@medusajs/framework/workflows-sdk" -import { OrderChangeDTO, OrderDTO, PromotionDTO } from "@medusajs/types" +import { + OrderChangeDTO, + OrderDTO, + PromotionDTO, +} from "@medusajs/framework/types" import { useRemoteQueryStep } from "../../common" import { createOrderChangeActionsWorkflow, @@ -39,10 +43,10 @@ export interface AddDraftOrderPromotionWorkflowInput { /** * This workflow adds promotions to a draft order. It's used by the * [Add Promotion to Draft Order Admin API Route](https://docs.medusajs.com/api/admin#draft-orders_postdraftordersideditpromotions). - * + * * You can use this workflow within your customizations or your own custom workflows, allowing you to wrap custom logic around adding promotions to * a draft order. - * + * * @example * const { result } = await addDraftOrderPromotionWorkflow(container) * .run({ @@ -51,9 +55,9 @@ export interface AddDraftOrderPromotionWorkflowInput { * promo_codes: ["PROMO_CODE_1", "PROMO_CODE_2"] * } * }) - * + * * @summary - * + * * Add promotions to a draft order. */ export const addDraftOrderPromotionWorkflow = createWorkflow( diff --git a/packages/core/core-flows/src/draft-order/workflows/add-draft-order-shipping-methods.ts b/packages/core/core-flows/src/draft-order/workflows/add-draft-order-shipping-methods.ts index dbc8f6fe51..0629c7592a 100644 --- a/packages/core/core-flows/src/draft-order/workflows/add-draft-order-shipping-methods.ts +++ b/packages/core/core-flows/src/draft-order/workflows/add-draft-order-shipping-methods.ts @@ -19,7 +19,7 @@ import { OrderChangeDTO, OrderDTO, ShippingOptionDTO, -} from "@medusajs/types" +} from "@medusajs/framework/types" import { useRemoteQueryStep } from "../../common" import { createOrderChangeActionsWorkflow, diff --git a/packages/core/core-flows/src/draft-order/workflows/begin-draft-order-edit.ts b/packages/core/core-flows/src/draft-order/workflows/begin-draft-order-edit.ts index 2734a1e228..cdd3561ca3 100644 --- a/packages/core/core-flows/src/draft-order/workflows/begin-draft-order-edit.ts +++ b/packages/core/core-flows/src/draft-order/workflows/begin-draft-order-edit.ts @@ -4,7 +4,7 @@ import { WorkflowData, WorkflowResponse, } from "@medusajs/framework/workflows-sdk" -import { OrderDTO, OrderWorkflow } from "@medusajs/types" +import type { OrderDTO, OrderWorkflow } from "@medusajs/framework/types" import { useRemoteQueryStep } from "../../common" import { createOrderChangeStep, previewOrderChangeStep } from "../../order" import { validateDraftOrderStep } from "../steps" @@ -14,12 +14,12 @@ export const beginDraftOrderEditWorkflowId = "begin-draft-order-edit" /** * This workflow begins a draft order edit. It's used by the * [Create Draft Order Edit Admin API Route](https://docs.medusajs.com/api/admin#draft-orders_postdraftordersidedit). - * + * * The draft order edit can later be requested using {@link requestDraftOrderEditWorkflow} or confirmed using {@link confirmDraftOrderEditWorkflow}. - * - * You can use this workflow within your customizations or your own custom workflows, allowing you to wrap custom logic around + * + * You can use this workflow within your customizations or your own custom workflows, allowing you to wrap custom logic around * creating a draft order edit request. - * + * * @example * const { result } = await beginDraftOrderEditWorkflow(container) * .run({ @@ -27,9 +27,9 @@ export const beginDraftOrderEditWorkflowId = "begin-draft-order-edit" * order_id: "order_123", * } * }) - * + * * @summary - * + * * Create a draft order edit request. */ export const beginDraftOrderEditWorkflow = createWorkflow( diff --git a/packages/core/core-flows/src/draft-order/workflows/cancel-draft-order-edit.ts b/packages/core/core-flows/src/draft-order/workflows/cancel-draft-order-edit.ts index 2bfb56f774..27afbf02a1 100644 --- a/packages/core/core-flows/src/draft-order/workflows/cancel-draft-order-edit.ts +++ b/packages/core/core-flows/src/draft-order/workflows/cancel-draft-order-edit.ts @@ -10,7 +10,7 @@ import { when, WorkflowData, } from "@medusajs/framework/workflows-sdk" -import { OrderChangeDTO, OrderDTO } from "@medusajs/types" +import type { OrderChangeDTO, OrderDTO } from "@medusajs/framework/types" import { useRemoteQueryStep } from "../../common" import { deleteOrderChangesStep, deleteOrderShippingMethods } from "../../order" import { restoreDraftOrderShippingMethodsStep } from "../steps/restore-draft-order-shipping-methods" diff --git a/packages/core/core-flows/src/draft-order/workflows/confirm-draft-order-edit.ts b/packages/core/core-flows/src/draft-order/workflows/confirm-draft-order-edit.ts index 799ad795f0..aac042d318 100644 --- a/packages/core/core-flows/src/draft-order/workflows/confirm-draft-order-edit.ts +++ b/packages/core/core-flows/src/draft-order/workflows/confirm-draft-order-edit.ts @@ -8,7 +8,11 @@ import { transform, WorkflowResponse, } from "@medusajs/framework/workflows-sdk" -import { BigNumberInput, OrderChangeDTO, OrderDTO } from "@medusajs/types" +import { + BigNumberInput, + OrderChangeDTO, + OrderDTO, +} from "@medusajs/framework/types" import { reserveInventoryStep } from "../../cart" import { prepareConfirmInventoryInput, diff --git a/packages/core/core-flows/src/draft-order/workflows/convert-draft-order.ts b/packages/core/core-flows/src/draft-order/workflows/convert-draft-order.ts index 8753caa13b..b550c3d736 100644 --- a/packages/core/core-flows/src/draft-order/workflows/convert-draft-order.ts +++ b/packages/core/core-flows/src/draft-order/workflows/convert-draft-order.ts @@ -10,7 +10,7 @@ import { WorkflowData, WorkflowResponse, } from "@medusajs/framework/workflows-sdk" -import { IOrderModuleService, OrderDTO } from "@medusajs/types" +import type { IOrderModuleService, OrderDTO } from "@medusajs/framework/types" import { emitEventStep, useRemoteQueryStep } from "../../common" import { validateDraftOrderStep } from "../steps/validate-draft-order" @@ -78,10 +78,10 @@ export const convertDraftOrderStep = createStep( /** * This workflow converts a draft order to a pending order. It's used by the * [Convert Draft Order to Order Admin API Route](https://docs.medusajs.com/api/admin#draft-orders_postdraftordersidconverttoorder). - * + * * You can use this workflow within your customizations or your own custom workflows, allowing you to wrap custom logic around * converting a draft order to a pending order. - * + * * @example * const { result } = await convertDraftOrderWorkflow(container) * .run({ @@ -89,9 +89,9 @@ export const convertDraftOrderStep = createStep( * id: "order_123", * } * }) - * + * * @summary - * + * * Convert a draft order to a pending order. */ export const convertDraftOrderWorkflow = createWorkflow( diff --git a/packages/core/core-flows/src/draft-order/workflows/delete-draft-order.ts b/packages/core/core-flows/src/draft-order/workflows/delete-draft-order.ts index 100984ae55..32a0d8e845 100644 --- a/packages/core/core-flows/src/draft-order/workflows/delete-draft-order.ts +++ b/packages/core/core-flows/src/draft-order/workflows/delete-draft-order.ts @@ -5,7 +5,7 @@ import { createWorkflow, transform, } from "@medusajs/framework/workflows-sdk" -import { OrderDTO } from "@medusajs/framework/types" +import type { OrderDTO } from "@medusajs/framework/types" import { Modules } from "@medusajs/framework/utils" import { removeRemoteLinkStep, useQueryGraphStep } from "../../common" diff --git a/packages/core/core-flows/src/draft-order/workflows/refresh-draft-order-adjustments.ts b/packages/core/core-flows/src/draft-order/workflows/refresh-draft-order-adjustments.ts index f458f19dae..f3be54d55e 100644 --- a/packages/core/core-flows/src/draft-order/workflows/refresh-draft-order-adjustments.ts +++ b/packages/core/core-flows/src/draft-order/workflows/refresh-draft-order-adjustments.ts @@ -5,7 +5,7 @@ import { WorkflowData, WorkflowResponse, } from "@medusajs/framework/workflows-sdk" -import { OrderDTO } from "@medusajs/types" +import type { OrderDTO } from "@medusajs/framework/types" import { getActionsToComputeFromPromotionsStep, getPromotionCodesToApply, diff --git a/packages/core/core-flows/src/draft-order/workflows/remove-draft-order-action-item.ts b/packages/core/core-flows/src/draft-order/workflows/remove-draft-order-action-item.ts index 864ed1147d..0307b12540 100644 --- a/packages/core/core-flows/src/draft-order/workflows/remove-draft-order-action-item.ts +++ b/packages/core/core-flows/src/draft-order/workflows/remove-draft-order-action-item.ts @@ -11,7 +11,7 @@ import { OrderDTO, OrderPreviewDTO, OrderWorkflow, -} from "@medusajs/types" +} from "@medusajs/framework/types" import { useRemoteQueryStep } from "../../common" import { deleteOrderChangeActionsStep, diff --git a/packages/core/core-flows/src/draft-order/workflows/remove-draft-order-action-shipping-method.ts b/packages/core/core-flows/src/draft-order/workflows/remove-draft-order-action-shipping-method.ts index 7315add866..a7b5fe9e20 100644 --- a/packages/core/core-flows/src/draft-order/workflows/remove-draft-order-action-shipping-method.ts +++ b/packages/core/core-flows/src/draft-order/workflows/remove-draft-order-action-shipping-method.ts @@ -13,7 +13,7 @@ import { OrderDTO, OrderPreviewDTO, OrderWorkflow, -} from "@medusajs/types" +} from "@medusajs/framework/types" import { useRemoteQueryStep } from "../../common" import { deleteOrderChangeActionsStep, diff --git a/packages/core/core-flows/src/draft-order/workflows/remove-draft-order-promotions.ts b/packages/core/core-flows/src/draft-order/workflows/remove-draft-order-promotions.ts index dcef23280f..6580aeb639 100644 --- a/packages/core/core-flows/src/draft-order/workflows/remove-draft-order-promotions.ts +++ b/packages/core/core-flows/src/draft-order/workflows/remove-draft-order-promotions.ts @@ -9,7 +9,11 @@ import { WorkflowData, WorkflowResponse, } from "@medusajs/framework/workflows-sdk" -import { OrderChangeDTO, OrderDTO, PromotionDTO } from "@medusajs/types" +import { + OrderChangeDTO, + OrderDTO, + PromotionDTO, +} from "@medusajs/framework/types" import { useRemoteQueryStep } from "../../common" import { createOrderChangeActionsWorkflow, @@ -40,10 +44,10 @@ export interface RemoveDraftOrderPromotionsWorkflowInput { /** * This workflow removes promotions from a draft order edit. It's used by the * [Remove Promotions from Draft Order Edit Admin API Route](https://docs.medusajs.com/api/admin#draft-orders_deletedraftordersideditpromotions). - * + * * You can use this workflow within your customizations or your own custom workflows, allowing you to wrap custom logic around * removing promotions from a draft order edit. - * + * * @example * const { result } = await removeDraftOrderPromotionsWorkflow(container) * .run({ @@ -52,9 +56,9 @@ export interface RemoveDraftOrderPromotionsWorkflowInput { * promo_codes: ["PROMO_CODE_1", "PROMO_CODE_2"], * } * }) - * + * * @summary - * + * * Remove promotions from a draft order edit. */ export const removeDraftOrderPromotionsWorkflow = createWorkflow( diff --git a/packages/core/core-flows/src/draft-order/workflows/remove-draft-order-shipping-method.ts b/packages/core/core-flows/src/draft-order/workflows/remove-draft-order-shipping-method.ts index 62585d0293..14a40fe67b 100644 --- a/packages/core/core-flows/src/draft-order/workflows/remove-draft-order-shipping-method.ts +++ b/packages/core/core-flows/src/draft-order/workflows/remove-draft-order-shipping-method.ts @@ -10,7 +10,7 @@ import { WorkflowData, WorkflowResponse, } from "@medusajs/framework/workflows-sdk" -import { OrderChangeDTO, OrderDTO } from "@medusajs/types" +import type { OrderChangeDTO, OrderDTO } from "@medusajs/framework/types" import { useRemoteQueryStep } from "../../common" import { createOrderChangeActionsWorkflow, diff --git a/packages/core/core-flows/src/draft-order/workflows/request-draft-order-edit.ts b/packages/core/core-flows/src/draft-order/workflows/request-draft-order-edit.ts index 3a400b5184..f3f183f5e2 100644 --- a/packages/core/core-flows/src/draft-order/workflows/request-draft-order-edit.ts +++ b/packages/core/core-flows/src/draft-order/workflows/request-draft-order-edit.ts @@ -4,7 +4,7 @@ import { transform, WorkflowResponse, } from "@medusajs/framework/workflows-sdk" -import { OrderChangeDTO, OrderDTO } from "@medusajs/types" +import type { OrderChangeDTO, OrderDTO } from "@medusajs/framework/types" import { useRemoteQueryStep } from "../../common" import { createOrUpdateOrderPaymentCollectionWorkflow, @@ -51,10 +51,10 @@ export type RequestDraftOrderEditWorkflowInput = { /** * This workflow requests a draft order edit. It's used by the * [Request Draft Order Edit Admin API Route](https://docs.medusajs.com/api/admin#draft-orders_postdraftordersideditrequest). - * + * * You can use this workflow within your customizations or your own custom workflows, allowing you to wrap custom logic around * requesting a draft order edit. - * + * * @example * const { result } = await requestDraftOrderEditWorkflow(container) * .run({ @@ -63,9 +63,9 @@ export type RequestDraftOrderEditWorkflowInput = { * requested_by: "user_123", * } * }) - * + * * @summary - * + * * Request a draft order edit. */ export const requestDraftOrderEditWorkflow = createWorkflow( diff --git a/packages/core/core-flows/src/draft-order/workflows/update-draft-order-action-item.ts b/packages/core/core-flows/src/draft-order/workflows/update-draft-order-action-item.ts index 5d46ec455a..06a2b2b748 100644 --- a/packages/core/core-flows/src/draft-order/workflows/update-draft-order-action-item.ts +++ b/packages/core/core-flows/src/draft-order/workflows/update-draft-order-action-item.ts @@ -11,7 +11,7 @@ import { OrderChangeDTO, OrderDTO, OrderWorkflow, -} from "@medusajs/types" +} from "@medusajs/framework/types" import { useRemoteQueryStep } from "../../common" import { previewOrderChangeStep, diff --git a/packages/core/core-flows/src/draft-order/workflows/update-draft-order-action-shipping-method.ts b/packages/core/core-flows/src/draft-order/workflows/update-draft-order-action-shipping-method.ts index d491f8f871..9417c8135e 100644 --- a/packages/core/core-flows/src/draft-order/workflows/update-draft-order-action-shipping-method.ts +++ b/packages/core/core-flows/src/draft-order/workflows/update-draft-order-action-shipping-method.ts @@ -13,7 +13,7 @@ import { OrderDTO, OrderPreviewDTO, OrderWorkflow, -} from "@medusajs/types" +} from "@medusajs/framework/types" import { useRemoteQueryStep } from "../../common" import { previewOrderChangeStep, diff --git a/packages/core/core-flows/src/draft-order/workflows/update-draft-order-item.ts b/packages/core/core-flows/src/draft-order/workflows/update-draft-order-item.ts index 27db48f2b5..464b33412b 100644 --- a/packages/core/core-flows/src/draft-order/workflows/update-draft-order-item.ts +++ b/packages/core/core-flows/src/draft-order/workflows/update-draft-order-item.ts @@ -17,7 +17,7 @@ import { OrderDTO, OrderPreviewDTO, OrderWorkflow, -} from "@medusajs/types" +} from "@medusajs/framework/types" import { useRemoteQueryStep } from "../../common" import { createOrderChangeActionsWorkflow, diff --git a/packages/core/core-flows/src/draft-order/workflows/update-draft-order-shipping-method.ts b/packages/core/core-flows/src/draft-order/workflows/update-draft-order-shipping-method.ts index 091c6eee6b..0e6b64a153 100644 --- a/packages/core/core-flows/src/draft-order/workflows/update-draft-order-shipping-method.ts +++ b/packages/core/core-flows/src/draft-order/workflows/update-draft-order-shipping-method.ts @@ -10,7 +10,11 @@ import { WorkflowData, WorkflowResponse, } from "@medusajs/framework/workflows-sdk" -import { BigNumberInput, OrderChangeDTO, OrderDTO } from "@medusajs/types" +import { + BigNumberInput, + OrderChangeDTO, + OrderDTO, +} from "@medusajs/framework/types" import { useRemoteQueryStep } from "../../common" import { createOrderChangeActionsWorkflow, diff --git a/packages/core/core-flows/src/draft-order/workflows/update-draft-order.ts b/packages/core/core-flows/src/draft-order/workflows/update-draft-order.ts index 6e0bc8d908..0fade3a2c8 100644 --- a/packages/core/core-flows/src/draft-order/workflows/update-draft-order.ts +++ b/packages/core/core-flows/src/draft-order/workflows/update-draft-order.ts @@ -13,7 +13,7 @@ import { RegisterOrderChangeDTO, UpdateOrderDTO, UpsertOrderAddressDTO, -} from "@medusajs/types" +} from "@medusajs/framework/types" import { emitEventStep, useRemoteQueryStep } from "../../common" import { previewOrderChangeStep, registerOrderChangesStep } from "../../order" import { validateDraftOrderStep } from "../steps/validate-draft-order" @@ -74,14 +74,14 @@ export interface UpdateDraftOrderStepInput { /** * This step updates a draft order's details. - * + * * :::note - * + * * You can retrieve a draft order's details using [Query](https://docs.medusajs.com/learn/fundamentals/module-links/query), * or [useQueryGraphStep](https://docs.medusajs.com/resources/references/medusa-workflows/steps/useQueryGraphStep). - * + * * ::: - * + * * @example * const data = updateDraftOrderStep({ * order: { @@ -123,15 +123,15 @@ export const updateDraftOrderStep = createStep( /** * This workflow updates a draft order's details. It's used by the * [Update Draft Order Admin API Route](https://docs.medusajs.com/api/admin#draft-orders_postdraftordersid). - * - * This workflow doesn't update the draft order's items, shipping methods, or promotions. Instead, you have to + * + * This workflow doesn't update the draft order's items, shipping methods, or promotions. Instead, you have to * create a draft order edit using {@link beginDraftOrderEditWorkflow} and make updates in the draft order edit. * Then, you can confirm the draft order edit using {@link confirmDraftOrderEditWorkflow} or request a draft order edit * using {@link requestDraftOrderEditWorkflow}. - * + * * You can use this workflow within your customizations or your own custom workflows, allowing you to wrap custom logic around * updating a draft order. - * + * * @example * const { result } = await updateDraftOrderWorkflow(container) * .run({ @@ -141,9 +141,9 @@ export const updateDraftOrderStep = createStep( * customer_id: "cus_123", * } * }) - * + * * @summary - * + * * Update a draft order's details. */ export const updateDraftOrderWorkflow = createWorkflow( diff --git a/packages/core/core-flows/src/file/steps/delete-files.ts b/packages/core/core-flows/src/file/steps/delete-files.ts index 36d0f043b1..e3decdd26e 100644 --- a/packages/core/core-flows/src/file/steps/delete-files.ts +++ b/packages/core/core-flows/src/file/steps/delete-files.ts @@ -1,4 +1,4 @@ -import { IFileModuleService } from "@medusajs/framework/types" +import type { IFileModuleService } from "@medusajs/framework/types" import { Modules } from "@medusajs/framework/utils" import { StepResponse, createStep } from "@medusajs/framework/workflows-sdk" @@ -12,7 +12,7 @@ export const deleteFilesStepId = "delete-files" * This step deletes one or more files using the installed * [File Module Provider](https://docs.medusajs.com/resources/infrastructure-modules/file). The files * will be removed from the database and the storage. - * + * * @example * const data = deleteFilesStep([ * "id_123" diff --git a/packages/core/core-flows/src/file/steps/upload-files.ts b/packages/core/core-flows/src/file/steps/upload-files.ts index 592faf7519..65490420e5 100644 --- a/packages/core/core-flows/src/file/steps/upload-files.ts +++ b/packages/core/core-flows/src/file/steps/upload-files.ts @@ -1,4 +1,4 @@ -import { IFileModuleService } from "@medusajs/framework/types" +import type { IFileModuleService } from "@medusajs/framework/types" import { Modules } from "@medusajs/framework/utils" import { StepResponse, createStep } from "@medusajs/framework/workflows-sdk" @@ -16,13 +16,13 @@ export type UploadFilesStepInput = { filename: string /** * The MIME type of the file. - * + * * @example * img/jpg */ mimeType: string /** - * The content of the file. For images, for example, + * The content of the file. For images, for example, * use binary string. For CSV files, use the CSV content. */ content: string @@ -41,7 +41,7 @@ export const uploadFilesStepId = "upload-files" /** * This step uploads one or more files using the installed * [File Module Provider](https://docs.medusajs.com/resources/infrastructure-modules/file). - * + * * @example * const data = uploadFilesStep({ * files: [ diff --git a/packages/core/core-flows/src/file/workflows/upload-files.ts b/packages/core/core-flows/src/file/workflows/upload-files.ts index afc0883233..4c63fa27a7 100644 --- a/packages/core/core-flows/src/file/workflows/upload-files.ts +++ b/packages/core/core-flows/src/file/workflows/upload-files.ts @@ -1,4 +1,4 @@ -import { FileDTO } from "@medusajs/framework/types" +import type { FileDTO } from "@medusajs/framework/types" import { WorkflowData, WorkflowResponse, @@ -20,13 +20,13 @@ export type UploadFilesWorkflowInput = { filename: string /** * The MIME type of the file. - * + * * @example * img/jpg */ mimeType: string /** - * The content of the file. For images, for example, + * The content of the file. For images, for example, * use binary string. For CSV files, use the CSV content. */ content: string @@ -34,7 +34,7 @@ export type UploadFilesWorkflowInput = { * The access level of the file. Use `public` for the file that * can be accessed by anyone. For example, for images that are displayed * on the storefront. Use `private` for files that are only accessible - * by authenticated users. For example, for CSV files used to + * by authenticated users. For example, for CSV files used to * import data. */ access: "public" | "private" @@ -43,13 +43,13 @@ export type UploadFilesWorkflowInput = { export const uploadFilesWorkflowId = "upload-files" /** - * This workflow uploads one or more files using the installed + * This workflow uploads one or more files using the installed * [File Module Provider](https://docs.medusajs.com/resources/infrastructure-modules/file). The workflow is used by the * [Upload Files Admin API Route](https://docs.medusajs.com/api/admin#uploads_postuploads). - * + * * You can use this workflow within your customizations or your own custom workflows, allowing you to * upload files within your custom flows. - * + * * @example * const { result } = await uploadFilesWorkflow(container) * .run({ @@ -64,9 +64,9 @@ export const uploadFilesWorkflowId = "upload-files" * ] * } * }) - * + * * @summary - * + * * Upload files using the installed File Module Provider. */ export const uploadFilesWorkflow = createWorkflow( diff --git a/packages/core/core-flows/src/fulfillment/steps/cancel-fulfillment.ts b/packages/core/core-flows/src/fulfillment/steps/cancel-fulfillment.ts index 673a126dbf..59c893cdb5 100644 --- a/packages/core/core-flows/src/fulfillment/steps/cancel-fulfillment.ts +++ b/packages/core/core-flows/src/fulfillment/steps/cancel-fulfillment.ts @@ -1,4 +1,4 @@ -import { IFulfillmentModuleService } from "@medusajs/framework/types" +import type { IFulfillmentModuleService } from "@medusajs/framework/types" import { Modules } from "@medusajs/framework/utils" import { StepResponse, createStep } from "@medusajs/framework/workflows-sdk" diff --git a/packages/core/core-flows/src/fulfillment/steps/delete-fulfillment-sets.ts b/packages/core/core-flows/src/fulfillment/steps/delete-fulfillment-sets.ts index 7b85569abd..3393ada178 100644 --- a/packages/core/core-flows/src/fulfillment/steps/delete-fulfillment-sets.ts +++ b/packages/core/core-flows/src/fulfillment/steps/delete-fulfillment-sets.ts @@ -1,4 +1,4 @@ -import { IFulfillmentModuleService } from "@medusajs/framework/types" +import type { IFulfillmentModuleService } from "@medusajs/framework/types" import { Modules } from "@medusajs/framework/utils" import { createStep, StepResponse } from "@medusajs/framework/workflows-sdk" diff --git a/packages/core/core-flows/src/fulfillment/steps/delete-service-zones.ts b/packages/core/core-flows/src/fulfillment/steps/delete-service-zones.ts index 35c376655b..d0088fe4e2 100644 --- a/packages/core/core-flows/src/fulfillment/steps/delete-service-zones.ts +++ b/packages/core/core-flows/src/fulfillment/steps/delete-service-zones.ts @@ -1,4 +1,4 @@ -import { IFulfillmentModuleService } from "@medusajs/framework/types" +import type { IFulfillmentModuleService } from "@medusajs/framework/types" import { Modules } from "@medusajs/framework/utils" import { StepResponse, createStep } from "@medusajs/framework/workflows-sdk" diff --git a/packages/core/core-flows/src/fulfillment/steps/delete-shipping-options.ts b/packages/core/core-flows/src/fulfillment/steps/delete-shipping-options.ts index a2221b21c1..ba7db5aa2f 100644 --- a/packages/core/core-flows/src/fulfillment/steps/delete-shipping-options.ts +++ b/packages/core/core-flows/src/fulfillment/steps/delete-shipping-options.ts @@ -1,5 +1,5 @@ import { DeleteEntityInput } from "@medusajs/framework/modules-sdk" -import { IFulfillmentModuleService } from "@medusajs/framework/types" +import type { IFulfillmentModuleService } from "@medusajs/framework/types" import { Modules } from "@medusajs/framework/utils" import { StepResponse, createStep } from "@medusajs/framework/workflows-sdk" diff --git a/packages/core/core-flows/src/fulfillment/steps/set-shipping-options-price-sets.ts b/packages/core/core-flows/src/fulfillment/steps/set-shipping-options-price-sets.ts index 3bc65449f3..e9eef4b441 100644 --- a/packages/core/core-flows/src/fulfillment/steps/set-shipping-options-price-sets.ts +++ b/packages/core/core-flows/src/fulfillment/steps/set-shipping-options-price-sets.ts @@ -1,5 +1,5 @@ import { Link } from "@medusajs/framework/modules-sdk" -import { RemoteQueryFunction } from "@medusajs/framework/types" +import type { RemoteQueryFunction } from "@medusajs/framework/types" import { createStep, StepResponse } from "@medusajs/framework/workflows-sdk" import { ContainerRegistrationKeys, diff --git a/packages/core/core-flows/src/fulfillment/steps/validate-fulfillment-providers.ts b/packages/core/core-flows/src/fulfillment/steps/validate-fulfillment-providers.ts index ed0c29614e..358bcdc86b 100644 --- a/packages/core/core-flows/src/fulfillment/steps/validate-fulfillment-providers.ts +++ b/packages/core/core-flows/src/fulfillment/steps/validate-fulfillment-providers.ts @@ -1,4 +1,7 @@ -import { ServiceZoneDTO, ShippingOptionDTO } from "@medusajs/framework/types" +import type { + ServiceZoneDTO, + ShippingOptionDTO, +} from "@medusajs/framework/types" import { ContainerRegistrationKeys, MedusaError, diff --git a/packages/core/core-flows/src/fulfillment/steps/validate-shipment.ts b/packages/core/core-flows/src/fulfillment/steps/validate-shipment.ts index 7a857c0520..e13510a155 100644 --- a/packages/core/core-flows/src/fulfillment/steps/validate-shipment.ts +++ b/packages/core/core-flows/src/fulfillment/steps/validate-shipment.ts @@ -1,4 +1,4 @@ -import { IFulfillmentModuleService } from "@medusajs/framework/types" +import type { IFulfillmentModuleService } from "@medusajs/framework/types" import { MedusaError, Modules } from "@medusajs/framework/utils" import { StepResponse, createStep } from "@medusajs/framework/workflows-sdk" diff --git a/packages/core/core-flows/src/fulfillment/steps/validate-shipping-option-prices.ts b/packages/core/core-flows/src/fulfillment/steps/validate-shipping-option-prices.ts index 9bb68f4ed8..4a5879e1c4 100644 --- a/packages/core/core-flows/src/fulfillment/steps/validate-shipping-option-prices.ts +++ b/packages/core/core-flows/src/fulfillment/steps/validate-shipping-option-prices.ts @@ -1,7 +1,11 @@ -import { FulfillmentWorkflow } from "@medusajs/framework/types" -import { MedusaError, Modules, ShippingOptionPriceType, } from "@medusajs/framework/utils" +import type { FulfillmentWorkflow } from "@medusajs/framework/types" +import { + MedusaError, + Modules, + ShippingOptionPriceType, +} from "@medusajs/framework/utils" import { createStep, StepResponse } from "@medusajs/framework/workflows-sdk" -import { CreateShippingOptionDTO } from "@medusajs/types" +import type { CreateShippingOptionDTO } from "@medusajs/framework/types" /** * The data to validate shipping option prices. diff --git a/packages/core/core-flows/src/fulfillment/workflows/calculate-shipping-options-prices.ts b/packages/core/core-flows/src/fulfillment/workflows/calculate-shipping-options-prices.ts index 4d477492b8..0e9e4c8e50 100644 --- a/packages/core/core-flows/src/fulfillment/workflows/calculate-shipping-options-prices.ts +++ b/packages/core/core-flows/src/fulfillment/workflows/calculate-shipping-options-prices.ts @@ -1,4 +1,4 @@ -import { FulfillmentWorkflow } from "@medusajs/framework/types" +import type { FulfillmentWorkflow } from "@medusajs/framework/types" import { createWorkflow, transform, @@ -14,17 +14,17 @@ export const calculateShippingOptionsPricesWorkflowId = /** * This workflow calculates the prices for one or more shipping options in a cart. It's used by the * [Calculate Shipping Option Price Store API Route](https://docs.medusajs.com/api/store#shipping-options_postshippingoptionsidcalculate). - * + * * :::note - * + * * Calculating shipping option prices may require sending requests to third-party fulfillment services. * This depends on the implementation of the fulfillment provider associated with the shipping option. - * + * * ::: - * + * * You can use this workflow within your own customizations or custom workflows, allowing you to * calculate the prices of shipping options within your custom flows. - * + * * @example * const { result } = await calculateShippingOptionsPricesWorkflow(container) * .run({ @@ -41,9 +41,9 @@ export const calculateShippingOptionsPricesWorkflowId = * ] * } * }) - * + * * @summary - * + * * Calculate shipping option prices in a cart. */ export const calculateShippingOptionsPricesWorkflow = createWorkflow( diff --git a/packages/core/core-flows/src/fulfillment/workflows/create-service-zones.ts b/packages/core/core-flows/src/fulfillment/workflows/create-service-zones.ts index 53ebad0067..42dc1cc758 100644 --- a/packages/core/core-flows/src/fulfillment/workflows/create-service-zones.ts +++ b/packages/core/core-flows/src/fulfillment/workflows/create-service-zones.ts @@ -1,4 +1,7 @@ -import { FulfillmentWorkflow, ServiceZoneDTO } from "@medusajs/framework/types" +import type { + FulfillmentWorkflow, + ServiceZoneDTO, +} from "@medusajs/framework/types" import { WorkflowData, WorkflowResponse, @@ -15,10 +18,10 @@ export const createServiceZonesWorkflowId = "create-service-zones-workflow" /** * This workflow creates one or more service zones. It's used by the * [Add Service Zone to Fulfillment Set Admin API Route](https://docs.medusajs.com/api/admin#fulfillment-sets_postfulfillmentsetsidservicezones). - * + * * You can use this workflow within your own customizations or custom workflows, allowing you to * create service zones within your custom flows. - * + * * @example * const { result } = await createServiceZonesWorkflow(container) * .run({ @@ -37,9 +40,9 @@ export const createServiceZonesWorkflowId = "create-service-zones-workflow" * ] * } * }) - * + * * @summary - * + * * Create one or more service zones. */ export const createServiceZonesWorkflow = createWorkflow( diff --git a/packages/core/core-flows/src/fulfillment/workflows/create-shipment.ts b/packages/core/core-flows/src/fulfillment/workflows/create-shipment.ts index 542fa97fb3..dd78b3b2b5 100644 --- a/packages/core/core-flows/src/fulfillment/workflows/create-shipment.ts +++ b/packages/core/core-flows/src/fulfillment/workflows/create-shipment.ts @@ -1,4 +1,4 @@ -import { FulfillmentWorkflow } from "@medusajs/framework/types" +import type { FulfillmentWorkflow } from "@medusajs/framework/types" import { WorkflowData, WorkflowResponse, @@ -12,10 +12,10 @@ export const createShipmentWorkflowId = "create-shipment-workflow" /** * This workflow creates shipments for a fulfillment. It's used by the * [Create Shipment Admin API Route](https://docs.medusajs.com/api/admin#fulfillments_postfulfillmentsidshipment). - * + * * You can use this workflow within your own customizations or custom workflows, allowing you to * create shipments within your custom flows. - * + * * @example * const { result } = await createShipmentWorkflow(container) * .run({ @@ -30,9 +30,9 @@ export const createShipmentWorkflowId = "create-shipment-workflow" * ] * } * }) - * + * * @summary - * + * * Create a shipment for a fulfillment. */ export const createShipmentWorkflow = createWorkflow( diff --git a/packages/core/core-flows/src/fulfillment/workflows/create-shipping-options.ts b/packages/core/core-flows/src/fulfillment/workflows/create-shipping-options.ts index 40b6822658..c459aa7372 100644 --- a/packages/core/core-flows/src/fulfillment/workflows/create-shipping-options.ts +++ b/packages/core/core-flows/src/fulfillment/workflows/create-shipping-options.ts @@ -1,4 +1,4 @@ -import { FulfillmentWorkflow } from "@medusajs/framework/types" +import type { FulfillmentWorkflow } from "@medusajs/framework/types" import { createWorkflow, parallelize, @@ -6,7 +6,10 @@ import { WorkflowData, WorkflowResponse, } from "@medusajs/framework/workflows-sdk" -import { createShippingOptionsPriceSetsStep, upsertShippingOptionsStep, } from "../steps" +import { + createShippingOptionsPriceSetsStep, + upsertShippingOptionsStep, +} from "../steps" import { setShippingOptionsPriceSetsStep } from "../steps/set-shipping-options-price-sets" import { validateFulfillmentProvidersStep } from "../steps/validate-fulfillment-providers" import { validateShippingOptionPricesStep } from "../steps/validate-shipping-option-prices" @@ -14,27 +17,28 @@ import { validateShippingOptionPricesStep } from "../steps/validate-shipping-opt /** * The data to create the shipping options. */ -export type CreateShippingOptionsWorkflowInput = FulfillmentWorkflow.CreateShippingOptionsWorkflowInput[] +export type CreateShippingOptionsWorkflowInput = + FulfillmentWorkflow.CreateShippingOptionsWorkflowInput[] export const createShippingOptionsWorkflowId = "create-shipping-options-workflow" /** - * This workflow creates one or more shipping options. It's used by the + * This workflow creates one or more shipping options. It's used by the * [Create Shipping Option Admin API Route](https://docs.medusajs.com/api/admin#shipping-options_postshippingoptions). - * + * * You can use this workflow within your own customizations or custom workflows, allowing you to * create shipping options within your custom flows. - * + * * @example * To calculate a shipping option with flat rate prices: - * + * * :::note - * - * Learn more about adding rules to the shipping option's prices in the Pricing Module's + * + * Learn more about adding rules to the shipping option's prices in the Pricing Module's * [Price Rules](https://docs.medusajs.com/resources/commerce-modules/pricing/price-rules) documentation. - * + * * ::: - * + * * ```ts * const { result } = await createShippingOptionsWorkflow(container) * .run({ @@ -60,15 +64,15 @@ export const createShippingOptionsWorkflowId = * ] * }) * ``` - * + * * To calculate shipping option with calculated prices, set `price_type` to `calculated` and don't pass a `prices` array: - * + * * :::note - * + * * You can calculate the shipping option's price for a cart using the [calculateShippingOptionsPricesWorkflow](https://docs.medusajs.com/resources/references/medusa-workflows/calculateShippingOptionsPricesWorkflow). - * + * * ::: - * + * * ```ts * const { result } = await createShippingOptionsWorkflow(container) * .run({ @@ -88,9 +92,9 @@ export const createShippingOptionsWorkflowId = * ] * }) * ``` - * + * * @summary - * + * * Create shipping options. */ export const createShippingOptionsWorkflow = createWorkflow( diff --git a/packages/core/core-flows/src/fulfillment/workflows/create-shipping-profiles.ts b/packages/core/core-flows/src/fulfillment/workflows/create-shipping-profiles.ts index b37267915c..4653415e41 100644 --- a/packages/core/core-flows/src/fulfillment/workflows/create-shipping-profiles.ts +++ b/packages/core/core-flows/src/fulfillment/workflows/create-shipping-profiles.ts @@ -1,4 +1,4 @@ -import { FulfillmentWorkflow } from "@medusajs/framework/types" +import type { FulfillmentWorkflow } from "@medusajs/framework/types" import { WorkflowData, WorkflowResponse, @@ -11,10 +11,10 @@ export const createShippingProfilesWorkflowId = /** * This workflow creates one or more shipping profiles. It's used by the * [Create Shipping Profile Admin API Route](https://docs.medusajs.com/api/admin#shipping-profiles_postshippingprofiles). - * + * * You can use this workflow within your own customizations or custom workflows, allowing you to * create shipping profiles within your custom flows. - * + * * @example * const { result } = await createShippingProfilesWorkflow(container) * .run({ @@ -27,9 +27,9 @@ export const createShippingProfilesWorkflowId = * ] * } * }) - * + * * @summary - * + * * Create one or more shipping profiles. */ export const createShippingProfilesWorkflow = createWorkflow( diff --git a/packages/core/core-flows/src/fulfillment/workflows/delete-shipping-options.ts b/packages/core/core-flows/src/fulfillment/workflows/delete-shipping-options.ts index 033314b32b..721b099982 100644 --- a/packages/core/core-flows/src/fulfillment/workflows/delete-shipping-options.ts +++ b/packages/core/core-flows/src/fulfillment/workflows/delete-shipping-options.ts @@ -1,4 +1,4 @@ -import { FulfillmentWorkflow } from "@medusajs/framework/types" +import type { FulfillmentWorkflow } from "@medusajs/framework/types" import { createWorkflow, WorkflowData } from "@medusajs/framework/workflows-sdk" import { deleteShippingOptionsStep } from "../steps" import { removeRemoteLinkStep } from "../../common" @@ -8,10 +8,10 @@ export const deleteShippingOptionsWorkflowId = /** * This workflow deletes one or more shipping options. It's used by the * [Delete Shipping Options Admin API Route](https://docs.medusajs.com/api/admin#shipping-options_deleteshippingoptionsid). - * + * * You can use this workflow within your own customizations or custom workflows, allowing you to * delete shipping options within your custom flows. - * + * * @example * const { result } = await deleteShippingOptionsWorkflow(container) * .run({ @@ -19,9 +19,9 @@ export const deleteShippingOptionsWorkflowId = * ids: ["so_123"] * } * }) - * + * * @summary - * + * * Delete one or more shipping options. */ export const deleteShippingOptionsWorkflow = createWorkflow( diff --git a/packages/core/core-flows/src/fulfillment/workflows/mark-fulfillment-as-delivered.ts b/packages/core/core-flows/src/fulfillment/workflows/mark-fulfillment-as-delivered.ts index d16335719f..66170380d7 100644 --- a/packages/core/core-flows/src/fulfillment/workflows/mark-fulfillment-as-delivered.ts +++ b/packages/core/core-flows/src/fulfillment/workflows/mark-fulfillment-as-delivered.ts @@ -1,4 +1,4 @@ -import { FulfillmentDTO } from "@medusajs/framework/types" +import type { FulfillmentDTO } from "@medusajs/framework/types" import { MedusaError } from "@medusajs/framework/utils" import { StepResponse, @@ -16,14 +16,14 @@ export const validateFulfillmentDeliverabilityStepId = /** * This step validates that a fulfillment can be marked delivered. * If the fulfillment has already been canceled or delivered, the step will throw an error. - * + * * :::note - * + * * You can retrieve a fulfillment's details using [Query](https://docs.medusajs.com/learn/fundamentals/module-links/query), * or [useQueryGraphStep](https://docs.medusajs.com/resources/references/medusa-workflows/steps/useQueryGraphStep). - * + * * ::: - * + * * @example * const data = validateFulfillmentDeliverabilityStep({ * id: "ful_123", @@ -65,10 +65,10 @@ export const markFulfillmentAsDeliveredWorkflowId = "mark-fulfillment-as-delivered-workflow" /** * This workflow marks a fulfillment as delivered. It's used by the {@link markOrderFulfillmentAsDeliveredWorkflow}. - * - * You can use this workflow within your customizations or your own custom workflows, allowing you + * + * You can use this workflow within your customizations or your own custom workflows, allowing you * to mark a fulfillment as delivered in your custom flows. - * + * * @example * const { result } = await markFulfillmentAsDeliveredWorkflow(container) * .run({ @@ -76,9 +76,9 @@ export const markFulfillmentAsDeliveredWorkflowId = * id: "ful_123", * } * }) - * + * * @summary - * + * * Mark a fulfillment as delivered. */ export const markFulfillmentAsDeliveredWorkflow = createWorkflow( diff --git a/packages/core/core-flows/src/fulfillment/workflows/update-fulfillment.ts b/packages/core/core-flows/src/fulfillment/workflows/update-fulfillment.ts index d23d90ba8c..6f0698641b 100644 --- a/packages/core/core-flows/src/fulfillment/workflows/update-fulfillment.ts +++ b/packages/core/core-flows/src/fulfillment/workflows/update-fulfillment.ts @@ -1,4 +1,4 @@ -import { FulfillmentWorkflow } from "@medusajs/framework/types" +import type { FulfillmentWorkflow } from "@medusajs/framework/types" import { WorkflowData, WorkflowResponse, @@ -8,12 +8,12 @@ import { updateFulfillmentStep } from "../steps" export const updateFulfillmentWorkflowId = "update-fulfillment-workflow" /** - * This workflow updates a fulfillment. It's used by other workflows that update a + * This workflow updates a fulfillment. It's used by other workflows that update a * fulfillment, such as {@link markFulfillmentAsDeliveredWorkflow}. - * + * * You can use this workflow within your own customizations or custom workflows, allowing you to * update a fulfillment within your custom flows. - * + * * @example * const { result } = await updateFulfillmentWorkflow(container) * .run({ @@ -22,9 +22,9 @@ export const updateFulfillmentWorkflowId = "update-fulfillment-workflow" * delivered_at: new Date(), * } * }) - * + * * @summary - * + * * Update a fulfillment. */ export const updateFulfillmentWorkflow = createWorkflow( diff --git a/packages/core/core-flows/src/fulfillment/workflows/update-service-zones.ts b/packages/core/core-flows/src/fulfillment/workflows/update-service-zones.ts index 103c14024a..78dae72dc3 100644 --- a/packages/core/core-flows/src/fulfillment/workflows/update-service-zones.ts +++ b/packages/core/core-flows/src/fulfillment/workflows/update-service-zones.ts @@ -1,4 +1,7 @@ -import { FulfillmentWorkflow, ServiceZoneDTO } from "@medusajs/framework/types" +import type { + FulfillmentWorkflow, + ServiceZoneDTO, +} from "@medusajs/framework/types" import { WorkflowData, WorkflowResponse, @@ -15,10 +18,10 @@ export const updateServiceZonesWorkflowId = "update-service-zones-workflow" /** * This workflow updates one or more service zones. It's used by the * [Update Service Zones Admin API Route](https://docs.medusajs.com/api/admin#fulfillment-sets_postfulfillmentsetsidservicezoneszone_id). - * + * * You can use this workflow within your own customizations or custom workflows, allowing you to * update service zones within your custom flows. - * + * * @example * const { result } = await updateServiceZonesWorkflow(container) * .run({ @@ -31,9 +34,9 @@ export const updateServiceZonesWorkflowId = "update-service-zones-workflow" * } * } * }) - * + * * @summary - * + * * Update one or more service zones. */ export const updateServiceZonesWorkflow = createWorkflow( diff --git a/packages/core/core-flows/src/fulfillment/workflows/update-shipping-options.ts b/packages/core/core-flows/src/fulfillment/workflows/update-shipping-options.ts index 2f608a6f0f..3fc20057df 100644 --- a/packages/core/core-flows/src/fulfillment/workflows/update-shipping-options.ts +++ b/packages/core/core-flows/src/fulfillment/workflows/update-shipping-options.ts @@ -1,4 +1,4 @@ -import { FulfillmentWorkflow } from "@medusajs/framework/types" +import type { FulfillmentWorkflow } from "@medusajs/framework/types" import { createWorkflow, parallelize, @@ -17,24 +17,25 @@ import { ShippingOptionPriceType } from "@medusajs/framework/utils" /** * The data to update the shipping options. */ -export type UpdateShippingOptionsWorkflowInput = FulfillmentWorkflow.UpdateShippingOptionsWorkflowInput[] +export type UpdateShippingOptionsWorkflowInput = + FulfillmentWorkflow.UpdateShippingOptionsWorkflowInput[] export const updateShippingOptionsWorkflowId = "update-shipping-options-workflow" /** * This workflow updates one or more shipping options. It's used by the * [Update Shipping Options Admin API Route](https://docs.medusajs.com/api/admin#shipping-options_postshippingoptionsid). - * + * * You can use this workflow within your own customizations or custom workflows, allowing you to * update shipping options within your custom flows. - * + * * :::note - * - * Learn more about adding rules to the shipping option's prices in the Pricing Module's + * + * Learn more about adding rules to the shipping option's prices in the Pricing Module's * [Price Rules](https://docs.medusajs.com/resources/commerce-modules/pricing/price-rules) documentation. - * + * * ::: - * + * * @example * const { result } = await updateShippingOptionsWorkflow(container) * .run({ @@ -45,9 +46,9 @@ export const updateShippingOptionsWorkflowId = * } * ] * }) - * + * * @summary - * + * * Update one or more shipping options. */ export const updateShippingOptionsWorkflow = createWorkflow( diff --git a/packages/core/core-flows/src/fulfillment/workflows/update-shipping-profiles.ts b/packages/core/core-flows/src/fulfillment/workflows/update-shipping-profiles.ts index 172588f14f..cad52e9516 100644 --- a/packages/core/core-flows/src/fulfillment/workflows/update-shipping-profiles.ts +++ b/packages/core/core-flows/src/fulfillment/workflows/update-shipping-profiles.ts @@ -1,4 +1,4 @@ -import { FulfillmentWorkflow } from "@medusajs/framework/types" +import type { FulfillmentWorkflow } from "@medusajs/framework/types" import { WorkflowData, WorkflowResponse, @@ -9,17 +9,18 @@ import { updateShippingProfilesStep } from "../steps/update-shipping-profiles" /** * The updated shipping profiles. */ -export type UpdateShippingProfilesWorkflowOutput = FulfillmentWorkflow.CreateShippingProfilesWorkflowOutput +export type UpdateShippingProfilesWorkflowOutput = + FulfillmentWorkflow.CreateShippingProfilesWorkflowOutput export const updateShippingProfilesWorkflowId = "update-shipping-profiles-workflow" /** * This workflow updates one or more shipping profiles. It's used by the * [Update Shipping Profiles Admin API Route](https://docs.medusajs.com/api/admin#shipping-profiles_postshippingprofilesid). - * + * * You can use this workflow within your own customizations or custom workflows, allowing you to * update shipping profiles within your custom flows. - * + * * @example * const { result } = await updateShippingProfilesWorkflow(container) * .run({ @@ -32,9 +33,9 @@ export const updateShippingProfilesWorkflowId = * } * } * }) - * + * * @summary - * + * * Update one or more shipping profiles. */ export const updateShippingProfilesWorkflow = createWorkflow( diff --git a/packages/core/core-flows/src/inventory/steps/adjust-inventory-levels.ts b/packages/core/core-flows/src/inventory/steps/adjust-inventory-levels.ts index 9593770660..61badaf132 100644 --- a/packages/core/core-flows/src/inventory/steps/adjust-inventory-levels.ts +++ b/packages/core/core-flows/src/inventory/steps/adjust-inventory-levels.ts @@ -1,4 +1,4 @@ -import { InventoryTypes } from "@medusajs/framework/types" +import type { InventoryTypes } from "@medusajs/framework/types" import { StepResponse, createStep } from "@medusajs/framework/workflows-sdk" import { MathBN, Modules } from "@medusajs/framework/utils" diff --git a/packages/core/core-flows/src/inventory/steps/create-inventory-items.ts b/packages/core/core-flows/src/inventory/steps/create-inventory-items.ts index 1da0083c6b..581301fa5e 100644 --- a/packages/core/core-flows/src/inventory/steps/create-inventory-items.ts +++ b/packages/core/core-flows/src/inventory/steps/create-inventory-items.ts @@ -1,12 +1,16 @@ import { StepResponse, createStep } from "@medusajs/framework/workflows-sdk" -import { IInventoryService, InventoryTypes } from "@medusajs/framework/types" +import type { + IInventoryService, + InventoryTypes, +} from "@medusajs/framework/types" import { Modules } from "@medusajs/framework/utils" /** * The data to create the inventory items. */ -export type CreateInventoryItemsStepInput = InventoryTypes.CreateInventoryItemInput[] +export type CreateInventoryItemsStepInput = + InventoryTypes.CreateInventoryItemInput[] export const createInventoryItemsStepId = "create-inventory-items" /** diff --git a/packages/core/core-flows/src/inventory/steps/create-inventory-levels.ts b/packages/core/core-flows/src/inventory/steps/create-inventory-levels.ts index f409c9e80a..c3174922ee 100644 --- a/packages/core/core-flows/src/inventory/steps/create-inventory-levels.ts +++ b/packages/core/core-flows/src/inventory/steps/create-inventory-levels.ts @@ -1,4 +1,7 @@ -import { IInventoryService, InventoryTypes } from "@medusajs/framework/types" +import type { + IInventoryService, + InventoryTypes, +} from "@medusajs/framework/types" import { StepResponse, createStep } from "@medusajs/framework/workflows-sdk" import { Modules } from "@medusajs/framework/utils" @@ -6,7 +9,8 @@ import { Modules } from "@medusajs/framework/utils" /** * The data to create the inventory levels. */ -export type CreateInventoryLevelsStepInput = InventoryTypes.CreateInventoryLevelInput[] +export type CreateInventoryLevelsStepInput = + InventoryTypes.CreateInventoryLevelInput[] export const createInventoryLevelsStepId = "create-inventory-levels" /** diff --git a/packages/core/core-flows/src/inventory/steps/delete-inventory-items.ts b/packages/core/core-flows/src/inventory/steps/delete-inventory-items.ts index 9e497e25ba..ed526e8a37 100644 --- a/packages/core/core-flows/src/inventory/steps/delete-inventory-items.ts +++ b/packages/core/core-flows/src/inventory/steps/delete-inventory-items.ts @@ -1,7 +1,7 @@ import { StepResponse, createStep } from "@medusajs/framework/workflows-sdk" import { MathBN, MedusaError, Modules } from "@medusajs/framework/utils" -import { BigNumberInput } from "@medusajs/types" +import type { BigNumberInput } from "@medusajs/framework/types" export interface ValidateInventoryDeleteStepInput { inventory_items: { id: string; reserved_quantity: BigNumberInput }[] diff --git a/packages/core/core-flows/src/inventory/steps/delete-inventory-levels.ts b/packages/core/core-flows/src/inventory/steps/delete-inventory-levels.ts index 739ddff6af..20047f846f 100644 --- a/packages/core/core-flows/src/inventory/steps/delete-inventory-levels.ts +++ b/packages/core/core-flows/src/inventory/steps/delete-inventory-levels.ts @@ -1,4 +1,4 @@ -import { IInventoryService } from "@medusajs/framework/types" +import type { IInventoryService } from "@medusajs/framework/types" import { StepResponse, createStep } from "@medusajs/framework/workflows-sdk" import { Modules } from "@medusajs/framework/utils" diff --git a/packages/core/core-flows/src/inventory/steps/update-inventory-items.ts b/packages/core/core-flows/src/inventory/steps/update-inventory-items.ts index 8a6170e5cf..280500c44c 100644 --- a/packages/core/core-flows/src/inventory/steps/update-inventory-items.ts +++ b/packages/core/core-flows/src/inventory/steps/update-inventory-items.ts @@ -1,4 +1,7 @@ -import { IInventoryService, InventoryTypes } from "@medusajs/framework/types" +import type { + IInventoryService, + InventoryTypes, +} from "@medusajs/framework/types" import { convertItemResponseToUpdateRequest, getSelectsAndRelationsFromObjectArray, @@ -10,7 +13,8 @@ import { Modules } from "@medusajs/framework/utils" /** * The data to update the inventory items. */ -export type UpdateInventoryItemsStepInput = InventoryTypes.UpdateInventoryItemInput[] +export type UpdateInventoryItemsStepInput = + InventoryTypes.UpdateInventoryItemInput[] export const updateInventoryItemsStepId = "update-inventory-items-step" /** diff --git a/packages/core/core-flows/src/inventory/steps/update-inventory-levels.ts b/packages/core/core-flows/src/inventory/steps/update-inventory-levels.ts index 3c4c002097..10bc719bff 100644 --- a/packages/core/core-flows/src/inventory/steps/update-inventory-levels.ts +++ b/packages/core/core-flows/src/inventory/steps/update-inventory-levels.ts @@ -1,4 +1,7 @@ -import { IInventoryService, InventoryTypes } from "@medusajs/framework/types" +import type { + IInventoryService, + InventoryTypes, +} from "@medusajs/framework/types" import { convertItemResponseToUpdateRequest, getSelectsAndRelationsFromObjectArray, @@ -10,7 +13,8 @@ import { Modules } from "@medusajs/framework/utils" /** * The data to update the inventory levels. */ -export type UpdateInventoryLevelsStepInput = InventoryTypes.UpdateInventoryLevelInput[] +export type UpdateInventoryLevelsStepInput = + InventoryTypes.UpdateInventoryLevelInput[] export const updateInventoryLevelsStepId = "update-inventory-levels-step" /** diff --git a/packages/core/core-flows/src/inventory/steps/validate-inventory-locations.ts b/packages/core/core-flows/src/inventory/steps/validate-inventory-locations.ts index e194b2d06a..afa3c7ab3b 100644 --- a/packages/core/core-flows/src/inventory/steps/validate-inventory-locations.ts +++ b/packages/core/core-flows/src/inventory/steps/validate-inventory-locations.ts @@ -4,17 +4,18 @@ import { MedusaError, } from "@medusajs/framework/utils" -import { InventoryTypes } from "@medusajs/framework/types" +import type { InventoryTypes } from "@medusajs/framework/types" import { createStep } from "@medusajs/framework/workflows-sdk" /** * The data to validate the inventory levels. */ -export type ValidateInventoryLocationsStepInput = InventoryTypes.CreateInventoryLevelInput[] +export type ValidateInventoryLocationsStepInput = + InventoryTypes.CreateInventoryLevelInput[] export const validateInventoryLocationsStepId = "validate-inventory-levels-step" /** - * This step ensures that the inventory levels exist for each + * This step ensures that the inventory levels exist for each * specified pair of inventory item and location. If not, * the step will throw an error. */ diff --git a/packages/core/core-flows/src/inventory/workflows/batch-inventory-item-levels.ts b/packages/core/core-flows/src/inventory/workflows/batch-inventory-item-levels.ts index 3ce9e0acc4..8405e9634f 100644 --- a/packages/core/core-flows/src/inventory/workflows/batch-inventory-item-levels.ts +++ b/packages/core/core-flows/src/inventory/workflows/batch-inventory-item-levels.ts @@ -5,13 +5,18 @@ import { WorkflowData, WorkflowResponse, } from "@medusajs/framework/workflows-sdk" -import { BatchWorkflowInput, BatchWorkflowOutput, InventoryLevelDTO, InventoryTypes } from "@medusajs/types" +import { + BatchWorkflowInput, + BatchWorkflowOutput, + InventoryLevelDTO, + InventoryTypes, +} from "@medusajs/framework/types" import { createInventoryLevelsStep, updateInventoryLevelsStep } from "../steps" import { deleteInventoryLevelsWorkflow } from "./delete-inventory-levels" /** * The data to manage the inventory levels in bulk. - * + * * @property create - The inventory levels to create. * @property update - The inventory levels to update. * @property delete - The IDs of inventory levels to delete. @@ -36,22 +41,23 @@ export interface BatchInventoryItemLevelsWorkflowInput /** * The result of managing inventory levels in bulk. - * + * * @property created - The inventory levels that were created. * @property updated - The inventory levels that were updated. * @property deleted - The IDs of the inventory levels that were deleted. */ -export interface BatchInventoryItemLevelsWorkflowOutput extends BatchWorkflowOutput {} +export interface BatchInventoryItemLevelsWorkflowOutput + extends BatchWorkflowOutput {} export const batchInventoryItemLevelsWorkflowId = "batch-inventory-item-levels-workflow" /** * This workflow creates, updates and deletes inventory levels in bulk. - * + * * You can use this workflow within your own customizations or custom workflows, allowing you * to manage inventory levels in your custom flows. - * + * * @example * const { result } = await batchInventoryItemLevelsWorkflow(container) * .run({ @@ -73,9 +79,9 @@ export const batchInventoryItemLevelsWorkflowId = * delete: ["iilev_321"] * } * }) - * + * * @summary - * + * * Manage inventory levels in bulk. */ export const batchInventoryItemLevelsWorkflow = createWorkflow( diff --git a/packages/core/core-flows/src/inventory/workflows/bulk-create-delete-levels.ts b/packages/core/core-flows/src/inventory/workflows/bulk-create-delete-levels.ts index 546cfdddbf..e13a738102 100644 --- a/packages/core/core-flows/src/inventory/workflows/bulk-create-delete-levels.ts +++ b/packages/core/core-flows/src/inventory/workflows/bulk-create-delete-levels.ts @@ -1,6 +1,9 @@ // TODO: Remove this workflow in a future release. -import { InventoryLevelDTO, InventoryTypes } from "@medusajs/framework/types" +import type { + InventoryLevelDTO, + InventoryTypes, +} from "@medusajs/framework/types" import { createWorkflow, when, diff --git a/packages/core/core-flows/src/inventory/workflows/create-inventory-items.ts b/packages/core/core-flows/src/inventory/workflows/create-inventory-items.ts index 305291d3aa..01f360bb57 100644 --- a/packages/core/core-flows/src/inventory/workflows/create-inventory-items.ts +++ b/packages/core/core-flows/src/inventory/workflows/create-inventory-items.ts @@ -6,7 +6,7 @@ import { } from "@medusajs/framework/workflows-sdk" import { createInventoryItemsStep } from "../steps" -import { InventoryTypes } from "@medusajs/framework/types" +import type { InventoryTypes } from "@medusajs/framework/types" import { createInventoryLevelsWorkflow } from "./create-inventory-levels" /** @@ -82,10 +82,10 @@ export const createInventoryItemsWorkflowId = "create-inventory-items-workflow" /** * This workflow creates one or more inventory items. It's used by the * [Create Inventory Item Admin API Route](https://docs.medusajs.com/api/admin#inventory-items_postinventoryitems). - * + * * You can use this workflow within your own customizations or custom workflows, allowing you * to create inventory items in your custom flows. - * + * * @example * const { result } = await createInventoryItemsWorkflow(container) * .run({ @@ -102,9 +102,9 @@ export const createInventoryItemsWorkflowId = "create-inventory-items-workflow" * ] * } * }) - * + * * @summary - * + * * Create one or more inventory items. */ export const createInventoryItemsWorkflow = createWorkflow( diff --git a/packages/core/core-flows/src/inventory/workflows/create-inventory-levels.ts b/packages/core/core-flows/src/inventory/workflows/create-inventory-levels.ts index 36edc9f99e..ee68fd735a 100644 --- a/packages/core/core-flows/src/inventory/workflows/create-inventory-levels.ts +++ b/packages/core/core-flows/src/inventory/workflows/create-inventory-levels.ts @@ -1,4 +1,7 @@ -import { InventoryLevelDTO, InventoryTypes } from "@medusajs/framework/types" +import type { + InventoryLevelDTO, + InventoryTypes, +} from "@medusajs/framework/types" import { WorkflowData, WorkflowResponse, @@ -23,10 +26,10 @@ export const createInventoryLevelsWorkflowId = /** * This workflow creates one or more inventory levels. It's used by the * [Create Inventory Level API Route](https://docs.medusajs.com/api/admin#inventory-items_postinventoryitemsidlocationlevels). - * + * * You can use this workflow within your own customizations or custom workflows, allowing you * to create inventory levels in your custom flows. - * + * * @example * const { result } = await createInventoryLevelsWorkflow(container) * .run({ @@ -39,9 +42,9 @@ export const createInventoryLevelsWorkflowId = * ] * } * }) - * + * * @summary - * + * * Create one or more inventory levels. */ export const createInventoryLevelsWorkflow = createWorkflow( diff --git a/packages/core/core-flows/src/inventory/workflows/update-inventory-items.ts b/packages/core/core-flows/src/inventory/workflows/update-inventory-items.ts index eb46c75d25..d116edf1bd 100644 --- a/packages/core/core-flows/src/inventory/workflows/update-inventory-items.ts +++ b/packages/core/core-flows/src/inventory/workflows/update-inventory-items.ts @@ -4,7 +4,7 @@ import { createWorkflow, } from "@medusajs/framework/workflows-sdk" -import { InventoryTypes } from "@medusajs/framework/types" +import type { InventoryTypes } from "@medusajs/framework/types" import { updateInventoryItemsStep } from "../steps" /** @@ -20,16 +20,17 @@ export interface UpdateInventoryItemsWorkflowInput { /** * The updated inventory items. */ -export type UpdateInventoryItemsWorkflowOutput = InventoryTypes.InventoryItemDTO[] +export type UpdateInventoryItemsWorkflowOutput = + InventoryTypes.InventoryItemDTO[] export const updateInventoryItemsWorkflowId = "update-inventory-items-workflow" /** * This workflow updates one or more inventory items. It's used by the * [Update an Inventory Item Admin API Route](https://docs.medusajs.com/api/admin#inventory-items_postinventoryitemsid). - * + * * You can use this workflow within your own customizations or custom workflows, allowing you * to update inventory items in your custom flows. - * + * * @example * const { result } = await updateInventoryItemsWorkflow(container) * .run({ @@ -42,9 +43,9 @@ export const updateInventoryItemsWorkflowId = "update-inventory-items-workflow" * ] * } * }) - * + * * @summary - * + * * Update one or more inventory items. */ export const updateInventoryItemsWorkflow = createWorkflow( diff --git a/packages/core/core-flows/src/inventory/workflows/update-inventory-levels.ts b/packages/core/core-flows/src/inventory/workflows/update-inventory-levels.ts index 1dd79e6577..5246df6df0 100644 --- a/packages/core/core-flows/src/inventory/workflows/update-inventory-levels.ts +++ b/packages/core/core-flows/src/inventory/workflows/update-inventory-levels.ts @@ -1,4 +1,7 @@ -import { InventoryLevelDTO, InventoryTypes } from "@medusajs/framework/types" +import type { + InventoryLevelDTO, + InventoryTypes, +} from "@medusajs/framework/types" import { WorkflowData, WorkflowResponse, @@ -27,10 +30,10 @@ export const updateInventoryLevelsWorkflowId = /** * This workflow updates one or more inventory levels. It's used by the * [Update Inventory Level Admin API Route](https://docs.medusajs.com/api/admin#inventory-items_postinventoryitemsidlocationlevelslocation_id). - * + * * You can use this workflow within your own customizations or custom workflows, allowing you * to update inventory levels in your custom flows. - * + * * @example * const { result } = await updateInventoryLevelsWorkflow(container) * .run({ @@ -45,9 +48,9 @@ export const updateInventoryLevelsWorkflowId = * ] * } * }) - * + * * @summary - * + * * Update one or more inventory levels. */ export const updateInventoryLevelsWorkflow = createWorkflow( diff --git a/packages/core/core-flows/src/invite/steps/create-invites.ts b/packages/core/core-flows/src/invite/steps/create-invites.ts index 2170ceb1e8..9cdecb718c 100644 --- a/packages/core/core-flows/src/invite/steps/create-invites.ts +++ b/packages/core/core-flows/src/invite/steps/create-invites.ts @@ -1,11 +1,14 @@ -import { CreateInviteDTO, IUserModuleService } from "@medusajs/framework/types" +import type { + CreateInviteDTO, + IUserModuleService, +} from "@medusajs/framework/types" import { Modules } from "@medusajs/framework/utils" import { StepResponse, createStep } from "@medusajs/framework/workflows-sdk" export const createInviteStepId = "create-invite-step" /** * This step creates one or more invites. - * + * * @example * const data = createInviteStep([ * { diff --git a/packages/core/core-flows/src/invite/steps/delete-invites.ts b/packages/core/core-flows/src/invite/steps/delete-invites.ts index 61f59bb786..db1b3dd6c5 100644 --- a/packages/core/core-flows/src/invite/steps/delete-invites.ts +++ b/packages/core/core-flows/src/invite/steps/delete-invites.ts @@ -1,4 +1,4 @@ -import { IUserModuleService } from "@medusajs/framework/types" +import type { IUserModuleService } from "@medusajs/framework/types" import { Modules } from "@medusajs/framework/utils" import { StepResponse, createStep } from "@medusajs/framework/workflows-sdk" diff --git a/packages/core/core-flows/src/invite/steps/refresh-invite-tokens.ts b/packages/core/core-flows/src/invite/steps/refresh-invite-tokens.ts index 27762f9658..39429f88f6 100644 --- a/packages/core/core-flows/src/invite/steps/refresh-invite-tokens.ts +++ b/packages/core/core-flows/src/invite/steps/refresh-invite-tokens.ts @@ -1,4 +1,4 @@ -import { IUserModuleService } from "@medusajs/framework/types" +import type { IUserModuleService } from "@medusajs/framework/types" import { StepResponse, createStep } from "@medusajs/framework/workflows-sdk" import { Modules } from "@medusajs/framework/utils" diff --git a/packages/core/core-flows/src/invite/steps/validate-token.ts b/packages/core/core-flows/src/invite/steps/validate-token.ts index 8f424d87d9..c8a0f87ac2 100644 --- a/packages/core/core-flows/src/invite/steps/validate-token.ts +++ b/packages/core/core-flows/src/invite/steps/validate-token.ts @@ -1,4 +1,4 @@ -import { IUserModuleService } from "@medusajs/framework/types" +import type { IUserModuleService } from "@medusajs/framework/types" import { Modules } from "@medusajs/framework/utils" import { StepResponse, createStep } from "@medusajs/framework/workflows-sdk" diff --git a/packages/core/core-flows/src/invite/workflows/accept-invite.ts b/packages/core/core-flows/src/invite/workflows/accept-invite.ts index 4498af7a25..d310f1b7ca 100644 --- a/packages/core/core-flows/src/invite/workflows/accept-invite.ts +++ b/packages/core/core-flows/src/invite/workflows/accept-invite.ts @@ -1,4 +1,4 @@ -import { InviteWorkflow, UserDTO } from "@medusajs/framework/types" +import type { InviteWorkflow, UserDTO } from "@medusajs/framework/types" import { InviteWorkflowEvents } from "@medusajs/framework/utils" import { WorkflowData, @@ -17,14 +17,14 @@ export const acceptInviteWorkflowId = "accept-invite-workflow" /** * This workflow accepts an invite and creates a user. It's used by the * [Accept Invite Admin API Route](https://docs.medusajs.com/api/admin#invites_postinvitesaccept). - * + * * The workflow throws an error if the specified token is not valid. Also, the workflow * requires an auth identity to be created previously. You can create an auth identity * using the [Retrieve Registration JWT Token API Route](https://docs.medusajs.com/api/admin#auth_postactor_typeauth_provider_register). - * + * * You can use this workflow within your customizations or your own custom workflows, allowing you to * accept invites within your custom flows. - * + * * @example * const { result } = await acceptInviteWorkflow(container) * .run({ @@ -38,9 +38,9 @@ export const acceptInviteWorkflowId = "accept-invite-workflow" * } * } * }) - * + * * @summary - * + * * Accept invite and create user. */ export const acceptInviteWorkflow = createWorkflow( diff --git a/packages/core/core-flows/src/invite/workflows/create-invites.ts b/packages/core/core-flows/src/invite/workflows/create-invites.ts index 301228cb12..504a57554c 100644 --- a/packages/core/core-flows/src/invite/workflows/create-invites.ts +++ b/packages/core/core-flows/src/invite/workflows/create-invites.ts @@ -1,4 +1,4 @@ -import { InviteDTO, InviteWorkflow } from "@medusajs/framework/types" +import type { InviteDTO, InviteWorkflow } from "@medusajs/framework/types" import { InviteWorkflowEvents } from "@medusajs/framework/utils" import { WorkflowData, @@ -12,10 +12,10 @@ export const createInvitesWorkflowId = "create-invite-step" /** * This workflow creates one or more user invites. It's used by the * [Create Invite Admin API Route](https://docs.medusajs.com/api/admin#invites_postinvites). - * + * * You can use this workflow within your customizations or your own custom workflows, allowing you to * create invites within your custom flows. - * + * * @example * const { result } = await createInvitesWorkflow(container) * .run({ @@ -27,9 +27,9 @@ export const createInvitesWorkflowId = "create-invite-step" * ] * } * }) - * + * * @summary - * + * * Create one or more user invites. */ export const createInvitesWorkflow = createWorkflow( diff --git a/packages/core/core-flows/src/invite/workflows/delete-invites.ts b/packages/core/core-flows/src/invite/workflows/delete-invites.ts index d58449651d..40759420e0 100644 --- a/packages/core/core-flows/src/invite/workflows/delete-invites.ts +++ b/packages/core/core-flows/src/invite/workflows/delete-invites.ts @@ -1,4 +1,4 @@ -import { InviteWorkflow } from "@medusajs/framework/types" +import type { InviteWorkflow } from "@medusajs/framework/types" import { InviteWorkflowEvents } from "@medusajs/framework/utils" import { WorkflowData, @@ -12,10 +12,10 @@ export const deleteInvitesWorkflowId = "delete-invites-workflow" /** * This workflow deletes one or more user invites. It's used by the * [Delete Invites Admin API Route](https://docs.medusajs.com/api/admin#invites_deleteinvitesid). - * + * * You can use this workflow within your customizations or your own custom workflows, allowing you to * delete invites within your custom flows. - * + * * @example * const { result } = await deleteInvitesWorkflow(container) * .run({ @@ -23,9 +23,9 @@ export const deleteInvitesWorkflowId = "delete-invites-workflow" * ids: ["invite_123"] * } * }) - * + * * @summary - * + * * Delete one or more user invites. */ export const deleteInvitesWorkflow = createWorkflow( diff --git a/packages/core/core-flows/src/invite/workflows/refresh-invite-tokens.ts b/packages/core/core-flows/src/invite/workflows/refresh-invite-tokens.ts index f83e9e3a20..19372fbe25 100644 --- a/packages/core/core-flows/src/invite/workflows/refresh-invite-tokens.ts +++ b/packages/core/core-flows/src/invite/workflows/refresh-invite-tokens.ts @@ -1,4 +1,4 @@ -import { InviteDTO, InviteWorkflow } from "@medusajs/framework/types" +import type { InviteDTO, InviteWorkflow } from "@medusajs/framework/types" import { WorkflowData, WorkflowResponse, @@ -15,13 +15,13 @@ export const refreshInviteTokensWorkflowId = "refresh-invite-tokens-workflow" * This workflow refreshes the token of one or more user invites, updating the * token and the expiry date. It's used by the * [Refresh Invite Token Admin API Route](https://docs.medusajs.com/api/admin#invites_postinvitesidresend). - * + * * This workflow is useful to trigger resending invite tokens. It emits the `invite.resent` event, * which you can listen to in a [Subscriber](https://docs.medusajs.com/learn/fundamentals/events-and-subscribers). - * + * * You can use this workflow within your customizations or your own custom workflows, allowing you to * refresh invite tokens within your custom flows. - * + * * @example * const { result } = await refreshInviteTokensWorkflow(container) * .run({ @@ -29,9 +29,9 @@ export const refreshInviteTokensWorkflowId = "refresh-invite-tokens-workflow" * invite_ids: ["invite_123"] * } * }) - * + * * @summary - * + * * Refresh user invite tokens. */ export const refreshInviteTokensWorkflow = createWorkflow( diff --git a/packages/core/core-flows/src/line-item/steps/delete-line-items.ts b/packages/core/core-flows/src/line-item/steps/delete-line-items.ts index 757db26cb3..3ccda8fd69 100644 --- a/packages/core/core-flows/src/line-item/steps/delete-line-items.ts +++ b/packages/core/core-flows/src/line-item/steps/delete-line-items.ts @@ -1,4 +1,4 @@ -import { ICartModuleService } from "@medusajs/framework/types" +import type { ICartModuleService } from "@medusajs/framework/types" import { Modules } from "@medusajs/framework/utils" import { StepResponse, createStep } from "@medusajs/framework/workflows-sdk" diff --git a/packages/core/core-flows/src/notification/steps/notify-on-failure.ts b/packages/core/core-flows/src/notification/steps/notify-on-failure.ts index 57ae2b9e05..dc454f9080 100644 --- a/packages/core/core-flows/src/notification/steps/notify-on-failure.ts +++ b/packages/core/core-flows/src/notification/steps/notify-on-failure.ts @@ -1,4 +1,4 @@ -import { INotificationModuleService } from "@medusajs/framework/types" +import type { INotificationModuleService } from "@medusajs/framework/types" import { Modules } from "@medusajs/framework/utils" import { StepResponse, createStep } from "@medusajs/framework/workflows-sdk" @@ -60,7 +60,7 @@ export const notifyOnFailureStepId = "notify-on-failure" * This step sends one or more notification when a workflow fails. This * step can be used in the beginning of a workflow so that, when the workflow fails, * the step's compensation function is triggered to send the notification. - * + * * @example * const data = notifyOnFailureStep([{ * to: "example@gmail.com", diff --git a/packages/core/core-flows/src/notification/steps/send-notifications.ts b/packages/core/core-flows/src/notification/steps/send-notifications.ts index cfc824f4f5..a0c6ae9b9c 100644 --- a/packages/core/core-flows/src/notification/steps/send-notifications.ts +++ b/packages/core/core-flows/src/notification/steps/send-notifications.ts @@ -1,4 +1,4 @@ -import { INotificationModuleService } from "@medusajs/framework/types" +import type { INotificationModuleService } from "@medusajs/framework/types" import { Modules } from "@medusajs/framework/utils" import { StepResponse, createStep } from "@medusajs/framework/workflows-sdk" diff --git a/packages/core/core-flows/src/order/steps/add-order-transaction.ts b/packages/core/core-flows/src/order/steps/add-order-transaction.ts index 63c18ebb01..64c21a5e6d 100644 --- a/packages/core/core-flows/src/order/steps/add-order-transaction.ts +++ b/packages/core/core-flows/src/order/steps/add-order-transaction.ts @@ -1,4 +1,4 @@ -import { CreateOrderTransactionDTO } from "@medusajs/framework/types" +import type { CreateOrderTransactionDTO } from "@medusajs/framework/types" import { Modules } from "@medusajs/framework/utils" import { StepResponse, createStep } from "@medusajs/framework/workflows-sdk" diff --git a/packages/core/core-flows/src/order/steps/archive-orders.ts b/packages/core/core-flows/src/order/steps/archive-orders.ts index b170da6427..83dd65625c 100644 --- a/packages/core/core-flows/src/order/steps/archive-orders.ts +++ b/packages/core/core-flows/src/order/steps/archive-orders.ts @@ -1,4 +1,4 @@ -import { IOrderModuleService } from "@medusajs/framework/types" +import type { IOrderModuleService } from "@medusajs/framework/types" import { Modules } from "@medusajs/framework/utils" import { createStep, StepResponse } from "@medusajs/framework/workflows-sdk" diff --git a/packages/core/core-flows/src/order/steps/cancel-orders.ts b/packages/core/core-flows/src/order/steps/cancel-orders.ts index 4eb683e641..235131c5d2 100644 --- a/packages/core/core-flows/src/order/steps/cancel-orders.ts +++ b/packages/core/core-flows/src/order/steps/cancel-orders.ts @@ -1,4 +1,4 @@ -import { IOrderModuleService } from "@medusajs/framework/types" +import type { IOrderModuleService } from "@medusajs/framework/types" import { Modules } from "@medusajs/framework/utils" import { createStep, StepResponse } from "@medusajs/framework/workflows-sdk" diff --git a/packages/core/core-flows/src/order/steps/claim/delete-claims.ts b/packages/core/core-flows/src/order/steps/claim/delete-claims.ts index b7d66f4e3e..9137da10f1 100644 --- a/packages/core/core-flows/src/order/steps/claim/delete-claims.ts +++ b/packages/core/core-flows/src/order/steps/claim/delete-claims.ts @@ -1,4 +1,4 @@ -import { IOrderModuleService } from "@medusajs/framework/types" +import type { IOrderModuleService } from "@medusajs/framework/types" import { Modules } from "@medusajs/framework/utils" import { createStep, StepResponse } from "@medusajs/framework/workflows-sdk" diff --git a/packages/core/core-flows/src/order/steps/complete-orders.ts b/packages/core/core-flows/src/order/steps/complete-orders.ts index 55ac07e75a..8e62ec6d58 100644 --- a/packages/core/core-flows/src/order/steps/complete-orders.ts +++ b/packages/core/core-flows/src/order/steps/complete-orders.ts @@ -1,4 +1,4 @@ -import { IOrderModuleService } from "@medusajs/framework/types" +import type { IOrderModuleService } from "@medusajs/framework/types" import { Modules } from "@medusajs/framework/utils" import { createStep, StepResponse } from "@medusajs/framework/workflows-sdk" diff --git a/packages/core/core-flows/src/order/steps/confirm-order-changes.ts b/packages/core/core-flows/src/order/steps/confirm-order-changes.ts index 960979163b..a53b10a115 100644 --- a/packages/core/core-flows/src/order/steps/confirm-order-changes.ts +++ b/packages/core/core-flows/src/order/steps/confirm-order-changes.ts @@ -1,4 +1,4 @@ -import { OrderChangeDTO } from "@medusajs/framework/types" +import type { OrderChangeDTO } from "@medusajs/framework/types" import { Modules } from "@medusajs/framework/utils" import { createStep, StepResponse } from "@medusajs/framework/workflows-sdk" diff --git a/packages/core/core-flows/src/order/steps/create-line-items.ts b/packages/core/core-flows/src/order/steps/create-line-items.ts index 05035524aa..9fcc080ae5 100644 --- a/packages/core/core-flows/src/order/steps/create-line-items.ts +++ b/packages/core/core-flows/src/order/steps/create-line-items.ts @@ -1,4 +1,4 @@ -import { CreateOrderLineItemDTO } from "@medusajs/framework/types" +import type { CreateOrderLineItemDTO } from "@medusajs/framework/types" import { Modules } from "@medusajs/framework/utils" import { StepResponse, createStep } from "@medusajs/framework/workflows-sdk" @@ -15,7 +15,7 @@ export interface CreateOrderLineItemsStepInput { export const createOrderLineItemsStepId = "create-order-line-items-step" /** * This step creates order line items. - * + * * @example * const data = createOrderLineItemsStep({ * items: [ diff --git a/packages/core/core-flows/src/order/steps/create-orders.ts b/packages/core/core-flows/src/order/steps/create-orders.ts index 42259c84a1..3a988f2da6 100644 --- a/packages/core/core-flows/src/order/steps/create-orders.ts +++ b/packages/core/core-flows/src/order/steps/create-orders.ts @@ -1,4 +1,7 @@ -import { CreateOrderDTO, IOrderModuleService } from "@medusajs/framework/types" +import type { + CreateOrderDTO, + IOrderModuleService, +} from "@medusajs/framework/types" import { Modules } from "@medusajs/framework/utils" import { StepResponse, createStep } from "@medusajs/framework/workflows-sdk" @@ -10,7 +13,7 @@ export type CreateOrdersStepInput = CreateOrderDTO[] export const createOrdersStepId = "create-orders" /** * This step creates one or more orders. - * + * * @example * const data = createOrdersStep([{ * region_id: "region_123", diff --git a/packages/core/core-flows/src/order/steps/delete-line-items.ts b/packages/core/core-flows/src/order/steps/delete-line-items.ts index 5e922ae353..22f3d4b45d 100644 --- a/packages/core/core-flows/src/order/steps/delete-line-items.ts +++ b/packages/core/core-flows/src/order/steps/delete-line-items.ts @@ -1,4 +1,4 @@ -import { IOrderModuleService } from "@medusajs/framework/types" +import type { IOrderModuleService } from "@medusajs/framework/types" import { Modules } from "@medusajs/framework/utils" import { StepResponse, createStep } from "@medusajs/framework/workflows-sdk" diff --git a/packages/core/core-flows/src/order/steps/delete-order-change-actions.ts b/packages/core/core-flows/src/order/steps/delete-order-change-actions.ts index f43b7f552d..c018a3b474 100644 --- a/packages/core/core-flows/src/order/steps/delete-order-change-actions.ts +++ b/packages/core/core-flows/src/order/steps/delete-order-change-actions.ts @@ -1,4 +1,4 @@ -import { IOrderModuleService } from "@medusajs/framework/types" +import type { IOrderModuleService } from "@medusajs/framework/types" import { Modules } from "@medusajs/framework/utils" import { StepResponse, createStep } from "@medusajs/framework/workflows-sdk" diff --git a/packages/core/core-flows/src/order/steps/delete-order-changes.ts b/packages/core/core-flows/src/order/steps/delete-order-changes.ts index b18d8c6d67..b3761ef020 100644 --- a/packages/core/core-flows/src/order/steps/delete-order-changes.ts +++ b/packages/core/core-flows/src/order/steps/delete-order-changes.ts @@ -1,4 +1,4 @@ -import { IOrderModuleService } from "@medusajs/framework/types" +import type { IOrderModuleService } from "@medusajs/framework/types" import { Modules } from "@medusajs/framework/utils" import { createStep, StepResponse } from "@medusajs/framework/workflows-sdk" diff --git a/packages/core/core-flows/src/order/steps/delete-order-shipping-methods.ts b/packages/core/core-flows/src/order/steps/delete-order-shipping-methods.ts index 13c4bb0ced..09bf8fabe7 100644 --- a/packages/core/core-flows/src/order/steps/delete-order-shipping-methods.ts +++ b/packages/core/core-flows/src/order/steps/delete-order-shipping-methods.ts @@ -1,4 +1,4 @@ -import { IOrderModuleService } from "@medusajs/framework/types" +import type { IOrderModuleService } from "@medusajs/framework/types" import { Modules } from "@medusajs/framework/utils" import { StepResponse, createStep } from "@medusajs/framework/workflows-sdk" diff --git a/packages/core/core-flows/src/order/steps/exchange/delete-exchanges.ts b/packages/core/core-flows/src/order/steps/exchange/delete-exchanges.ts index bedb51718b..73189dfb5d 100644 --- a/packages/core/core-flows/src/order/steps/exchange/delete-exchanges.ts +++ b/packages/core/core-flows/src/order/steps/exchange/delete-exchanges.ts @@ -1,4 +1,4 @@ -import { IOrderModuleService } from "@medusajs/framework/types" +import type { IOrderModuleService } from "@medusajs/framework/types" import { Modules } from "@medusajs/framework/utils" import { createStep, StepResponse } from "@medusajs/framework/workflows-sdk" diff --git a/packages/core/core-flows/src/order/steps/preview-order-change.ts b/packages/core/core-flows/src/order/steps/preview-order-change.ts index f587a6eeee..9ebb5571df 100644 --- a/packages/core/core-flows/src/order/steps/preview-order-change.ts +++ b/packages/core/core-flows/src/order/steps/preview-order-change.ts @@ -1,4 +1,4 @@ -import { IOrderModuleService } from "@medusajs/framework/types" +import type { IOrderModuleService } from "@medusajs/framework/types" import { Modules } from "@medusajs/framework/utils" import { StepResponse, createStep } from "@medusajs/framework/workflows-sdk" diff --git a/packages/core/core-flows/src/order/steps/return/delete-returns.ts b/packages/core/core-flows/src/order/steps/return/delete-returns.ts index 1a0b6ff548..df05c0c92b 100644 --- a/packages/core/core-flows/src/order/steps/return/delete-returns.ts +++ b/packages/core/core-flows/src/order/steps/return/delete-returns.ts @@ -1,4 +1,4 @@ -import { IOrderModuleService } from "@medusajs/framework/types" +import type { IOrderModuleService } from "@medusajs/framework/types" import { Modules } from "@medusajs/framework/utils" import { createStep, StepResponse } from "@medusajs/framework/workflows-sdk" diff --git a/packages/core/core-flows/src/order/steps/return/update-returns.ts b/packages/core/core-flows/src/order/steps/return/update-returns.ts index d26eacd95d..ea8d4e8752 100644 --- a/packages/core/core-flows/src/order/steps/return/update-returns.ts +++ b/packages/core/core-flows/src/order/steps/return/update-returns.ts @@ -1,4 +1,4 @@ -import { UpdateReturnDTO } from "@medusajs/framework/types" +import type { UpdateReturnDTO } from "@medusajs/framework/types" import { Modules, getSelectsAndRelationsFromObjectArray, diff --git a/packages/core/core-flows/src/order/utils/aggregate-status.ts b/packages/core/core-flows/src/order/utils/aggregate-status.ts index 786b236370..4a60da5fbb 100644 --- a/packages/core/core-flows/src/order/utils/aggregate-status.ts +++ b/packages/core/core-flows/src/order/utils/aggregate-status.ts @@ -1,4 +1,4 @@ -import { OrderDetailDTO } from "@medusajs/framework/types" +import type { OrderDetailDTO } from "@medusajs/framework/types" import { isDefined, MathBN, MEDUSA_EPSILON } from "@medusajs/framework/utils" export const getLastPaymentStatus = (order: OrderDetailDTO) => { diff --git a/packages/core/core-flows/src/order/utils/build-reservations-map.ts b/packages/core/core-flows/src/order/utils/build-reservations-map.ts index 46b702a589..dddd4dc529 100644 --- a/packages/core/core-flows/src/order/utils/build-reservations-map.ts +++ b/packages/core/core-flows/src/order/utils/build-reservations-map.ts @@ -1,4 +1,4 @@ -import { ReservationItemDTO } from "@medusajs/types" +import type { ReservationItemDTO } from "@medusajs/framework/types" /** * Builds a map of reservations by line item id. diff --git a/packages/core/core-flows/src/order/utils/prepare-shipping-method.ts b/packages/core/core-flows/src/order/utils/prepare-shipping-method.ts index 275c459488..9d9ea5703f 100644 --- a/packages/core/core-flows/src/order/utils/prepare-shipping-method.ts +++ b/packages/core/core-flows/src/order/utils/prepare-shipping-method.ts @@ -1,4 +1,4 @@ -import { OrderChangeActionDTO } from "@medusajs/framework/types" +import type { OrderChangeActionDTO } from "@medusajs/framework/types" import { isDefined } from "@medusajs/framework/utils" export function prepareShippingMethod(relatedEntityField?: string) { diff --git a/packages/core/core-flows/src/order/workflows/add-line-items.ts b/packages/core/core-flows/src/order/workflows/add-line-items.ts index ad0acaf233..6e0a88aaa5 100644 --- a/packages/core/core-flows/src/order/workflows/add-line-items.ts +++ b/packages/core/core-flows/src/order/workflows/add-line-items.ts @@ -1,60 +1,29 @@ import { AdditionalData, + ConfirmVariantInventoryWorkflowInputDTO, + CreateOrderLineItemDTO, OrderLineItemDTO, OrderWorkflow, } from "@medusajs/framework/types" -import { deduplicate, isDefined, MedusaError } from "@medusajs/framework/utils" +import { deduplicate } from "@medusajs/framework/utils" import { createHook, createWorkflow, parallelize, transform, - when, WorkflowData, WorkflowResponse, } from "@medusajs/framework/workflows-sdk" import { findOneOrAnyRegionStep } from "../../cart/steps/find-one-or-any-region" import { findOrCreateCustomerStep } from "../../cart/steps/find-or-create-customer" import { findSalesChannelStep } from "../../cart/steps/find-sales-channel" -import { validateLineItemPricesStep } from "../../cart/steps/validate-line-item-prices" -import { validateVariantPricesStep } from "../../cart/steps/validate-variant-prices" import { requiredVariantFieldsForInventoryConfirmation } from "../../cart/utils/prepare-confirm-inventory-input" -import { - prepareLineItemData, - PrepareLineItemDataInput, -} from "../../cart/utils/prepare-line-item-data" import { pricingContextResult } from "../../cart/utils/schemas" import { confirmVariantInventoryWorkflow } from "../../cart/workflows/confirm-variant-inventory" -import { useQueryGraphStep, useRemoteQueryStep } from "../../common" +import { getVariantsAndItemsWithPrices } from "../../cart/workflows/get-variants-and-items-with-prices" +import { useRemoteQueryStep } from "../../common" import { createOrderLineItemsStep } from "../steps" import { productVariantsFields } from "../utils/fields" -import { getVariantPriceSetsStep } from "../../cart" - -function prepareLineItems(data) { - const items = (data.input.items ?? []).map((item) => { - const variant = data.variants?.find((v) => v.id === item.variant_id) - - const input: PrepareLineItemDataInput = { - item, - variant: variant, - unitPrice: item.unit_price, - isTaxInclusive: - item.is_tax_inclusive ?? - variant?.calculated_price?.is_calculated_price_tax_inclusive, - isCustomPrice: isDefined(item?.unit_price), - taxLines: item.tax_lines ?? [], - adjustments: item.adjustments ?? [], - } - - if (variant && !isDefined(input.unitPrice)) { - input.unitPrice = variant.calculated_price?.calculated_amount - } - - return prepareLineItemData(input) - }) - - return items -} /** * The created order line items. @@ -178,93 +147,39 @@ export const addOrderLineItemsWorkflow = createWorkflow( ) const setPricingContextResult = setPricingContext.getResult() - const pricingContext = transform( - { input, region, customerData, order, setPricingContextResult }, - (data) => { - if (!data.region) { - throw new MedusaError(MedusaError.Types.NOT_FOUND, "Region not found") - } - - return { - ...(data.setPricingContextResult ? data.setPricingContextResult : {}), - currency_code: data.order.currency_code ?? data.region.currency_code, - region_id: data.region.id, - customer_id: data.customerData.customer?.id, - } - } - ) - - const variants = when( - "fetch-variants-with-calculated-price", - { variantIds }, - ({ variantIds }) => { - return !!variantIds.length - } - ).then(() => { - const { data: variantsData } = useQueryGraphStep({ - entity: "variants", - fields: deduplicate([ - ...productVariantsFields, - ...requiredVariantFieldsForInventoryConfirmation, - ]), - filters: { + const { variants, lineItems } = getVariantsAndItemsWithPrices.runAsStep({ + input: { + cart: order, + items: input.items, + setPricingContextResult: setPricingContextResult!, + variants: { id: variantIds, + fields: deduplicate([ + ...productVariantsFields, + ...requiredVariantFieldsForInventoryConfirmation, + ]), }, - }) - - const calculatedPriceContext = transform( - { pricingContext, items: input.items }, - (data): { variantId: string; context: Record }[] => { - const baseContext = data.pricingContext - - return (data.items ?? []) - .filter((i) => i.variant_id) - .map((item) => { - return { - variantId: item.variant_id!, - context: { - ...baseContext, - quantity: item.quantity, - }, - } - }) - } - ) - - const calculatedPriceSets = getVariantPriceSetsStep({ - data: calculatedPriceContext, - }) - - const variants = transform( - { variantsData, calculatedPriceSets }, - ({ variantsData, calculatedPriceSets }) => { - return variantsData.map((variant) => { - variant.calculated_price = calculatedPriceSets[variant.id] - return variant - }) - } - ) - - validateVariantPricesStep({ variants }) - - return variants + }, }) confirmVariantInventoryWorkflow.runAsStep({ input: { sales_channel_id: salesChannel.id, - variants: variants!, + variants: + variants as unknown as ConfirmVariantInventoryWorkflowInputDTO["variants"], items: input.items!, }, }) - const lineItems = transform({ input, variants }, prepareLineItems) - - validateLineItemPricesStep({ items: lineItems }) + const items = transform({ lineItems }, (data) => { + return data.lineItems.map((item) => { + return item.data as CreateOrderLineItemDTO + }) + }) return new WorkflowResponse( createOrderLineItemsStep({ - items: lineItems, + items: items, }) satisfies OrderAddLineItemWorkflowOutput, { hooks: [setPricingContext] as const, diff --git a/packages/core/core-flows/src/order/workflows/archive-orders.ts b/packages/core/core-flows/src/order/workflows/archive-orders.ts index 19e578ff69..b50e1e2530 100644 --- a/packages/core/core-flows/src/order/workflows/archive-orders.ts +++ b/packages/core/core-flows/src/order/workflows/archive-orders.ts @@ -1,4 +1,4 @@ -import { OrderDTO } from "@medusajs/framework/types" +import type { OrderDTO } from "@medusajs/framework/types" import { OrderWorkflowEvents } from "@medusajs/framework/utils" import { WorkflowData, @@ -26,11 +26,11 @@ export type ArchiveOrdersWorkflowOutput = OrderDTO[] export const archiveOrderWorkflowId = "archive-order-workflow" /** - * This workflow archives one or more orders. It's used by the + * This workflow archives one or more orders. It's used by the * [Archive Order Admin API Route](https://docs.medusajs.com/api/admin#orders_postordersidarchive). - * + * * You can use this workflow within your customizations or your own custom workflows, allowing you to wrap custom logic around archiving orders. - * + * * @example * const { result } = await archiveOrderWorkflow(container) * .run({ @@ -38,9 +38,9 @@ export const archiveOrderWorkflowId = "archive-order-workflow" * orderIds: ["order_123"] * } * }) - * + * * @summary - * + * * Archive one or more orders. */ export const archiveOrderWorkflow = createWorkflow( diff --git a/packages/core/core-flows/src/order/workflows/cancel-order-change.ts b/packages/core/core-flows/src/order/workflows/cancel-order-change.ts index 2524932d2b..548cb86dda 100644 --- a/packages/core/core-flows/src/order/workflows/cancel-order-change.ts +++ b/packages/core/core-flows/src/order/workflows/cancel-order-change.ts @@ -1,16 +1,16 @@ -import { CancelOrderChangeDTO } from "@medusajs/framework/types" +import type { CancelOrderChangeDTO } from "@medusajs/framework/types" import { WorkflowData, createWorkflow } from "@medusajs/framework/workflows-sdk" import { cancelOrderChangeStep } from "../steps" export const cancelOrderChangeWorkflowId = "cancel-order-change" /** * This workflow cancels an order change. - * - * You can use this workflow within your customizations or your own custom workflows, allowing you to wrap custom logic around + * + * You can use this workflow within your customizations or your own custom workflows, allowing you to wrap custom logic around * canceling an order change. - * + * * @summary - * + * * Cancel an order change. */ export const cancelOrderChangeWorkflow = createWorkflow( diff --git a/packages/core/core-flows/src/order/workflows/complete-orders.ts b/packages/core/core-flows/src/order/workflows/complete-orders.ts index c557cbcd20..f9465bdd36 100644 --- a/packages/core/core-flows/src/order/workflows/complete-orders.ts +++ b/packages/core/core-flows/src/order/workflows/complete-orders.ts @@ -1,4 +1,4 @@ -import { AdditionalData } from "@medusajs/framework/types" +import type { AdditionalData } from "@medusajs/framework/types" import { OrderWorkflowEvents } from "@medusajs/framework/utils" import { WorkflowData, @@ -23,12 +23,12 @@ export type CompleteOrdersWorkflowInput = { export const completeOrderWorkflowId = "complete-order-workflow" /** * This workflow marks one or more orders as completed. It's used by the [Complete Cart Admin API Route](https://docs.medusajs.com/api/admin#orders_postordersidcomplete). - * - * This workflow has a hook that allows you to perform custom actions on the completed orders. For example, you can pass under `additional_data` custom data that + * + * This workflow has a hook that allows you to perform custom actions on the completed orders. For example, you can pass under `additional_data` custom data that * allows you to update custom data models linked to the orders. - * + * * You can also use this workflow within your customizations or your own custom workflows, allowing you to wrap custom logic around order completion. - * + * * @example * const { result } = await completeOrderWorkflow(container) * .run({ @@ -39,11 +39,11 @@ export const completeOrderWorkflowId = "complete-order-workflow" * } * } * }) - * + * * @summary - * + * * Complete one or more orders. - * + * * @property hooks.ordersCompleted - This hook is executed after the orders are completed. You can consume this hook to perform custom actions on the completed orders. */ export const completeOrderWorkflow = createWorkflow( diff --git a/packages/core/core-flows/src/order/workflows/create-or-update-order-payment-collection.ts b/packages/core/core-flows/src/order/workflows/create-or-update-order-payment-collection.ts index 686f3d6a55..c0b7951c15 100644 --- a/packages/core/core-flows/src/order/workflows/create-or-update-order-payment-collection.ts +++ b/packages/core/core-flows/src/order/workflows/create-or-update-order-payment-collection.ts @@ -1,4 +1,4 @@ -import { PaymentCollectionDTO } from "@medusajs/framework/types" +import type { PaymentCollectionDTO } from "@medusajs/framework/types" import { MathBN, MedusaError, diff --git a/packages/core/core-flows/src/order/workflows/create-order-change.ts b/packages/core/core-flows/src/order/workflows/create-order-change.ts index 637a41aa44..4e904027f1 100644 --- a/packages/core/core-flows/src/order/workflows/create-order-change.ts +++ b/packages/core/core-flows/src/order/workflows/create-order-change.ts @@ -1,4 +1,7 @@ -import { CreateOrderChangeDTO, OrderChangeDTO } from "@medusajs/framework/types" +import type { + CreateOrderChangeDTO, + OrderChangeDTO, +} from "@medusajs/framework/types" import { WorkflowData, WorkflowResponse, @@ -9,12 +12,12 @@ import { createOrderChangeStep } from "../steps" export const createOrderChangeWorkflowId = "create-order-change" /** * This workflow creates an order change. - * - * You can use this workflow within your customizations or your own custom workflows, allowing you to wrap custom logic around + * + * You can use this workflow within your customizations or your own custom workflows, allowing you to wrap custom logic around * creating an order change. - * + * * @summary - * + * * Create an order change. */ export const createOrderChangeWorkflow = createWorkflow( diff --git a/packages/core/core-flows/src/order/workflows/create-order-credit-lines.ts b/packages/core/core-flows/src/order/workflows/create-order-credit-lines.ts index ae8d47510a..9abd9266ec 100644 --- a/packages/core/core-flows/src/order/workflows/create-order-credit-lines.ts +++ b/packages/core/core-flows/src/order/workflows/create-order-credit-lines.ts @@ -1,4 +1,7 @@ -import { CreateOrderCreditLineDTO, OrderDTO } from "@medusajs/framework/types" +import type { + CreateOrderCreditLineDTO, + OrderDTO, +} from "@medusajs/framework/types" import { ChangeActionType, MathBN, diff --git a/packages/core/core-flows/src/order/workflows/create-order.ts b/packages/core/core-flows/src/order/workflows/create-order.ts index 141814a3d0..eeeb8a3432 100644 --- a/packages/core/core-flows/src/order/workflows/create-order.ts +++ b/packages/core/core-flows/src/order/workflows/create-order.ts @@ -1,6 +1,5 @@ -import { AdditionalData, CreateOrderDTO } from "@medusajs/framework/types" +import type { AdditionalData, CreateOrderDTO } from "@medusajs/framework/types" import { - MedusaError, PromotionActions, deduplicate, isDefined, @@ -15,12 +14,10 @@ import { transform, when, } from "@medusajs/framework/workflows-sdk" -import { getVariantPriceSetsStep } from "../../cart" import { findOneOrAnyRegionStep } from "../../cart/steps/find-one-or-any-region" import { findOrCreateCustomerStep } from "../../cart/steps/find-or-create-customer" import { findSalesChannelStep } from "../../cart/steps/find-sales-channel" import { validateLineItemPricesStep } from "../../cart/steps/validate-line-item-prices" -import { validateVariantPricesStep } from "../../cart/steps/validate-variant-prices" import { requiredVariantFieldsForInventoryConfirmation } from "../../cart/utils/prepare-confirm-inventory-input" import { PrepareLineItemDataInput, @@ -28,6 +25,7 @@ import { } from "../../cart/utils/prepare-line-item-data" import { pricingContextResult } from "../../cart/utils/schemas" import { confirmVariantInventoryWorkflow } from "../../cart/workflows/confirm-variant-inventory" +import { getVariantsAndItemsWithPrices } from "../../cart/workflows/get-variants-and-items-with-prices" import { useQueryGraphStep } from "../../common" import { refreshDraftOrderAdjustmentsWorkflow } from "../../draft-order/workflows/refresh-draft-order-adjustments" import { createOrdersStep } from "../steps" @@ -208,22 +206,6 @@ export const createOrderWorkflow = createWorkflow( ) const setPricingContextResult = setPricingContext.getResult() - const pricingContext = transform( - { input, region, customerData, setPricingContextResult }, - (data) => { - if (!data.region) { - throw new MedusaError(MedusaError.Types.NOT_FOUND, "Region not found") - } - - return { - ...(data.setPricingContextResult ? data.setPricingContextResult : {}), - currency_code: data.input.currency_code ?? data.region.currency_code, - region_id: data.region.id, - customer_id: data.customerData.customer?.id, - } - } - ) - /** * Only fetch variants with calculated prices if needed, otherwise only fetch variants without * calculated prices. @@ -270,70 +252,32 @@ export const createOrderWorkflow = createWorkflow( /** * Fetch all variants for which we need to calculate the price. */ - const variantsWithCalculatedPrice = when( + const variantsAndItemsWithCalculatedPrice = when( "fetch-variants-with-calculated-price", { variantIdsForPriceCalculation }, ({ variantIdsForPriceCalculation }) => { return !!variantIdsForPriceCalculation.length } ).then(() => { - const calculatePricesContext = transform( - { items: input.items, variantIdsForPriceCalculation, pricingContext }, - (data) => { - const baseContext = data.pricingContext - - return data.variantIdsForPriceCalculation - ?.map((variant) => { - // Since we retrieve the variant ids from the item, it is not possible to not find the item back from the variant id. - const item = data.items?.find( - (item) => item.variant_id === variant - )! - - return { - variantId: variant, - context: { - ...baseContext, - quantity: item.quantity, - }, - } - }) - .filter(Boolean) - } - ) - - const { data: variants } = useQueryGraphStep({ - entity: "variants", - fields: deduplicate([ - ...productVariantsFields, - ...requiredVariantFieldsForInventoryConfirmation, - ]), - filters: { - id: variantIdsForPriceCalculation, + return getVariantsAndItemsWithPrices.runAsStep({ + input: { + cart: { + currency_code: input.currency_code, + region, + region_id: region.id, + customer_id: customerData.customer?.id, + }, + items: input.items, + setPricingContextResult: setPricingContextResult!, + variants: { + id: variantIdsForPriceCalculation, + fields: deduplicate([ + ...productVariantsFields, + ...requiredVariantFieldsForInventoryConfirmation, + ]), + }, }, - }).config({ name: "query-variants-to-calculate-prices" }) - - const calculatedPriceSets = getVariantPriceSetsStep({ - data: calculatePricesContext, }) - - const reconstructedVariants = transform( - { - variants, - calculatedPriceSets, - }, - (data) => { - return data.variants.map((variant) => { - variant.calculated_price = data.calculatedPriceSets[variant.id] - return variant - }) - } - ) - - validateVariantPricesStep({ variants: reconstructedVariants }).config({ - name: "validate-variants-with-calculated-price", - }) - - return reconstructedVariants }) /** @@ -342,12 +286,12 @@ export const createOrderWorkflow = createWorkflow( const variants = transform( { variantsWithoutCalculatedPrice, - variantsWithCalculatedPrice, + variantsAndItemsWithCalculatedPrice, }, (data) => { return [ ...data.variantsWithoutCalculatedPrice, - ...(data.variantsWithCalculatedPrice ?? []), + ...(data.variantsAndItemsWithCalculatedPrice?.variants ?? []), ] } ) @@ -365,7 +309,49 @@ export const createOrderWorkflow = createWorkflow( getOrderInput ) - const lineItems = transform({ input, variants }, prepareLineItems) + const lineItems = transform( + { + input, + variants, + variantsWithoutCalculatedPrice, + variantsAndItemsWithCalculatedPrice, + }, + (data) => { + const itemsForVariantWithCalculatedPrice = + data.variantsAndItemsWithCalculatedPrice?.lineItems?.map( + (i) => i.data + ) ?? [] + + // all other items that are not in the itemsForVariantWithCalculatedPrice + const itemsForVariantWithoutCalculatedPrice = data.input.items?.filter( + (item) => { + return !data.variantsAndItemsWithCalculatedPrice?.lineItems?.find( + (i) => + i.data.id === (item as any).id || + i.data.variant_id === item.variant_id || + (i.data.title === item.title && + i.data.subtitle === item.subtitle && + i.data.thumbnail === item.thumbnail) + ) + } + ) + + if (!itemsForVariantWithoutCalculatedPrice?.length) { + return itemsForVariantWithCalculatedPrice + } + + const preparedItemsForVariantWithoutCalculatedPrice = prepareLineItems({ + input: { + items: itemsForVariantWithoutCalculatedPrice, + }, + variants: data.variantsWithoutCalculatedPrice, + }) + + return preparedItemsForVariantWithoutCalculatedPrice.concat( + ...itemsForVariantWithCalculatedPrice + ) + } + ) validateLineItemPricesStep({ items: lineItems }) diff --git a/packages/core/core-flows/src/order/workflows/decline-order-change.ts b/packages/core/core-flows/src/order/workflows/decline-order-change.ts index b5807318b0..c2e877665a 100644 --- a/packages/core/core-flows/src/order/workflows/decline-order-change.ts +++ b/packages/core/core-flows/src/order/workflows/decline-order-change.ts @@ -1,16 +1,16 @@ -import { DeclineOrderChangeDTO } from "@medusajs/framework/types" +import type { DeclineOrderChangeDTO } from "@medusajs/framework/types" import { WorkflowData, createWorkflow } from "@medusajs/framework/workflows-sdk" import { declineOrderChangeStep } from "../steps" export const declineOrderChangeWorkflowId = "decline-order-change" /** * This workflow declines an order change. - * + * * You can use this workflow within your customizations or your own custom workflows, allowing you to wrap custom logic around * declining an order change. - * + * * @summary - * + * * Decline an order change. */ export const declineOrderChangeWorkflow = createWorkflow( diff --git a/packages/core/core-flows/src/order/workflows/delete-order-payment-collection.ts b/packages/core/core-flows/src/order/workflows/delete-order-payment-collection.ts index 11794dfd47..7d052647ec 100644 --- a/packages/core/core-flows/src/order/workflows/delete-order-payment-collection.ts +++ b/packages/core/core-flows/src/order/workflows/delete-order-payment-collection.ts @@ -1,4 +1,4 @@ -import { PaymentCollectionDTO } from "@medusajs/framework/types" +import type { PaymentCollectionDTO } from "@medusajs/framework/types" import { MedusaError, Modules, @@ -39,12 +39,12 @@ export type DeleteOrderPaymentCollectionsInput = { export const deleteOrderPaymentCollectionsId = "delete-order-payment-collectionworkflow" /** - * This workflow deletes one or more payment collections of an order. It's used by the + * This workflow deletes one or more payment collections of an order. It's used by the * [Delete Payment Collection API Route](https://docs.medusajs.com/api/admin#payment-collections_deletepaymentcollectionsid). - * + * * You can use this workflow within your customizations or your own custom workflows, allowing you to wrap custom logic around * deleting a payment collection of an order. - * + * * @example * const { result } = await deleteOrderPaymentCollections(container) * .run({ @@ -52,14 +52,16 @@ export const deleteOrderPaymentCollectionsId = * id: "order_123" * } * }) - * + * * @summary - * + * * Delete a payment collection of an order. */ export const deleteOrderPaymentCollections = createWorkflow( deleteOrderPaymentCollectionsId, - (input: WorkflowData): WorkflowData => { + ( + input: WorkflowData + ): WorkflowData => { const paymentCollection = useRemoteQueryStep({ entry_point: "payment_collection", fields: ["id", "status"], diff --git a/packages/core/core-flows/src/order/workflows/exchange/refresh-shipping.ts b/packages/core/core-flows/src/order/workflows/exchange/refresh-shipping.ts index 0983ecb06a..09145eeb03 100644 --- a/packages/core/core-flows/src/order/workflows/exchange/refresh-shipping.ts +++ b/packages/core/core-flows/src/order/workflows/exchange/refresh-shipping.ts @@ -1,4 +1,4 @@ -import { OrderChangeDTO } from "@medusajs/framework/types" +import type { OrderChangeDTO } from "@medusajs/framework/types" import { ChangeActionType, OrderChangeStatus } from "@medusajs/framework/utils" import { WorkflowData, diff --git a/packages/core/core-flows/src/order/workflows/get-order-detail.ts b/packages/core/core-flows/src/order/workflows/get-order-detail.ts index 7c272e2fd5..6625ce3784 100644 --- a/packages/core/core-flows/src/order/workflows/get-order-detail.ts +++ b/packages/core/core-flows/src/order/workflows/get-order-detail.ts @@ -1,4 +1,4 @@ -import { OrderDTO, OrderDetailDTO } from "@medusajs/framework/types" +import type { OrderDTO, OrderDetailDTO } from "@medusajs/framework/types" import { deduplicate } from "@medusajs/framework/utils" import { WorkflowData, @@ -19,7 +19,7 @@ export type GetOrderDetailWorkflowInput = { /** * Additional filters to apply on the retrieved order. */ - filters?: { + filters?: { /** * Whether to retrieve a draft order. */ @@ -51,10 +51,10 @@ export const getOrderDetailWorkflowId = "get-order-detail" * This workflow retrieves an order's details. It's used by many API routes, including * [Get an Order Admin API Route](https://docs.medusajs.com/api/admin#orders_getordersid), and * [Get an Order Store API Route](https://docs.medusajs.com/api/store#orders_getordersid). - * - * You can use this workflow within your customizations or your own custom workflows, allowing you to retrieve an + * + * You can use this workflow within your customizations or your own custom workflows, allowing you to retrieve an * order's details in your custom flows. - * + * * @example * const { result } = await getOrderDetailWorkflow(container) * .run({ @@ -63,9 +63,9 @@ export const getOrderDetailWorkflowId = "get-order-detail" * fields: ["id", "status", "items"] * } * }) - * + * * @summary - * + * * Retrieve an order's details. */ export const getOrderDetailWorkflow = createWorkflow( diff --git a/packages/core/core-flows/src/order/workflows/get-orders-list.ts b/packages/core/core-flows/src/order/workflows/get-orders-list.ts index e03e11fcce..52683b3822 100644 --- a/packages/core/core-flows/src/order/workflows/get-orders-list.ts +++ b/packages/core/core-flows/src/order/workflows/get-orders-list.ts @@ -1,4 +1,4 @@ -import { OrderDTO, OrderDetailDTO } from "@medusajs/framework/types" +import type { OrderDTO, OrderDetailDTO } from "@medusajs/framework/types" import { deduplicate } from "@medusajs/framework/utils" import { WorkflowData, @@ -13,16 +13,16 @@ import { } from "../utils/aggregate-status" /** - * The retrieved list of orders. If you passed pagination configurations in the + * The retrieved list of orders. If you passed pagination configurations in the * input, the response will return an object that includes the list of * orders and their pagination details. Otherwise, only the list of orders are returned. */ export type GetOrdersListWorkflowOutput = | OrderDTO[] | { - /** - * The list of orders. - */ + /** + * The list of orders. + */ rows: OrderDTO[] /** * Pagination details. @@ -72,17 +72,17 @@ export type GetOrdersListWorkflowInput = { export const getOrdersListWorkflowId = "get-orders-list" /** - * This workflow retrieves a list of orders. It's used by the + * This workflow retrieves a list of orders. It's used by the * [List Orders Admin API Route](https://docs.medusajs.com/api/admin#orders_getorders), and the * [List Orders Store API Route](https://docs.medusajs.com/api/store#orders_getorders). - * + * * You can use this workflow within your customizations or your own custom workflows, allowing you to retrieve a list of * orders in your custom flows. For example, you can retrieve the list of orders to export them * to a third-party system. - * + * * @example * To retrieve the list of orders: - * + * * ```ts * const { result } = await getOrdersListWorkflow(container) * .run({ @@ -91,9 +91,9 @@ export const getOrdersListWorkflowId = "get-orders-list" * } * }) * ``` - * + * * To retrieve the list of orders with pagination: - * + * * ```ts * const { result } = await getOrdersListWorkflow(container) * .run({ @@ -106,9 +106,9 @@ export const getOrdersListWorkflowId = "get-orders-list" * } * }) * ``` - * + * * @summary - * + * * Retrieve a list of orders. */ export const getOrdersListWorkflow = createWorkflow( diff --git a/packages/core/core-flows/src/order/workflows/list-shipping-options-for-order.ts b/packages/core/core-flows/src/order/workflows/list-shipping-options-for-order.ts index 13bce9c44b..80f360a947 100644 --- a/packages/core/core-flows/src/order/workflows/list-shipping-options-for-order.ts +++ b/packages/core/core-flows/src/order/workflows/list-shipping-options-for-order.ts @@ -4,7 +4,7 @@ import { WorkflowData, WorkflowResponse, } from "@medusajs/framework/workflows-sdk" -import { ListShippingOptionsForOrderWorkflowInput } from "@medusajs/types" +import type { ListShippingOptionsForOrderWorkflowInput } from "@medusajs/framework/types" import { useQueryGraphStep, validatePresenceOfStep } from "../../common" import { useRemoteQueryStep } from "../../common/steps/use-remote-query" diff --git a/packages/core/core-flows/src/order/workflows/mark-payment-collection-as-paid.ts b/packages/core/core-flows/src/order/workflows/mark-payment-collection-as-paid.ts index 9e8cf498b4..050fadbdc4 100644 --- a/packages/core/core-flows/src/order/workflows/mark-payment-collection-as-paid.ts +++ b/packages/core/core-flows/src/order/workflows/mark-payment-collection-as-paid.ts @@ -1,4 +1,4 @@ -import { PaymentCollectionDTO } from "@medusajs/framework/types" +import type { PaymentCollectionDTO } from "@medusajs/framework/types" import { MedusaError } from "@medusajs/framework/utils" import { WorkflowData, diff --git a/packages/core/core-flows/src/order/workflows/order-edit/cancel-begin-order-edit.ts b/packages/core/core-flows/src/order/workflows/order-edit/cancel-begin-order-edit.ts index 049fbab9cc..da3608180e 100644 --- a/packages/core/core-flows/src/order/workflows/order-edit/cancel-begin-order-edit.ts +++ b/packages/core/core-flows/src/order/workflows/order-edit/cancel-begin-order-edit.ts @@ -1,4 +1,4 @@ -import { OrderChangeDTO, OrderDTO } from "@medusajs/framework/types" +import type { OrderChangeDTO, OrderDTO } from "@medusajs/framework/types" import { ChangeActionType, OrderChangeStatus, diff --git a/packages/core/core-flows/src/order/workflows/payments/create-order-refund-credit-lines.ts b/packages/core/core-flows/src/order/workflows/payments/create-order-refund-credit-lines.ts index beac0e7a8f..a365033fb7 100644 --- a/packages/core/core-flows/src/order/workflows/payments/create-order-refund-credit-lines.ts +++ b/packages/core/core-flows/src/order/workflows/payments/create-order-refund-credit-lines.ts @@ -1,4 +1,4 @@ -import { BigNumberInput, OrderDTO } from "@medusajs/framework/types" +import type { BigNumberInput, OrderDTO } from "@medusajs/framework/types" import { ChangeActionType, OrderChangeStatus, diff --git a/packages/core/core-flows/src/order/workflows/payments/refund-captured-payments.ts b/packages/core/core-flows/src/order/workflows/payments/refund-captured-payments.ts index e65b03b565..4da763ee10 100644 --- a/packages/core/core-flows/src/order/workflows/payments/refund-captured-payments.ts +++ b/packages/core/core-flows/src/order/workflows/payments/refund-captured-payments.ts @@ -1,4 +1,4 @@ -import { PaymentDTO } from "@medusajs/framework/types" +import type { PaymentDTO } from "@medusajs/framework/types" import { deepFlatMap, MathBN } from "@medusajs/framework/utils" import { createWorkflow, diff --git a/packages/core/core-flows/src/order/workflows/return/cancel-receive-return.ts b/packages/core/core-flows/src/order/workflows/return/cancel-receive-return.ts index 6f21d69566..457d4755a7 100644 --- a/packages/core/core-flows/src/order/workflows/return/cancel-receive-return.ts +++ b/packages/core/core-flows/src/order/workflows/return/cancel-receive-return.ts @@ -1,4 +1,8 @@ -import { OrderChangeDTO, OrderDTO, ReturnDTO } from "@medusajs/framework/types" +import type { + OrderChangeDTO, + OrderDTO, + ReturnDTO, +} from "@medusajs/framework/types" import { OrderChangeStatus } from "@medusajs/framework/utils" import { WorkflowData, @@ -33,14 +37,14 @@ export type CancelReceiveReturnValidationStepInput = { /** * This step validates that a return receival can be canceled. * If the order or return is canceled, or the order change is not active, the step will throw an error. - * + * * :::note - * + * * You can retrieve an order, return, and order change details using [Query](https://docs.medusajs.com/learn/fundamentals/module-links/query), * or [useQueryGraphStep](https://docs.medusajs.com/resources/references/medusa-workflows/steps/useQueryGraphStep). - * + * * ::: - * + * * @example * const data = cancelReceiveReturnValidationStep({ * order: { @@ -84,10 +88,10 @@ export const cancelReturnReceiveWorkflowId = "cancel-receive-return" /** * This workflow cancels a return receival. It's used by the * [Cancel Return Receival Admin API Route](https://docs.medusajs.com/api/admin#returns_deletereturnsidreceive). - * + * * You can use this workflow within your customizations or your own custom workflows, allowing you * to cancel a return receival in your custom flow. - * + * * @example * const { result } = await cancelReturnReceiveWorkflow(container) * .run({ @@ -95,9 +99,9 @@ export const cancelReturnReceiveWorkflowId = "cancel-receive-return" * return_id: "return_123", * } * }) - * + * * @summary - * + * * Cancel a return receival. */ export const cancelReturnReceiveWorkflow = createWorkflow( diff --git a/packages/core/core-flows/src/order/workflows/return/cancel-request-return.ts b/packages/core/core-flows/src/order/workflows/return/cancel-request-return.ts index 7ddd756b5d..4b4ae655d2 100644 --- a/packages/core/core-flows/src/order/workflows/return/cancel-request-return.ts +++ b/packages/core/core-flows/src/order/workflows/return/cancel-request-return.ts @@ -1,4 +1,8 @@ -import { OrderChangeDTO, OrderDTO, ReturnDTO } from "@medusajs/framework/types" +import type { + OrderChangeDTO, + OrderDTO, + ReturnDTO, +} from "@medusajs/framework/types" import { ChangeActionType, OrderChangeStatus } from "@medusajs/framework/utils" import { WorkflowData, @@ -38,16 +42,16 @@ export type CancelRequestReturnValidationStepInput = { /** * This step validates that a requested return can be canceled. - * If the order or return is canceled, or the order change is not active, + * If the order or return is canceled, or the order change is not active, * the step will throw an error. - * + * * :::note - * + * * You can retrieve an order, return, and order change details using [Query](https://docs.medusajs.com/learn/fundamentals/module-links/query), * or [useQueryGraphStep](https://docs.medusajs.com/resources/references/medusa-workflows/steps/useQueryGraphStep). - * + * * ::: - * + * * @example * const data = cancelRequestReturnValidationStep({ * order: { @@ -91,10 +95,10 @@ export const cancelReturnRequestWorkflowId = "cancel-return-request" /** * This workflow cancels a requested return. It's used by the * [Cancel Return Request API Route](https://docs.medusajs.com/api/admin#returns_deletereturnsidrequest). - * + * * You can use this workflow within your customizations or your own custom workflows, allowing you * to cancel a return request in your custom flow. - * + * * @example * const { result } = await cancelReturnRequestWorkflow(container) * .run({ @@ -102,9 +106,9 @@ export const cancelReturnRequestWorkflowId = "cancel-return-request" * return_id: "return_123", * } * }) - * + * * @summary - * + * * Cancel a requested return. */ export const cancelReturnRequestWorkflow = createWorkflow( diff --git a/packages/core/core-flows/src/order/workflows/return/receive-complete-return.ts b/packages/core/core-flows/src/order/workflows/return/receive-complete-return.ts index db90fa0770..45c758a079 100644 --- a/packages/core/core-flows/src/order/workflows/return/receive-complete-return.ts +++ b/packages/core/core-flows/src/order/workflows/return/receive-complete-return.ts @@ -1,4 +1,4 @@ -import { OrderWorkflow } from "@medusajs/framework/types" +import type { OrderWorkflow } from "@medusajs/framework/types" import { WorkflowData, WorkflowResponse, @@ -7,7 +7,7 @@ import { } from "@medusajs/framework/workflows-sdk" import { useRemoteQueryStep } from "../../../common" -import { ReturnDTO } from "@medusajs/framework/types" +import type { ReturnDTO } from "@medusajs/framework/types" import { receiveReturnStep } from "../../steps/return/receive-return" import { throwIfIsCancelled, @@ -31,14 +31,14 @@ export type ReceiveCompleteReturnValidationStepInput = { /** * This step validates that a return can be received and completed. * If the return is canceled or the items do not exist in the return, the step will throw an error. - * + * * :::note - * + * * You can retrieve a return details using [Query](https://docs.medusajs.com/learn/fundamentals/module-links/query), * or [useQueryGraphStep](https://docs.medusajs.com/resources/references/medusa-workflows/steps/useQueryGraphStep). - * + * * ::: - * + * * @example * const data = receiveCompleteReturnValidationStep({ * orderReturn: { @@ -59,10 +59,7 @@ export type ReceiveCompleteReturnValidationStepInput = { export const receiveCompleteReturnValidationStep = createStep( "receive-return-order-validation", async function ( - { - orderReturn, - input, - }: ReceiveCompleteReturnValidationStepInput, + { orderReturn, input }: ReceiveCompleteReturnValidationStepInput, context ) { throwIfIsCancelled(orderReturn, "Return") @@ -73,10 +70,10 @@ export const receiveCompleteReturnValidationStep = createStep( export const receiveAndCompleteReturnOrderWorkflowId = "receive-return-order" /** * This workflow marks a return as received and completes it. - * + * * You can use this workflow within your customizations or your own custom workflows, allowing you * to receive and complete a return. - * + * * @example * const { result } = await receiveAndCompleteReturnOrderWorkflow(container) * .run({ @@ -90,9 +87,9 @@ export const receiveAndCompleteReturnOrderWorkflowId = "receive-return-order" * ] * } * }) - * + * * @summary - * + * * Receive and complete a return. */ export const receiveAndCompleteReturnOrderWorkflow = createWorkflow( diff --git a/packages/core/core-flows/src/order/workflows/return/refresh-shipping.ts b/packages/core/core-flows/src/order/workflows/return/refresh-shipping.ts index 802fff4ce6..c845793792 100644 --- a/packages/core/core-flows/src/order/workflows/return/refresh-shipping.ts +++ b/packages/core/core-flows/src/order/workflows/return/refresh-shipping.ts @@ -1,4 +1,4 @@ -import { OrderChangeDTO } from "@medusajs/framework/types" +import type { OrderChangeDTO } from "@medusajs/framework/types" import { ChangeActionType, OrderChangeStatus } from "@medusajs/framework/utils" import { WorkflowData, diff --git a/packages/core/core-flows/src/order/workflows/transfer/accept-order-transfer.ts b/packages/core/core-flows/src/order/workflows/transfer/accept-order-transfer.ts index 9ead905357..cb765a0881 100644 --- a/packages/core/core-flows/src/order/workflows/transfer/accept-order-transfer.ts +++ b/packages/core/core-flows/src/order/workflows/transfer/accept-order-transfer.ts @@ -10,7 +10,7 @@ import { createWorkflow, transform, } from "@medusajs/framework/workflows-sdk" -import { OrderPreviewDTO } from "@medusajs/types" +import type { OrderPreviewDTO } from "@medusajs/framework/types" import { ChangeActionType, MedusaError, diff --git a/packages/core/core-flows/src/order/workflows/transfer/request-order-transfer.ts b/packages/core/core-flows/src/order/workflows/transfer/request-order-transfer.ts index f8794b7f22..e9cb07a2bb 100644 --- a/packages/core/core-flows/src/order/workflows/transfer/request-order-transfer.ts +++ b/packages/core/core-flows/src/order/workflows/transfer/request-order-transfer.ts @@ -1,4 +1,4 @@ -import { OrderDTO, OrderWorkflow } from "@medusajs/framework/types" +import type { OrderDTO, OrderWorkflow } from "@medusajs/framework/types" import { WorkflowData, WorkflowResponse, @@ -6,7 +6,7 @@ import { createWorkflow, transform, } from "@medusajs/framework/workflows-sdk" -import { CustomerDTO, OrderPreviewDTO } from "@medusajs/types" +import type { CustomerDTO, OrderPreviewDTO } from "@medusajs/framework/types" import { v4 as uid } from "uuid" import { emitEventStep, useRemoteQueryStep } from "../../../common" @@ -39,14 +39,14 @@ export type RequestOrderTransferValidationStepInput = { * This step validates that an order transfer can be requested. If the customer * is a guest customer, or the order already belongs to a registered customer, * the step throws an error. - * + * * :::note - * + * * You can retrieve an order and customer details using [Query](https://docs.medusajs.com/learn/fundamentals/module-links/query), * or [useQueryGraphStep](https://docs.medusajs.com/resources/references/medusa-workflows/steps/useQueryGraphStep). - * + * * ::: - * + * * @example * const data = requestOrderTransferValidationStep({ * order: { @@ -87,12 +87,12 @@ export const requestOrderTransferWorkflowId = "request-order-transfer-workflow" /** * This workflow requests an order transfer from a guest customer to a registered customer. It can be requested by an admin user or a customer. * If a customer requested the transfer, the `logged_in_user` input property should be the same as the customer's ID. - * + * * This workflow is used by the [Request Order Transfer Store API Route](https://docs.medusajs.com/api/store#orders_postordersidtransferrequest), * and the [Request Order Transfer Admin API Route](https://docs.medusajs.com/api/admin#orders_postordersidtransfer). - * + * * You can use this workflow within your customizations or your own custom workflows, allowing you to build a custom flow around requesting an order transfer. - * + * * @example * const { result } = await requestOrderTransferWorkflow(container) * .run({ @@ -102,9 +102,9 @@ export const requestOrderTransferWorkflowId = "request-order-transfer-workflow" * logged_in_user: "user_123", * } * }) - * + * * @summary - * + * * Request a transfer of an order to a customer. */ export const requestOrderTransferWorkflow = createWorkflow( diff --git a/packages/core/core-flows/src/order/workflows/update-order.ts b/packages/core/core-flows/src/order/workflows/update-order.ts index 1bfe2afd09..526b25066e 100644 --- a/packages/core/core-flows/src/order/workflows/update-order.ts +++ b/packages/core/core-flows/src/order/workflows/update-order.ts @@ -1,4 +1,4 @@ -import { OrderDTO, OrderWorkflow } from "@medusajs/framework/types" +import type { OrderDTO, OrderWorkflow } from "@medusajs/framework/types" import { MedusaError, OrderWorkflowEvents, @@ -15,7 +15,7 @@ import { OrderPreviewDTO, RegisterOrderChangeDTO, UpdateOrderDTO, -} from "@medusajs/types" +} from "@medusajs/framework/types" import { emitEventStep, useQueryGraphStep } from "../../common" import { diff --git a/packages/core/core-flows/src/order/workflows/update-tax-lines.ts b/packages/core/core-flows/src/order/workflows/update-tax-lines.ts index 3333f45471..29924d4dee 100644 --- a/packages/core/core-flows/src/order/workflows/update-tax-lines.ts +++ b/packages/core/core-flows/src/order/workflows/update-tax-lines.ts @@ -1,4 +1,4 @@ -import { OrderWorkflowDTO } from "@medusajs/framework/types" +import type { OrderWorkflowDTO } from "@medusajs/framework/types" import { WorkflowData, createWorkflow, diff --git a/packages/core/core-flows/src/payment-collection/steps/cancel-payment.ts b/packages/core/core-flows/src/payment-collection/steps/cancel-payment.ts index adbca23a20..a88a9d4b35 100644 --- a/packages/core/core-flows/src/payment-collection/steps/cancel-payment.ts +++ b/packages/core/core-flows/src/payment-collection/steps/cancel-payment.ts @@ -1,4 +1,4 @@ -import { IPaymentModuleService, Logger } from "@medusajs/framework/types" +import type { IPaymentModuleService, Logger } from "@medusajs/framework/types" import { ContainerRegistrationKeys, Modules, diff --git a/packages/core/core-flows/src/payment-collection/steps/delete-refund-reasons.ts b/packages/core/core-flows/src/payment-collection/steps/delete-refund-reasons.ts index 3221f5050e..fc6178c7c9 100644 --- a/packages/core/core-flows/src/payment-collection/steps/delete-refund-reasons.ts +++ b/packages/core/core-flows/src/payment-collection/steps/delete-refund-reasons.ts @@ -1,4 +1,4 @@ -import { IPaymentModuleService } from "@medusajs/framework/types" +import type { IPaymentModuleService } from "@medusajs/framework/types" import { Modules } from "@medusajs/framework/utils" import { createStep, StepResponse } from "@medusajs/framework/workflows-sdk" diff --git a/packages/core/core-flows/src/payment-collection/workflows/cancel-payment-collection.ts b/packages/core/core-flows/src/payment-collection/workflows/cancel-payment-collection.ts index e6fe7c38ec..beff976c73 100644 --- a/packages/core/core-flows/src/payment-collection/workflows/cancel-payment-collection.ts +++ b/packages/core/core-flows/src/payment-collection/workflows/cancel-payment-collection.ts @@ -1,4 +1,4 @@ -import { PaymentCollectionDTO } from "@medusajs/framework/types" +import type { PaymentCollectionDTO } from "@medusajs/framework/types" import { MedusaError, PaymentCollectionStatus } from "@medusajs/framework/utils" import { WorkflowData, diff --git a/packages/core/core-flows/src/payment/steps/cancel-payment.ts b/packages/core/core-flows/src/payment/steps/cancel-payment.ts index 989d6b0c44..5ade9126fb 100644 --- a/packages/core/core-flows/src/payment/steps/cancel-payment.ts +++ b/packages/core/core-flows/src/payment/steps/cancel-payment.ts @@ -1,4 +1,4 @@ -import { IPaymentModuleService, Logger } from "@medusajs/framework/types" +import type { IPaymentModuleService, Logger } from "@medusajs/framework/types" import { ContainerRegistrationKeys, Modules, diff --git a/packages/core/core-flows/src/payment/workflows/capture-payment.ts b/packages/core/core-flows/src/payment/workflows/capture-payment.ts index 99c4307634..e9db9d2c09 100644 --- a/packages/core/core-flows/src/payment/workflows/capture-payment.ts +++ b/packages/core/core-flows/src/payment/workflows/capture-payment.ts @@ -1,4 +1,4 @@ -import { BigNumberInput, PaymentDTO } from "@medusajs/framework/types" +import type { BigNumberInput, PaymentDTO } from "@medusajs/framework/types" import { PaymentEvents } from "@medusajs/framework/utils" import { WorkflowData, diff --git a/packages/core/core-flows/src/payment/workflows/process-payment.ts b/packages/core/core-flows/src/payment/workflows/process-payment.ts index 7c8e97943a..1855f56b43 100644 --- a/packages/core/core-flows/src/payment/workflows/process-payment.ts +++ b/packages/core/core-flows/src/payment/workflows/process-payment.ts @@ -1,4 +1,4 @@ -import { WebhookActionResult } from "@medusajs/types" +import type { WebhookActionResult } from "@medusajs/framework/types" import { PaymentActions } from "@medusajs/utils" import { createWorkflow, when } from "@medusajs/workflows-sdk" import { useQueryGraphStep } from "../../common" diff --git a/packages/core/core-flows/src/payment/workflows/refund-payment.ts b/packages/core/core-flows/src/payment/workflows/refund-payment.ts index 89c406a92c..6b30c219f5 100644 --- a/packages/core/core-flows/src/payment/workflows/refund-payment.ts +++ b/packages/core/core-flows/src/payment/workflows/refund-payment.ts @@ -1,4 +1,8 @@ -import { BigNumberInput, OrderDTO, PaymentDTO } from "@medusajs/framework/types" +import type { + BigNumberInput, + OrderDTO, + PaymentDTO, +} from "@medusajs/framework/types" import { MathBN, MedusaError, PaymentEvents } from "@medusajs/framework/utils" import { WorkflowData, diff --git a/packages/core/core-flows/src/payment/workflows/refund-payments.ts b/packages/core/core-flows/src/payment/workflows/refund-payments.ts index 55fb6c76d9..156637235f 100644 --- a/packages/core/core-flows/src/payment/workflows/refund-payments.ts +++ b/packages/core/core-flows/src/payment/workflows/refund-payments.ts @@ -1,4 +1,4 @@ -import { BigNumberInput, PaymentDTO } from "@medusajs/framework/types" +import type { BigNumberInput, PaymentDTO } from "@medusajs/framework/types" import { isDefined, MathBN, MedusaError } from "@medusajs/framework/utils" import { createStep, diff --git a/packages/core/core-flows/src/price-list/steps/delete-price-lists.ts b/packages/core/core-flows/src/price-list/steps/delete-price-lists.ts index 4ea7fbdcca..eaee0748f6 100644 --- a/packages/core/core-flows/src/price-list/steps/delete-price-lists.ts +++ b/packages/core/core-flows/src/price-list/steps/delete-price-lists.ts @@ -1,4 +1,4 @@ -import { IPricingModuleService } from "@medusajs/framework/types" +import type { IPricingModuleService } from "@medusajs/framework/types" import { Modules } from "@medusajs/framework/utils" import { StepResponse, createStep } from "@medusajs/framework/workflows-sdk" diff --git a/packages/core/core-flows/src/price-list/steps/get-existing-price-lists-price-ids.ts b/packages/core/core-flows/src/price-list/steps/get-existing-price-lists-price-ids.ts index 76b08ae23a..d4f74ec36e 100644 --- a/packages/core/core-flows/src/price-list/steps/get-existing-price-lists-price-ids.ts +++ b/packages/core/core-flows/src/price-list/steps/get-existing-price-lists-price-ids.ts @@ -1,4 +1,4 @@ -import { IPricingModuleService } from "@medusajs/framework/types" +import type { IPricingModuleService } from "@medusajs/framework/types" import { Modules } from "@medusajs/framework/utils" import { StepResponse, createStep } from "@medusajs/framework/workflows-sdk" @@ -26,8 +26,7 @@ export const getExistingPriceListsPriceIdsStep = createStep( getExistingPriceListsPriceIdsStepId, async (data: GetExistingPriceListsPriceIdsStepInput, { container }) => { const { price_list_ids: priceListIds = [] } = data - const priceListPriceIdsMap: - GetExistingPriceListsPriceIdsStepOutput = {} + const priceListPriceIdsMap: GetExistingPriceListsPriceIdsStepOutput = {} const pricingModule = container.resolve( Modules.PRICING ) diff --git a/packages/core/core-flows/src/price-list/steps/remove-price-list-prices.ts b/packages/core/core-flows/src/price-list/steps/remove-price-list-prices.ts index 168bc7a33d..d21a945272 100644 --- a/packages/core/core-flows/src/price-list/steps/remove-price-list-prices.ts +++ b/packages/core/core-flows/src/price-list/steps/remove-price-list-prices.ts @@ -1,4 +1,4 @@ -import { IPricingModuleService } from "@medusajs/framework/types" +import type { IPricingModuleService } from "@medusajs/framework/types" import { Modules } from "@medusajs/framework/utils" import { StepResponse, createStep } from "@medusajs/framework/workflows-sdk" diff --git a/packages/core/core-flows/src/price-list/workflows/update-price-lists.ts b/packages/core/core-flows/src/price-list/workflows/update-price-lists.ts index 03ae899417..b6fff12761 100644 --- a/packages/core/core-flows/src/price-list/workflows/update-price-lists.ts +++ b/packages/core/core-flows/src/price-list/workflows/update-price-lists.ts @@ -1,4 +1,4 @@ -import { UpdatePriceListWorkflowInputDTO } from "@medusajs/framework/types" +import type { UpdatePriceListWorkflowInputDTO } from "@medusajs/framework/types" import { WorkflowData, createWorkflow } from "@medusajs/framework/workflows-sdk" import { updatePriceListsStep, validatePriceListsStep } from "../steps" @@ -16,10 +16,10 @@ export const updatePriceListsWorkflowId = "update-price-lists" /** * This workflow updates one or more price lists. It's used by the * [Update Price List Admin API Route](https://docs.medusajs.com/api/admin#price-lists_postpricelistsid). - * + * * You can use this workflow within your customizations or your own custom workflows, allowing you to * update price lists in your custom flows. - * + * * @example * const { result } = await updatePriceListsWorkflow(container) * .run({ @@ -32,9 +32,9 @@ export const updatePriceListsWorkflowId = "update-price-lists" * ] * } * }) - * + * * @summary - * + * * Update one or more price lists. */ export const updatePriceListsWorkflow = createWorkflow( diff --git a/packages/core/core-flows/src/pricing/steps/delete-price-preferences.ts b/packages/core/core-flows/src/pricing/steps/delete-price-preferences.ts index d4f141fdac..57b32b123d 100644 --- a/packages/core/core-flows/src/pricing/steps/delete-price-preferences.ts +++ b/packages/core/core-flows/src/pricing/steps/delete-price-preferences.ts @@ -1,4 +1,4 @@ -import { IPricingModuleService } from "@medusajs/framework/types" +import type { IPricingModuleService } from "@medusajs/framework/types" import { Modules } from "@medusajs/framework/utils" import { StepResponse, createStep } from "@medusajs/framework/workflows-sdk" diff --git a/packages/core/core-flows/src/pricing/steps/update-price-sets.ts b/packages/core/core-flows/src/pricing/steps/update-price-sets.ts index f5d6b7879c..2f582855cc 100644 --- a/packages/core/core-flows/src/pricing/steps/update-price-sets.ts +++ b/packages/core/core-flows/src/pricing/steps/update-price-sets.ts @@ -1,4 +1,7 @@ -import { IPricingModuleService, PricingTypes } from "@medusajs/framework/types" +import type { + IPricingModuleService, + PricingTypes, +} from "@medusajs/framework/types" import { MedusaError, Modules, @@ -12,9 +15,9 @@ import { StepResponse, createStep } from "@medusajs/framework/workflows-sdk" */ export type UpdatePriceSetsStepInput = | { - /** - * The filters to select which price sets to update. - */ + /** + * The filters to select which price sets to update. + */ selector?: PricingTypes.FilterablePriceSetProps /** * The data to update the price sets with. @@ -22,16 +25,16 @@ export type UpdatePriceSetsStepInput = update?: PricingTypes.UpdatePriceSetDTO } | { - /** - * The price sets to update. - */ + /** + * The price sets to update. + */ price_sets: PricingTypes.UpsertPriceSetDTO[] } export const updatePriceSetsStepId = "update-price-sets" /** * This step updates price sets. - * + * * @example * const data = updatePriceSetsStep({ * selector: { diff --git a/packages/core/core-flows/src/pricing/workflows/create-price-preferences.ts b/packages/core/core-flows/src/pricing/workflows/create-price-preferences.ts index 9861869fa7..859c904859 100644 --- a/packages/core/core-flows/src/pricing/workflows/create-price-preferences.ts +++ b/packages/core/core-flows/src/pricing/workflows/create-price-preferences.ts @@ -1,4 +1,4 @@ -import { PricingWorkflow } from "@medusajs/framework/types" +import type { PricingWorkflow } from "@medusajs/framework/types" import { WorkflowData, WorkflowResponse, @@ -9,16 +9,17 @@ import { createPricePreferencesStep } from "../steps" /** * The price preferences to create. */ -export type CreatePricePreferencesWorkflowInput = PricingWorkflow.CreatePricePreferencesWorkflowInput[] +export type CreatePricePreferencesWorkflowInput = + PricingWorkflow.CreatePricePreferencesWorkflowInput[] export const createPricePreferencesWorkflowId = "create-price-preferences" /** * This workflow creates one or more price preferences. It's used by the * [Create Price Preferences Admin API Route](https://docs.medusajs.com/api/admin#price-preferences_postpricepreferences). - * - * You can use this workflow within your customizations or your own custom workflows, allowing you to + * + * You can use this workflow within your customizations or your own custom workflows, allowing you to * create price preferences in your custom flows. - * + * * @example * const { result } = await createPricePreferencesWorkflow(container) * .run({ @@ -30,16 +31,14 @@ export const createPricePreferencesWorkflowId = "create-price-preferences" * } * ] * }) - * + * * @summary - * + * * Create one or more price preferences. */ export const createPricePreferencesWorkflow = createWorkflow( createPricePreferencesWorkflowId, - ( - input: WorkflowData - ) => { + (input: WorkflowData) => { return new WorkflowResponse(createPricePreferencesStep(input)) } ) diff --git a/packages/core/core-flows/src/pricing/workflows/update-price-preferences.ts b/packages/core/core-flows/src/pricing/workflows/update-price-preferences.ts index 5052618a57..2b0d3d1f99 100644 --- a/packages/core/core-flows/src/pricing/workflows/update-price-preferences.ts +++ b/packages/core/core-flows/src/pricing/workflows/update-price-preferences.ts @@ -1,4 +1,4 @@ -import { PricingWorkflow } from "@medusajs/framework/types" +import type { PricingWorkflow } from "@medusajs/framework/types" import { WorkflowData, WorkflowResponse, @@ -10,10 +10,10 @@ export const updatePricePreferencesWorkflowId = "update-price-preferences" /** * This workflow updates one or more price preferences. It's used by the * [Update Price Preference Admin API Route](https://docs.medusajs.com/api/admin#price-preferences_postpricepreferencesid). - * + * * You can use this workflow within your customizations or your own custom workflows, allowing you to * update price preferences in your custom flows. - * + * * @example * const { result } = await updatePricePreferencesWorkflow(container) * .run({ @@ -26,9 +26,9 @@ export const updatePricePreferencesWorkflowId = "update-price-preferences" * } * } * }) - * + * * @summary - * + * * Update one or more price preferences. */ export const updatePricePreferencesWorkflow = createWorkflow( diff --git a/packages/core/core-flows/src/product-category/steps/delete-product-categories.ts b/packages/core/core-flows/src/product-category/steps/delete-product-categories.ts index 9dce718f69..4487e83064 100644 --- a/packages/core/core-flows/src/product-category/steps/delete-product-categories.ts +++ b/packages/core/core-flows/src/product-category/steps/delete-product-categories.ts @@ -1,4 +1,4 @@ -import { IProductModuleService } from "@medusajs/framework/types" +import type { IProductModuleService } from "@medusajs/framework/types" import { Modules } from "@medusajs/framework/utils" import { StepResponse, createStep } from "@medusajs/framework/workflows-sdk" diff --git a/packages/core/core-flows/src/product/helpers/normalize-for-import.ts b/packages/core/core-flows/src/product/helpers/normalize-for-import.ts index 67bbf55473..20e11284df 100644 --- a/packages/core/core-flows/src/product/helpers/normalize-for-import.ts +++ b/packages/core/core-flows/src/product/helpers/normalize-for-import.ts @@ -1,5 +1,5 @@ -import { ProductTypes } from "@medusajs/framework/types" -import { HttpTypes, RegionTypes } from "@medusajs/framework/types" +import type { ProductTypes } from "@medusajs/framework/types" +import type { HttpTypes, RegionTypes } from "@medusajs/framework/types" import { MedusaError, lowerCaseFirst } from "@medusajs/framework/utils" // We want to convert the csv data format to a standard DTO format. diff --git a/packages/core/core-flows/src/product/steps/create-collections.ts b/packages/core/core-flows/src/product/steps/create-collections.ts index 68fad33348..b6b257787a 100644 --- a/packages/core/core-flows/src/product/steps/create-collections.ts +++ b/packages/core/core-flows/src/product/steps/create-collections.ts @@ -1,4 +1,7 @@ -import { IProductModuleService, ProductTypes } from "@medusajs/framework/types" +import type { + IProductModuleService, + ProductTypes, +} from "@medusajs/framework/types" import { Modules } from "@medusajs/framework/utils" import { StepResponse, createStep } from "@medusajs/framework/workflows-sdk" diff --git a/packages/core/core-flows/src/product/steps/create-product-options.ts b/packages/core/core-flows/src/product/steps/create-product-options.ts index 9761786a76..ac311c1b80 100644 --- a/packages/core/core-flows/src/product/steps/create-product-options.ts +++ b/packages/core/core-flows/src/product/steps/create-product-options.ts @@ -1,11 +1,14 @@ -import { IProductModuleService, ProductTypes } from "@medusajs/framework/types" +import type { + IProductModuleService, + ProductTypes, +} from "@medusajs/framework/types" import { Modules } from "@medusajs/framework/utils" import { StepResponse, createStep } from "@medusajs/framework/workflows-sdk" export const createProductOptionsStepId = "create-product-options" /** * This step creates one or more product options. - * + * * @example * const data = createProductOptionsStep([{ * title: "Size", diff --git a/packages/core/core-flows/src/product/steps/create-product-tags.ts b/packages/core/core-flows/src/product/steps/create-product-tags.ts index dee2edb21a..88f1875972 100644 --- a/packages/core/core-flows/src/product/steps/create-product-tags.ts +++ b/packages/core/core-flows/src/product/steps/create-product-tags.ts @@ -1,4 +1,7 @@ -import { IProductModuleService, ProductTypes } from "@medusajs/framework/types" +import type { + IProductModuleService, + ProductTypes, +} from "@medusajs/framework/types" import { Modules } from "@medusajs/framework/utils" import { StepResponse, createStep } from "@medusajs/framework/workflows-sdk" diff --git a/packages/core/core-flows/src/product/steps/create-product-types.ts b/packages/core/core-flows/src/product/steps/create-product-types.ts index f38a4aab72..731667f98b 100644 --- a/packages/core/core-flows/src/product/steps/create-product-types.ts +++ b/packages/core/core-flows/src/product/steps/create-product-types.ts @@ -1,4 +1,7 @@ -import { IProductModuleService, ProductTypes } from "@medusajs/framework/types" +import type { + IProductModuleService, + ProductTypes, +} from "@medusajs/framework/types" import { Modules } from "@medusajs/framework/utils" import { StepResponse, createStep } from "@medusajs/framework/workflows-sdk" diff --git a/packages/core/core-flows/src/product/steps/create-product-variants.ts b/packages/core/core-flows/src/product/steps/create-product-variants.ts index 69b38bf763..acdcbda842 100644 --- a/packages/core/core-flows/src/product/steps/create-product-variants.ts +++ b/packages/core/core-flows/src/product/steps/create-product-variants.ts @@ -1,11 +1,14 @@ -import { IProductModuleService, ProductTypes } from "@medusajs/framework/types" +import type { + IProductModuleService, + ProductTypes, +} from "@medusajs/framework/types" import { Modules } from "@medusajs/framework/utils" import { StepResponse, createStep } from "@medusajs/framework/workflows-sdk" export const createProductVariantsStepId = "create-product-variants" /** * This step creates one or more product variants. - * + * * @example * const data = createProductVariantsStep([{ * title: "Small Shirt", diff --git a/packages/core/core-flows/src/product/steps/create-products.ts b/packages/core/core-flows/src/product/steps/create-products.ts index 0f7615175b..d8452a8384 100644 --- a/packages/core/core-flows/src/product/steps/create-products.ts +++ b/packages/core/core-flows/src/product/steps/create-products.ts @@ -1,11 +1,14 @@ -import { IProductModuleService, ProductTypes } from "@medusajs/framework/types" +import type { + IProductModuleService, + ProductTypes, +} from "@medusajs/framework/types" import { Modules } from "@medusajs/framework/utils" import { StepResponse, createStep } from "@medusajs/framework/workflows-sdk" export const createProductsStepId = "create-products" /** * This step creates one or more products. - * + * * @example * const data = createProductsStep([{ * title: "Shirt", diff --git a/packages/core/core-flows/src/product/steps/delete-collections.ts b/packages/core/core-flows/src/product/steps/delete-collections.ts index 972dba99a2..9426f99b7f 100644 --- a/packages/core/core-flows/src/product/steps/delete-collections.ts +++ b/packages/core/core-flows/src/product/steps/delete-collections.ts @@ -1,4 +1,4 @@ -import { IProductModuleService } from "@medusajs/framework/types" +import type { IProductModuleService } from "@medusajs/framework/types" import { Modules } from "@medusajs/framework/utils" import { StepResponse, createStep } from "@medusajs/framework/workflows-sdk" diff --git a/packages/core/core-flows/src/product/steps/delete-product-options.ts b/packages/core/core-flows/src/product/steps/delete-product-options.ts index b106a4d0c2..31fd9caed5 100644 --- a/packages/core/core-flows/src/product/steps/delete-product-options.ts +++ b/packages/core/core-flows/src/product/steps/delete-product-options.ts @@ -1,4 +1,4 @@ -import { IProductModuleService } from "@medusajs/framework/types" +import type { IProductModuleService } from "@medusajs/framework/types" import { Modules } from "@medusajs/framework/utils" import { StepResponse, createStep } from "@medusajs/framework/workflows-sdk" diff --git a/packages/core/core-flows/src/product/steps/delete-product-tags.ts b/packages/core/core-flows/src/product/steps/delete-product-tags.ts index 04ade4dd11..f428c37a82 100644 --- a/packages/core/core-flows/src/product/steps/delete-product-tags.ts +++ b/packages/core/core-flows/src/product/steps/delete-product-tags.ts @@ -1,4 +1,4 @@ -import { IProductModuleService } from "@medusajs/framework/types" +import type { IProductModuleService } from "@medusajs/framework/types" import { Modules } from "@medusajs/framework/utils" import { StepResponse, createStep } from "@medusajs/framework/workflows-sdk" diff --git a/packages/core/core-flows/src/product/steps/delete-product-types.ts b/packages/core/core-flows/src/product/steps/delete-product-types.ts index 32800a27d5..345500e925 100644 --- a/packages/core/core-flows/src/product/steps/delete-product-types.ts +++ b/packages/core/core-flows/src/product/steps/delete-product-types.ts @@ -1,4 +1,4 @@ -import { IProductModuleService } from "@medusajs/framework/types" +import type { IProductModuleService } from "@medusajs/framework/types" import { Modules } from "@medusajs/framework/utils" import { StepResponse, createStep } from "@medusajs/framework/workflows-sdk" diff --git a/packages/core/core-flows/src/product/steps/delete-product-variants.ts b/packages/core/core-flows/src/product/steps/delete-product-variants.ts index 3e42c06d80..e0f09571a2 100644 --- a/packages/core/core-flows/src/product/steps/delete-product-variants.ts +++ b/packages/core/core-flows/src/product/steps/delete-product-variants.ts @@ -1,4 +1,4 @@ -import { IProductModuleService } from "@medusajs/framework/types" +import type { IProductModuleService } from "@medusajs/framework/types" import { Modules } from "@medusajs/framework/utils" import { StepResponse, createStep } from "@medusajs/framework/workflows-sdk" diff --git a/packages/core/core-flows/src/product/steps/delete-products.ts b/packages/core/core-flows/src/product/steps/delete-products.ts index 6f649778df..d4ed42bc79 100644 --- a/packages/core/core-flows/src/product/steps/delete-products.ts +++ b/packages/core/core-flows/src/product/steps/delete-products.ts @@ -1,4 +1,4 @@ -import { IProductModuleService } from "@medusajs/framework/types" +import type { IProductModuleService } from "@medusajs/framework/types" import { Modules } from "@medusajs/framework/utils" import { StepResponse, createStep } from "@medusajs/framework/workflows-sdk" diff --git a/packages/core/core-flows/src/product/steps/get-products.ts b/packages/core/core-flows/src/product/steps/get-products.ts index ab85b415d3..1b2d5177e0 100644 --- a/packages/core/core-flows/src/product/steps/get-products.ts +++ b/packages/core/core-flows/src/product/steps/get-products.ts @@ -1,4 +1,4 @@ -import { IProductModuleService } from "@medusajs/framework/types" +import type { IProductModuleService } from "@medusajs/framework/types" import { Modules } from "@medusajs/framework/utils" import { createStep, StepResponse } from "@medusajs/framework/workflows-sdk" diff --git a/packages/core/core-flows/src/product/steps/normalize-products-to-chunks.ts b/packages/core/core-flows/src/product/steps/normalize-products-to-chunks.ts index 424145b58c..4dabcf9100 100644 --- a/packages/core/core-flows/src/product/steps/normalize-products-to-chunks.ts +++ b/packages/core/core-flows/src/product/steps/normalize-products-to-chunks.ts @@ -1,5 +1,5 @@ import { parse, Parser } from "csv-parse" -import { HttpTypes, IFileModuleService } from "@medusajs/framework/types" +import type { HttpTypes, IFileModuleService } from "@medusajs/framework/types" import { Modules, CSVNormalizer, diff --git a/packages/core/core-flows/src/product/steps/normalize-products.ts b/packages/core/core-flows/src/product/steps/normalize-products.ts index b8cc080d76..ab13a17c47 100644 --- a/packages/core/core-flows/src/product/steps/normalize-products.ts +++ b/packages/core/core-flows/src/product/steps/normalize-products.ts @@ -1,4 +1,4 @@ -import { HttpTypes } from "@medusajs/framework/types" +import type { HttpTypes } from "@medusajs/framework/types" import { CSVNormalizer, productValidators } from "@medusajs/framework/utils" import { StepResponse, createStep } from "@medusajs/framework/workflows-sdk" import { convertCsvToJson } from "../utils" diff --git a/packages/core/core-flows/src/product/steps/update-collections.ts b/packages/core/core-flows/src/product/steps/update-collections.ts index 7a31260f2f..b9f8ac0e90 100644 --- a/packages/core/core-flows/src/product/steps/update-collections.ts +++ b/packages/core/core-flows/src/product/steps/update-collections.ts @@ -1,4 +1,7 @@ -import { IProductModuleService, ProductTypes } from "@medusajs/framework/types" +import type { + IProductModuleService, + ProductTypes, +} from "@medusajs/framework/types" import { Modules, getSelectsAndRelationsFromObjectArray, @@ -22,7 +25,7 @@ export type UpdateCollectionsStepInput = { export const updateCollectionsStepId = "update-collections" /** * This step updates collections matching the specified filters. - * + * * @example * const data = updateCollectionsStep({ * selector: { diff --git a/packages/core/core-flows/src/product/steps/update-product-options.ts b/packages/core/core-flows/src/product/steps/update-product-options.ts index 121c5c6ff2..31b6cc60d0 100644 --- a/packages/core/core-flows/src/product/steps/update-product-options.ts +++ b/packages/core/core-flows/src/product/steps/update-product-options.ts @@ -1,4 +1,7 @@ -import { IProductModuleService, ProductTypes } from "@medusajs/framework/types" +import type { + IProductModuleService, + ProductTypes, +} from "@medusajs/framework/types" import { Modules, getSelectsAndRelationsFromObjectArray, @@ -22,7 +25,7 @@ export type UpdateProductOptionsStepInput = { export const updateProductOptionsStepId = "update-product-options" /** * This step updates product options matching the specified filters. - * + * * @example * const data = updateProductOptionsStep({ * selector: { diff --git a/packages/core/core-flows/src/product/steps/update-product-tags.ts b/packages/core/core-flows/src/product/steps/update-product-tags.ts index b78b48b3e0..b5b5a249d8 100644 --- a/packages/core/core-flows/src/product/steps/update-product-tags.ts +++ b/packages/core/core-flows/src/product/steps/update-product-tags.ts @@ -1,4 +1,7 @@ -import { IProductModuleService, ProductTypes } from "@medusajs/framework/types" +import type { + IProductModuleService, + ProductTypes, +} from "@medusajs/framework/types" import { Modules, getSelectsAndRelationsFromObjectArray, @@ -22,7 +25,7 @@ export type UpdateProductTagsStepInput = { export const updateProductTagsStepId = "update-product-tags" /** * This step updates product tags matching the specified filters. - * + * * @example * const data = updateProductTagsStep({ * selector: { diff --git a/packages/core/core-flows/src/product/steps/update-product-types.ts b/packages/core/core-flows/src/product/steps/update-product-types.ts index e81b9c4ebb..7356bd5f83 100644 --- a/packages/core/core-flows/src/product/steps/update-product-types.ts +++ b/packages/core/core-flows/src/product/steps/update-product-types.ts @@ -1,4 +1,7 @@ -import { IProductModuleService, ProductTypes } from "@medusajs/framework/types" +import type { + IProductModuleService, + ProductTypes, +} from "@medusajs/framework/types" import { Modules, getSelectsAndRelationsFromObjectArray, @@ -22,7 +25,7 @@ export type UpdateProductTypesStepInput = { export const updateProductTypesStepId = "update-product-types" /** * This step updates product types matching the specified filters. - * + * * @example * const data = updateProductTypesStep({ * selector: { diff --git a/packages/core/core-flows/src/product/steps/update-product-variants.ts b/packages/core/core-flows/src/product/steps/update-product-variants.ts index 7556d4d358..a12c83e847 100644 --- a/packages/core/core-flows/src/product/steps/update-product-variants.ts +++ b/packages/core/core-flows/src/product/steps/update-product-variants.ts @@ -1,4 +1,7 @@ -import { IProductModuleService, ProductTypes } from "@medusajs/framework/types" +import type { + IProductModuleService, + ProductTypes, +} from "@medusajs/framework/types" import { MedusaError, Modules, @@ -21,19 +24,19 @@ export type UpdateProductVariantsStepInput = update: ProductTypes.UpdateProductVariantDTO } | { - /** - * The data to create or update product variants. - */ + /** + * The data to create or update product variants. + */ product_variants: ProductTypes.UpsertProductVariantDTO[] } export const updateProductVariantsStepId = "update-product-variants" /** * This step updates one or more product variants. - * + * * @example * To update product variants by their ID: - * + * * ```ts * const data = updateProductVariantsStep({ * product_variants: [ @@ -44,9 +47,9 @@ export const updateProductVariantsStepId = "update-product-variants" * ] * }) * ``` - * + * * To update product variants matching a filter: - * + * * ```ts * const data = updateProductVariantsStep({ * selector: { diff --git a/packages/core/core-flows/src/product/steps/update-products.ts b/packages/core/core-flows/src/product/steps/update-products.ts index d498686f37..4e11fce7fa 100644 --- a/packages/core/core-flows/src/product/steps/update-products.ts +++ b/packages/core/core-flows/src/product/steps/update-products.ts @@ -1,4 +1,7 @@ -import { IProductModuleService, ProductTypes } from "@medusajs/framework/types" +import type { + IProductModuleService, + ProductTypes, +} from "@medusajs/framework/types" import { MedusaError, Modules, diff --git a/packages/core/core-flows/src/product/workflows/batch-link-products-collection.ts b/packages/core/core-flows/src/product/workflows/batch-link-products-collection.ts index e06f88aaf6..ed0a4f7263 100644 --- a/packages/core/core-flows/src/product/workflows/batch-link-products-collection.ts +++ b/packages/core/core-flows/src/product/workflows/batch-link-products-collection.ts @@ -1,4 +1,4 @@ -import { LinkWorkflowInput } from "@medusajs/framework/types" +import type { LinkWorkflowInput } from "@medusajs/framework/types" import { WorkflowData, createWorkflow } from "@medusajs/framework/workflows-sdk" import { batchLinkProductsToCollectionStep } from "../steps/batch-link-products-collection" @@ -8,9 +8,9 @@ export const batchLinkProductsToCollectionWorkflowId = /** * This workflow manages the links between a collection and products. It's used by the * [Manage Products of Collection Admin API Route](https://docs.medusajs.com/api/admin#collections_postcollectionsidproducts). - * + * * You can use this workflow within your own customizations or custom workflows to manage the products in a collection. - * + * * @example * const { result } = await batchLinkProductsToCollectionWorkflow(container) * .run({ @@ -20,9 +20,9 @@ export const batchLinkProductsToCollectionWorkflowId = * remove: ["prod_456"], * } * }) - * + * * @summary - * + * * Manage the links between a collection and products. */ export const batchLinkProductsToCollectionWorkflow = createWorkflow( diff --git a/packages/core/core-flows/src/product/workflows/batch-products-in-category.ts b/packages/core/core-flows/src/product/workflows/batch-products-in-category.ts index 1ecead3054..3d05e602cc 100644 --- a/packages/core/core-flows/src/product/workflows/batch-products-in-category.ts +++ b/packages/core/core-flows/src/product/workflows/batch-products-in-category.ts @@ -1,4 +1,4 @@ -import { ProductCategoryWorkflow } from "@medusajs/framework/types" +import type { ProductCategoryWorkflow } from "@medusajs/framework/types" import { WorkflowData, createWorkflow } from "@medusajs/framework/workflows-sdk" import { batchLinkProductsToCategoryStep } from "../steps/batch-link-products-in-category" @@ -7,9 +7,9 @@ export const batchLinkProductsToCategoryWorkflowId = /** * This workflow manages the links between a category and products. It's used by the * [Manage Products of Category Admin API Route](https://docs.medusajs.com/api/admin#product-categories_postproductcategoriesidproducts). - * + * * You can use this workflow within your own customizations or custom workflows to manage the products in a category. - * + * * @example * const { result } = await batchLinkProductsToCategoryWorkflow(container) * .run({ @@ -17,11 +17,11 @@ export const batchLinkProductsToCategoryWorkflowId = * id: "pcat_123", * add: ["prod_123"], * remove: ["prod_321"] - * } + * } * }) - * + * * @summary - * + * * Manage the links between a collection and products. */ export const batchLinkProductsToCategoryWorkflow = createWorkflow( diff --git a/packages/core/core-flows/src/product/workflows/create-collections.ts b/packages/core/core-flows/src/product/workflows/create-collections.ts index 9adafba77f..bc6a972142 100644 --- a/packages/core/core-flows/src/product/workflows/create-collections.ts +++ b/packages/core/core-flows/src/product/workflows/create-collections.ts @@ -1,4 +1,4 @@ -import { AdditionalData, ProductTypes } from "@medusajs/framework/types" +import type { AdditionalData, ProductTypes } from "@medusajs/framework/types" import { ProductCollectionWorkflowEvents } from "@medusajs/framework/utils" import { WorkflowData, @@ -22,14 +22,14 @@ export type CreateCollectionsWorkflowInput = { export const createCollectionsWorkflowId = "create-collections" /** - * This workflow creates one or more collections. It's used by the + * This workflow creates one or more collections. It's used by the * [Create Collection Admin API Route](https://docs.medusajs.com/api/admin#collections_postcollections). - * - * This workflow has a hook that allows you to perform custom actions on the created collections. For example, you can pass under `additional_data` custom data that + * + * This workflow has a hook that allows you to perform custom actions on the created collections. For example, you can pass under `additional_data` custom data that * allows you to create custom data models linked to the product collections. - * + * * You can also use this workflow within your own custom workflows, allowing you to wrap custom logic around product-collection creation. - * + * * @example * const { result } = await createCollectionsWorkflow(container) * .run({ @@ -44,11 +44,11 @@ export const createCollectionsWorkflowId = "create-collections" * } * } * }) - * + * * @summary - * + * * Create one or more product collections. - * + * * @property hooks.collectionsCreated - This hook is executed after the collections are created. You can consume this hook to perform custom actions on the created collections. */ export const createCollectionsWorkflow = createWorkflow( diff --git a/packages/core/core-flows/src/product/workflows/create-product-options.ts b/packages/core/core-flows/src/product/workflows/create-product-options.ts index 070d1e2acf..8bf1a28e93 100644 --- a/packages/core/core-flows/src/product/workflows/create-product-options.ts +++ b/packages/core/core-flows/src/product/workflows/create-product-options.ts @@ -1,4 +1,4 @@ -import { AdditionalData, ProductTypes } from "@medusajs/framework/types" +import type { AdditionalData, ProductTypes } from "@medusajs/framework/types" import { ProductOptionWorkflowEvents } from "@medusajs/framework/utils" import { WorkflowData, @@ -23,12 +23,12 @@ export type CreateProductOptionsWorkflowInput = { export const createProductOptionsWorkflowId = "create-product-options" /** * This workflow creates one or more product options. It's used by the [Create Product Option Admin API Route](https://docs.medusajs.com/api/admin#products_postproductsidoptions). - * - * This workflow has a hook that allows you to perform custom actions on the created product options. For example, you can pass under `additional_data` custom data that + * + * This workflow has a hook that allows you to perform custom actions on the created product options. For example, you can pass under `additional_data` custom data that * allows you to create custom data models linked to the product options. - * + * * You can also use this workflow within your customizations or your own custom workflows, allowing you to wrap custom logic around product-option creation. - * + * * @example * const { result } = await createProductOptionsWorkflow(container) * .run({ @@ -48,11 +48,11 @@ export const createProductOptionsWorkflowId = "create-product-options" * } * } * }) - * + * * @summary - * + * * Create one or more product options. - * + * * @property hooks.productOptionsCreated - This hook is executed after the product options are created. You can consume this hook to perform custom actions on the created product options. */ export const createProductOptionsWorkflow = createWorkflow( diff --git a/packages/core/core-flows/src/product/workflows/create-product-tags.ts b/packages/core/core-flows/src/product/workflows/create-product-tags.ts index 970246087f..2767028719 100644 --- a/packages/core/core-flows/src/product/workflows/create-product-tags.ts +++ b/packages/core/core-flows/src/product/workflows/create-product-tags.ts @@ -1,4 +1,4 @@ -import { AdditionalData, ProductTypes } from "@medusajs/framework/types" +import type { AdditionalData, ProductTypes } from "@medusajs/framework/types" import { ProductTagWorkflowEvents } from "@medusajs/framework/utils" import { WorkflowData, @@ -22,14 +22,14 @@ export type CreateProductTagsWorkflowInput = { export const createProductTagsWorkflowId = "create-product-tags" /** - * This workflow creates one or more product tags. It's used by the + * This workflow creates one or more product tags. It's used by the * [Create Product Tag Admin API Route](https://docs.medusajs.com/api/admin#product-tags_postproducttags). - * - * This workflow has a hook that allows you to perform custom actions on the created product tags. For example, you can pass under `additional_data` custom data that + * + * This workflow has a hook that allows you to perform custom actions on the created product tags. For example, you can pass under `additional_data` custom data that * allows you to create custom data models linked to the product tags. - * + * * You can also use this workflow within your own custom workflows, allowing you to wrap custom logic around product-tag creation. - * + * * @example * const { result } = await createProductTagsWorkflow(container) * .run({ @@ -44,11 +44,11 @@ export const createProductTagsWorkflowId = "create-product-tags" * } * } * }) - * + * * @summary - * + * * Create one or more product tags. - * + * * @property hooks.productTagsCreated - This hook is executed after the product tags are created. You can consume this hook to perform custom actions on the created product tags. */ export const createProductTagsWorkflow = createWorkflow( diff --git a/packages/core/core-flows/src/product/workflows/create-product-types.ts b/packages/core/core-flows/src/product/workflows/create-product-types.ts index 66dc5bc36e..b21d768e12 100644 --- a/packages/core/core-flows/src/product/workflows/create-product-types.ts +++ b/packages/core/core-flows/src/product/workflows/create-product-types.ts @@ -1,4 +1,4 @@ -import { AdditionalData, ProductTypes } from "@medusajs/framework/types" +import type { AdditionalData, ProductTypes } from "@medusajs/framework/types" import { ProductTypeWorkflowEvents } from "@medusajs/framework/utils" import { WorkflowData, @@ -22,14 +22,14 @@ export type CreateProductTypesWorkflowInput = { export const createProductTypesWorkflowId = "create-product-types" /** - * This workflow creates one or more product types. It's used by the + * This workflow creates one or more product types. It's used by the * [Create Product Type Admin API Route](https://docs.medusajs.com/api/admin#product-types_postproducttypes). - * - * This workflow has a hook that allows you to perform custom actions on the created product types. For example, you can pass under `additional_data` custom data that + * + * This workflow has a hook that allows you to perform custom actions on the created product types. For example, you can pass under `additional_data` custom data that * allows you to create custom data models linked to the product types. - * + * * You can also use this workflow within your own custom workflows, allowing you to wrap custom logic around product-type creation. - * + * * @example * const { result } = await createProductTypesWorkflow(container) * .run({ @@ -44,11 +44,11 @@ export const createProductTypesWorkflowId = "create-product-types" * } * } * }) - * + * * @summary - * + * * Create one or more product types. - * + * * @property hooks.productTypesCreated - This hook is executed after the product types are created. You can consume this hook to perform custom actions on the created product types. */ export const createProductTypesWorkflow = createWorkflow( diff --git a/packages/core/core-flows/src/product/workflows/export-products.ts b/packages/core/core-flows/src/product/workflows/export-products.ts index 6739c3ac8f..c5b3793c8f 100644 --- a/packages/core/core-flows/src/product/workflows/export-products.ts +++ b/packages/core/core-flows/src/product/workflows/export-products.ts @@ -3,26 +3,26 @@ import { createWorkflow, transform, } from "@medusajs/framework/workflows-sdk" -import { WorkflowTypes } from "@medusajs/framework/types" +import type { WorkflowTypes } from "@medusajs/framework/types" import { generateProductCsvStep, getAllProductsStep } from "../steps" import { useRemoteQueryStep } from "../../common" import { notifyOnFailureStep, sendNotificationsStep } from "../../notification" export const exportProductsWorkflowId = "export-products" /** - * This workflow exports products matching the specified filters. It's used by the + * This workflow exports products matching the specified filters. It's used by the * [Export Products Admin API Route](https://docs.medusajs.com/api/admin#products_postproductsexport). - * + * * :::note - * + * * This workflow doesn't return the exported products. Instead, it sends a notification to the admin * users that they can download the exported products. Learn more in the [API Reference](https://docs.medusajs.com/api/admin#products_postproductsexport). - * + * * ::: - * + * * @example * To export all products: - * + * * ```ts * const { result } = await exportProductsWorkflow(container) * .run({ @@ -31,9 +31,9 @@ export const exportProductsWorkflowId = "export-products" * } * }) * ``` - * + * * To export products matching a criteria: - * + * * ```ts * const { result } = await exportProductsWorkflow(container) * .run({ @@ -45,9 +45,9 @@ export const exportProductsWorkflowId = "export-products" * } * }) * ``` - * + * * @summary - * + * * Export products with filtering capabilities. */ export const exportProductsWorkflow = createWorkflow( diff --git a/packages/core/core-flows/src/product/workflows/import-products-as-chunks.ts b/packages/core/core-flows/src/product/workflows/import-products-as-chunks.ts index ee0a34cc04..58d712d460 100644 --- a/packages/core/core-flows/src/product/workflows/import-products-as-chunks.ts +++ b/packages/core/core-flows/src/product/workflows/import-products-as-chunks.ts @@ -1,4 +1,4 @@ -import { WorkflowTypes } from "@medusajs/framework/types" +import type { WorkflowTypes } from "@medusajs/framework/types" import { WorkflowData, WorkflowResponse, @@ -51,7 +51,7 @@ export const importProductsAsChunksWorkflowId = "import-products-as-chunks" * importProductsAsChunksWorkflowId, * waitConfirmationProductImportStepId, * } from "@medusajs/core-flows" - * import { IWorkflowEngineService } from "@medusajs/framework/types" + * import type { IWorkflowEngineService } from "@medusajs/framework/types" * import { Modules, TransactionHandlerType } from "@medusajs/framework/utils" * import { StepResponse } from "@medusajs/framework/workflows-sdk" * diff --git a/packages/core/core-flows/src/product/workflows/import-products.ts b/packages/core/core-flows/src/product/workflows/import-products.ts index e89069c028..420fac4562 100644 --- a/packages/core/core-flows/src/product/workflows/import-products.ts +++ b/packages/core/core-flows/src/product/workflows/import-products.ts @@ -1,4 +1,4 @@ -import { WorkflowTypes } from "@medusajs/framework/types" +import type { WorkflowTypes } from "@medusajs/framework/types" import { WorkflowData, WorkflowResponse, @@ -48,7 +48,7 @@ export const importProductsWorkflowId = "import-products" * importProductsWorkflowId, * waitConfirmationProductImportStepId, * } from "@medusajs/core-flows" - * import { IWorkflowEngineService } from "@medusajs/framework/types" + * import type { IWorkflowEngineService } from "@medusajs/framework/types" * import { Modules, TransactionHandlerType } from "@medusajs/framework/utils" * import { StepResponse } from "@medusajs/framework/workflows-sdk" * diff --git a/packages/core/core-flows/src/product/workflows/update-collections.ts b/packages/core/core-flows/src/product/workflows/update-collections.ts index 0c977cf459..7727253d04 100644 --- a/packages/core/core-flows/src/product/workflows/update-collections.ts +++ b/packages/core/core-flows/src/product/workflows/update-collections.ts @@ -1,4 +1,4 @@ -import { AdditionalData, ProductTypes } from "@medusajs/framework/types" +import type { AdditionalData, ProductTypes } from "@medusajs/framework/types" import { ProductCollectionWorkflowEvents } from "@medusajs/framework/utils" import { WorkflowData, @@ -26,14 +26,14 @@ export type UpdateCollectionsWorkflowInput = { export const updateCollectionsWorkflowId = "update-collections" /** - * This workflow updates one or more collections. It's used by the + * This workflow updates one or more collections. It's used by the * [Create Collection Admin API Route](https://docs.medusajs.com/api/admin#collections_postcollectionsid). - * - * This workflow has a hook that allows you to perform custom actions on the updated collections. For example, you can pass under `additional_data` custom data that + * + * This workflow has a hook that allows you to perform custom actions on the updated collections. For example, you can pass under `additional_data` custom data that * allows you to update custom data models linked to the product collections. - * + * * You can also use this workflow within your own custom workflows, allowing you to wrap custom logic around product-collection update. - * + * * @example * const { result } = await updateCollectionsWorkflow(container) * .run({ @@ -49,11 +49,11 @@ export const updateCollectionsWorkflowId = "update-collections" * } * } * }) - * + * * @summary - * + * * Update one or more product collections. - * + * * @property hooks.collectionsUpdated - This hook is executed after the collections are updated. You can consume this hook to perform custom actions on the updated collections. */ export const updateCollectionsWorkflow = createWorkflow( diff --git a/packages/core/core-flows/src/product/workflows/update-product-options.ts b/packages/core/core-flows/src/product/workflows/update-product-options.ts index c3226f2f89..fb4d882ae2 100644 --- a/packages/core/core-flows/src/product/workflows/update-product-options.ts +++ b/packages/core/core-flows/src/product/workflows/update-product-options.ts @@ -1,4 +1,4 @@ -import { AdditionalData, ProductTypes } from "@medusajs/framework/types" +import type { AdditionalData, ProductTypes } from "@medusajs/framework/types" import { ProductOptionWorkflowEvents } from "@medusajs/framework/utils" import { WorkflowData, @@ -27,12 +27,12 @@ export type UpdateProductOptionsWorkflowInput = { export const updateProductOptionsWorkflowId = "update-product-options" /** * This workflow updates one or more product options. It's used by the [Update Product Option Admin API Route](https://docs.medusajs.com/api/admin#products_postproductsidvariantsvariant_id). - * - * This workflow has a hook that allows you to perform custom actions on the updated product options. For example, you can pass under `additional_data` custom data that + * + * This workflow has a hook that allows you to perform custom actions on the updated product options. For example, you can pass under `additional_data` custom data that * allows you to update custom data models linked to the product options. - * + * * You can also use this workflow within your customizations or your own custom workflows, allowing you to wrap custom logic around product-option update. - * + * * @example * const { result } = await updateProductOptionsWorkflow(container) * .run({ @@ -48,11 +48,11 @@ export const updateProductOptionsWorkflowId = "update-product-options" * } * } * }) - * + * * @summary - * + * * Update one or more product options. - * + * * @property hooks.productOptionsUpdated - This hook is executed after the product options are updated. You can consume this hook to perform custom actions on the updated product options. */ export const updateProductOptionsWorkflow = createWorkflow( diff --git a/packages/core/core-flows/src/product/workflows/update-product-tags.ts b/packages/core/core-flows/src/product/workflows/update-product-tags.ts index 36ba4b6af8..2254b42c63 100644 --- a/packages/core/core-flows/src/product/workflows/update-product-tags.ts +++ b/packages/core/core-flows/src/product/workflows/update-product-tags.ts @@ -1,4 +1,4 @@ -import { AdditionalData, ProductTypes } from "@medusajs/framework/types" +import type { AdditionalData, ProductTypes } from "@medusajs/framework/types" import { ProductTagWorkflowEvents } from "@medusajs/framework/utils" import { WorkflowData, @@ -26,14 +26,14 @@ export type UpdateProductTagsWorkflowInput = { export const updateProductTagsWorkflowId = "update-product-tags" /** - * This workflow updates one or more product tags. It's used by the + * This workflow updates one or more product tags. It's used by the * [Update Product Tag Admin API Route](https://docs.medusajs.com/api/admin#product-tags_postproducttagsid). - * - * This workflow has a hook that allows you to perform custom actions on the updated product tags. For example, you can pass under `additional_data` custom data that + * + * This workflow has a hook that allows you to perform custom actions on the updated product tags. For example, you can pass under `additional_data` custom data that * allows you to update custom data models linked to the product tags. - * + * * You can also use this workflow within your own custom workflows, allowing you to wrap custom logic around product-tag updates. - * + * * @example * const { result } = await updateProductTagsWorkflow(container) * .run({ @@ -49,11 +49,11 @@ export const updateProductTagsWorkflowId = "update-product-tags" * } * } * }) - * + * * @summary - * + * * Update one or more product tags. - * + * * @property hooks.productTagsUpdated - This hook is executed after the product tags are updated. You can consume this hook to perform custom actions on the updated product tags. */ export const updateProductTagsWorkflow = createWorkflow( diff --git a/packages/core/core-flows/src/product/workflows/update-product-types.ts b/packages/core/core-flows/src/product/workflows/update-product-types.ts index 494e10cd20..9ace25f828 100644 --- a/packages/core/core-flows/src/product/workflows/update-product-types.ts +++ b/packages/core/core-flows/src/product/workflows/update-product-types.ts @@ -1,4 +1,4 @@ -import { AdditionalData, ProductTypes } from "@medusajs/framework/types" +import type { AdditionalData, ProductTypes } from "@medusajs/framework/types" import { ProductTypeWorkflowEvents } from "@medusajs/framework/utils" import { WorkflowData, @@ -26,14 +26,14 @@ type UpdateProductTypesWorkflowInput = { export const updateProductTypesWorkflowId = "update-product-types" /** - * This workflow updates one or more product types. It's used by the + * This workflow updates one or more product types. It's used by the * [Update Product Type Admin API Route](https://docs.medusajs.com/api/admin#product-types_postproducttypesid). - * - * This workflow has a hook that allows you to perform custom actions on the updated product types. For example, you can pass under `additional_data` custom data that + * + * This workflow has a hook that allows you to perform custom actions on the updated product types. For example, you can pass under `additional_data` custom data that * allows you to update custom data models linked to the product types. - * + * * You can also use this workflow within your own custom workflows, allowing you to wrap custom logic around product-type updates. - * + * * @example * const { result } = await updateProductTypesWorkflow(container) * .run({ @@ -49,11 +49,11 @@ export const updateProductTypesWorkflowId = "update-product-types" * } * } * }) - * + * * @summary - * + * * Update one or more product types. - * + * * @property hooks.productTypesUpdated - This hook is executed after the product types are updated. You can consume this hook to perform custom actions on the updated product types. */ export const updateProductTypesWorkflow = createWorkflow( diff --git a/packages/core/core-flows/src/promotion/steps/delete-campaigns.ts b/packages/core/core-flows/src/promotion/steps/delete-campaigns.ts index 0aee576d44..94ae7113c7 100644 --- a/packages/core/core-flows/src/promotion/steps/delete-campaigns.ts +++ b/packages/core/core-flows/src/promotion/steps/delete-campaigns.ts @@ -1,4 +1,4 @@ -import { IPromotionModuleService } from "@medusajs/framework/types" +import type { IPromotionModuleService } from "@medusajs/framework/types" import { Modules } from "@medusajs/framework/utils" import { StepResponse, createStep } from "@medusajs/framework/workflows-sdk" diff --git a/packages/core/core-flows/src/promotion/steps/delete-promotion-rules-workflow.ts b/packages/core/core-flows/src/promotion/steps/delete-promotion-rules-workflow.ts index 3d95795622..99db6337b5 100644 --- a/packages/core/core-flows/src/promotion/steps/delete-promotion-rules-workflow.ts +++ b/packages/core/core-flows/src/promotion/steps/delete-promotion-rules-workflow.ts @@ -1,4 +1,4 @@ -import { RemovePromotionRulesWorkflowDTO } from "@medusajs/framework/types" +import type { RemovePromotionRulesWorkflowDTO } from "@medusajs/framework/types" import { StepResponse, createStep } from "@medusajs/framework/workflows-sdk" import { deletePromotionRulesWorkflow } from "../workflows/delete-promotion-rules" diff --git a/packages/core/core-flows/src/promotion/steps/delete-promotions.ts b/packages/core/core-flows/src/promotion/steps/delete-promotions.ts index fbd0e33241..2d9fe3b6b7 100644 --- a/packages/core/core-flows/src/promotion/steps/delete-promotions.ts +++ b/packages/core/core-flows/src/promotion/steps/delete-promotions.ts @@ -1,4 +1,4 @@ -import { IPromotionModuleService } from "@medusajs/framework/types" +import type { IPromotionModuleService } from "@medusajs/framework/types" import { Modules } from "@medusajs/framework/utils" import { StepResponse, createStep } from "@medusajs/framework/workflows-sdk" diff --git a/packages/core/core-flows/src/promotion/workflows/add-or-remove-campaign-promotions.ts b/packages/core/core-flows/src/promotion/workflows/add-or-remove-campaign-promotions.ts index a0f77b6225..8d5a4d7696 100644 --- a/packages/core/core-flows/src/promotion/workflows/add-or-remove-campaign-promotions.ts +++ b/packages/core/core-flows/src/promotion/workflows/add-or-remove-campaign-promotions.ts @@ -1,4 +1,4 @@ -import { LinkWorkflowInput } from "@medusajs/framework/types" +import type { LinkWorkflowInput } from "@medusajs/framework/types" import { WorkflowData, createWorkflow, @@ -11,7 +11,7 @@ import { /** * The data to manage the promotions of a campaign. - * + * * @property id - The ID of the campaign to manage the promotions of. * @property add - The IDs of the promotions to add to the campaign. * @property remove - The IDs of the promotions to remove from the campaign. @@ -21,12 +21,12 @@ export type AddOrRemoveCampaignPromotionsWorkflowInput = LinkWorkflowInput export const addOrRemoveCampaignPromotionsWorkflowId = "add-or-remove-campaign-promotions" /** - * This workflow manages the promotions of a campaign. It's used by the + * This workflow manages the promotions of a campaign. It's used by the * [Manage Promotions Admin API Route](https://docs.medusajs.com/api/admin#campaigns_postcampaignsidpromotions). - * + * * You can use this workflow within your own customizations or custom workflows, allowing you to * manage the promotions of a campaign within your custom flows. - * + * * @example * const { result } = await addOrRemoveCampaignPromotionsWorkflow(container) * .run({ @@ -36,14 +36,16 @@ export const addOrRemoveCampaignPromotionsWorkflowId = * remove: ["promo_321"] * } * }) - * + * * @summary - * + * * Manage the promotions of a campaign. */ export const addOrRemoveCampaignPromotionsWorkflow = createWorkflow( addOrRemoveCampaignPromotionsWorkflowId, - (input: WorkflowData): WorkflowData => { + ( + input: WorkflowData + ): WorkflowData => { parallelize( addCampaignPromotionsStep(input), removeCampaignPromotionsStep(input) diff --git a/packages/core/core-flows/src/promotion/workflows/create-campaigns.ts b/packages/core/core-flows/src/promotion/workflows/create-campaigns.ts index 2d4125f733..4fb8213dda 100644 --- a/packages/core/core-flows/src/promotion/workflows/create-campaigns.ts +++ b/packages/core/core-flows/src/promotion/workflows/create-campaigns.ts @@ -1,4 +1,7 @@ -import { AdditionalData, CreateCampaignDTO } from "@medusajs/framework/types" +import type { + AdditionalData, + CreateCampaignDTO, +} from "@medusajs/framework/types" import { WorkflowData, WorkflowResponse, @@ -20,12 +23,12 @@ export type CreateCampaignsWorkflowInput = { export const createCampaignsWorkflowId = "create-campaigns" /** * This workflow creates one or more campaigns. It's used by the [Create Campaign Admin API Route](https://docs.medusajs.com/api/admin#campaigns_postcampaigns). - * + * * This workflow has a hook that allows you to perform custom actions on the created campaigns. For example, you can pass under `additional_data` custom data that * allows you to create custom data models linked to the campaigns. - * + * * You can also use this workflow within your customizations or your own custom workflows, allowing you to wrap custom logic around creating campaigns. - * + * * @example * const { result } = await createCampaignsWorkflow(container) * .run({ @@ -47,11 +50,11 @@ export const createCampaignsWorkflowId = "create-campaigns" * } * } * }) - * + * * @summary - * + * * Create one or more campaigns. - * + * * @property hooks.campaignsCreated - This hook is executed after the campaigns are created. You can consume this hook to perform custom actions on the created campaigns. */ export const createCampaignsWorkflow = createWorkflow( diff --git a/packages/core/core-flows/src/promotion/workflows/create-promotions.ts b/packages/core/core-flows/src/promotion/workflows/create-promotions.ts index f46b25bf70..971eb2bc5a 100644 --- a/packages/core/core-flows/src/promotion/workflows/create-promotions.ts +++ b/packages/core/core-flows/src/promotion/workflows/create-promotions.ts @@ -1,4 +1,7 @@ -import { AdditionalData, CreatePromotionDTO } from "@medusajs/framework/types" +import type { + AdditionalData, + CreatePromotionDTO, +} from "@medusajs/framework/types" import { WorkflowData, WorkflowResponse, @@ -20,12 +23,12 @@ export type CreatePromotionsWorkflowInput = { export const createPromotionsWorkflowId = "create-promotions" /** * This workflow creates one or more promotions. It's used by the [Create Promotion Admin API Route](https://docs.medusajs.com/api/admin#promotions_postpromotions). - * + * * This workflow has a hook that allows you to perform custom actions on the created promotion. For example, you can pass under `additional_data` custom data that * allows you to create custom data models linked to the promotions. - * + * * You can also use this workflow within your customizations or your own custom workflows, allowing you to wrap custom logic around creating promotions. - * + * * @example * const { result } = await createPromotionsWorkflow(container) * .run({ @@ -49,11 +52,11 @@ export const createPromotionsWorkflowId = "create-promotions" * } * } * }) - * + * * @summary - * + * * Create one or more promotions. - * + * * @property hooks.promotionsCreated - This hook is executed after the promotions are created. You can consume this hook to perform custom actions on the created promotions. */ export const createPromotionsWorkflow = createWorkflow( diff --git a/packages/core/core-flows/src/promotion/workflows/delete-promotion-rules.ts b/packages/core/core-flows/src/promotion/workflows/delete-promotion-rules.ts index 2da0b7e8c7..d2dcdb2f12 100644 --- a/packages/core/core-flows/src/promotion/workflows/delete-promotion-rules.ts +++ b/packages/core/core-flows/src/promotion/workflows/delete-promotion-rules.ts @@ -1,4 +1,4 @@ -import { RemovePromotionRulesWorkflowDTO } from "@medusajs/framework/types" +import type { RemovePromotionRulesWorkflowDTO } from "@medusajs/framework/types" import { WorkflowData, createWorkflow } from "@medusajs/framework/workflows-sdk" import { removeRulesFromPromotionsStep } from "../steps" @@ -6,10 +6,10 @@ export const deletePromotionRulesWorkflowId = "delete-promotion-rules-workflow" /** * This workflow deletes one or more promotion rules. It's used by other workflows, * such as {@link batchPromotionRulesWorkflow} that manages the rules of a promotion. - * + * * You can use this workflow within your own customizations or custom workflows, allowing you to * delete promotion rules within your custom flows. - * + * * @example * const { result } = await deletePromotionRulesWorkflow(container) * .run({ @@ -21,9 +21,9 @@ export const deletePromotionRulesWorkflowId = "delete-promotion-rules-workflow" * } * } * }) - * + * * @summary - * + * * Delete one or more promotion rules. */ export const deletePromotionRulesWorkflow = createWorkflow( diff --git a/packages/core/core-flows/src/promotion/workflows/update-campaigns.ts b/packages/core/core-flows/src/promotion/workflows/update-campaigns.ts index bc5d8a7fee..d4549f2c03 100644 --- a/packages/core/core-flows/src/promotion/workflows/update-campaigns.ts +++ b/packages/core/core-flows/src/promotion/workflows/update-campaigns.ts @@ -1,4 +1,7 @@ -import { AdditionalData, UpdateCampaignDTO } from "@medusajs/framework/types" +import type { + AdditionalData, + UpdateCampaignDTO, +} from "@medusajs/framework/types" import { WorkflowData, WorkflowResponse, @@ -20,12 +23,12 @@ export type UpdateCampaignsWorkflowInput = { export const updateCampaignsWorkflowId = "update-campaigns" /** * This workflow updates one or more campaigns. It's used by the [Update Campaign Admin API Route](https://docs.medusajs.com/api/admin#campaigns_postcampaignsid). - * + * * This workflow has a hook that allows you to perform custom actions on the updated campaigns. For example, you can pass under `additional_data` custom data that * allows you to update custom data models linked to the campaigns. - * + * * You can also use this workflow within your customizations or your own custom workflows, allowing you to wrap custom logic around updating campaigns. - * + * * @example * const { result } = await updateCampaignsWorkflow(container) * .run({ @@ -42,11 +45,11 @@ export const updateCampaignsWorkflowId = "update-campaigns" * } * } * }) - * + * * @summary - * + * * Update one or more campaigns. - * + * * @property hooks.campaignsUpdated - This hook is executed after the campaigns are updated. You can consume this hook to perform custom actions on the updated campaigns. */ export const updateCampaignsWorkflow = createWorkflow( diff --git a/packages/core/core-flows/src/region/steps/delete-regions.ts b/packages/core/core-flows/src/region/steps/delete-regions.ts index 73682897d3..5fbb0a9ea4 100644 --- a/packages/core/core-flows/src/region/steps/delete-regions.ts +++ b/packages/core/core-flows/src/region/steps/delete-regions.ts @@ -1,4 +1,4 @@ -import { IRegionModuleService } from "@medusajs/framework/types" +import type { IRegionModuleService } from "@medusajs/framework/types" import { Modules } from "@medusajs/framework/utils" import { StepResponse, createStep } from "@medusajs/framework/workflows-sdk" diff --git a/packages/core/core-flows/src/region/workflows/create-regions.ts b/packages/core/core-flows/src/region/workflows/create-regions.ts index 51b320c0a9..6352982673 100644 --- a/packages/core/core-flows/src/region/workflows/create-regions.ts +++ b/packages/core/core-flows/src/region/workflows/create-regions.ts @@ -1,4 +1,4 @@ -import { WorkflowTypes } from "@medusajs/framework/types" +import type { WorkflowTypes } from "@medusajs/framework/types" import { RegionWorkflowEvents } from "@medusajs/framework/utils" import { WorkflowData, @@ -16,10 +16,10 @@ export const createRegionsWorkflowId = "create-regions" /** * This workflow creates one or more regions. It's used by the * [Create Region Admin API Route](https://docs.medusajs.com/api/admin#regions_postregions). - * + * * You can use this workflow within your own customizations or custom workflows, allowing you * to create regions in your custom flows. - * + * * @example * const { result } = await createRegionsWorkflow(container) * .run({ @@ -33,9 +33,9 @@ export const createRegionsWorkflowId = "create-regions" * ] * } * }) - * + * * @summary - * + * * Create one or more regions. */ export const createRegionsWorkflow = createWorkflow( diff --git a/packages/core/core-flows/src/region/workflows/update-regions.ts b/packages/core/core-flows/src/region/workflows/update-regions.ts index 339d40f83b..a9126d55c9 100644 --- a/packages/core/core-flows/src/region/workflows/update-regions.ts +++ b/packages/core/core-flows/src/region/workflows/update-regions.ts @@ -1,4 +1,4 @@ -import { WorkflowTypes } from "@medusajs/framework/types" +import type { WorkflowTypes } from "@medusajs/framework/types" import { RegionWorkflowEvents } from "@medusajs/framework/utils" import { createWorkflow, @@ -17,10 +17,10 @@ export const updateRegionsWorkflowId = "update-regions" /** * This workflow updates regions matching the specified filters. It's used by the * [Update Region Admin API Route](https://docs.medusajs.com/api/admin#regions_postregionsid). - * + * * You can use this workflow within your own customizations or custom workflows, allowing you * to update regions in your custom flows. - * + * * @example * const { result } = await updateRegionsWorkflow(container) * .run({ @@ -33,9 +33,9 @@ export const updateRegionsWorkflowId = "update-regions" * } * } * }) - * + * * @summary - * + * * Update regions. */ export const updateRegionsWorkflow = createWorkflow( diff --git a/packages/core/core-flows/src/reservation/steps/create-reservations.ts b/packages/core/core-flows/src/reservation/steps/create-reservations.ts index 6a14d37af0..0ba00d2db2 100644 --- a/packages/core/core-flows/src/reservation/steps/create-reservations.ts +++ b/packages/core/core-flows/src/reservation/steps/create-reservations.ts @@ -1,4 +1,4 @@ -import { InventoryTypes } from "@medusajs/framework/types" +import type { InventoryTypes } from "@medusajs/framework/types" import { createStep, StepResponse } from "@medusajs/framework/workflows-sdk" import { Modules } from "@medusajs/framework/utils" diff --git a/packages/core/core-flows/src/reservation/steps/delete-reservations-by-line-items.ts b/packages/core/core-flows/src/reservation/steps/delete-reservations-by-line-items.ts index a465909a6f..592bde63e7 100644 --- a/packages/core/core-flows/src/reservation/steps/delete-reservations-by-line-items.ts +++ b/packages/core/core-flows/src/reservation/steps/delete-reservations-by-line-items.ts @@ -1,6 +1,6 @@ import { StepResponse, createStep } from "@medusajs/framework/workflows-sdk" -import { IInventoryService } from "@medusajs/framework/types" +import type { IInventoryService } from "@medusajs/framework/types" import { Modules } from "@medusajs/framework/utils" /** diff --git a/packages/core/core-flows/src/reservation/steps/delete-reservations.ts b/packages/core/core-flows/src/reservation/steps/delete-reservations.ts index 4e85addca1..4afc994e84 100644 --- a/packages/core/core-flows/src/reservation/steps/delete-reservations.ts +++ b/packages/core/core-flows/src/reservation/steps/delete-reservations.ts @@ -1,6 +1,6 @@ import { StepResponse, createStep } from "@medusajs/framework/workflows-sdk" -import { IInventoryService } from "@medusajs/framework/types" +import type { IInventoryService } from "@medusajs/framework/types" import { Modules } from "@medusajs/framework/utils" /** diff --git a/packages/core/core-flows/src/reservation/steps/update-reservations.ts b/packages/core/core-flows/src/reservation/steps/update-reservations.ts index 7d85f50781..ba04f5c65f 100644 --- a/packages/core/core-flows/src/reservation/steps/update-reservations.ts +++ b/packages/core/core-flows/src/reservation/steps/update-reservations.ts @@ -1,4 +1,7 @@ -import { IInventoryService, InventoryTypes } from "@medusajs/framework/types" +import type { + IInventoryService, + InventoryTypes, +} from "@medusajs/framework/types" import { convertItemResponseToUpdateRequest, getSelectsAndRelationsFromObjectArray, @@ -10,12 +13,13 @@ import { Modules } from "@medusajs/framework/utils" /** * The data to update reservation items. */ -export type UpdateReservationsStepInput = InventoryTypes.UpdateReservationItemInput[] +export type UpdateReservationsStepInput = + InventoryTypes.UpdateReservationItemInput[] export const updateReservationsStepId = "update-reservations-step" /** * This step updates one or more reservations. - * + * * @example * const data = updateReservationsStep([ * { diff --git a/packages/core/core-flows/src/reservation/workflows/create-reservations.ts b/packages/core/core-flows/src/reservation/workflows/create-reservations.ts index bac872b17a..466eb26f7d 100644 --- a/packages/core/core-flows/src/reservation/workflows/create-reservations.ts +++ b/packages/core/core-flows/src/reservation/workflows/create-reservations.ts @@ -4,17 +4,17 @@ import { createWorkflow, } from "@medusajs/framework/workflows-sdk" -import { WorkflowTypes } from "@medusajs/framework/types" +import type { WorkflowTypes } from "@medusajs/framework/types" import { createReservationsStep } from "../steps" export const createReservationsWorkflowId = "create-reservations-workflow" /** - * This workflow creates one or more reservations. It's used by the + * This workflow creates one or more reservations. It's used by the * [Create Reservations Admin API Route](https://docs.medusajs.com/api/admin#reservations_postreservations). - * + * * You can use this workflow within your own customizations or custom workflows, allowing you * to create reservations in your custom flows. - * + * * @example * const { result } = await createReservationsWorkflow(container) * .run({ @@ -28,9 +28,9 @@ export const createReservationsWorkflowId = "create-reservations-workflow" * ] * } * }) - * + * * @summary - * + * * Create one or more reservations. */ export const createReservationsWorkflow = createWorkflow( diff --git a/packages/core/core-flows/src/reservation/workflows/update-reservations.ts b/packages/core/core-flows/src/reservation/workflows/update-reservations.ts index 1476a49f55..ef55b2c892 100644 --- a/packages/core/core-flows/src/reservation/workflows/update-reservations.ts +++ b/packages/core/core-flows/src/reservation/workflows/update-reservations.ts @@ -4,17 +4,17 @@ import { createWorkflow, } from "@medusajs/framework/workflows-sdk" -import { WorkflowTypes } from "@medusajs/framework/types" +import type { WorkflowTypes } from "@medusajs/framework/types" import { updateReservationsStep } from "../steps" export const updateReservationsWorkflowId = "update-reservations-workflow" /** - * This workflow updates one or more reservations. It's used by the + * This workflow updates one or more reservations. It's used by the * [Update Reservations Admin API Route](https://docs.medusajs.com/api/admin#reservations_postreservationsid). - * + * * You can use this workflow within your own customizations or custom workflows, allowing you * to update reservations in your custom flows. - * + * * @example * const { result } = await updateReservationsWorkflow(container) * .run({ @@ -27,9 +27,9 @@ export const updateReservationsWorkflowId = "update-reservations-workflow" * ] * } * }) - * + * * @summary - * + * * Update one or more reservations. */ export const updateReservationsWorkflow = createWorkflow( diff --git a/packages/core/core-flows/src/return-reason/steps/delete-return-reasons.ts b/packages/core/core-flows/src/return-reason/steps/delete-return-reasons.ts index a0d6858442..4cb48ba51b 100644 --- a/packages/core/core-flows/src/return-reason/steps/delete-return-reasons.ts +++ b/packages/core/core-flows/src/return-reason/steps/delete-return-reasons.ts @@ -1,4 +1,4 @@ -import { IOrderModuleService } from "@medusajs/framework/types" +import type { IOrderModuleService } from "@medusajs/framework/types" import { Modules } from "@medusajs/framework/utils" import { createStep, StepResponse } from "@medusajs/framework/workflows-sdk" @@ -10,7 +10,7 @@ export type DeleteReturnReasonStepInput = string[] export const deleteReturnReasonStepId = "delete-return-reasons" /** * This step deletes one or more return reasons. - * + * * @example * const data = deleteReturnReasonStep(["rr_123"]) */ diff --git a/packages/core/core-flows/src/sales-channel/steps/delete-sales-channels.ts b/packages/core/core-flows/src/sales-channel/steps/delete-sales-channels.ts index 1073d2016b..96458a5b1a 100644 --- a/packages/core/core-flows/src/sales-channel/steps/delete-sales-channels.ts +++ b/packages/core/core-flows/src/sales-channel/steps/delete-sales-channels.ts @@ -1,4 +1,4 @@ -import { ISalesChannelModuleService } from "@medusajs/framework/types" +import type { ISalesChannelModuleService } from "@medusajs/framework/types" import { Modules } from "@medusajs/framework/utils" import { StepResponse, createStep } from "@medusajs/framework/workflows-sdk" diff --git a/packages/core/core-flows/src/sales-channel/workflows/link-products-to-sales-channel.ts b/packages/core/core-flows/src/sales-channel/workflows/link-products-to-sales-channel.ts index 975877d2e6..b0fc4345e1 100644 --- a/packages/core/core-flows/src/sales-channel/workflows/link-products-to-sales-channel.ts +++ b/packages/core/core-flows/src/sales-channel/workflows/link-products-to-sales-channel.ts @@ -1,4 +1,4 @@ -import { LinkWorkflowInput } from "@medusajs/framework/types" +import type { LinkWorkflowInput } from "@medusajs/framework/types" import { WorkflowData, createWorkflow } from "@medusajs/framework/workflows-sdk" import { associateProductsWithSalesChannelsStep } from "../steps/associate-products-with-channels" import { transform } from "@medusajs/framework/workflows-sdk" @@ -6,7 +6,7 @@ import { detachProductsFromSalesChannelsStep } from "../steps" /** * The data to manage products available in a sales channel. - * + * * @property id - The ID of the sales channel. * @property add - The products to add to the sales channel. * @property remove - The products to remove from the sales channel. @@ -18,10 +18,10 @@ export const linkProductsToSalesChannelWorkflowId = /** * This workflow manages the products available in a sales channel. It's used by the * [Manage Products Admin API Route](https://docs.medusajs.com/api/admin#sales-channels_postsaleschannelsidproducts). - * + * * You can use this workflow within your customizations or your own custom workflows, allowing you to * manage the products available in a sales channel within your custom flows. - * + * * @example * const { result } = await linkProductsToSalesChannelWorkflow(container) * .run({ @@ -31,14 +31,16 @@ export const linkProductsToSalesChannelWorkflowId = * remove: ["prod_321"] * } * }) - * + * * @summary - * + * * Manage the products available in a sales channel. */ export const linkProductsToSalesChannelWorkflow = createWorkflow( linkProductsToSalesChannelWorkflowId, - (input: WorkflowData): WorkflowData => { + ( + input: WorkflowData + ): WorkflowData => { const toAdd = transform({ input }, (data) => { return data.input.add?.map((productId) => ({ sales_channel_id: data.input.id, diff --git a/packages/core/core-flows/src/shipping-options/steps/create-shipping-option-types.ts b/packages/core/core-flows/src/shipping-options/steps/create-shipping-option-types.ts index ead25491f4..a787f8a36b 100644 --- a/packages/core/core-flows/src/shipping-options/steps/create-shipping-option-types.ts +++ b/packages/core/core-flows/src/shipping-options/steps/create-shipping-option-types.ts @@ -1,18 +1,22 @@ -import { FulfillmentTypes, IFulfillmentModuleService, } from "@medusajs/framework/types" +import type { + FulfillmentTypes, + IFulfillmentModuleService, +} from "@medusajs/framework/types" import { Modules } from "@medusajs/framework/utils" import { createStep, StepResponse } from "@medusajs/framework/workflows-sdk" /** * The shipping option types to create. */ -export type CreateShippingOptionTypesStepInput = FulfillmentTypes.CreateShippingOptionTypeDTO[] +export type CreateShippingOptionTypesStepInput = + FulfillmentTypes.CreateShippingOptionTypeDTO[] export const createShippingOptionTypesStepId = "create-shipping-option-types" /** * This step creates one or more shipping option types. - * + * * @since 2.10.0 - * + * * @example * const shippingOptionTypes = createShippingOptionTypesStep([ * { @@ -25,7 +29,9 @@ export const createShippingOptionTypesStepId = "create-shipping-option-types" export const createShippingOptionTypesStep = createStep( createShippingOptionTypesStepId, async (data: CreateShippingOptionTypesStepInput, { container }) => { - const service = container.resolve(Modules.FULFILLMENT) + const service = container.resolve( + Modules.FULFILLMENT + ) const created = await service.createShippingOptionTypes(data) return new StepResponse( @@ -38,7 +44,9 @@ export const createShippingOptionTypesStep = createStep( return } - const service = container.resolve(Modules.FULFILLMENT) + const service = container.resolve( + Modules.FULFILLMENT + ) await service.deleteShippingOptionTypes(createdIds) } diff --git a/packages/core/core-flows/src/shipping-options/steps/delete-shipping-option-types.ts b/packages/core/core-flows/src/shipping-options/steps/delete-shipping-option-types.ts index 57408076ff..eb08bf6aad 100644 --- a/packages/core/core-flows/src/shipping-options/steps/delete-shipping-option-types.ts +++ b/packages/core/core-flows/src/shipping-options/steps/delete-shipping-option-types.ts @@ -1,4 +1,4 @@ -import { IFulfillmentModuleService, } from "@medusajs/framework/types" +import type { IFulfillmentModuleService } from "@medusajs/framework/types" import { Modules } from "@medusajs/framework/utils" import { createStep, StepResponse } from "@medusajs/framework/workflows-sdk" @@ -10,13 +10,15 @@ export type DeleteShippingOptionTypesStepInput = string[] export const deleteShippingOptionTypesStepId = "delete-shipping-option-types" /** * This step deletes one or more shipping option types. - * + * * @since 2.10.0 */ export const deleteShippingOptionTypesStep = createStep( deleteShippingOptionTypesStepId, async (ids: DeleteShippingOptionTypesStepInput, { container }) => { - const service = container.resolve(Modules.FULFILLMENT) + const service = container.resolve( + Modules.FULFILLMENT + ) await service.softDeleteShippingOptionTypes(ids) return new StepResponse(void 0, ids) @@ -26,7 +28,9 @@ export const deleteShippingOptionTypesStep = createStep( return } - const service = container.resolve(Modules.FULFILLMENT) + const service = container.resolve( + Modules.FULFILLMENT + ) await service.restoreShippingOptionTypes(prevIds) } diff --git a/packages/core/core-flows/src/shipping-options/steps/update-shipping-option-types.ts b/packages/core/core-flows/src/shipping-options/steps/update-shipping-option-types.ts index fc25e3a570..26c21b524a 100644 --- a/packages/core/core-flows/src/shipping-options/steps/update-shipping-option-types.ts +++ b/packages/core/core-flows/src/shipping-options/steps/update-shipping-option-types.ts @@ -1,5 +1,11 @@ -import { FulfillmentTypes, IFulfillmentModuleService, } from "@medusajs/framework/types" -import { getSelectsAndRelationsFromObjectArray, Modules, } from "@medusajs/framework/utils" +import type { + FulfillmentTypes, + IFulfillmentModuleService, +} from "@medusajs/framework/types" +import { + getSelectsAndRelationsFromObjectArray, + Modules, +} from "@medusajs/framework/utils" import { createStep, StepResponse } from "@medusajs/framework/workflows-sdk" /** @@ -19,9 +25,9 @@ export type UpdateShippingOptionTypesStepInput = { export const updateShippingOptionTypesStepId = "update-shipping-option-types" /** * This step updates shipping option types matching the specified filters. - * + * * @since 2.10.0 - * + * * @example * const shippingOptionTypes = updateShippingOptionTypesStep({ * selector: { @@ -35,7 +41,9 @@ export const updateShippingOptionTypesStepId = "update-shipping-option-types" export const updateShippingOptionTypesStep = createStep( updateShippingOptionTypesStepId, async (data: UpdateShippingOptionTypesStepInput, { container }) => { - const service = container.resolve(Modules.FULFILLMENT) + const service = container.resolve( + Modules.FULFILLMENT + ) const { selects, relations } = getSelectsAndRelationsFromObjectArray([ data.update, @@ -57,7 +65,9 @@ export const updateShippingOptionTypesStep = createStep( return } - const service = container.resolve(Modules.FULFILLMENT) + const service = container.resolve( + Modules.FULFILLMENT + ) await service.upsertShippingOptionTypes(prevData) } diff --git a/packages/core/core-flows/src/shipping-options/workflows/create-shipping-option-types.ts b/packages/core/core-flows/src/shipping-options/workflows/create-shipping-option-types.ts index fc3e0ca675..33c405e3bb 100644 --- a/packages/core/core-flows/src/shipping-options/workflows/create-shipping-option-types.ts +++ b/packages/core/core-flows/src/shipping-options/workflows/create-shipping-option-types.ts @@ -1,4 +1,7 @@ -import { AdditionalData, FulfillmentTypes, } from "@medusajs/framework/types" +import type { + AdditionalData, + FulfillmentTypes, +} from "@medusajs/framework/types" import { ShippingOptionTypeWorkflowEvents } from "@medusajs/framework/utils" import { createHook, @@ -20,18 +23,19 @@ export type CreateShippingOptionTypesWorkflowInput = { shipping_option_types: FulfillmentTypes.CreateShippingOptionTypeDTO[] } & AdditionalData -export const createShippingOptionTypesWorkflowId = "create-shipping-option-types" +export const createShippingOptionTypesWorkflowId = + "create-shipping-option-types" /** * This workflow creates one or more shipping option types. It's used by the * [Create Shipping Option Type Admin API Route](https://docs.medusajs.com/api/admin#shipping-option-types_postshippingoptiontypes). - * + * * This workflow has a hook that allows you to perform custom actions on the created shipping option types. For example, you can pass under `additional_data` custom data that * allows you to create custom data models linked to the shipping option types. - * + * * You can also use this workflow within your own custom workflows, allowing you to wrap custom logic around shipping option type creation. - * + * * @since 2.10.0 - * + * * @example * const { result } = await createShippingOptionTypesWorkflow(container) * .run({ @@ -48,27 +52,35 @@ export const createShippingOptionTypesWorkflowId = "create-shipping-option-types * } * } * }) - * + * * @summary - * + * * Create one or more shipping option types. - * + * * @property hooks.shippingOptionTypesCreated - This hook is executed after the shipping option types are created. You can consume this hook to perform custom actions on the created shipping option types. */ export const createShippingOptionTypesWorkflow = createWorkflow( createShippingOptionTypesWorkflowId, (input: WorkflowData) => { - const shippingOptionTypes = createShippingOptionTypesStep(input.shipping_option_types) - const shippingOptionTypesCreated = createHook("shippingOptionTypesCreated", { - shipping_option_types: shippingOptionTypes, - additional_data: input.additional_data, - }) + const shippingOptionTypes = createShippingOptionTypesStep( + input.shipping_option_types + ) + const shippingOptionTypesCreated = createHook( + "shippingOptionTypesCreated", + { + shipping_option_types: shippingOptionTypes, + additional_data: input.additional_data, + } + ) - const typeIdEvents = transform({ shippingOptionTypes }, ({ shippingOptionTypes }) => { - return shippingOptionTypes.map((v) => { - return { id: v.id } - }) - }) + const typeIdEvents = transform( + { shippingOptionTypes }, + ({ shippingOptionTypes }) => { + return shippingOptionTypes.map((v) => { + return { id: v.id } + }) + } + ) emitEventStep({ eventName: ShippingOptionTypeWorkflowEvents.CREATED, diff --git a/packages/core/core-flows/src/shipping-options/workflows/update-shipping-option-types.ts b/packages/core/core-flows/src/shipping-options/workflows/update-shipping-option-types.ts index 1d47e2a7cf..75c963d1bd 100644 --- a/packages/core/core-flows/src/shipping-options/workflows/update-shipping-option-types.ts +++ b/packages/core/core-flows/src/shipping-options/workflows/update-shipping-option-types.ts @@ -1,4 +1,7 @@ -import { AdditionalData, FulfillmentTypes } from "@medusajs/framework/types" +import type { + AdditionalData, + FulfillmentTypes, +} from "@medusajs/framework/types" import { ShippingOptionTypeWorkflowEvents } from "@medusajs/framework/utils" import { createHook, @@ -24,18 +27,19 @@ export type UpdateShippingOptionTypesWorkflowInput = { update: FulfillmentTypes.UpdateShippingOptionTypeDTO } & AdditionalData -export const updateShippingOptionTypesWorkflowId = "update-shipping-option-types" +export const updateShippingOptionTypesWorkflowId = + "update-shipping-option-types" /** * This workflow updates one or more shipping option types. It's used by the * [Update Shipping Option Type Admin API Route](https://docs.medusajs.com/api/admin#shipping-option-types_postshippingoptiontypesid). - * + * * This workflow has a hook that allows you to perform custom actions on the updated shipping option types. For example, you can pass under `additional_data` custom data that * allows you to update custom data models linked to the shipping option types. - * + * * You can also use this workflow within your own custom workflows, allowing you to wrap custom logic around shipping option type updates. - * + * * @since 2.10.0 - * + * * @example * const { result } = await updateShippingOptionTypesWorkflow(container) * .run({ @@ -51,21 +55,24 @@ export const updateShippingOptionTypesWorkflowId = "update-shipping-option-types * } * } * }) - * + * * @summary - * + * * Update one or more shipping option types. - * + * * @property hooks.shippingOptionTypesUpdated - This hook is executed after the shipping option types are updated. You can consume this hook to perform custom actions on the updated shipping option types. */ export const updateShippingOptionTypesWorkflow = createWorkflow( updateShippingOptionTypesWorkflowId, (input: WorkflowData) => { const updatedShippingOptionTypes = updateShippingOptionTypesStep(input) - const shippingOptionTypesUpdated = createHook("shippingOptionTypesUpdated", { - shipping_option_types: updatedShippingOptionTypes, - additional_data: input.additional_data, - }) + const shippingOptionTypesUpdated = createHook( + "shippingOptionTypesUpdated", + { + shipping_option_types: updatedShippingOptionTypes, + additional_data: input.additional_data, + } + ) const typeIdEvents = transform( { updatedShippingOptionTypes }, diff --git a/packages/core/core-flows/src/shipping-profile/steps/delete-shipping-profile.ts b/packages/core/core-flows/src/shipping-profile/steps/delete-shipping-profile.ts index 50203f5228..be3bf4850e 100644 --- a/packages/core/core-flows/src/shipping-profile/steps/delete-shipping-profile.ts +++ b/packages/core/core-flows/src/shipping-profile/steps/delete-shipping-profile.ts @@ -1,4 +1,4 @@ -import { IFulfillmentModuleService } from "@medusajs/framework/types" +import type { IFulfillmentModuleService } from "@medusajs/framework/types" import { Modules } from "@medusajs/framework/utils" import { StepResponse, createStep } from "@medusajs/framework/workflows-sdk" diff --git a/packages/core/core-flows/src/stock-location/workflows/create-location-fulfillment-set.ts b/packages/core/core-flows/src/stock-location/workflows/create-location-fulfillment-set.ts index 471456782e..ac9ebcb7c3 100644 --- a/packages/core/core-flows/src/stock-location/workflows/create-location-fulfillment-set.ts +++ b/packages/core/core-flows/src/stock-location/workflows/create-location-fulfillment-set.ts @@ -1,4 +1,4 @@ -import { CreateLocationFulfillmentSetWorkflowInputDTO } from "@medusajs/framework/types" +import type { CreateLocationFulfillmentSetWorkflowInputDTO } from "@medusajs/framework/types" import { WorkflowData, createWorkflow, @@ -12,10 +12,10 @@ export const createLocationFulfillmentSetWorkflowId = /** * This workflow adds a fulfillment set to a stock location. It's used by the * [Add Fulfillment Set to Stock Location Admin API Route](https://docs.medusajs.com/api/admin#stock-locations_poststocklocationsidfulfillmentsets). - * + * * You can use this workflow within your own customizations or custom workflows, allowing you * to add fulfillment sets to a stock location in your custom flows. - * + * * @example * const { result } = await createLocationFulfillmentSetWorkflow(container) * .run({ @@ -27,9 +27,9 @@ export const createLocationFulfillmentSetWorkflowId = * } * } * }) - * + * * @summary - * + * * Add fulfillment set to a stock location. */ export const createLocationFulfillmentSetWorkflow = createWorkflow( diff --git a/packages/core/core-flows/src/stock-location/workflows/create-stock-locations.ts b/packages/core/core-flows/src/stock-location/workflows/create-stock-locations.ts index 8ddd079868..69c3f8586a 100644 --- a/packages/core/core-flows/src/stock-location/workflows/create-stock-locations.ts +++ b/packages/core/core-flows/src/stock-location/workflows/create-stock-locations.ts @@ -5,7 +5,7 @@ import { createWorkflow, } from "@medusajs/framework/workflows-sdk" -import { CreateStockLocationInput } from "@medusajs/framework/types" +import type { CreateStockLocationInput } from "@medusajs/framework/types" import { createStockLocations } from "../steps" /** @@ -22,10 +22,10 @@ export const createStockLocationsWorkflowId = "create-stock-locations-workflow" /** * This workflow creates one or more stock locations. It's used by the * [Create Stock Location Admin API Route](https://docs.medusajs.com/api/admin#stock-locations_poststocklocations). - * + * * You can use this workflow within your own customizations or custom workflows, allowing you * to create stock locations in your custom flows. - * + * * @example * const { result } = await createStockLocationsWorkflow(container) * .run({ @@ -37,9 +37,9 @@ export const createStockLocationsWorkflowId = "create-stock-locations-workflow" * ] * } * }) - * + * * @summary - * + * * Create one or more stock locations. */ export const createStockLocationsWorkflow = createWorkflow( diff --git a/packages/core/core-flows/src/stock-location/workflows/link-sales-channels-to-stock-location.ts b/packages/core/core-flows/src/stock-location/workflows/link-sales-channels-to-stock-location.ts index 1de7c1f24b..e6e5a7daee 100644 --- a/packages/core/core-flows/src/stock-location/workflows/link-sales-channels-to-stock-location.ts +++ b/packages/core/core-flows/src/stock-location/workflows/link-sales-channels-to-stock-location.ts @@ -1,4 +1,4 @@ -import { LinkWorkflowInput } from "@medusajs/framework/types" +import type { LinkWorkflowInput } from "@medusajs/framework/types" import { WorkflowData, createWorkflow } from "@medusajs/framework/workflows-sdk" import { transform } from "@medusajs/framework/workflows-sdk" import { @@ -8,7 +8,7 @@ import { /** * The sales channels to manage for a stock location. - * + * * @property id - The ID of the stock location. * @property add - The IDs of the sales channels to add to the stock location. * @property remove - The IDs of the sales channels to remove from the stock location. @@ -20,11 +20,11 @@ export const linkSalesChannelsToStockLocationWorkflowId = /** * This workflow manages the sales channels of a stock location. It's used by the * [Manage Sales Channels Admin API Route](https://docs.medusajs.com/api/admin#stock-locations_poststocklocationsidsaleschannels). - * + * * You can use this workflow within your own customizations or custom workflows, allowing you * to manage the sales channels of a stock location in your custom flows. - * - * @example + * + * @example * const { result } = await linkSalesChannelsToStockLocationWorkflow(container) * .run({ * input: { @@ -33,14 +33,16 @@ export const linkSalesChannelsToStockLocationWorkflowId = * remove: ["sc_321"] * } * }) - * + * * @summary - * + * * Manage the sales channels of a stock location. */ export const linkSalesChannelsToStockLocationWorkflow = createWorkflow( linkSalesChannelsToStockLocationWorkflowId, - (input: WorkflowData): void => { + ( + input: WorkflowData + ): void => { const toAdd = transform({ input }, (data) => { return data.input.add?.map((salesChannelId) => ({ sales_channel_id: salesChannelId, diff --git a/packages/core/core-flows/src/store/steps/create-stores.ts b/packages/core/core-flows/src/store/steps/create-stores.ts index 1bbda7226e..d81fe79367 100644 --- a/packages/core/core-flows/src/store/steps/create-stores.ts +++ b/packages/core/core-flows/src/store/steps/create-stores.ts @@ -1,11 +1,14 @@ -import { CreateStoreDTO, IStoreModuleService } from "@medusajs/framework/types" +import type { + CreateStoreDTO, + IStoreModuleService, +} from "@medusajs/framework/types" import { Modules } from "@medusajs/framework/utils" import { StepResponse, createStep } from "@medusajs/framework/workflows-sdk" export const createStoresStepId = "create-stores" /** * This step creates one or more stores. - * + * * @example * const data = createStoresStep([{ * name: "Acme" diff --git a/packages/core/core-flows/src/store/steps/delete-stores.ts b/packages/core/core-flows/src/store/steps/delete-stores.ts index aaa33aa931..b6d7f06b97 100644 --- a/packages/core/core-flows/src/store/steps/delete-stores.ts +++ b/packages/core/core-flows/src/store/steps/delete-stores.ts @@ -1,4 +1,4 @@ -import { IStoreModuleService } from "@medusajs/framework/types" +import type { IStoreModuleService } from "@medusajs/framework/types" import { Modules } from "@medusajs/framework/utils" import { StepResponse, createStep } from "@medusajs/framework/workflows-sdk" diff --git a/packages/core/core-flows/src/store/workflows/create-stores.ts b/packages/core/core-flows/src/store/workflows/create-stores.ts index 5221ca9fdb..1676471504 100644 --- a/packages/core/core-flows/src/store/workflows/create-stores.ts +++ b/packages/core/core-flows/src/store/workflows/create-stores.ts @@ -1,4 +1,4 @@ -import { StoreDTO, StoreWorkflow } from "@medusajs/framework/types" +import type { StoreDTO, StoreWorkflow } from "@medusajs/framework/types" import { WorkflowData, WorkflowResponse, @@ -27,10 +27,10 @@ export const createStoresWorkflowId = "create-stores" /** * This workflow creates one or more stores. By default, Medusa uses a single store. This is useful * if you're building a multi-tenant application or a marketplace where each tenant has its own store. - * + * * You can use this workflow within your customizations or your own custom workflows, allowing you to * create stores within your custom flows. - * + * * @example * const { result } = await createStoresWorkflow(container) * .run({ @@ -46,9 +46,9 @@ export const createStoresWorkflowId = "create-stores" * ] * } * }) - * + * * @summary - * + * * Create one or more stores. */ export const createStoresWorkflow = createWorkflow( diff --git a/packages/core/core-flows/src/store/workflows/update-stores.ts b/packages/core/core-flows/src/store/workflows/update-stores.ts index f67b536700..ee553c7197 100644 --- a/packages/core/core-flows/src/store/workflows/update-stores.ts +++ b/packages/core/core-flows/src/store/workflows/update-stores.ts @@ -1,4 +1,4 @@ -import { StoreDTO, StoreWorkflow } from "@medusajs/framework/types" +import type { StoreDTO, StoreWorkflow } from "@medusajs/framework/types" import { WorkflowData, WorkflowResponse, @@ -18,10 +18,10 @@ export const updateStoresWorkflowId = "update-stores" /** * This workflow updates stores matching the specified filters. It's used by the * [Update Store Admin API Route](https://docs.medusajs.com/api/admin#stores_poststoresid). - * + * * You can use this workflow within your customizations or your own custom workflows, allowing you to * update stores within your custom flows. - * + * * @example * const { result } = await updateStoresWorkflow(container) * .run({ @@ -34,9 +34,9 @@ export const updateStoresWorkflowId = "update-stores" * } * } * }) - * + * * @summary - * + * * Update stores. */ export const updateStoresWorkflow = createWorkflow( diff --git a/packages/core/core-flows/src/tax/steps/create-tax-rates.ts b/packages/core/core-flows/src/tax/steps/create-tax-rates.ts index 2fd72f16ac..7e1ce6db75 100644 --- a/packages/core/core-flows/src/tax/steps/create-tax-rates.ts +++ b/packages/core/core-flows/src/tax/steps/create-tax-rates.ts @@ -1,11 +1,14 @@ -import { CreateTaxRateDTO, ITaxModuleService } from "@medusajs/framework/types" +import type { + CreateTaxRateDTO, + ITaxModuleService, +} from "@medusajs/framework/types" import { Modules } from "@medusajs/framework/utils" import { StepResponse, createStep } from "@medusajs/framework/workflows-sdk" export const createTaxRatesStepId = "create-tax-rates" /** * This step creates one or more tax rates. - * + * * @example * const data = createTaxRatesStep([ * { diff --git a/packages/core/core-flows/src/tax/steps/delete-tax-rate-rules.ts b/packages/core/core-flows/src/tax/steps/delete-tax-rate-rules.ts index c0bc44a624..5bf5224f01 100644 --- a/packages/core/core-flows/src/tax/steps/delete-tax-rate-rules.ts +++ b/packages/core/core-flows/src/tax/steps/delete-tax-rate-rules.ts @@ -1,4 +1,4 @@ -import { ITaxModuleService } from "@medusajs/framework/types" +import type { ITaxModuleService } from "@medusajs/framework/types" import { Modules } from "@medusajs/framework/utils" import { StepResponse, createStep } from "@medusajs/framework/workflows-sdk" diff --git a/packages/core/core-flows/src/tax/steps/delete-tax-rates.ts b/packages/core/core-flows/src/tax/steps/delete-tax-rates.ts index 7c12c9ea20..3cf51e7a36 100644 --- a/packages/core/core-flows/src/tax/steps/delete-tax-rates.ts +++ b/packages/core/core-flows/src/tax/steps/delete-tax-rates.ts @@ -1,4 +1,4 @@ -import { ITaxModuleService } from "@medusajs/framework/types" +import type { ITaxModuleService } from "@medusajs/framework/types" import { Modules } from "@medusajs/framework/utils" import { createStep, StepResponse } from "@medusajs/framework/workflows-sdk" diff --git a/packages/core/core-flows/src/tax/steps/delete-tax-regions.ts b/packages/core/core-flows/src/tax/steps/delete-tax-regions.ts index 973e05733b..16352e1a7f 100644 --- a/packages/core/core-flows/src/tax/steps/delete-tax-regions.ts +++ b/packages/core/core-flows/src/tax/steps/delete-tax-regions.ts @@ -1,4 +1,4 @@ -import { ITaxModuleService } from "@medusajs/framework/types" +import type { ITaxModuleService } from "@medusajs/framework/types" import { Modules } from "@medusajs/framework/utils" import { StepResponse, createStep } from "@medusajs/framework/workflows-sdk" diff --git a/packages/core/core-flows/src/tax/workflows/create-tax-rate-rules.ts b/packages/core/core-flows/src/tax/workflows/create-tax-rate-rules.ts index 6d1b67b7c1..02c53f62c4 100644 --- a/packages/core/core-flows/src/tax/workflows/create-tax-rate-rules.ts +++ b/packages/core/core-flows/src/tax/workflows/create-tax-rate-rules.ts @@ -1,4 +1,7 @@ -import { CreateTaxRateRuleDTO, TaxRateRuleDTO } from "@medusajs/framework/types" +import type { + CreateTaxRateRuleDTO, + TaxRateRuleDTO, +} from "@medusajs/framework/types" import { WorkflowData, WorkflowResponse, @@ -25,10 +28,10 @@ export const createTaxRateRulesWorkflowId = "create-tax-rate-rules" /** * This workflow creates one or more tax rules for rates. It's used by the * [Create Tax Rules for Rates Admin API Route](https://docs.medusajs.com/api/admin#tax-rates_posttaxratesidrules). - * + * * You can use this workflow within your own customizations or custom workflows, allowing you * to create tax rules for rates in your custom flows. - * + * * @example * const { result } = await createTaxRateRulesWorkflow(container) * .run({ @@ -42,9 +45,9 @@ export const createTaxRateRulesWorkflowId = "create-tax-rate-rules" * ] * } * }) - * + * * @summary - * + * * Create one or more tax rules for rates. */ export const createTaxRateRulesWorkflow = createWorkflow( diff --git a/packages/core/core-flows/src/tax/workflows/create-tax-rates.ts b/packages/core/core-flows/src/tax/workflows/create-tax-rates.ts index af45be66be..a86f561e90 100644 --- a/packages/core/core-flows/src/tax/workflows/create-tax-rates.ts +++ b/packages/core/core-flows/src/tax/workflows/create-tax-rates.ts @@ -1,4 +1,4 @@ -import { CreateTaxRateDTO, TaxRateDTO } from "@medusajs/framework/types" +import type { CreateTaxRateDTO, TaxRateDTO } from "@medusajs/framework/types" import { WorkflowData, WorkflowResponse, @@ -20,10 +20,10 @@ export const createTaxRatesWorkflowId = "create-tax-rates" /** * This workflow creates one or more tax rates. It's used by the * [Create Tax Rates Admin API Route](https://docs.medusajs.com/api/admin#tax-rates_posttaxrates). - * + * * You can use this workflow within your own customizations or custom workflows, allowing you * to create tax rates in your custom flows. - * + * * @example * const { result } = await createTaxRatesWorkflow(container) * .run({ @@ -34,16 +34,16 @@ export const createTaxRatesWorkflowId = "create-tax-rates" * } * ] * }) - * + * * @summary - * + * * Create one or more tax rates. */ export const createTaxRatesWorkflow = createWorkflow( createTaxRatesWorkflowId, - (input: WorkflowData): WorkflowResponse< - CreateTaxRatesWorkflowOutput - > => { + ( + input: WorkflowData + ): WorkflowResponse => { return new WorkflowResponse(createTaxRatesStep(input)) } ) diff --git a/packages/core/core-flows/src/tax/workflows/create-tax-regions.ts b/packages/core/core-flows/src/tax/workflows/create-tax-regions.ts index 4f76af575f..bb775572ce 100644 --- a/packages/core/core-flows/src/tax/workflows/create-tax-regions.ts +++ b/packages/core/core-flows/src/tax/workflows/create-tax-regions.ts @@ -1,4 +1,7 @@ -import { CreateTaxRegionDTO, TaxRegionDTO } from "@medusajs/framework/types" +import type { + CreateTaxRegionDTO, + TaxRegionDTO, +} from "@medusajs/framework/types" import { WorkflowData, WorkflowResponse, @@ -20,10 +23,10 @@ export const createTaxRegionsWorkflowId = "create-tax-regions" /** * This workflow creates one or more tax regions. It's used by the * [Create Tax Region Admin API Route](https://docs.medusajs.com/api/admin#tax-regions_posttaxregions). - * + * * You can use this workflow within your own customizations or custom workflows, allowing you * to create tax regions in your custom flows. - * + * * @example * const { result } = await createTaxRegionsWorkflow(container) * .run({ @@ -33,9 +36,9 @@ export const createTaxRegionsWorkflowId = "create-tax-regions" * } * ] * }) - * + * * @summary - * + * * Create one or more tax regions. */ export const createTaxRegionsWorkflow = createWorkflow( diff --git a/packages/core/core-flows/src/tax/workflows/set-tax-rate-rules.ts b/packages/core/core-flows/src/tax/workflows/set-tax-rate-rules.ts index c029e171d5..a74cd8b819 100644 --- a/packages/core/core-flows/src/tax/workflows/set-tax-rate-rules.ts +++ b/packages/core/core-flows/src/tax/workflows/set-tax-rate-rules.ts @@ -1,4 +1,7 @@ -import { CreateTaxRateRuleDTO, TaxRateRuleDTO } from "@medusajs/framework/types" +import type { + CreateTaxRateRuleDTO, + TaxRateRuleDTO, +} from "@medusajs/framework/types" import { WorkflowData, WorkflowResponse, @@ -28,10 +31,10 @@ export type SetTaxRatesRulesWorkflowInput = { export const setTaxRateRulesWorkflowId = "set-tax-rate-rules" /** * This workflow sets the rules of tax rates. - * + * * You can use this workflow within your own customizations or custom workflows, allowing you * to set the rules of tax rates in your custom flows. - * + * * @example * const { result } = await setTaxRateRulesWorkflow(container) * .run({ @@ -45,9 +48,9 @@ export const setTaxRateRulesWorkflowId = "set-tax-rate-rules" * ] * } * }) - * + * * @summary - * + * * Set the rules of tax rates. */ export const setTaxRateRulesWorkflow = createWorkflow( diff --git a/packages/core/core-flows/src/tax/workflows/update-tax-regions.ts b/packages/core/core-flows/src/tax/workflows/update-tax-regions.ts index a234e35184..b9d2ce0c10 100644 --- a/packages/core/core-flows/src/tax/workflows/update-tax-regions.ts +++ b/packages/core/core-flows/src/tax/workflows/update-tax-regions.ts @@ -1,4 +1,7 @@ -import { TaxRegionDTO, UpdateTaxRegionDTO } from "@medusajs/framework/types" +import type { + TaxRegionDTO, + UpdateTaxRegionDTO, +} from "@medusajs/framework/types" import { WorkflowData, WorkflowResponse, diff --git a/packages/core/core-flows/src/user/steps/create-users.ts b/packages/core/core-flows/src/user/steps/create-users.ts index 160a5b23cf..e2df170229 100644 --- a/packages/core/core-flows/src/user/steps/create-users.ts +++ b/packages/core/core-flows/src/user/steps/create-users.ts @@ -1,12 +1,15 @@ -import { CreateUserDTO, IUserModuleService } from "@medusajs/framework/types" +import type { + CreateUserDTO, + IUserModuleService, +} from "@medusajs/framework/types" import { Modules } from "@medusajs/framework/utils" import { StepResponse, createStep } from "@medusajs/framework/workflows-sdk" export const createUsersStepId = "create-users-step" /** - * This step creates one or more users. To allow these users to log in, + * This step creates one or more users. To allow these users to log in, * you must attach an auth identity to each user using the {@link setAuthAppMetadataStep}. - * + * * @example * const data = createUsersStep([ * { diff --git a/packages/core/core-flows/src/user/steps/delete-users.ts b/packages/core/core-flows/src/user/steps/delete-users.ts index ba12f574ea..4a70122502 100644 --- a/packages/core/core-flows/src/user/steps/delete-users.ts +++ b/packages/core/core-flows/src/user/steps/delete-users.ts @@ -1,4 +1,4 @@ -import { IUserModuleService } from "@medusajs/framework/types" +import type { IUserModuleService } from "@medusajs/framework/types" import { Modules } from "@medusajs/framework/utils" import { StepResponse, createStep } from "@medusajs/framework/workflows-sdk" diff --git a/packages/core/core-flows/src/user/steps/update-users.ts b/packages/core/core-flows/src/user/steps/update-users.ts index 13a3ef43a2..7db282afb9 100644 --- a/packages/core/core-flows/src/user/steps/update-users.ts +++ b/packages/core/core-flows/src/user/steps/update-users.ts @@ -1,11 +1,14 @@ -import { IUserModuleService, UpdateUserDTO } from "@medusajs/framework/types" +import type { + IUserModuleService, + UpdateUserDTO, +} from "@medusajs/framework/types" import { Modules } from "@medusajs/framework/utils" import { StepResponse, createStep } from "@medusajs/framework/workflows-sdk" export const updateUsersStepId = "update-users-step" /** * This step updates one or more users. - * + * * @example * const data = updateUsersStep([ * { diff --git a/packages/core/core-flows/src/user/workflows/create-user-account.ts b/packages/core/core-flows/src/user/workflows/create-user-account.ts index 22d389ba6a..9de2547a9d 100644 --- a/packages/core/core-flows/src/user/workflows/create-user-account.ts +++ b/packages/core/core-flows/src/user/workflows/create-user-account.ts @@ -1,4 +1,4 @@ -import { CreateUserDTO, UserDTO } from "@medusajs/framework/types" +import type { CreateUserDTO, UserDTO } from "@medusajs/framework/types" import { WorkflowData, WorkflowResponse, @@ -25,13 +25,13 @@ export type CreateUserAccountWorkflowInput = { export const createUserAccountWorkflowId = "create-user-account" /** * This workflow creates a user and attaches it to an auth identity. - * + * * You can create an auth identity first using the [Retrieve Registration JWT Token API Route](https://docs.medusajs.com/api/admin#auth_postactor_typeauth_provider_register). * Learn more about basic authentication flows in [this documentation](https://docs.medusajs.com/resources/commerce-modules/auth/authentication-route). - * - * You can use this workflow within your customizations or your own custom workflows, allowing you to + * + * You can use this workflow within your customizations or your own custom workflows, allowing you to * register or create user accounts within your custom flows. - * + * * @example * const { result } = await createUserAccountWorkflow(container) * .run({ @@ -44,9 +44,9 @@ export const createUserAccountWorkflowId = "create-user-account" * } * } * }) - * + * * @summary - * + * * Create a user account and attach an auth identity. */ export const createUserAccountWorkflow = createWorkflow( diff --git a/packages/core/core-flows/src/user/workflows/create-users.ts b/packages/core/core-flows/src/user/workflows/create-users.ts index 5f81c5468f..67d69b58d2 100644 --- a/packages/core/core-flows/src/user/workflows/create-users.ts +++ b/packages/core/core-flows/src/user/workflows/create-users.ts @@ -1,4 +1,4 @@ -import { UserDTO, UserWorkflow } from "@medusajs/framework/types" +import type { UserDTO, UserWorkflow } from "@medusajs/framework/types" import { UserWorkflowEvents } from "@medusajs/framework/utils" import { WorkflowData, @@ -13,14 +13,14 @@ export const createUsersWorkflowId = "create-users-workflow" /** * This workflow creates one or more users. It's used by other workflows, such * as {@link acceptInviteWorkflow} to create a user for an invite. - * - * You can attach an auth identity to each user to allow the user to log in using the + * + * You can attach an auth identity to each user to allow the user to log in using the * {@link setAuthAppMetadataStep}. Learn more about auth identities in * [this documentation](https://docs.medusajs.com/resources/commerce-modules/auth/auth-identity-and-actor-types). - * - * You can use this workflow within your customizations or your own custom workflows, allowing you to + * + * You can use this workflow within your customizations or your own custom workflows, allowing you to * create users within your custom flows. - * + * * @example * const { result } = await createUsersWorkflow(container) * .run({ @@ -32,9 +32,9 @@ export const createUsersWorkflowId = "create-users-workflow" * }] * } * }) - * + * * @summary - * + * * Create one or more users. */ export const createUsersWorkflow = createWorkflow( diff --git a/packages/core/core-flows/src/user/workflows/delete-users.ts b/packages/core/core-flows/src/user/workflows/delete-users.ts index 0683e803ce..7e1761073f 100644 --- a/packages/core/core-flows/src/user/workflows/delete-users.ts +++ b/packages/core/core-flows/src/user/workflows/delete-users.ts @@ -1,4 +1,4 @@ -import { UserWorkflow } from "@medusajs/framework/types" +import type { UserWorkflow } from "@medusajs/framework/types" import { Modules, UserWorkflowEvents } from "@medusajs/framework/utils" import { WorkflowData, diff --git a/packages/core/core-flows/src/user/workflows/update-users.ts b/packages/core/core-flows/src/user/workflows/update-users.ts index 82c134a818..56e4fd5ec0 100644 --- a/packages/core/core-flows/src/user/workflows/update-users.ts +++ b/packages/core/core-flows/src/user/workflows/update-users.ts @@ -1,4 +1,4 @@ -import { UserDTO, UserWorkflow } from "@medusajs/framework/types" +import type { UserDTO, UserWorkflow } from "@medusajs/framework/types" import { UserWorkflowEvents } from "@medusajs/framework/utils" import { WorkflowData, @@ -13,10 +13,10 @@ export const updateUsersWorkflowId = "update-users-workflow" /** * This workflow updates one or more users. It's used by the * [Update User Admin API Route](https://docs.medusajs.com/api/admin#users_postusersid). - * + * * You can use this workflow within your customizations or your own custom workflows, allowing you to * update users within your custom flows. - * + * * @example * const { result } = await updateUsersWorkflow(container) * .run({ @@ -29,9 +29,9 @@ export const updateUsersWorkflowId = "update-users-workflow" * ] * } * }) - * + * * @summary - * + * * Update one or more users. */ export const updateUsersWorkflow = createWorkflow(