Merge branch 'develop' into docs/quote-management-guide
This commit is contained in:
commit
4c4f97c940
269 files changed
+27488
-24056
No files matched your search
@@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
"@medusajs/core-flows": patch
|
||||||
|
"@medusajs/cart": patch
|
||||||
|
"@medusajs/types": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
chore: improve tax lines
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"@medusajs/core-flows": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix(core-flows): fulfillment reservation check
|
||||||
@@ -0,0 +1,62 @@
|
|||||||
|
---
|
||||||
|
"@medusajs/notification-sendgrid": patch
|
||||||
|
"@medusajs/fulfillment-manual": patch
|
||||||
|
"@medusajs/notification-local": patch
|
||||||
|
"@medusajs/locking-postgres": patch
|
||||||
|
"@medusajs/auth-emailpass": patch
|
||||||
|
"@medusajs/payment-stripe": patch
|
||||||
|
"@medusajs/workflow-engine-inmemory": patch
|
||||||
|
"@medusajs/locking-redis": patch
|
||||||
|
"@medusajs/auth-github": patch
|
||||||
|
"@medusajs/auth-google": patch
|
||||||
|
"@medusajs/workflow-engine-redis": patch
|
||||||
|
"@medusajs/file-local": patch
|
||||||
|
"@medusajs/file-s3": patch
|
||||||
|
"@medusajs/ui-preset": patch
|
||||||
|
"@medusajs/event-bus-local": patch
|
||||||
|
"@medusajs/event-bus-redis": patch
|
||||||
|
"@medusajs/medusa-oas-cli": patch
|
||||||
|
"@medusajs/cache-inmemory": patch
|
||||||
|
"@medusajs/stock-location": patch
|
||||||
|
"create-medusa-app": patch
|
||||||
|
"@medusajs/sales-channel": patch
|
||||||
|
"@medusajs/link-modules": patch
|
||||||
|
"@medusajs/notification": patch
|
||||||
|
"@medusajs/admin-bundler": patch
|
||||||
|
"@medusajs/icons": patch
|
||||||
|
"@medusajs/cache-redis": patch
|
||||||
|
"@medusajs/fulfillment": patch
|
||||||
|
"@medusajs/orchestration": patch
|
||||||
|
"@medusajs/workflows-sdk": patch
|
||||||
|
"@medusajs/test-utils": patch
|
||||||
|
"@medusajs/inventory": patch
|
||||||
|
"@medusajs/promotion": patch
|
||||||
|
"@medusajs/modules-sdk": patch
|
||||||
|
"@medusajs/ui": patch
|
||||||
|
"@medusajs/currency": patch
|
||||||
|
"@medusajs/customer": patch
|
||||||
|
"@medusajs/admin-sdk": patch
|
||||||
|
"@medusajs/dashboard": patch
|
||||||
|
"@medusajs/core-flows": patch
|
||||||
|
"@medusajs/api-key": patch
|
||||||
|
"@medusajs/locking": patch
|
||||||
|
"@medusajs/payment": patch
|
||||||
|
"@medusajs/pricing": patch
|
||||||
|
"@medusajs/product": patch
|
||||||
|
"@medusajs/cli": patch
|
||||||
|
"@medusajs/framework": patch
|
||||||
|
"@medusajs/region": patch
|
||||||
|
"@medusajs/index": patch
|
||||||
|
"@medusajs/order": patch
|
||||||
|
"@medusajs/store": patch
|
||||||
|
"@medusajs/auth": patch
|
||||||
|
"@medusajs/cart": patch
|
||||||
|
"@medusajs/file": patch
|
||||||
|
"@medusajs/user": patch
|
||||||
|
"@medusajs/js-sdk": patch
|
||||||
|
"@medusajs/tax": patch
|
||||||
|
"@medusajs/utils": patch
|
||||||
|
"@medusajs/medusa": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
chore: Remove ranges on Medusa packages
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"@medusajs/framework": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Fix(framework): http cors middleware order and options
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
"@medusajs/core-flows": patch
|
||||||
|
"@medusajs/workflows-sdk": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
feat(workflows-sdk): Allow when then in parallelize
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"@medusajs/medusa": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
chore: pin swc to 1.5.7
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"@medusajs/pricing": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix(pricing): emit events
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"@medusajs/workflow-engine-redis": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix(workflow-engine-redis): Split the queues and respect worker mode for job executions
|
||||||
@@ -88,7 +88,7 @@ jobs:
|
|||||||
- name: Get Directories to Scan
|
- name: Get Directories to Scan
|
||||||
if: ${{ steps.pr-files.outputs.files_lt_threshold == 'true' }}
|
if: ${{ steps.pr-files.outputs.files_lt_threshold == 'true' }}
|
||||||
working-directory: www/vale
|
working-directory: www/vale
|
||||||
run: ./get-files.sh book app
|
run: ./get-files.sh book/app/learn resources
|
||||||
id: directories
|
id: directories
|
||||||
|
|
||||||
- name: Vale Linter
|
- name: Vale Linter
|
||||||
@@ -145,7 +145,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Get Directories to Scan
|
- name: Get Directories to Scan
|
||||||
working-directory: www/vale
|
working-directory: www/vale
|
||||||
run: ./get-files.sh resources app contribution-guidelines usage
|
run: ./get-files.sh resources/app
|
||||||
id: directories
|
id: directories
|
||||||
|
|
||||||
- name: Vale Linter
|
- name: Vale Linter
|
||||||
@@ -202,7 +202,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Get Directories to Scan
|
- name: Get Directories to Scan
|
||||||
working-directory: www/vale
|
working-directory: www/vale
|
||||||
run: ./get-files.sh user-guide app
|
run: ./get-files.sh user-guide/app
|
||||||
id: directories
|
id: directories
|
||||||
|
|
||||||
- name: Vale Linter
|
- name: Vale Linter
|
||||||
@@ -260,7 +260,7 @@ jobs:
|
|||||||
- name: Get Directories to Scan
|
- name: Get Directories to Scan
|
||||||
if: ${{ steps.pr-files.outputs.files_lt_threshold == 'true' }}
|
if: ${{ steps.pr-files.outputs.files_lt_threshold == 'true' }}
|
||||||
working-directory: www/vale
|
working-directory: www/vale
|
||||||
run: ./get-files.sh ui src/content/docs
|
run: ./get-files.sh ui/src/content/docs
|
||||||
id: directories
|
id: directories
|
||||||
|
|
||||||
- name: Vale Linter
|
- name: Vale Linter
|
||||||
@@ -318,7 +318,7 @@ jobs:
|
|||||||
- name: Get Directories to Scan
|
- name: Get Directories to Scan
|
||||||
if: ${{ steps.pr-files.outputs.files_lt_threshold == 'true' }}
|
if: ${{ steps.pr-files.outputs.files_lt_threshold == 'true' }}
|
||||||
working-directory: www/vale
|
working-directory: www/vale
|
||||||
run: ./get-files.sh api-reference markdown
|
run: ./get-files.sh api-reference/markdown
|
||||||
id: directories
|
id: directories
|
||||||
|
|
||||||
- name: Vale Linter
|
- name: Vale Linter
|
||||||
|
|||||||
@@ -331,6 +331,17 @@ medusaIntegrationTestRunner({
|
|||||||
},
|
},
|
||||||
])
|
])
|
||||||
|
|
||||||
|
// create reservation for inventory item that is initially on the order
|
||||||
|
const inventoryModule = container.resolve(Modules.INVENTORY)
|
||||||
|
await inventoryModule.createReservationItems([
|
||||||
|
{
|
||||||
|
inventory_item_id: inventoryItem.id,
|
||||||
|
location_id: location.id,
|
||||||
|
quantity: 2,
|
||||||
|
line_item_id: order.items[0].id,
|
||||||
|
},
|
||||||
|
])
|
||||||
|
|
||||||
const shippingOptionPayload = {
|
const shippingOptionPayload = {
|
||||||
name: "Return shipping",
|
name: "Return shipping",
|
||||||
service_zone_id: fulfillmentSet.service_zones[0].id,
|
service_zone_id: fulfillmentSet.service_zones[0].id,
|
||||||
|
|||||||
@@ -325,6 +325,17 @@ medusaIntegrationTestRunner({
|
|||||||
},
|
},
|
||||||
])
|
])
|
||||||
|
|
||||||
|
// create reservation for inventory item that is initially on the order
|
||||||
|
const inventoryModule = container.resolve(Modules.INVENTORY)
|
||||||
|
await inventoryModule.createReservationItems([
|
||||||
|
{
|
||||||
|
inventory_item_id: inventoryItem.id,
|
||||||
|
location_id: location.id,
|
||||||
|
quantity: 2,
|
||||||
|
line_item_id: order.items[0].id,
|
||||||
|
},
|
||||||
|
])
|
||||||
|
|
||||||
const shippingOptionPayload = {
|
const shippingOptionPayload = {
|
||||||
name: "Return shipping",
|
name: "Return shipping",
|
||||||
service_zone_id: fulfillmentSet.service_zones[0].id,
|
service_zone_id: fulfillmentSet.service_zones[0].id,
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ medusaIntegrationTestRunner({
|
|||||||
let location
|
let location
|
||||||
let item
|
let item
|
||||||
let returnShippingOption
|
let returnShippingOption
|
||||||
|
let outboundShippingOption
|
||||||
const shippingProviderId = "manual_test-provider"
|
const shippingProviderId = "manual_test-provider"
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
@@ -135,7 +136,7 @@ medusaIntegrationTestRunner({
|
|||||||
prices: [
|
prices: [
|
||||||
{
|
{
|
||||||
currency_code: "usd",
|
currency_code: "usd",
|
||||||
amount: 20,
|
amount: 0, // Free shipping
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
rules: [
|
rules: [
|
||||||
@@ -160,7 +161,7 @@ medusaIntegrationTestRunner({
|
|||||||
)
|
)
|
||||||
).data.shipping_option
|
).data.shipping_option
|
||||||
|
|
||||||
const outboundShippingOption = (
|
outboundShippingOption = (
|
||||||
await api.post(
|
await api.post(
|
||||||
"/admin/shipping-options",
|
"/admin/shipping-options",
|
||||||
outboundShippingOptionPayload,
|
outboundShippingOptionPayload,
|
||||||
@@ -289,6 +290,15 @@ medusaIntegrationTestRunner({
|
|||||||
adminHeaders
|
adminHeaders
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// If claim has outbound items, we need to set the outbound shipping method for reservation to be created
|
||||||
|
// TODO: change condition in confirm workfow to crate reservation depending on shipping since we can have
|
||||||
|
// reservations for inventory items that don't require shipping
|
||||||
|
await api.post(
|
||||||
|
`/admin/claims/${singleOutboundClaim.id}/outbound/shipping-method`,
|
||||||
|
{ shipping_option_id: outboundShippingOption.id },
|
||||||
|
adminHeaders
|
||||||
|
)
|
||||||
|
|
||||||
await api.post(
|
await api.post(
|
||||||
`/admin/claims/${singleOutboundClaim.id}/request`,
|
`/admin/claims/${singleOutboundClaim.id}/request`,
|
||||||
{},
|
{},
|
||||||
|
|||||||
@@ -3100,6 +3100,25 @@ medusaIntegrationTestRunner({
|
|||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it("should successfully delete products", async () => {
|
||||||
|
const response = await api.post(
|
||||||
|
"/admin/products/batch",
|
||||||
|
{ delete: [baseProduct.id] },
|
||||||
|
adminHeaders
|
||||||
|
)
|
||||||
|
|
||||||
|
expect(response.status).toEqual(200)
|
||||||
|
expect(response.data.created).toHaveLength(0)
|
||||||
|
expect(response.data.updated).toHaveLength(0)
|
||||||
|
expect(response.data.deleted.ids).toHaveLength(1)
|
||||||
|
|
||||||
|
expect(response.data.created).toEqual([])
|
||||||
|
expect(response.data.updated).toEqual([])
|
||||||
|
expect(response.data.deleted).toEqual(
|
||||||
|
expect.objectContaining({ ids: [baseProduct.id] })
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
it("successfully creates, updates, and deletes product variants", async () => {
|
it("successfully creates, updates, and deletes product variants", async () => {
|
||||||
const productWithMultipleVariants = getProductFixture({
|
const productWithMultipleVariants = getProductFixture({
|
||||||
title: "Test batch variants",
|
title: "Test batch variants",
|
||||||
|
|||||||
@@ -239,6 +239,17 @@ medusaIntegrationTestRunner({
|
|||||||
},
|
},
|
||||||
])
|
])
|
||||||
|
|
||||||
|
// create reservation for inventory item that is initially on the order
|
||||||
|
const inventoryModule = container.resolve(Modules.INVENTORY)
|
||||||
|
await inventoryModule.createReservationItems([
|
||||||
|
{
|
||||||
|
inventory_item_id: inventoryItem.id,
|
||||||
|
location_id: location.id,
|
||||||
|
quantity: 2,
|
||||||
|
line_item_id: order.items[0].id,
|
||||||
|
},
|
||||||
|
])
|
||||||
|
|
||||||
const shippingOptionPayload = {
|
const shippingOptionPayload = {
|
||||||
name: "Return shipping",
|
name: "Return shipping",
|
||||||
service_zone_id: fulfillmentSet.service_zones[0].id,
|
service_zone_id: fulfillmentSet.service_zones[0].id,
|
||||||
@@ -866,7 +877,9 @@ medusaIntegrationTestRunner({
|
|||||||
adminHeaders
|
adminHeaders
|
||||||
)
|
)
|
||||||
).data.inventory_levels
|
).data.inventory_levels
|
||||||
expect(inventoryLevel[0].stocked_quantity).toEqual(2)
|
|
||||||
|
// we had 2 items in stock that were reserved for the order and then fulfilled
|
||||||
|
expect(inventoryLevel[0].stocked_quantity).toEqual(0)
|
||||||
|
|
||||||
let result = await api.post(
|
let result = await api.post(
|
||||||
`/admin/returns/${returnId}/receive`,
|
`/admin/returns/${returnId}/receive`,
|
||||||
@@ -987,7 +1000,7 @@ medusaIntegrationTestRunner({
|
|||||||
adminHeaders
|
adminHeaders
|
||||||
)
|
)
|
||||||
).data.inventory_levels
|
).data.inventory_levels
|
||||||
expect(inventoryLevel[0].stocked_quantity).toEqual(3)
|
expect(inventoryLevel[0].stocked_quantity).toEqual(1)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -486,6 +486,9 @@ medusaIntegrationTestRunner({
|
|||||||
it("should revert an order fulfillment when it fails and recreate it when tried again", async () => {
|
it("should revert an order fulfillment when it fails and recreate it when tried again", async () => {
|
||||||
const order = await createOrderFixture({ container, product, location })
|
const order = await createOrderFixture({ container, product, location })
|
||||||
|
|
||||||
|
const itemId = order.items?.find((i) => i.title === "Custom Item 2")!
|
||||||
|
.id as string
|
||||||
|
|
||||||
// Create a fulfillment
|
// Create a fulfillment
|
||||||
const createOrderFulfillmentData: OrderWorkflow.CreateOrderFulfillmentWorkflowInput =
|
const createOrderFulfillmentData: OrderWorkflow.CreateOrderFulfillmentWorkflowInput =
|
||||||
{
|
{
|
||||||
@@ -493,7 +496,7 @@ medusaIntegrationTestRunner({
|
|||||||
created_by: "user_1",
|
created_by: "user_1",
|
||||||
items: [
|
items: [
|
||||||
{
|
{
|
||||||
id: order.items![0].id,
|
id: itemId,
|
||||||
quantity: 1,
|
quantity: 1,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
@@ -540,12 +543,14 @@ medusaIntegrationTestRunner({
|
|||||||
|
|
||||||
const [orderFulfill] = await remoteQuery(remoteQueryObject)
|
const [orderFulfill] = await remoteQuery(remoteQueryObject)
|
||||||
|
|
||||||
|
const fulfilledItem = orderFulfill.items?.find((i) => i.id === itemId)
|
||||||
|
|
||||||
expect(orderFulfill.fulfillments).toHaveLength(1)
|
expect(orderFulfill.fulfillments).toHaveLength(1)
|
||||||
expect(orderFulfill.items[0].detail.fulfilled_quantity).toEqual(1)
|
expect(fulfilledItem?.detail.fulfilled_quantity).toEqual(1)
|
||||||
|
|
||||||
const inventoryModule = container.resolve(Modules.INVENTORY)
|
const inventoryModule = container.resolve(Modules.INVENTORY)
|
||||||
const reservation = await inventoryModule.listReservationItems({
|
const reservation = await inventoryModule.listReservationItems({
|
||||||
line_item_id: order.items![0].id,
|
line_item_id: itemId,
|
||||||
})
|
})
|
||||||
expect(reservation).toHaveLength(0)
|
expect(reservation).toHaveLength(0)
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
"package.json"
|
"package.json"
|
||||||
],
|
],
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@medusajs/types": "^2.6.0",
|
"@medusajs/types": "2.6.0",
|
||||||
"@types/compression": "^1.7.5",
|
"@types/compression": "^1.7.5",
|
||||||
"copyfiles": "^2.4.1",
|
"copyfiles": "^2.4.1",
|
||||||
"express": "^4.21.0",
|
"express": "^4.21.0",
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
"typescript": "^5.3.3"
|
"typescript": "^5.3.3"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@medusajs/admin-shared": "^2.6.0",
|
"@medusajs/admin-shared": "2.6.0",
|
||||||
"zod": "3.22.4"
|
"zod": "3.22.4"
|
||||||
},
|
},
|
||||||
"packageManager": "yarn@3.2.1"
|
"packageManager": "yarn@3.2.1"
|
||||||
|
|||||||
@@ -45,10 +45,10 @@
|
|||||||
"@dnd-kit/sortable": "^8.0.0",
|
"@dnd-kit/sortable": "^8.0.0",
|
||||||
"@hookform/error-message": "^2.0.1",
|
"@hookform/error-message": "^2.0.1",
|
||||||
"@hookform/resolvers": "3.4.2",
|
"@hookform/resolvers": "3.4.2",
|
||||||
"@medusajs/admin-shared": "^2.6.0",
|
"@medusajs/admin-shared": "2.6.0",
|
||||||
"@medusajs/icons": "^2.6.0",
|
"@medusajs/icons": "2.6.0",
|
||||||
"@medusajs/js-sdk": "^2.6.0",
|
"@medusajs/js-sdk": "2.6.0",
|
||||||
"@medusajs/ui": "~4.0.6",
|
"@medusajs/ui": "4.0.6",
|
||||||
"@tanstack/react-query": "5.64.2",
|
"@tanstack/react-query": "5.64.2",
|
||||||
"@tanstack/react-table": "8.20.5",
|
"@tanstack/react-table": "8.20.5",
|
||||||
"@tanstack/react-virtual": "^3.8.3",
|
"@tanstack/react-virtual": "^3.8.3",
|
||||||
@@ -75,10 +75,10 @@
|
|||||||
"zod": "3.22.4"
|
"zod": "3.22.4"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@medusajs/admin-shared": "^2.6.0",
|
"@medusajs/admin-shared": "2.6.0",
|
||||||
"@medusajs/admin-vite-plugin": "^2.6.0",
|
"@medusajs/admin-vite-plugin": "2.6.0",
|
||||||
"@medusajs/types": "^2.6.0",
|
"@medusajs/types": "2.6.0",
|
||||||
"@medusajs/ui-preset": "^2.6.0",
|
"@medusajs/ui-preset": "2.6.0",
|
||||||
"@types/node": "^20.11.15",
|
"@types/node": "^20.11.15",
|
||||||
"@types/react": "^18.2.79",
|
"@types/react": "^18.2.79",
|
||||||
"@types/react-dom": "^18.2.25",
|
"@types/react-dom": "^18.2.25",
|
||||||
|
|||||||
+20
-20
@@ -111,30 +111,28 @@ export function OrderCreateFulfillmentForm({
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const selectedShippingProfileId =
|
let items = Object.entries(data.quantity)
|
||||||
selectedShippingOption?.shipping_profile_id
|
|
||||||
|
|
||||||
const itemShippingProfileMap = order.items.reduce(
|
|
||||||
(acc, item) => {
|
|
||||||
acc[item.id] = item.variant?.product?.shipping_profile?.id
|
|
||||||
return acc
|
|
||||||
},
|
|
||||||
{} as Record<string, string | null>
|
|
||||||
)
|
|
||||||
|
|
||||||
const items = Object.entries(data.quantity)
|
|
||||||
.filter(
|
|
||||||
([id, value]) =>
|
|
||||||
!!value && itemShippingProfileMap[id] === selectedShippingProfileId
|
|
||||||
)
|
|
||||||
.map(([id, quantity]) => ({
|
.map(([id, quantity]) => ({
|
||||||
id,
|
id,
|
||||||
quantity,
|
quantity,
|
||||||
}))
|
}))
|
||||||
|
.filter(({ quantity }) => !!quantity)
|
||||||
|
|
||||||
if (!items.length) {
|
/**
|
||||||
toast.error(t("orders.fulfillment.error.noItems"))
|
* If items require shipping fulfill only items with matching shipping profile.
|
||||||
return
|
*/
|
||||||
|
if (requiresShipping) {
|
||||||
|
const selectedShippingProfileId =
|
||||||
|
selectedShippingOption?.shipping_profile_id
|
||||||
|
|
||||||
|
const itemShippingProfileMap = order.items.reduce((acc, item) => {
|
||||||
|
acc[item.id] = item.variant?.product?.shipping_profile?.id
|
||||||
|
return acc
|
||||||
|
}, {} as any)
|
||||||
|
|
||||||
|
items = items.filter(
|
||||||
|
({ id }) => itemShippingProfileMap[id] === selectedShippingProfileId
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const payload: HttpTypes.AdminCreateOrderFulfillment = {
|
const payload: HttpTypes.AdminCreateOrderFulfillment = {
|
||||||
@@ -357,7 +355,9 @@ export function OrderCreateFulfillmentForm({
|
|||||||
form={form}
|
form={form}
|
||||||
item={item}
|
item={item}
|
||||||
locationId={selectedLocationId}
|
locationId={selectedLocationId}
|
||||||
disabled={!isShippingProfileMatching}
|
disabled={
|
||||||
|
requiresShipping && !isShippingProfileMatching
|
||||||
|
}
|
||||||
itemReservedQuantitiesMap={
|
itemReservedQuantitiesMap={
|
||||||
itemReservedQuantitiesMap
|
itemReservedQuantitiesMap
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
"watch": "tsc --watch"
|
"watch": "tsc --watch"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@medusajs/telemetry": "^2.6.0",
|
"@medusajs/telemetry": "2.6.0",
|
||||||
"boxen": "^5",
|
"boxen": "^5",
|
||||||
"chalk": "^5.2.0",
|
"chalk": "^5.2.0",
|
||||||
"commander": "^10.0.1",
|
"commander": "^10.0.1",
|
||||||
|
|||||||
@@ -46,7 +46,7 @@
|
|||||||
"typescript": "^5.6.2"
|
"typescript": "^5.6.2"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@medusajs/telemetry": "^2.6.0",
|
"@medusajs/telemetry": "2.6.0",
|
||||||
"@medusajs/utils": "2.6.0",
|
"@medusajs/utils": "2.6.0",
|
||||||
"@types/express": "^4.17.17",
|
"@types/express": "^4.17.17",
|
||||||
"chalk": "^4.0.0",
|
"chalk": "^4.0.0",
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
"author": "Medusa",
|
"author": "Medusa",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@medusajs/types": "^2.6.0",
|
"@medusajs/types": "2.6.0",
|
||||||
"@types/js-yaml": "^4.0.9",
|
"@types/js-yaml": "^4.0.9",
|
||||||
"jest": "^29.1.0",
|
"jest": "^29.1.0",
|
||||||
"js-yaml": "^4.1.0",
|
"js-yaml": "^4.1.0",
|
||||||
@@ -35,8 +35,8 @@
|
|||||||
"medusa-oas": "ts-node src/index.ts"
|
"medusa-oas": "ts-node src/index.ts"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@medusajs/medusa": "^2.6.0",
|
"@medusajs/medusa": "2.6.0",
|
||||||
"@medusajs/utils": "^2.6.0",
|
"@medusajs/utils": "2.6.0",
|
||||||
"@readme/json-schema-ref-parser": "^1.2.0",
|
"@readme/json-schema-ref-parser": "^1.2.0",
|
||||||
"@readme/openapi-parser": "^2.4.0",
|
"@readme/openapi-parser": "^2.4.0",
|
||||||
"@redocly/cli": "^1.7.0",
|
"@redocly/cli": "^1.7.0",
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
"author": "Medusa",
|
"author": "Medusa",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@medusajs/framework": "^2.6.0",
|
"@medusajs/framework": "2.6.0",
|
||||||
"@mikro-orm/core": "6.4.3",
|
"@mikro-orm/core": "6.4.3",
|
||||||
"@mikro-orm/knex": "6.4.3",
|
"@mikro-orm/knex": "6.4.3",
|
||||||
"@mikro-orm/migrations": "6.4.3",
|
"@mikro-orm/migrations": "6.4.3",
|
||||||
@@ -44,7 +44,7 @@
|
|||||||
"json-2-csv": "^5.5.4"
|
"json-2-csv": "^5.5.4"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@medusajs/framework": "^2.4.0",
|
"@medusajs/framework": "2.6.0",
|
||||||
"awilix": "^8.0.1"
|
"awilix": "^8.0.1"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import {
|
|||||||
ItemTaxLineDTO,
|
ItemTaxLineDTO,
|
||||||
ShippingTaxLineDTO,
|
ShippingTaxLineDTO,
|
||||||
} from "@medusajs/framework/types"
|
} from "@medusajs/framework/types"
|
||||||
import { Modules } from "@medusajs/framework/utils"
|
import { Modules, promiseAll } from "@medusajs/framework/utils"
|
||||||
import { StepResponse, createStep } from "@medusajs/framework/workflows-sdk"
|
import { StepResponse, createStep } from "@medusajs/framework/workflows-sdk"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -64,21 +64,31 @@ export const setTaxLinesForItemsStep = createStep(
|
|||||||
const { cart, item_tax_lines, shipping_tax_lines } = data
|
const { cart, item_tax_lines, shipping_tax_lines } = data
|
||||||
const cartService = container.resolve<ICartModuleService>(Modules.CART)
|
const cartService = container.resolve<ICartModuleService>(Modules.CART)
|
||||||
|
|
||||||
const existingShippingMethodTaxLines =
|
const [existingShippingMethodTaxLines, existingLineItemTaxLines] =
|
||||||
await cartService.listShippingMethodTaxLines({
|
await promiseAll([
|
||||||
shipping_method_id: shipping_tax_lines.map((t) => t.shipping_line_id),
|
shipping_tax_lines.length
|
||||||
|
? cartService.listShippingMethodTaxLines({
|
||||||
|
shipping_method_id: shipping_tax_lines.map(
|
||||||
|
(t) => t.shipping_line_id
|
||||||
|
),
|
||||||
})
|
})
|
||||||
|
: [],
|
||||||
|
|
||||||
const existingLineItemTaxLines = await cartService.listLineItemTaxLines({
|
item_tax_lines.length
|
||||||
|
? cartService.listLineItemTaxLines({
|
||||||
item_id: item_tax_lines.map((t) => t.line_item_id),
|
item_id: item_tax_lines.map((t) => t.line_item_id),
|
||||||
})
|
})
|
||||||
|
: [],
|
||||||
|
])
|
||||||
|
|
||||||
const itemsTaxLinesData = normalizeItemTaxLinesForCart(item_tax_lines)
|
const itemsTaxLinesData = normalizeItemTaxLinesForCart(item_tax_lines)
|
||||||
await cartService.setLineItemTaxLines(cart.id, itemsTaxLinesData)
|
|
||||||
|
|
||||||
const shippingTaxLinesData =
|
const shippingTaxLinesData =
|
||||||
normalizeShippingTaxLinesForCart(shipping_tax_lines)
|
normalizeShippingTaxLinesForCart(shipping_tax_lines)
|
||||||
await cartService.setShippingMethodTaxLines(cart.id, shippingTaxLinesData)
|
|
||||||
|
await promiseAll([
|
||||||
|
cartService.setLineItemTaxLines(cart.id, itemsTaxLinesData),
|
||||||
|
cartService.setShippingMethodTaxLines(cart.id, shippingTaxLinesData),
|
||||||
|
])
|
||||||
|
|
||||||
return new StepResponse(null, {
|
return new StepResponse(null, {
|
||||||
cart,
|
cart,
|
||||||
|
|||||||
@@ -0,0 +1,176 @@
|
|||||||
|
import {
|
||||||
|
CartWorkflowDTO,
|
||||||
|
CreateLineItemTaxLineDTO,
|
||||||
|
CreateShippingMethodTaxLineDTO,
|
||||||
|
ICartModuleService,
|
||||||
|
ItemTaxLineDTO,
|
||||||
|
LineItemTaxLineDTO,
|
||||||
|
ShippingMethodTaxLineDTO,
|
||||||
|
ShippingTaxLineDTO,
|
||||||
|
} from "@medusajs/framework/types"
|
||||||
|
import { Modules, promiseAll } from "@medusajs/framework/utils"
|
||||||
|
import { StepResponse, createStep } from "@medusajs/framework/workflows-sdk"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The details of the tax lines to set in a cart.
|
||||||
|
*/
|
||||||
|
export interface SetTaxLinesForItemsStepInput {
|
||||||
|
/**
|
||||||
|
* The cart's details.
|
||||||
|
*/
|
||||||
|
cart: CartWorkflowDTO
|
||||||
|
/**
|
||||||
|
* The tax lines to set for line items.
|
||||||
|
*/
|
||||||
|
item_tax_lines: ItemTaxLineDTO[]
|
||||||
|
/**
|
||||||
|
* The tax lines to set for shipping methods.
|
||||||
|
*/
|
||||||
|
shipping_tax_lines: ShippingTaxLineDTO[]
|
||||||
|
}
|
||||||
|
|
||||||
|
export const upsertTaxLinesForItemsStepId = "set-tax-lines-for-items"
|
||||||
|
/**
|
||||||
|
* This step sets the tax lines of shipping methods and line items in a cart.
|
||||||
|
*
|
||||||
|
* :::tip
|
||||||
|
*
|
||||||
|
* You can use the {@link retrieveCartStep} to retrieve a cart's details.
|
||||||
|
*
|
||||||
|
* :::
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* const data = upsertTaxLinesForItemsStep({
|
||||||
|
* // retrieve the details of the cart from another workflow
|
||||||
|
* // or in another step using the Cart Module's service
|
||||||
|
* cart,
|
||||||
|
* "item_tax_lines": [{
|
||||||
|
* "rate": 48,
|
||||||
|
* "code": "CODE123",
|
||||||
|
* "name": "Tax rate 2",
|
||||||
|
* "provider_id": "provider_1",
|
||||||
|
* "line_item_id": "litem_123"
|
||||||
|
* }],
|
||||||
|
* "shipping_tax_lines": [{
|
||||||
|
* "rate": 49,
|
||||||
|
* "code": "CODE456",
|
||||||
|
* "name": "Tax rate 1",
|
||||||
|
* "provider_id": "provider_1",
|
||||||
|
* "shipping_line_id": "sm_123"
|
||||||
|
* }]
|
||||||
|
* })
|
||||||
|
*/
|
||||||
|
export const upsertTaxLinesForItemsStep = createStep(
|
||||||
|
upsertTaxLinesForItemsStepId,
|
||||||
|
async (data: SetTaxLinesForItemsStepInput, { container }) => {
|
||||||
|
const { cart, item_tax_lines, shipping_tax_lines } = data
|
||||||
|
const cartService = container.resolve<ICartModuleService>(Modules.CART)
|
||||||
|
|
||||||
|
const [existingShippingMethodTaxLines, existingLineItemTaxLines] =
|
||||||
|
await promiseAll([
|
||||||
|
shipping_tax_lines.length
|
||||||
|
? cartService.listShippingMethodTaxLines({
|
||||||
|
shipping_method_id: shipping_tax_lines.map(
|
||||||
|
(t) => t.shipping_line_id
|
||||||
|
),
|
||||||
|
})
|
||||||
|
: [],
|
||||||
|
|
||||||
|
item_tax_lines.length
|
||||||
|
? cartService.listLineItemTaxLines({
|
||||||
|
item_id: item_tax_lines.map((t) => t.line_item_id),
|
||||||
|
})
|
||||||
|
: [],
|
||||||
|
])
|
||||||
|
|
||||||
|
const itemsTaxLinesData = normalizeItemTaxLinesForCart(
|
||||||
|
item_tax_lines,
|
||||||
|
existingLineItemTaxLines
|
||||||
|
)
|
||||||
|
const shippingTaxLinesData = normalizeShippingTaxLinesForCart(
|
||||||
|
shipping_tax_lines,
|
||||||
|
existingShippingMethodTaxLines
|
||||||
|
)
|
||||||
|
|
||||||
|
await promiseAll([
|
||||||
|
itemsTaxLinesData.length
|
||||||
|
? cartService.upsertLineItemTaxLines(itemsTaxLinesData)
|
||||||
|
: [],
|
||||||
|
shippingTaxLinesData.length
|
||||||
|
? cartService.upsertShippingMethodTaxLines(shippingTaxLinesData)
|
||||||
|
: [],
|
||||||
|
])
|
||||||
|
|
||||||
|
return new StepResponse(null, {
|
||||||
|
cart,
|
||||||
|
existingLineItemTaxLines,
|
||||||
|
existingShippingMethodTaxLines,
|
||||||
|
})
|
||||||
|
},
|
||||||
|
async (revertData, { container }) => {
|
||||||
|
if (!revertData) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const { existingLineItemTaxLines, existingShippingMethodTaxLines } =
|
||||||
|
revertData
|
||||||
|
|
||||||
|
const cartService = container.resolve<ICartModuleService>(Modules.CART)
|
||||||
|
|
||||||
|
if (existingLineItemTaxLines) {
|
||||||
|
await cartService.upsertLineItemTaxLines(
|
||||||
|
existingLineItemTaxLines.map((taxLine) => ({
|
||||||
|
description: taxLine.description,
|
||||||
|
tax_rate_id: taxLine.tax_rate_id,
|
||||||
|
code: taxLine.code,
|
||||||
|
rate: taxLine.rate,
|
||||||
|
provider_id: taxLine.provider_id,
|
||||||
|
item_id: taxLine.item_id,
|
||||||
|
}))
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
await cartService.upsertShippingMethodTaxLines(
|
||||||
|
existingShippingMethodTaxLines.map((taxLine) => ({
|
||||||
|
description: taxLine.description,
|
||||||
|
tax_rate_id: taxLine.tax_rate_id,
|
||||||
|
code: taxLine.code,
|
||||||
|
rate: taxLine.rate,
|
||||||
|
provider_id: taxLine.provider_id,
|
||||||
|
shipping_method_id: taxLine.shipping_method_id,
|
||||||
|
}))
|
||||||
|
)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
function normalizeItemTaxLinesForCart(
|
||||||
|
taxLines: ItemTaxLineDTO[],
|
||||||
|
existingTaxLines: LineItemTaxLineDTO[]
|
||||||
|
): CreateLineItemTaxLineDTO[] {
|
||||||
|
return taxLines.map((taxLine: ItemTaxLineDTO & { id?: string }) => ({
|
||||||
|
id: existingTaxLines.find((t) => t.item_id === taxLine.line_item_id)?.id,
|
||||||
|
description: taxLine.name,
|
||||||
|
tax_rate_id: taxLine.rate_id,
|
||||||
|
code: taxLine.code!,
|
||||||
|
rate: taxLine.rate!,
|
||||||
|
provider_id: taxLine.provider_id,
|
||||||
|
item_id: taxLine.line_item_id,
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
|
||||||
|
function normalizeShippingTaxLinesForCart(
|
||||||
|
taxLines: ShippingTaxLineDTO[],
|
||||||
|
existingTaxLines: ShippingMethodTaxLineDTO[]
|
||||||
|
): CreateShippingMethodTaxLineDTO[] {
|
||||||
|
return taxLines.map((taxLine: ShippingTaxLineDTO & { id?: string }) => ({
|
||||||
|
id: existingTaxLines.find(
|
||||||
|
(t) => t.shipping_method_id === taxLine.shipping_line_id
|
||||||
|
)?.id,
|
||||||
|
description: taxLine.name,
|
||||||
|
tax_rate_id: taxLine.rate_id,
|
||||||
|
code: taxLine.code!,
|
||||||
|
rate: taxLine.rate!,
|
||||||
|
provider_id: taxLine.provider_id,
|
||||||
|
shipping_method_id: taxLine.shipping_line_id,
|
||||||
|
}))
|
||||||
|
}
|
||||||
@@ -186,7 +186,7 @@ export const addShippingMethodToCartWorkflow = createWorkflow(
|
|||||||
cart.shipping_methods.map((sm) => sm.id)
|
cart.shipping_methods.map((sm) => sm.id)
|
||||||
)
|
)
|
||||||
|
|
||||||
parallelize(
|
const [, createdShippingMethods] = parallelize(
|
||||||
removeShippingMethodFromCartStep({
|
removeShippingMethodFromCartStep({
|
||||||
shipping_method_ids: currentShippingMethods,
|
shipping_method_ids: currentShippingMethods,
|
||||||
}),
|
}),
|
||||||
@@ -200,7 +200,7 @@ export const addShippingMethodToCartWorkflow = createWorkflow(
|
|||||||
)
|
)
|
||||||
|
|
||||||
refreshCartItemsWorkflow.runAsStep({
|
refreshCartItemsWorkflow.runAsStep({
|
||||||
input: { cart_id: cart.id },
|
input: { cart_id: cart.id, shipping_methods: createdShippingMethods },
|
||||||
})
|
})
|
||||||
|
|
||||||
return new WorkflowResponse(void 0, {
|
return new WorkflowResponse(void 0, {
|
||||||
|
|||||||
@@ -173,7 +173,7 @@ export const addToCartWorkflow = createWorkflow(
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
parallelize(
|
const [createdLineItems, updatedLineItems] = parallelize(
|
||||||
createLineItemsStep({
|
createLineItemsStep({
|
||||||
id: cart.id,
|
id: cart.id,
|
||||||
items: itemsToCreate,
|
items: itemsToCreate,
|
||||||
@@ -184,8 +184,15 @@ export const addToCartWorkflow = createWorkflow(
|
|||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const allItems = transform(
|
||||||
|
{ createdLineItems, updatedLineItems },
|
||||||
|
({ createdLineItems = [], updatedLineItems = [] }) => {
|
||||||
|
return createdLineItems.concat(updatedLineItems)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
refreshCartItemsWorkflow.runAsStep({
|
refreshCartItemsWorkflow.runAsStep({
|
||||||
input: { cart_id: cart.id },
|
input: { cart_id: cart.id, items: allItems },
|
||||||
})
|
})
|
||||||
|
|
||||||
emitEventStep({
|
emitEventStep({
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ import { refreshCartShippingMethodsWorkflow } from "./refresh-cart-shipping-meth
|
|||||||
import { refreshPaymentCollectionForCartWorkflow } from "./refresh-payment-collection"
|
import { refreshPaymentCollectionForCartWorkflow } from "./refresh-payment-collection"
|
||||||
import { updateCartPromotionsWorkflow } from "./update-cart-promotions"
|
import { updateCartPromotionsWorkflow } from "./update-cart-promotions"
|
||||||
import { updateTaxLinesWorkflow } from "./update-tax-lines"
|
import { updateTaxLinesWorkflow } from "./update-tax-lines"
|
||||||
|
import { upsertTaxLinesWorkflow } from "./upsert-tax-lines"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The details of the cart to refresh.
|
* The details of the cart to refresh.
|
||||||
@@ -44,6 +45,23 @@ export type RefreshCartItemsWorkflowInput = {
|
|||||||
* Force refresh the cart items
|
* Force refresh the cart items
|
||||||
*/
|
*/
|
||||||
force_refresh?: boolean
|
force_refresh?: boolean
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The items to refresh.
|
||||||
|
*/
|
||||||
|
items?: any[]
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The shipping methods to refresh.
|
||||||
|
*/
|
||||||
|
shipping_methods?: any[]
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether to force re-calculating tax amounts, which
|
||||||
|
* may include sending requests to a third-part tax provider, depending
|
||||||
|
* on the configurations of the cart's tax region.
|
||||||
|
*/
|
||||||
|
force_tax_calculation?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export const refreshCartItemsWorkflowId = "refresh-cart-items"
|
export const refreshCartItemsWorkflowId = "refresh-cart-items"
|
||||||
@@ -162,9 +180,34 @@ export const refreshCartItemsWorkflow = createWorkflow(
|
|||||||
input: refreshCartInput,
|
input: refreshCartInput,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
when({ input }, ({ input }) => {
|
||||||
|
return !!input.force_refresh
|
||||||
|
}).then(() => {
|
||||||
updateTaxLinesWorkflow.runAsStep({
|
updateTaxLinesWorkflow.runAsStep({
|
||||||
input: refreshCartInput,
|
input: refreshCartInput,
|
||||||
})
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
when({ input }, ({ input }) => {
|
||||||
|
return (
|
||||||
|
!input.force_refresh &&
|
||||||
|
(!!input.items?.length || !!input.shipping_methods?.length)
|
||||||
|
)
|
||||||
|
}).then(() => {
|
||||||
|
upsertTaxLinesWorkflow.runAsStep({
|
||||||
|
input: transform(
|
||||||
|
{ refetchedCart, input },
|
||||||
|
({ refetchedCart, input }) => {
|
||||||
|
return {
|
||||||
|
cart: refetchedCart,
|
||||||
|
items: input.items ?? [],
|
||||||
|
shipping_methods: input.shipping_methods ?? [],
|
||||||
|
force_tax_calculation: input.force_tax_calculation,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
),
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
const cartPromoCodes = transform(
|
const cartPromoCodes = transform(
|
||||||
{ refetchedCart, input },
|
{ refetchedCart, input },
|
||||||
|
|||||||
@@ -0,0 +1,154 @@
|
|||||||
|
import {
|
||||||
|
CartLineItemDTO,
|
||||||
|
CartShippingMethodDTO,
|
||||||
|
} from "@medusajs/framework/types"
|
||||||
|
import {
|
||||||
|
WorkflowData,
|
||||||
|
createWorkflow,
|
||||||
|
transform,
|
||||||
|
when,
|
||||||
|
} from "@medusajs/framework/workflows-sdk"
|
||||||
|
import { useRemoteQueryStep } from "../../common"
|
||||||
|
import { getItemTaxLinesStep } from "../../tax/steps/get-item-tax-lines"
|
||||||
|
import { upsertTaxLinesForItemsStep } from "../steps/upsert-tax-lines-for-items"
|
||||||
|
|
||||||
|
const cartFields = [
|
||||||
|
"id",
|
||||||
|
"currency_code",
|
||||||
|
"email",
|
||||||
|
"region.id",
|
||||||
|
"region.automatic_taxes",
|
||||||
|
"items.id",
|
||||||
|
"items.variant_id",
|
||||||
|
"items.product_id",
|
||||||
|
"items.product_title",
|
||||||
|
"items.product_description",
|
||||||
|
"items.product_subtitle",
|
||||||
|
"items.product_type",
|
||||||
|
"items.product_type_id",
|
||||||
|
"items.product_collection",
|
||||||
|
"items.product_handle",
|
||||||
|
"items.variant_sku",
|
||||||
|
"items.variant_barcode",
|
||||||
|
"items.variant_title",
|
||||||
|
"items.title",
|
||||||
|
"items.quantity",
|
||||||
|
"items.unit_price",
|
||||||
|
"items.tax_lines.id",
|
||||||
|
"items.tax_lines.description",
|
||||||
|
"items.tax_lines.code",
|
||||||
|
"items.tax_lines.rate",
|
||||||
|
"items.tax_lines.provider_id",
|
||||||
|
"shipping_methods.tax_lines.id",
|
||||||
|
"shipping_methods.tax_lines.description",
|
||||||
|
"shipping_methods.tax_lines.code",
|
||||||
|
"shipping_methods.tax_lines.rate",
|
||||||
|
"shipping_methods.tax_lines.provider_id",
|
||||||
|
"shipping_methods.shipping_option_id",
|
||||||
|
"shipping_methods.amount",
|
||||||
|
"customer.id",
|
||||||
|
"customer.email",
|
||||||
|
"customer.metadata",
|
||||||
|
"customer.groups.id",
|
||||||
|
"shipping_address.id",
|
||||||
|
"shipping_address.address_1",
|
||||||
|
"shipping_address.address_2",
|
||||||
|
"shipping_address.city",
|
||||||
|
"shipping_address.postal_code",
|
||||||
|
"shipping_address.country_code",
|
||||||
|
"shipping_address.region_code",
|
||||||
|
"shipping_address.province",
|
||||||
|
"shipping_address.metadata",
|
||||||
|
]
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The details of the cart to upsert tax lines for.
|
||||||
|
*/
|
||||||
|
export type UpsertTaxLinesWorkflowInput = {
|
||||||
|
/**
|
||||||
|
* The cart's ID.
|
||||||
|
*/
|
||||||
|
cart_id?: string
|
||||||
|
/**
|
||||||
|
* The Cart reference.
|
||||||
|
*/
|
||||||
|
cart?: any
|
||||||
|
/**
|
||||||
|
* The items to upsert their tax lines.
|
||||||
|
* If not specified, taxes are upsertd for all of the cart's
|
||||||
|
* line items.
|
||||||
|
*/
|
||||||
|
items: CartLineItemDTO[]
|
||||||
|
/**
|
||||||
|
* The shipping methods to upsert their tax lines.
|
||||||
|
* If not specified, taxes are upsertd for all of the cart's
|
||||||
|
* shipping methods.
|
||||||
|
*/
|
||||||
|
shipping_methods: CartShippingMethodDTO[]
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether to force re-calculating tax amounts, which
|
||||||
|
* may include sending requests to a third-part tax provider, depending
|
||||||
|
* on the configurations of the cart's tax region.
|
||||||
|
*
|
||||||
|
* @defaultValue false
|
||||||
|
*/
|
||||||
|
force_tax_calculation?: boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
export const upsertTaxLinesWorkflowId = "upsert-tax-lines"
|
||||||
|
/**
|
||||||
|
* This workflow upserts a cart's tax lines that are applied on line items and shipping methods. You can upsert the line item's quantity, unit price, and more. This workflow is executed
|
||||||
|
* by the [Calculate Taxes Store API Route](https://docs.medusajs.com/api/store#carts_postcartsidtaxes).
|
||||||
|
*
|
||||||
|
* You can use this workflow within your own customizations or custom workflows, allowing you to upsert a cart's tax lines in your custom flows.
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* const { result } = await upsertTaxLinesWorkflow(container)
|
||||||
|
* .run({
|
||||||
|
* input: {
|
||||||
|
* cart_id: "cart_123",
|
||||||
|
* items: [],
|
||||||
|
* shipping_methods: [],
|
||||||
|
* }
|
||||||
|
* })
|
||||||
|
*
|
||||||
|
* @summary
|
||||||
|
*
|
||||||
|
* Update a cart's tax lines.
|
||||||
|
*/
|
||||||
|
export const upsertTaxLinesWorkflow = createWorkflow(
|
||||||
|
upsertTaxLinesWorkflowId,
|
||||||
|
(input: WorkflowData<UpsertTaxLinesWorkflowInput>): WorkflowData<void> => {
|
||||||
|
const fetchCart = when({ input }, ({ input }) => {
|
||||||
|
return !input.cart
|
||||||
|
}).then(() => {
|
||||||
|
return useRemoteQueryStep({
|
||||||
|
entry_point: "cart",
|
||||||
|
fields: cartFields,
|
||||||
|
variables: { id: input.cart_id },
|
||||||
|
throw_if_key_not_found: true,
|
||||||
|
list: false,
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
const cart = transform({ fetchCart, input }, ({ fetchCart, input }) => {
|
||||||
|
return input.cart ?? fetchCart
|
||||||
|
})
|
||||||
|
|
||||||
|
const taxLineItems = getItemTaxLinesStep(
|
||||||
|
transform({ input, cart }, (data) => ({
|
||||||
|
orderOrCart: data.cart,
|
||||||
|
items: data.input.items ?? [],
|
||||||
|
shipping_methods: data.input.shipping_methods ?? [],
|
||||||
|
force_tax_calculation: data.input.force_tax_calculation,
|
||||||
|
}))
|
||||||
|
)
|
||||||
|
|
||||||
|
upsertTaxLinesForItemsStep({
|
||||||
|
cart,
|
||||||
|
item_tax_lines: taxLineItems.lineItemTaxLines,
|
||||||
|
shipping_tax_lines: taxLineItems.shippingMethodsTaxLines,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
)
|
||||||
@@ -239,7 +239,7 @@ function extractShippingOption({ orderPreview, orderClaim, returnId }) {
|
|||||||
|
|
||||||
for (const action of modifiedShippingMethod_.actions) {
|
for (const action of modifiedShippingMethod_.actions) {
|
||||||
if (action.action === ChangeActionType.SHIPPING_ADD) {
|
if (action.action === ChangeActionType.SHIPPING_ADD) {
|
||||||
if (action.return?.id === returnId) {
|
if (!!action.return_id && action.return_id === returnId) {
|
||||||
returnShippingMethod = shippingMethod
|
returnShippingMethod = shippingMethod
|
||||||
} else if (action.claim_id === orderClaim.id) {
|
} else if (action.claim_id === orderClaim.id) {
|
||||||
claimShippingMethod = shippingMethod
|
claimShippingMethod = shippingMethod
|
||||||
|
|||||||
@@ -241,10 +241,14 @@ function prepareInventoryUpdate({
|
|||||||
}[] = []
|
}[] = []
|
||||||
|
|
||||||
const allItems = itemsList ?? order.items
|
const allItems = itemsList ?? order.items
|
||||||
for (const item of allItems) {
|
const itemsToFulfill = allItems.filter((i) => i.id in inputItemsMap)
|
||||||
|
|
||||||
|
// iterate over items that are being fulfilled
|
||||||
|
for (const item of itemsToFulfill) {
|
||||||
const reservation = reservationMap[item.id]
|
const reservation = reservationMap[item.id]
|
||||||
|
|
||||||
if (!reservation) {
|
if (!reservation) {
|
||||||
if (item.manage_inventory) {
|
if (item.variant?.manage_inventory) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`No stock reservation found for item ${item.id} - ${item.title} (${item.variant_title})`
|
`No stock reservation found for item ${item.id} - ${item.title} (${item.variant_title})`
|
||||||
)
|
)
|
||||||
@@ -345,6 +349,7 @@ export const createOrderFulfillmentWorkflow = createWorkflow(
|
|||||||
"items.variant.height",
|
"items.variant.height",
|
||||||
"items.variant.width",
|
"items.variant.width",
|
||||||
"items.variant.material",
|
"items.variant.material",
|
||||||
|
"items.variant_title",
|
||||||
"shipping_address.*",
|
"shipping_address.*",
|
||||||
"shipping_methods.id",
|
"shipping_methods.id",
|
||||||
"shipping_methods.shipping_option_id",
|
"shipping_methods.shipping_option_id",
|
||||||
@@ -394,9 +399,11 @@ export const createOrderFulfillmentWorkflow = createWorkflow(
|
|||||||
}).config({ name: "get-shipping-option" })
|
}).config({ name: "get-shipping-option" })
|
||||||
|
|
||||||
const lineItemIds = transform(
|
const lineItemIds = transform(
|
||||||
{ order, itemsList: input.items_list },
|
{ order, itemsList: input.items_list, inputItemsMap },
|
||||||
({ order, itemsList }) => {
|
({ order, itemsList, inputItemsMap }) => {
|
||||||
return (itemsList ?? order.items)!.map((i) => i.id)
|
return (itemsList ?? order.items)!
|
||||||
|
.map((i) => i.id)
|
||||||
|
.filter((i) => i in inputItemsMap)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
const reservations = useRemoteQueryStep({
|
const reservations = useRemoteQueryStep({
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import {
|
|||||||
createWorkflow,
|
createWorkflow,
|
||||||
parallelize,
|
parallelize,
|
||||||
transform,
|
transform,
|
||||||
|
when,
|
||||||
} from "@medusajs/framework/workflows-sdk"
|
} from "@medusajs/framework/workflows-sdk"
|
||||||
import { createProductsWorkflow } from "./create-products"
|
import { createProductsWorkflow } from "./create-products"
|
||||||
import { deleteProductsWorkflow } from "./delete-products"
|
import { deleteProductsWorkflow } from "./delete-products"
|
||||||
@@ -19,10 +20,27 @@ import { updateProductsWorkflow } from "./update-products"
|
|||||||
/**
|
/**
|
||||||
* The products to manage.
|
* The products to manage.
|
||||||
*/
|
*/
|
||||||
export interface BatchProductWorkflowInput extends BatchWorkflowInput<
|
export interface BatchProductWorkflowInput
|
||||||
|
extends BatchWorkflowInput<
|
||||||
CreateProductWorkflowInputDTO,
|
CreateProductWorkflowInputDTO,
|
||||||
UpdateProductWorkflowInputDTO
|
UpdateProductWorkflowInputDTO
|
||||||
> {}
|
> {}
|
||||||
|
|
||||||
|
const conditionallyCreateProducts = (input: BatchProductWorkflowInput) =>
|
||||||
|
when({ input }, ({ input }) => !!input.create?.length).then(() =>
|
||||||
|
createProductsWorkflow.runAsStep({ input: { products: input.create! } })
|
||||||
|
)
|
||||||
|
|
||||||
|
const conditionallyUpdateProducts = (input: BatchProductWorkflowInput) =>
|
||||||
|
when({ input }, ({ input }) => !!input.update?.length).then(() =>
|
||||||
|
updateProductsWorkflow.runAsStep({ input: { products: input.update! } })
|
||||||
|
)
|
||||||
|
|
||||||
|
const conditionallyDeleteProducts = (input: BatchProductWorkflowInput) =>
|
||||||
|
when({ input }, ({ input }) => !!input.delete?.length).then(() =>
|
||||||
|
deleteProductsWorkflow.runAsStep({ input: { ids: input.delete! } })
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
export const batchProductsWorkflowId = "batch-products"
|
export const batchProductsWorkflowId = "batch-products"
|
||||||
/**
|
/**
|
||||||
@@ -81,22 +99,16 @@ export const batchProductsWorkflow = createWorkflow(
|
|||||||
input: WorkflowData<BatchProductWorkflowInput>
|
input: WorkflowData<BatchProductWorkflowInput>
|
||||||
): WorkflowResponse<BatchWorkflowOutput<ProductTypes.ProductDTO>> => {
|
): WorkflowResponse<BatchWorkflowOutput<ProductTypes.ProductDTO>> => {
|
||||||
const res = parallelize(
|
const res = parallelize(
|
||||||
createProductsWorkflow.runAsStep({
|
conditionallyCreateProducts(input),
|
||||||
input: { products: input.create ?? [] },
|
conditionallyUpdateProducts(input),
|
||||||
}),
|
conditionallyDeleteProducts(input)
|
||||||
updateProductsWorkflow.runAsStep({
|
|
||||||
input: { products: input.update ?? [] },
|
|
||||||
}),
|
|
||||||
deleteProductsWorkflow.runAsStep({
|
|
||||||
input: { ids: input.delete ?? [] },
|
|
||||||
})
|
|
||||||
)
|
)
|
||||||
|
|
||||||
return new WorkflowResponse(
|
return new WorkflowResponse(
|
||||||
transform({ res, input }, (data) => {
|
transform({ res, input }, (data) => {
|
||||||
return {
|
return {
|
||||||
created: data.res[0],
|
created: data.res[0] ?? [],
|
||||||
updated: data.res[1],
|
updated: data.res[1] ?? [],
|
||||||
deleted: data.input.delete ?? [],
|
deleted: data.input.delete ?? [],
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -54,7 +54,7 @@
|
|||||||
"test": "jest --runInBand --bail --forceExit -- src/**/__tests__/**/*.ts"
|
"test": "jest --runInBand --bail --forceExit -- src/**/__tests__/**/*.ts"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@medusajs/cli": "^2.6.0",
|
"@medusajs/cli": "2.6.0",
|
||||||
"@mikro-orm/core": "6.4.3",
|
"@mikro-orm/core": "6.4.3",
|
||||||
"@mikro-orm/knex": "6.4.3",
|
"@mikro-orm/knex": "6.4.3",
|
||||||
"@mikro-orm/migrations": "6.4.3",
|
"@mikro-orm/migrations": "6.4.3",
|
||||||
@@ -74,12 +74,12 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@jercle/yargonaut": "^1.1.5",
|
"@jercle/yargonaut": "^1.1.5",
|
||||||
"@medusajs/modules-sdk": "^2.6.0",
|
"@medusajs/modules-sdk": "2.6.0",
|
||||||
"@medusajs/orchestration": "^2.6.0",
|
"@medusajs/orchestration": "2.6.0",
|
||||||
"@medusajs/telemetry": "^2.6.0",
|
"@medusajs/telemetry": "2.6.0",
|
||||||
"@medusajs/types": "^2.6.0",
|
"@medusajs/types": "2.6.0",
|
||||||
"@medusajs/utils": "^2.6.0",
|
"@medusajs/utils": "2.6.0",
|
||||||
"@medusajs/workflows-sdk": "^2.6.0",
|
"@medusajs/workflows-sdk": "2.6.0",
|
||||||
"@opentelemetry/api": "^1.9.0",
|
"@opentelemetry/api": "^1.9.0",
|
||||||
"@types/express": "^4.17.17",
|
"@types/express": "^4.17.17",
|
||||||
"chokidar": "^3.4.2",
|
"chokidar": "^3.4.2",
|
||||||
@@ -98,7 +98,7 @@
|
|||||||
"zod": "3.22.4"
|
"zod": "3.22.4"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@medusajs/cli": "^2.4.0",
|
"@medusajs/cli": "2.6.0",
|
||||||
"@mikro-orm/cli": "6.4.3",
|
"@mikro-orm/cli": "6.4.3",
|
||||||
"@mikro-orm/core": "6.4.3",
|
"@mikro-orm/core": "6.4.3",
|
||||||
"@mikro-orm/knex": "6.4.3",
|
"@mikro-orm/knex": "6.4.3",
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
export function GET(req, res) {
|
||||||
|
res.send("Hello from store custom route")
|
||||||
|
}
|
||||||
@@ -110,6 +110,7 @@ export const createServer = async (rootDir) => {
|
|||||||
`${url}${queryParams ? "?" + queryParams : ""}`
|
`${url}${queryParams ? "?" + queryParams : ""}`
|
||||||
)
|
)
|
||||||
headers.Cookie = headers.Cookie || ""
|
headers.Cookie = headers.Cookie || ""
|
||||||
|
|
||||||
if (opts.adminSession) {
|
if (opts.adminSession) {
|
||||||
const token = generateJwtToken(
|
const token = generateJwtToken(
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -46,12 +46,83 @@ describe("RoutesLoader", function () {
|
|||||||
})
|
})
|
||||||
|
|
||||||
expect(res.status).toBe(500)
|
expect(res.status).toBe(500)
|
||||||
console.log(res)
|
|
||||||
expect(res.text).toBe(
|
expect(res.text).toBe(
|
||||||
'{"code":"unknown_error","type":"unknown_error","message":"An unknown error occurred."}'
|
'{"code":"unknown_error","type":"unknown_error","message":"An unknown error occurred."}'
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it("should not succeed on cors preflight admin request failing", async function () {
|
||||||
|
const res = await request("OPTIONS", "/admin/orders", {
|
||||||
|
headers: {
|
||||||
|
origin: "http://localhost:3000",
|
||||||
|
"access-control-request-method": "GET",
|
||||||
|
},
|
||||||
|
adminSession: {
|
||||||
|
jwt: {
|
||||||
|
userId: "admin_user",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
expect(res.status).toBe(204)
|
||||||
|
expect(res.headers["access-control-allow-origin"]).not.toBeTruthy()
|
||||||
|
})
|
||||||
|
|
||||||
|
it("should not succeed on cors preflight store request failing", async function () {
|
||||||
|
const res = await request("OPTIONS", "/store/custom", {
|
||||||
|
headers: {
|
||||||
|
origin: "http://localhost:3000",
|
||||||
|
"access-control-request-method": "GET",
|
||||||
|
},
|
||||||
|
adminSession: {
|
||||||
|
jwt: {
|
||||||
|
userId: "admin_user",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
expect(res.status).toBe(204)
|
||||||
|
expect(res.headers["access-control-allow-origin"]).not.toBeTruthy()
|
||||||
|
})
|
||||||
|
|
||||||
|
it("should succeed on cors preflight admin request", async function () {
|
||||||
|
const res = await request("OPTIONS", "/admin/orders", {
|
||||||
|
headers: {
|
||||||
|
origin: "http://localhost:7001",
|
||||||
|
"access-control-request-method": "GET",
|
||||||
|
},
|
||||||
|
adminSession: {
|
||||||
|
jwt: {
|
||||||
|
userId: "admin_user",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
expect(res.status).toBe(204)
|
||||||
|
expect(res.headers["access-control-allow-origin"]).toBe(
|
||||||
|
"http://localhost:7001"
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
it("should succeed on cors preflight store request", async function () {
|
||||||
|
const res = await request("OPTIONS", "/store/custom", {
|
||||||
|
headers: {
|
||||||
|
origin: "http://localhost:8000",
|
||||||
|
"access-control-request-method": "GET",
|
||||||
|
},
|
||||||
|
adminSession: {
|
||||||
|
jwt: {
|
||||||
|
userId: "admin_user",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
expect(res.status).toBe(204)
|
||||||
|
expect(res.headers["access-control-allow-origin"]).toBe(
|
||||||
|
"http://localhost:8000"
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
it("should return a status 200 on GET admin/order/:id", async function () {
|
it("should return a status 200 on GET admin/order/:id", async function () {
|
||||||
const res = await request("GET", "/admin/orders/1000", {
|
const res = await request("GET", "/admin/orders/1000", {
|
||||||
adminSession: {
|
adminSession: {
|
||||||
|
|||||||
@@ -201,6 +201,18 @@ describe("Routes loader", () => {
|
|||||||
"shouldAppendAuthCors": false,
|
"shouldAppendAuthCors": false,
|
||||||
"shouldAppendStoreCors": false,
|
"shouldAppendStoreCors": false,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"absolutePath": "${BASE_DIR}/store/custom/route.ts",
|
||||||
|
"handler": [Function],
|
||||||
|
"isRoute": true,
|
||||||
|
"matcher": "/store/custom",
|
||||||
|
"method": "GET",
|
||||||
|
"optedOutOfAuth": false,
|
||||||
|
"relativePath": "/store/custom/route.ts",
|
||||||
|
"shouldAppendAdminCors": false,
|
||||||
|
"shouldAppendAuthCors": false,
|
||||||
|
"shouldAppendStoreCors": true,
|
||||||
|
},
|
||||||
]
|
]
|
||||||
`)
|
`)
|
||||||
})
|
})
|
||||||
@@ -409,6 +421,18 @@ describe("Routes loader", () => {
|
|||||||
"shouldAppendAuthCors": false,
|
"shouldAppendAuthCors": false,
|
||||||
"shouldAppendStoreCors": false,
|
"shouldAppendStoreCors": false,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"absolutePath": "${BASE_DIR}/store/custom/route.ts",
|
||||||
|
"handler": [Function],
|
||||||
|
"isRoute": true,
|
||||||
|
"matcher": "/store/custom",
|
||||||
|
"method": "GET",
|
||||||
|
"optedOutOfAuth": false,
|
||||||
|
"relativePath": "/store/custom/route.ts",
|
||||||
|
"shouldAppendAdminCors": false,
|
||||||
|
"shouldAppendAuthCors": false,
|
||||||
|
"shouldAppendStoreCors": true,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"absolutePath": "${BASE_DIR_2}/store/[customer_id]/orders/[order_id]/route.ts",
|
"absolutePath": "${BASE_DIR_2}/store/[customer_id]/orders/[order_id]/route.ts",
|
||||||
"handler": [Function],
|
"handler": [Function],
|
||||||
|
|||||||
@@ -19,14 +19,11 @@ export async function ensurePublishableApiKeyMiddleware(
|
|||||||
const publishableApiKey = req.get(PUBLISHABLE_KEY_HEADER)
|
const publishableApiKey = req.get(PUBLISHABLE_KEY_HEADER)
|
||||||
|
|
||||||
if (!isPresent(publishableApiKey)) {
|
if (!isPresent(publishableApiKey)) {
|
||||||
try {
|
const error = new MedusaError(
|
||||||
throw new MedusaError(
|
|
||||||
MedusaError.Types.NOT_ALLOWED,
|
MedusaError.Types.NOT_ALLOWED,
|
||||||
`Publishable API key required in the request header: ${PUBLISHABLE_KEY_HEADER}. You can manage your keys in settings in the dashboard.`
|
`Publishable API key required in the request header: ${PUBLISHABLE_KEY_HEADER}. You can manage your keys in settings in the dashboard.`
|
||||||
)
|
)
|
||||||
} catch (e) {
|
return next(error)
|
||||||
return next(e)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let apiKey
|
let apiKey
|
||||||
|
|||||||
@@ -173,6 +173,7 @@ export class ApiLoader {
|
|||||||
return {
|
return {
|
||||||
origin: parseCorsOrigins(origin),
|
origin: parseCorsOrigins(origin),
|
||||||
credentials: true,
|
credentials: true,
|
||||||
|
preflightContinue: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -194,11 +195,13 @@ export class ApiLoader {
|
|||||||
res,
|
res,
|
||||||
next
|
next
|
||||||
) {
|
) {
|
||||||
|
let method: string = req.method
|
||||||
|
if (req.method === "OPTIONS") {
|
||||||
|
method = req.headers["access-control-request-method"] ?? req.method
|
||||||
|
}
|
||||||
|
|
||||||
const path = `${namespace}${req.path}`
|
const path = `${namespace}${req.path}`
|
||||||
const matchingRoute = routesFinder.find(
|
const matchingRoute = routesFinder.find(path, method as MiddlewareVerb)
|
||||||
path,
|
|
||||||
req.method as MiddlewareVerb
|
|
||||||
)
|
|
||||||
if (matchingRoute && matchingRoute[toggleKey] === true) {
|
if (matchingRoute && matchingRoute[toggleKey] === true) {
|
||||||
return corsFn(req, res, next)
|
return corsFn(req, res, next)
|
||||||
}
|
}
|
||||||
@@ -213,7 +216,7 @@ export class ApiLoader {
|
|||||||
? (ApiLoader.traceMiddleware(corsMiddleware, {
|
? (ApiLoader.traceMiddleware(corsMiddleware, {
|
||||||
route: namespace,
|
route: namespace,
|
||||||
}) as RequestHandler)
|
}) as RequestHandler)
|
||||||
: cors(corsOptions)
|
: corsMiddleware
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -334,16 +337,17 @@ export class ApiLoader {
|
|||||||
"api-key",
|
"api-key",
|
||||||
])
|
])
|
||||||
|
|
||||||
/**
|
|
||||||
* Publishable key check, CORS and auth setup for store routes.
|
|
||||||
*/
|
|
||||||
this.#applyStorePublishableKeyMiddleware("/store")
|
|
||||||
this.#applyCorsMiddleware(
|
this.#applyCorsMiddleware(
|
||||||
routesFinder,
|
routesFinder,
|
||||||
"/store",
|
"/store",
|
||||||
"shouldAppendStoreCors",
|
"shouldAppendStoreCors",
|
||||||
this.#createCorsOptions(configManager.config.projectConfig.http.storeCors)
|
this.#createCorsOptions(configManager.config.projectConfig.http.storeCors)
|
||||||
)
|
)
|
||||||
|
/**
|
||||||
|
* Publishable key check, CORS and auth setup for store routes.
|
||||||
|
*/
|
||||||
|
this.#applyStorePublishableKeyMiddleware("/store")
|
||||||
|
|
||||||
this.#applyAuthMiddleware(
|
this.#applyAuthMiddleware(
|
||||||
routesFinder,
|
routesFinder,
|
||||||
"/store",
|
"/store",
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { join, parse, sep } from "path"
|
|
||||||
import { dynamicImport, readDirRecursive } from "@medusajs/utils"
|
import { dynamicImport, readDirRecursive } from "@medusajs/utils"
|
||||||
|
import { join, parse, sep } from "path"
|
||||||
import { logger } from "../logger"
|
import { logger } from "../logger"
|
||||||
import { type RouteVerb, HTTP_METHODS, type RouteDescriptor } from "./types"
|
import { HTTP_METHODS, type RouteDescriptor, type RouteVerb } from "./types"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* File name that is used to indicate that the file is a route file
|
* File name that is used to indicate that the file is a route file
|
||||||
|
|||||||
@@ -35,7 +35,7 @@
|
|||||||
"typescript": "^5.6.2"
|
"typescript": "^5.6.2"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@medusajs/types": "^2.6.0",
|
"@medusajs/types": "2.6.0",
|
||||||
"fetch-event-stream": "^0.1.5",
|
"fetch-event-stream": "^0.1.5",
|
||||||
"qs": "^6.12.1"
|
"qs": "^6.12.1"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -128,7 +128,7 @@ export class Admin {
|
|||||||
*/
|
*/
|
||||||
public order: Order
|
public order: Order
|
||||||
/**
|
/**
|
||||||
* @tags draft order
|
* @tags order
|
||||||
*/
|
*/
|
||||||
public draftOrder: DraftOrder
|
public draftOrder: DraftOrder
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ export class ProductCollection {
|
|||||||
* This method retrieves a paginated list of collections. It sends a request to the
|
* This method retrieves a paginated list of collections. It sends a request to the
|
||||||
* [List Collections](https://docs.medusajs.com/api/admin#collections_getcollections) API route.
|
* [List Collections](https://docs.medusajs.com/api/admin#collections_getcollections) API route.
|
||||||
*
|
*
|
||||||
* @param query - Filters and pagination configurations.
|
* @param queryParams - Filters and pagination configurations.
|
||||||
* @param headers - Headers to pass in the request.
|
* @param headers - Headers to pass in the request.
|
||||||
* @returns The paginated list of collections.
|
* @returns The paginated list of collections.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -276,7 +276,7 @@ export class Product {
|
|||||||
* This method retrieves a paginated list of products. It sends a request to the
|
* This method retrieves a paginated list of products. It sends a request to the
|
||||||
* [List Products](https://docs.medusajs.com/api/admin#products_getproducts) API route.
|
* [List Products](https://docs.medusajs.com/api/admin#products_getproducts) API route.
|
||||||
*
|
*
|
||||||
* @param query - Filters and pagination configurations.
|
* @param queryParams - Filters and pagination configurations.
|
||||||
* @param headers - Headers to pass in the request.
|
* @param headers - Headers to pass in the request.
|
||||||
* @returns The paginated list of products.
|
* @returns The paginated list of products.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -45,9 +45,9 @@
|
|||||||
"typescript": "^5.6.2"
|
"typescript": "^5.6.2"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@medusajs/orchestration": "^2.6.0",
|
"@medusajs/orchestration": "2.6.0",
|
||||||
"@medusajs/types": "^2.6.0",
|
"@medusajs/types": "2.6.0",
|
||||||
"@medusajs/utils": "^2.6.0"
|
"@medusajs/utils": "2.6.0"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@mikro-orm/core": "6.4.3",
|
"@mikro-orm/core": "6.4.3",
|
||||||
|
|||||||
@@ -39,8 +39,8 @@
|
|||||||
"typescript": "^5.6.2"
|
"typescript": "^5.6.2"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@medusajs/types": "^2.6.0",
|
"@medusajs/types": "2.6.0",
|
||||||
"@medusajs/utils": "^2.6.0"
|
"@medusajs/utils": "2.6.0"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@mikro-orm/core": "6.4.3",
|
"@mikro-orm/core": "6.4.3",
|
||||||
|
|||||||
@@ -430,12 +430,24 @@ export interface UpdateTaxLineDTO {
|
|||||||
/**
|
/**
|
||||||
* The shipping method tax line to be created.
|
* The shipping method tax line to be created.
|
||||||
*/
|
*/
|
||||||
export interface CreateShippingMethodTaxLineDTO extends CreateTaxLineDTO {}
|
export interface CreateShippingMethodTaxLineDTO
|
||||||
|
extends Omit<CreateTaxLineDTO, "item_id"> {
|
||||||
|
/**
|
||||||
|
* The associated shipping method's ID.
|
||||||
|
*/
|
||||||
|
shipping_method_id: string
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The attributes to update in the shipping method tax line.
|
* The attributes to update in the shipping method tax line.
|
||||||
*/
|
*/
|
||||||
export interface UpdateShippingMethodTaxLineDTO extends UpdateTaxLineDTO {}
|
export interface UpdateShippingMethodTaxLineDTO
|
||||||
|
extends Omit<UpdateTaxLineDTO, "item_id"> {
|
||||||
|
/**
|
||||||
|
* The associated shipping method's ID.
|
||||||
|
*/
|
||||||
|
shipping_method_id?: string
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The line item tax line to be created.
|
* The line item tax line to be created.
|
||||||
|
|||||||
@@ -2075,4 +2075,123 @@ export interface ICartModuleService extends IModuleService {
|
|||||||
config?: RestoreReturn<TReturnableLinkableKeys>,
|
config?: RestoreReturn<TReturnableLinkableKeys>,
|
||||||
sharedContext?: Context
|
sharedContext?: Context
|
||||||
): Promise<Record<TReturnableLinkableKeys, string[]> | void>
|
): Promise<Record<TReturnableLinkableKeys, string[]> | void>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method upserts line item adjustments.
|
||||||
|
*
|
||||||
|
* @param {UpsertLineItemAdjustmentDTO[]} data - The line item adjustments to create or update. If the `id` property is provided
|
||||||
|
* in an object, it means an existing line item adjustment will be updated. Otherwise, a new one is created.
|
||||||
|
* @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
|
||||||
|
* @returns {Promise<LineItemAdjustmentDTO[]>} The line item adjustments.
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* const lineItemAdjustments = await orderModuleService.upsertLineItemAdjustments(
|
||||||
|
* [
|
||||||
|
* {
|
||||||
|
* item_id: "1234",
|
||||||
|
* amount: 10
|
||||||
|
* },
|
||||||
|
* {
|
||||||
|
* id: "123",
|
||||||
|
* item_id: "4321",
|
||||||
|
* amount: 20
|
||||||
|
* }
|
||||||
|
* ]
|
||||||
|
* )
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
upsertLineItemAdjustments(
|
||||||
|
data: UpsertLineItemAdjustmentDTO[],
|
||||||
|
sharedContext?: Context
|
||||||
|
): Promise<LineItemAdjustmentDTO[]>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method upserts shipping method adjustments.
|
||||||
|
*
|
||||||
|
* @param {(CreateShippingMethodAdjustmentDTO | UpdateShippingMethodAdjustmentDTO)[]} data - The shipping method adjustments to be created
|
||||||
|
* or updated. If an adjustment object has an `id` property, it's updated. Otherwise, a new adjustment is created.
|
||||||
|
* @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
|
||||||
|
* @returns {Promise<ShippingMethodAdjustmentDTO[]>} The shipping method adjustments.
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* const shippingMethodAdjustments = await orderModuleService
|
||||||
|
* .upsertShippingMethodAdjustments(
|
||||||
|
* [
|
||||||
|
* {
|
||||||
|
* shipping_method_id: "123",
|
||||||
|
* code: "50OFF",
|
||||||
|
* amount: 5
|
||||||
|
* },
|
||||||
|
* {
|
||||||
|
* id: "321",
|
||||||
|
* amount: 5
|
||||||
|
* }
|
||||||
|
* ]
|
||||||
|
* )
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
upsertShippingMethodAdjustments(
|
||||||
|
data: (
|
||||||
|
| CreateShippingMethodAdjustmentDTO
|
||||||
|
| UpdateShippingMethodAdjustmentDTO
|
||||||
|
)[],
|
||||||
|
sharedContext?: Context
|
||||||
|
): Promise<ShippingMethodAdjustmentDTO[]>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method upserts line item tax lines.
|
||||||
|
*
|
||||||
|
* @param {(CreateLineItemTaxLineDTO | UpdateLineItemTaxLineDTO)[]} taxLines - The line item tax lines to create or update. If the
|
||||||
|
* tax line object has an `id` property, it'll be updated. Otherwise, a tax line is created.
|
||||||
|
* @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
|
||||||
|
* @returns {Promise<LineItemTaxLineDTO[]>} The line item tax lines.
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* const lineItemTaxLines = await orderModuleService
|
||||||
|
* .upsertLineItemTaxLines(
|
||||||
|
* [
|
||||||
|
* {
|
||||||
|
* code: "123",
|
||||||
|
* rate: 2
|
||||||
|
* }
|
||||||
|
* ]
|
||||||
|
* )
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
upsertLineItemTaxLines(
|
||||||
|
taxLines: (CreateLineItemTaxLineDTO | UpdateLineItemTaxLineDTO)[],
|
||||||
|
sharedContext?: Context
|
||||||
|
): Promise<LineItemTaxLineDTO[]>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method upsert shipping method tax lines.
|
||||||
|
*
|
||||||
|
* @param {(CreateShippingMethodTaxLineDTO | UpdateShippingMethodTaxLineDTO)[]} taxLines - The shipping method tax lines to create or update.
|
||||||
|
* If a tax line object has an `id` property, it's updated. Otherwise, a tax line is created.
|
||||||
|
* @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
|
||||||
|
* @returns {Promise<ShippingMethodTaxLineDTO[]>} The shipping method tax lines.
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* const shippingMethodTaxLines = await orderModuleService
|
||||||
|
* .upsertShippingMethodTaxLines(
|
||||||
|
* [
|
||||||
|
* {
|
||||||
|
* code: "123",
|
||||||
|
* rate: 2
|
||||||
|
* },
|
||||||
|
* {
|
||||||
|
* id: "321",
|
||||||
|
* rate: 2
|
||||||
|
* }
|
||||||
|
* ]
|
||||||
|
* )
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
upsertShippingMethodTaxLines(
|
||||||
|
taxLines: (
|
||||||
|
| CreateShippingMethodTaxLineDTO
|
||||||
|
| UpdateShippingMethodTaxLineDTO
|
||||||
|
)[],
|
||||||
|
sharedContext?: Context
|
||||||
|
): Promise<ShippingMethodTaxLineDTO[]>
|
||||||
}
|
}
|
||||||
@@ -552,6 +552,16 @@ export interface PaymentSessionDTO {
|
|||||||
*/
|
*/
|
||||||
authorized_at?: Date
|
authorized_at?: Date
|
||||||
|
|
||||||
|
/**
|
||||||
|
* When the payment session was created
|
||||||
|
*/
|
||||||
|
created_at: Date | string
|
||||||
|
|
||||||
|
/**
|
||||||
|
* When the payment session was updated
|
||||||
|
*/
|
||||||
|
updated_at: Date | string
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The ID of the associated payment collection.
|
* The ID of the associated payment collection.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -47,7 +47,7 @@
|
|||||||
"@graphql-codegen/typescript": "^4.0.9",
|
"@graphql-codegen/typescript": "^4.0.9",
|
||||||
"@graphql-tools/merge": "^9.0.7",
|
"@graphql-tools/merge": "^9.0.7",
|
||||||
"@graphql-tools/schema": "^10.0.6",
|
"@graphql-tools/schema": "^10.0.6",
|
||||||
"@medusajs/types": "^2.6.0",
|
"@medusajs/types": "2.6.0",
|
||||||
"@types/pluralize": "^0.0.33",
|
"@types/pluralize": "^0.0.33",
|
||||||
"bignumber.js": "^9.1.2",
|
"bignumber.js": "^9.1.2",
|
||||||
"dotenv": "^16.4.5",
|
"dotenv": "^16.4.5",
|
||||||
|
|||||||
@@ -40,10 +40,10 @@
|
|||||||
"typescript": "^5.6.2"
|
"typescript": "^5.6.2"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@medusajs/modules-sdk": "^2.6.0",
|
"@medusajs/modules-sdk": "2.6.0",
|
||||||
"@medusajs/orchestration": "^2.6.0",
|
"@medusajs/orchestration": "2.6.0",
|
||||||
"@medusajs/types": "^2.6.0",
|
"@medusajs/types": "2.6.0",
|
||||||
"@medusajs/utils": "^2.6.0",
|
"@medusajs/utils": "2.6.0",
|
||||||
"ulid": "^2.3.0"
|
"ulid": "^2.3.0"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
|
|||||||
@@ -19,10 +19,12 @@ import {
|
|||||||
StepFunction,
|
StepFunction,
|
||||||
StepResponse,
|
StepResponse,
|
||||||
transform,
|
transform,
|
||||||
|
when,
|
||||||
WorkflowResponse,
|
WorkflowResponse,
|
||||||
} from ".."
|
} from ".."
|
||||||
import { MedusaWorkflow } from "../../../medusa-workflow"
|
import { MedusaWorkflow } from "../../../medusa-workflow"
|
||||||
import { createHook } from "../create-hook"
|
import { createHook } from "../create-hook"
|
||||||
|
import { setTimeout } from "timers/promises"
|
||||||
|
|
||||||
jest.setTimeout(30000)
|
jest.setTimeout(30000)
|
||||||
|
|
||||||
@@ -742,6 +744,71 @@ describe("Workflow composer", function () {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it("should compose a new workflow with conditional parallelized steps", async () => {
|
||||||
|
const stepResults: string[] = []
|
||||||
|
|
||||||
|
const mockStep1Fn = jest.fn().mockImplementation(async () => {
|
||||||
|
await setTimeout(100)
|
||||||
|
stepResults.push("step1")
|
||||||
|
return new StepResponse(true)
|
||||||
|
}) as any
|
||||||
|
const mockStep2Fn = jest.fn().mockImplementation(() => {
|
||||||
|
stepResults.push("step2")
|
||||||
|
return new StepResponse(true)
|
||||||
|
}) as any
|
||||||
|
const mockStep3Fn = jest.fn().mockImplementation(() => {
|
||||||
|
stepResults.push("step3")
|
||||||
|
return new StepResponse(true)
|
||||||
|
}) as any
|
||||||
|
const mockStep4Fn = jest.fn().mockImplementation(() => {
|
||||||
|
stepResults.push("step4")
|
||||||
|
return new StepResponse(true)
|
||||||
|
}) as any
|
||||||
|
|
||||||
|
const step1 = createStep("step1", mockStep1Fn)
|
||||||
|
const step2 = createStep("step2", mockStep2Fn)
|
||||||
|
const step3 = createStep("step3", mockStep3Fn)
|
||||||
|
const step4 = createStep("step4", mockStep4Fn)
|
||||||
|
|
||||||
|
const callStep2IfNeeded = () => {
|
||||||
|
return when({}, () => false).then(() => {
|
||||||
|
return step2()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
const callStep3IfNeeded = () => {
|
||||||
|
return when({}, () => false).then(() => {
|
||||||
|
return step4()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
const workflow = createWorkflow("workflow1", function (input) {
|
||||||
|
const [ret1, ret2, ret3, ret4] = parallelize(
|
||||||
|
step1(),
|
||||||
|
callStep2IfNeeded(),
|
||||||
|
step3(),
|
||||||
|
callStep3IfNeeded()
|
||||||
|
)
|
||||||
|
return new WorkflowResponse({ ret1, ret2, ret3, ret4 })
|
||||||
|
})
|
||||||
|
|
||||||
|
const { result: workflowResult } = await workflow().run()
|
||||||
|
|
||||||
|
expect(mockStep1Fn).toHaveBeenCalledTimes(1)
|
||||||
|
expect(mockStep2Fn).toHaveBeenCalledTimes(0)
|
||||||
|
expect(mockStep3Fn).toHaveBeenCalledTimes(1)
|
||||||
|
expect(mockStep4Fn).toHaveBeenCalledTimes(0)
|
||||||
|
|
||||||
|
expect(workflowResult).toEqual({
|
||||||
|
ret1: true,
|
||||||
|
ret2: undefined,
|
||||||
|
ret3: true,
|
||||||
|
ret4: undefined,
|
||||||
|
})
|
||||||
|
|
||||||
|
expect(stepResults).toEqual(["step3", "step1"])
|
||||||
|
})
|
||||||
|
|
||||||
it("should compose a new workflow with parallelize steps and rollback them all in case of error", async () => {
|
it("should compose a new workflow with parallelize steps and rollback them all in case of error", async () => {
|
||||||
const step1CompensationFn = jest.fn().mockImplementation(() => {
|
const step1CompensationFn = jest.fn().mockImplementation(() => {
|
||||||
return "step1 compensation"
|
return "step1 compensation"
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ import { OrchestrationUtils } from "@medusajs/utils"
|
|||||||
* }
|
* }
|
||||||
* )
|
* )
|
||||||
*/
|
*/
|
||||||
export function parallelize<TResult extends WorkflowData[]>(
|
export function parallelize<TResult extends (WorkflowData | undefined)[]>(
|
||||||
...steps: TResult
|
...steps: TResult
|
||||||
): TResult {
|
): TResult {
|
||||||
if (!global[OrchestrationUtils.SymbolMedusaWorkflowComposerContext]) {
|
if (!global[OrchestrationUtils.SymbolMedusaWorkflowComposerContext]) {
|
||||||
@@ -64,7 +64,7 @@ export function parallelize<TResult extends WorkflowData[]>(
|
|||||||
const stepOntoMerge = steps.shift()!
|
const stepOntoMerge = steps.shift()!
|
||||||
this.flow.mergeActions(
|
this.flow.mergeActions(
|
||||||
stepOntoMerge.__step__,
|
stepOntoMerge.__step__,
|
||||||
...steps.map((step) => step.__step__)
|
...steps.map((step) => step!.__step__)
|
||||||
)
|
)
|
||||||
|
|
||||||
return resultSteps as unknown as TResult
|
return resultSteps as unknown as TResult
|
||||||
|
|||||||
@@ -104,7 +104,9 @@ export type CreateWorkflowComposerContext = {
|
|||||||
fn: StepFunctionResult
|
fn: StepFunctionResult
|
||||||
) => WorkflowData<TOutput>
|
) => WorkflowData<TOutput>
|
||||||
hookBinder: (name: string, fn: () => HookHandler) => void
|
hookBinder: (name: string, fn: () => HookHandler) => void
|
||||||
parallelizeBinder: <TOutput extends WorkflowData[] = WorkflowData[]>(
|
parallelizeBinder: <
|
||||||
|
TOutput extends (WorkflowData | undefined)[] = WorkflowData[]
|
||||||
|
>(
|
||||||
fn: (this: CreateWorkflowComposerContext) => TOutput
|
fn: (this: CreateWorkflowComposerContext) => TOutput
|
||||||
) => TOutput
|
) => TOutput
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,7 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@atomico/rollup-plugin-sizes": "^1.1.4",
|
"@atomico/rollup-plugin-sizes": "^1.1.4",
|
||||||
"@medusajs/toolbox": "^2.6.0",
|
"@medusajs/toolbox": "2.6.0",
|
||||||
"@rollup/plugin-node-resolve": "^15.1.0",
|
"@rollup/plugin-node-resolve": "^15.1.0",
|
||||||
"@rollup/plugin-replace": "^5.0.2",
|
"@rollup/plugin-replace": "^5.0.2",
|
||||||
"@testing-library/dom": "^9.3.1",
|
"@testing-library/dom": "^9.3.1",
|
||||||
|
|||||||
@@ -30,7 +30,7 @@
|
|||||||
"tailwindcss": ">=3.0.0"
|
"tailwindcss": ">=3.0.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@medusajs/toolbox": "^2.6.0",
|
"@medusajs/toolbox": "2.6.0",
|
||||||
"tailwindcss": "^3.4.1",
|
"tailwindcss": "^3.4.1",
|
||||||
"tsup": "^7.1.0",
|
"tsup": "^7.1.0",
|
||||||
"typescript": "^5.1.6"
|
"typescript": "^5.1.6"
|
||||||
|
|||||||
@@ -43,7 +43,7 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@faker-js/faker": "^9.2.0",
|
"@faker-js/faker": "^9.2.0",
|
||||||
"@medusajs/ui-preset": "^2.5.1",
|
"@medusajs/ui-preset": "2.6.0",
|
||||||
"@storybook/addon-essentials": "^8.3.5",
|
"@storybook/addon-essentials": "^8.3.5",
|
||||||
"@storybook/addon-interactions": "^8.3.5",
|
"@storybook/addon-interactions": "^8.3.5",
|
||||||
"@storybook/addon-links": "^8.3.5",
|
"@storybook/addon-links": "^8.3.5",
|
||||||
@@ -81,7 +81,7 @@
|
|||||||
"vitest": "^3.0.5"
|
"vitest": "^3.0.5"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@medusajs/icons": "^2.5.1",
|
"@medusajs/icons": "2.6.0",
|
||||||
"@tanstack/react-table": "8.20.5",
|
"@tanstack/react-table": "8.20.5",
|
||||||
"clsx": "^1.2.1",
|
"clsx": "^1.2.1",
|
||||||
"copy-to-clipboard": "^3.3.3",
|
"copy-to-clipboard": "^3.3.3",
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
"author": "Medusa",
|
"author": "Medusa",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@medusajs/framework": "^2.6.0",
|
"@medusajs/framework": "2.6.0",
|
||||||
"@mikro-orm/core": "6.4.3",
|
"@mikro-orm/core": "6.4.3",
|
||||||
"@mikro-orm/knex": "6.4.3",
|
"@mikro-orm/knex": "6.4.3",
|
||||||
"@mikro-orm/migrations": "6.4.3",
|
"@mikro-orm/migrations": "6.4.3",
|
||||||
@@ -45,8 +45,8 @@
|
|||||||
"randomatic": "^3.1.1"
|
"randomatic": "^3.1.1"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@medusajs/framework": "^2.4.0",
|
"@medusajs/framework": "2.6.0",
|
||||||
"@medusajs/medusa": "^2.4.0",
|
"@medusajs/medusa": "2.6.0",
|
||||||
"@mikro-orm/postgresql": "6.4.3",
|
"@mikro-orm/postgresql": "6.4.3",
|
||||||
"awilix": "^8.0.1"
|
"awilix": "^8.0.1"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -44,15 +44,15 @@
|
|||||||
"test:integration": "jest --forceExit -- src/**/integration-tests/**/__tests__/**/*.ts"
|
"test:integration": "jest --forceExit -- src/**/integration-tests/**/__tests__/**/*.ts"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@medusajs/framework": "^2.6.0",
|
"@medusajs/framework": "2.6.0",
|
||||||
"@opentelemetry/api": "^1.9.0",
|
"@opentelemetry/api": "^1.9.0",
|
||||||
"@opentelemetry/instrumentation": "^0.53.0",
|
"@opentelemetry/instrumentation": "^0.53.0",
|
||||||
"@opentelemetry/instrumentation-pg": "^0.44.0",
|
"@opentelemetry/instrumentation-pg": "^0.44.0",
|
||||||
"@opentelemetry/resources": "^1.26.0",
|
"@opentelemetry/resources": "^1.26.0",
|
||||||
"@opentelemetry/sdk-node": "^0.53.0",
|
"@opentelemetry/sdk-node": "^0.53.0",
|
||||||
"@opentelemetry/sdk-trace-node": "^1.26.0",
|
"@opentelemetry/sdk-trace-node": "^1.26.0",
|
||||||
"@swc/core": "^1.7.28",
|
"@swc/core": "1.5.7",
|
||||||
"@swc/helpers": "^0.5.0",
|
"@swc/helpers": "^0.5.11",
|
||||||
"@swc/jest": "^0.2.36",
|
"@swc/jest": "^0.2.36",
|
||||||
"@types/express": "^4.17.17",
|
"@types/express": "^4.17.17",
|
||||||
"@types/jsonwebtoken": "^8.5.9",
|
"@types/jsonwebtoken": "^8.5.9",
|
||||||
@@ -67,49 +67,49 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@inquirer/checkbox": "^2.3.11",
|
"@inquirer/checkbox": "^2.3.11",
|
||||||
"@inquirer/input": "^2.2.9",
|
"@inquirer/input": "^2.2.9",
|
||||||
"@medusajs/admin-bundler": "^2.6.0",
|
"@medusajs/admin-bundler": "2.6.0",
|
||||||
"@medusajs/api-key": "^2.6.0",
|
"@medusajs/api-key": "2.6.0",
|
||||||
"@medusajs/auth": "^2.6.0",
|
"@medusajs/auth": "2.6.0",
|
||||||
"@medusajs/auth-emailpass": "^2.6.0",
|
"@medusajs/auth-emailpass": "2.6.0",
|
||||||
"@medusajs/auth-github": "^2.6.0",
|
"@medusajs/auth-github": "2.6.0",
|
||||||
"@medusajs/auth-google": "^2.6.0",
|
"@medusajs/auth-google": "2.6.0",
|
||||||
"@medusajs/cache-inmemory": "^2.6.0",
|
"@medusajs/cache-inmemory": "2.6.0",
|
||||||
"@medusajs/cache-redis": "^2.6.0",
|
"@medusajs/cache-redis": "2.6.0",
|
||||||
"@medusajs/cart": "^2.6.0",
|
"@medusajs/cart": "2.6.0",
|
||||||
"@medusajs/core-flows": "^2.6.0",
|
"@medusajs/core-flows": "2.6.0",
|
||||||
"@medusajs/currency": "^2.6.0",
|
"@medusajs/currency": "2.6.0",
|
||||||
"@medusajs/customer": "^2.6.0",
|
"@medusajs/customer": "2.6.0",
|
||||||
"@medusajs/event-bus-local": "^2.6.0",
|
"@medusajs/event-bus-local": "2.6.0",
|
||||||
"@medusajs/event-bus-redis": "^2.6.0",
|
"@medusajs/event-bus-redis": "2.6.0",
|
||||||
"@medusajs/file": "^2.6.0",
|
"@medusajs/file": "2.6.0",
|
||||||
"@medusajs/file-local": "^2.6.0",
|
"@medusajs/file-local": "2.6.0",
|
||||||
"@medusajs/file-s3": "^2.6.0",
|
"@medusajs/file-s3": "2.6.0",
|
||||||
"@medusajs/fulfillment": "^2.6.0",
|
"@medusajs/fulfillment": "2.6.0",
|
||||||
"@medusajs/fulfillment-manual": "^2.6.0",
|
"@medusajs/fulfillment-manual": "2.6.0",
|
||||||
"@medusajs/index": "^2.6.0",
|
"@medusajs/index": "2.6.0",
|
||||||
"@medusajs/inventory": "^2.6.0",
|
"@medusajs/inventory": "2.6.0",
|
||||||
"@medusajs/link-modules": "^2.6.0",
|
"@medusajs/link-modules": "2.6.0",
|
||||||
"@medusajs/locking": "^2.6.0",
|
"@medusajs/locking": "2.6.0",
|
||||||
"@medusajs/locking-postgres": "^2.6.0",
|
"@medusajs/locking-postgres": "2.6.0",
|
||||||
"@medusajs/locking-redis": "^2.6.0",
|
"@medusajs/locking-redis": "2.6.0",
|
||||||
"@medusajs/notification": "^2.6.0",
|
"@medusajs/notification": "2.6.0",
|
||||||
"@medusajs/notification-local": "^2.6.0",
|
"@medusajs/notification-local": "2.6.0",
|
||||||
"@medusajs/notification-sendgrid": "^2.6.0",
|
"@medusajs/notification-sendgrid": "2.6.0",
|
||||||
"@medusajs/order": "^2.6.0",
|
"@medusajs/order": "2.6.0",
|
||||||
"@medusajs/payment": "^2.6.0",
|
"@medusajs/payment": "2.6.0",
|
||||||
"@medusajs/payment-stripe": "^2.6.0",
|
"@medusajs/payment-stripe": "2.6.0",
|
||||||
"@medusajs/pricing": "^2.6.0",
|
"@medusajs/pricing": "2.6.0",
|
||||||
"@medusajs/product": "^2.6.0",
|
"@medusajs/product": "2.6.0",
|
||||||
"@medusajs/promotion": "^2.6.0",
|
"@medusajs/promotion": "2.6.0",
|
||||||
"@medusajs/region": "^2.6.0",
|
"@medusajs/region": "2.6.0",
|
||||||
"@medusajs/sales-channel": "^2.6.0",
|
"@medusajs/sales-channel": "2.6.0",
|
||||||
"@medusajs/stock-location": "^2.6.0",
|
"@medusajs/stock-location": "2.6.0",
|
||||||
"@medusajs/store": "^2.6.0",
|
"@medusajs/store": "2.6.0",
|
||||||
"@medusajs/tax": "^2.6.0",
|
"@medusajs/tax": "2.6.0",
|
||||||
"@medusajs/telemetry": "^2.6.0",
|
"@medusajs/telemetry": "2.6.0",
|
||||||
"@medusajs/user": "^2.6.0",
|
"@medusajs/user": "2.6.0",
|
||||||
"@medusajs/workflow-engine-inmemory": "^2.6.0",
|
"@medusajs/workflow-engine-inmemory": "2.6.0",
|
||||||
"@medusajs/workflow-engine-redis": "^2.6.0",
|
"@medusajs/workflow-engine-redis": "2.6.0",
|
||||||
"boxen": "^5.0.1",
|
"boxen": "^5.0.1",
|
||||||
"chalk": "^4.0.0",
|
"chalk": "^4.0.0",
|
||||||
"chokidar": "^3.4.2",
|
"chokidar": "^3.4.2",
|
||||||
@@ -127,12 +127,12 @@
|
|||||||
"zod": "3.22.4"
|
"zod": "3.22.4"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@medusajs/framework": "^2.4.0",
|
"@medusajs/framework": "2.6.0",
|
||||||
"@mikro-orm/core": "6.4.3",
|
"@mikro-orm/core": "6.4.3",
|
||||||
"@mikro-orm/knex": "6.4.3",
|
"@mikro-orm/knex": "6.4.3",
|
||||||
"@mikro-orm/migrations": "6.4.3",
|
"@mikro-orm/migrations": "6.4.3",
|
||||||
"@mikro-orm/postgresql": "6.4.3",
|
"@mikro-orm/postgresql": "6.4.3",
|
||||||
"@swc/core": "^1.7.28",
|
"@swc/core": "1.5.7",
|
||||||
"awilix": "^8.0.1",
|
"awilix": "^8.0.1",
|
||||||
"react-dom": "^18.0.0",
|
"react-dom": "^18.0.0",
|
||||||
"yalc": "1.0.0-pre.53"
|
"yalc": "1.0.0-pre.53"
|
||||||
|
|||||||
@@ -36,8 +36,8 @@
|
|||||||
"orm:cache:clear": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm cache:clear"
|
"orm:cache:clear": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm cache:clear"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@medusajs/framework": "^2.6.0",
|
"@medusajs/framework": "2.6.0",
|
||||||
"@medusajs/test-utils": "^2.6.0",
|
"@medusajs/test-utils": "2.6.0",
|
||||||
"@mikro-orm/cli": "6.4.3",
|
"@mikro-orm/cli": "6.4.3",
|
||||||
"@swc/core": "^1.7.28",
|
"@swc/core": "^1.7.28",
|
||||||
"@swc/jest": "^0.2.36",
|
"@swc/jest": "^0.2.36",
|
||||||
@@ -47,7 +47,7 @@
|
|||||||
"typescript": "^5.6.2"
|
"typescript": "^5.6.2"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@medusajs/framework": "^2.4.0",
|
"@medusajs/framework": "2.6.0",
|
||||||
"@mikro-orm/core": "6.4.3",
|
"@mikro-orm/core": "6.4.3",
|
||||||
"@mikro-orm/migrations": "6.4.3",
|
"@mikro-orm/migrations": "6.4.3",
|
||||||
"@mikro-orm/postgresql": "6.4.3",
|
"@mikro-orm/postgresql": "6.4.3",
|
||||||
|
|||||||
@@ -36,8 +36,8 @@
|
|||||||
"orm:cache:clear": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm cache:clear"
|
"orm:cache:clear": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm cache:clear"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@medusajs/framework": "^2.6.0",
|
"@medusajs/framework": "2.6.0",
|
||||||
"@medusajs/test-utils": "^2.6.0",
|
"@medusajs/test-utils": "2.6.0",
|
||||||
"@mikro-orm/cli": "6.4.3",
|
"@mikro-orm/cli": "6.4.3",
|
||||||
"@mikro-orm/core": "6.4.3",
|
"@mikro-orm/core": "6.4.3",
|
||||||
"@mikro-orm/migrations": "6.4.3",
|
"@mikro-orm/migrations": "6.4.3",
|
||||||
@@ -50,7 +50,7 @@
|
|||||||
"typescript": "^5.6.2"
|
"typescript": "^5.6.2"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@medusajs/framework": "^2.4.0",
|
"@medusajs/framework": "2.6.0",
|
||||||
"@mikro-orm/core": "6.4.3",
|
"@mikro-orm/core": "6.4.3",
|
||||||
"@mikro-orm/migrations": "6.4.3",
|
"@mikro-orm/migrations": "6.4.3",
|
||||||
"@mikro-orm/postgresql": "6.4.3",
|
"@mikro-orm/postgresql": "6.4.3",
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
"author": "Medusa",
|
"author": "Medusa",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@medusajs/framework": "^2.6.0",
|
"@medusajs/framework": "2.6.0",
|
||||||
"@swc/core": "^1.7.28",
|
"@swc/core": "^1.7.28",
|
||||||
"@swc/jest": "^0.2.36",
|
"@swc/jest": "^0.2.36",
|
||||||
"jest": "^29.7.0",
|
"jest": "^29.7.0",
|
||||||
@@ -36,6 +36,6 @@
|
|||||||
"test": "jest --passWithNoTests"
|
"test": "jest --passWithNoTests"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@medusajs/framework": "^2.4.0"
|
"@medusajs/framework": "2.6.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -23,7 +23,7 @@
|
|||||||
"author": "Medusa",
|
"author": "Medusa",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@medusajs/framework": "^2.6.0",
|
"@medusajs/framework": "2.6.0",
|
||||||
"@swc/core": "^1.7.28",
|
"@swc/core": "^1.7.28",
|
||||||
"@swc/jest": "^0.2.36",
|
"@swc/jest": "^0.2.36",
|
||||||
"jest": "^29.7.0",
|
"jest": "^29.7.0",
|
||||||
@@ -39,7 +39,7 @@
|
|||||||
"ioredis": "^5.4.1"
|
"ioredis": "^5.4.1"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@medusajs/framework": "^2.4.0",
|
"@medusajs/framework": "2.6.0",
|
||||||
"awilix": "^8.0.1"
|
"awilix": "^8.0.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2272,6 +2272,343 @@ moduleIntegrationTestRunner<ICartModuleService>({
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe("setShippingMethodTaxLines", () => {
|
||||||
|
it("should set shipping item tax lines for a cart", async () => {
|
||||||
|
const [createdCart] = await service.createCarts([
|
||||||
|
{
|
||||||
|
currency_code: "eur",
|
||||||
|
},
|
||||||
|
])
|
||||||
|
|
||||||
|
const [itemOne] = await service.addShippingMethods(createdCart.id, [
|
||||||
|
{
|
||||||
|
name: "test",
|
||||||
|
amount: 100,
|
||||||
|
},
|
||||||
|
])
|
||||||
|
|
||||||
|
const [itemTwo] = await service.addShippingMethods(createdCart.id, [
|
||||||
|
{
|
||||||
|
name: "test-2",
|
||||||
|
amount: 200,
|
||||||
|
},
|
||||||
|
])
|
||||||
|
|
||||||
|
const taxLines = await service.setShippingMethodTaxLines(
|
||||||
|
createdCart.id,
|
||||||
|
[
|
||||||
|
{
|
||||||
|
shipping_method_id: itemOne.id,
|
||||||
|
rate: 20,
|
||||||
|
code: "TX",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
shipping_method_id: itemTwo.id,
|
||||||
|
rate: 20,
|
||||||
|
code: "TX",
|
||||||
|
},
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
|
expect(taxLines).toEqual(
|
||||||
|
expect.arrayContaining([
|
||||||
|
expect.objectContaining({
|
||||||
|
shipping_method_id: itemOne.id,
|
||||||
|
rate: 20,
|
||||||
|
code: "TX",
|
||||||
|
}),
|
||||||
|
expect.objectContaining({
|
||||||
|
shipping_method_id: itemTwo.id,
|
||||||
|
rate: 20,
|
||||||
|
code: "TX",
|
||||||
|
}),
|
||||||
|
])
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
it("should replace shipping item tax lines for a cart", async () => {
|
||||||
|
const [createdCart] = await service.createCarts([
|
||||||
|
{
|
||||||
|
currency_code: "eur",
|
||||||
|
},
|
||||||
|
])
|
||||||
|
|
||||||
|
const [itemOne] = await service.addShippingMethods(createdCart.id, [
|
||||||
|
{
|
||||||
|
name: "test",
|
||||||
|
amount: 100,
|
||||||
|
},
|
||||||
|
])
|
||||||
|
|
||||||
|
const taxLines = await service.setShippingMethodTaxLines(
|
||||||
|
createdCart.id,
|
||||||
|
[
|
||||||
|
{
|
||||||
|
shipping_method_id: itemOne.id,
|
||||||
|
rate: 20.753,
|
||||||
|
code: "TX",
|
||||||
|
},
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
|
expect(taxLines).toEqual(
|
||||||
|
expect.arrayContaining([
|
||||||
|
expect.objectContaining({
|
||||||
|
shipping_method_id: itemOne.id,
|
||||||
|
rate: 20.753,
|
||||||
|
code: "TX",
|
||||||
|
}),
|
||||||
|
])
|
||||||
|
)
|
||||||
|
|
||||||
|
await service.setShippingMethodTaxLines(createdCart.id, [
|
||||||
|
{
|
||||||
|
shipping_method_id: itemOne.id,
|
||||||
|
rate: 25.14789,
|
||||||
|
code: "TX-2",
|
||||||
|
},
|
||||||
|
])
|
||||||
|
|
||||||
|
const cart = await service.retrieveCart(createdCart.id, {
|
||||||
|
relations: ["shipping_methods.tax_lines"],
|
||||||
|
})
|
||||||
|
|
||||||
|
expect(cart.shipping_methods).toEqual(
|
||||||
|
expect.arrayContaining([
|
||||||
|
expect.objectContaining({
|
||||||
|
id: itemOne.id,
|
||||||
|
tax_lines: expect.arrayContaining([
|
||||||
|
expect.objectContaining({
|
||||||
|
shipping_method_id: itemOne.id,
|
||||||
|
rate: 25.14789,
|
||||||
|
code: "TX-2",
|
||||||
|
}),
|
||||||
|
]),
|
||||||
|
}),
|
||||||
|
])
|
||||||
|
)
|
||||||
|
|
||||||
|
expect(cart.shipping_methods?.length).toBe(1)
|
||||||
|
expect(cart.shipping_methods?.[0].tax_lines?.length).toBe(1)
|
||||||
|
})
|
||||||
|
|
||||||
|
it("should remove all shipping item tax lines for a cart", async () => {
|
||||||
|
const [createdCart] = await service.createCarts([
|
||||||
|
{
|
||||||
|
currency_code: "eur",
|
||||||
|
},
|
||||||
|
])
|
||||||
|
|
||||||
|
const [itemOne] = await service.addShippingMethods(createdCart.id, [
|
||||||
|
{
|
||||||
|
name: "test",
|
||||||
|
amount: 100,
|
||||||
|
},
|
||||||
|
])
|
||||||
|
|
||||||
|
const taxLines = await service.setShippingMethodTaxLines(
|
||||||
|
createdCart.id,
|
||||||
|
[
|
||||||
|
{
|
||||||
|
shipping_method_id: itemOne.id,
|
||||||
|
rate: 20,
|
||||||
|
code: "TX",
|
||||||
|
},
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
|
expect(taxLines).toEqual(
|
||||||
|
expect.arrayContaining([
|
||||||
|
expect.objectContaining({
|
||||||
|
shipping_method_id: itemOne.id,
|
||||||
|
rate: 20,
|
||||||
|
code: "TX",
|
||||||
|
}),
|
||||||
|
])
|
||||||
|
)
|
||||||
|
|
||||||
|
await service.setShippingMethodTaxLines(createdCart.id, [])
|
||||||
|
|
||||||
|
const cart = await service.retrieveCart(createdCart.id, {
|
||||||
|
relations: ["shipping_methods.tax_lines"],
|
||||||
|
})
|
||||||
|
|
||||||
|
expect(cart.shipping_methods).toEqual(
|
||||||
|
expect.arrayContaining([
|
||||||
|
expect.objectContaining({
|
||||||
|
id: itemOne.id,
|
||||||
|
tax_lines: [],
|
||||||
|
}),
|
||||||
|
])
|
||||||
|
)
|
||||||
|
|
||||||
|
expect(cart.shipping_methods?.length).toBe(1)
|
||||||
|
expect(cart.shipping_methods?.[0].tax_lines?.length).toBe(0)
|
||||||
|
})
|
||||||
|
|
||||||
|
it("should update shipping item tax lines for a cart", async () => {
|
||||||
|
const [createdCart] = await service.createCarts([
|
||||||
|
{
|
||||||
|
currency_code: "eur",
|
||||||
|
},
|
||||||
|
])
|
||||||
|
|
||||||
|
const [itemOne] = await service.addShippingMethods(createdCart.id, [
|
||||||
|
{
|
||||||
|
name: "test",
|
||||||
|
amount: 100,
|
||||||
|
},
|
||||||
|
])
|
||||||
|
|
||||||
|
const taxLines = await service.setShippingMethodTaxLines(
|
||||||
|
createdCart.id,
|
||||||
|
[
|
||||||
|
{
|
||||||
|
shipping_method_id: itemOne.id,
|
||||||
|
rate: 20,
|
||||||
|
code: "TX",
|
||||||
|
},
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
|
expect(taxLines).toEqual(
|
||||||
|
expect.arrayContaining([
|
||||||
|
expect.objectContaining({
|
||||||
|
shipping_method_id: itemOne.id,
|
||||||
|
rate: 20,
|
||||||
|
code: "TX",
|
||||||
|
}),
|
||||||
|
])
|
||||||
|
)
|
||||||
|
|
||||||
|
await service.setShippingMethodTaxLines(createdCart.id, [
|
||||||
|
{
|
||||||
|
id: taxLines[0].id,
|
||||||
|
shipping_method_id: itemOne.id,
|
||||||
|
rate: 25,
|
||||||
|
code: "TX",
|
||||||
|
},
|
||||||
|
])
|
||||||
|
|
||||||
|
const cart = await service.retrieveCart(createdCart.id, {
|
||||||
|
relations: ["shipping_methods.tax_lines"],
|
||||||
|
})
|
||||||
|
|
||||||
|
expect(cart.shipping_methods).toEqual(
|
||||||
|
expect.arrayContaining([
|
||||||
|
expect.objectContaining({
|
||||||
|
id: itemOne.id,
|
||||||
|
tax_lines: [
|
||||||
|
expect.objectContaining({
|
||||||
|
id: taxLines[0].id,
|
||||||
|
shipping_method_id: itemOne.id,
|
||||||
|
rate: 25,
|
||||||
|
code: "TX",
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
])
|
||||||
|
)
|
||||||
|
|
||||||
|
expect(cart.shipping_methods?.length).toBe(1)
|
||||||
|
expect(cart.shipping_methods?.[0].tax_lines?.length).toBe(1)
|
||||||
|
})
|
||||||
|
|
||||||
|
it("should remove, update, and create shipping item tax lines for a cart", async () => {
|
||||||
|
const [createdCart] = await service.createCarts([
|
||||||
|
{
|
||||||
|
currency_code: "eur",
|
||||||
|
},
|
||||||
|
])
|
||||||
|
|
||||||
|
const [itemOne] = await service.addShippingMethods(createdCart.id, [
|
||||||
|
{
|
||||||
|
name: "test",
|
||||||
|
amount: 100,
|
||||||
|
},
|
||||||
|
])
|
||||||
|
|
||||||
|
const taxLines = await service.setShippingMethodTaxLines(
|
||||||
|
createdCart.id,
|
||||||
|
[
|
||||||
|
{
|
||||||
|
shipping_method_id: itemOne.id,
|
||||||
|
rate: 20,
|
||||||
|
code: "TX",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
shipping_method_id: itemOne.id,
|
||||||
|
rate: 25,
|
||||||
|
code: "TX",
|
||||||
|
},
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
|
expect(taxLines).toEqual(
|
||||||
|
expect.arrayContaining([
|
||||||
|
expect.objectContaining({
|
||||||
|
shipping_method_id: itemOne.id,
|
||||||
|
rate: 20,
|
||||||
|
code: "TX",
|
||||||
|
}),
|
||||||
|
expect.objectContaining({
|
||||||
|
shipping_method_id: itemOne.id,
|
||||||
|
rate: 25,
|
||||||
|
code: "TX",
|
||||||
|
}),
|
||||||
|
])
|
||||||
|
)
|
||||||
|
|
||||||
|
const taxLine = taxLines.find(
|
||||||
|
(tx) => tx.shipping_method_id === itemOne.id
|
||||||
|
)
|
||||||
|
|
||||||
|
await service.setShippingMethodTaxLines(createdCart.id, [
|
||||||
|
// update
|
||||||
|
{
|
||||||
|
id: taxLine.id,
|
||||||
|
rate: 40,
|
||||||
|
code: "TX",
|
||||||
|
},
|
||||||
|
// create
|
||||||
|
{
|
||||||
|
shipping_method_id: itemOne.id,
|
||||||
|
rate: 25,
|
||||||
|
code: "TX-2",
|
||||||
|
},
|
||||||
|
// remove: should remove the initial tax line for itemOne
|
||||||
|
])
|
||||||
|
|
||||||
|
const cart = await service.retrieveCart(createdCart.id, {
|
||||||
|
relations: ["shipping_methods.tax_lines"],
|
||||||
|
})
|
||||||
|
|
||||||
|
expect(cart.shipping_methods).toEqual(
|
||||||
|
expect.arrayContaining([
|
||||||
|
expect.objectContaining({
|
||||||
|
id: itemOne.id,
|
||||||
|
tax_lines: [
|
||||||
|
expect.objectContaining({
|
||||||
|
id: taxLine!.id,
|
||||||
|
shipping_method_id: itemOne.id,
|
||||||
|
rate: 40,
|
||||||
|
code: "TX",
|
||||||
|
}),
|
||||||
|
expect.objectContaining({
|
||||||
|
shipping_method_id: itemOne.id,
|
||||||
|
rate: 25,
|
||||||
|
code: "TX-2",
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
])
|
||||||
|
)
|
||||||
|
|
||||||
|
expect(cart.shipping_methods?.length).toBe(1)
|
||||||
|
expect(cart.shipping_methods?.[0].tax_lines?.length).toBe(2)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
describe("addLineItemAdjustments", () => {
|
describe("addLineItemAdjustments", () => {
|
||||||
it("should add line item tax lines for items in a cart", async () => {
|
it("should add line item tax lines for items in a cart", async () => {
|
||||||
const [createdCart] = await service.createCarts([
|
const [createdCart] = await service.createCarts([
|
||||||
|
|||||||
@@ -36,8 +36,8 @@
|
|||||||
"orm:cache:clear": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm cache:clear"
|
"orm:cache:clear": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm cache:clear"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@medusajs/framework": "^2.6.0",
|
"@medusajs/framework": "2.6.0",
|
||||||
"@medusajs/test-utils": "^2.6.0",
|
"@medusajs/test-utils": "2.6.0",
|
||||||
"@mikro-orm/cli": "6.4.3",
|
"@mikro-orm/cli": "6.4.3",
|
||||||
"@mikro-orm/core": "6.4.3",
|
"@mikro-orm/core": "6.4.3",
|
||||||
"@mikro-orm/migrations": "6.4.3",
|
"@mikro-orm/migrations": "6.4.3",
|
||||||
@@ -50,7 +50,7 @@
|
|||||||
"typescript": "^5.6.2"
|
"typescript": "^5.6.2"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@medusajs/framework": "^2.4.0",
|
"@medusajs/framework": "2.6.0",
|
||||||
"@mikro-orm/core": "6.4.3",
|
"@mikro-orm/core": "6.4.3",
|
||||||
"@mikro-orm/migrations": "6.4.3",
|
"@mikro-orm/migrations": "6.4.3",
|
||||||
"@mikro-orm/postgresql": "6.4.3",
|
"@mikro-orm/postgresql": "6.4.3",
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import {
|
|||||||
createRawPropertiesFromBigNumber,
|
createRawPropertiesFromBigNumber,
|
||||||
decorateCartTotals,
|
decorateCartTotals,
|
||||||
deduplicate,
|
deduplicate,
|
||||||
|
generateEntityId,
|
||||||
InjectManager,
|
InjectManager,
|
||||||
InjectTransactionManager,
|
InjectTransactionManager,
|
||||||
isObject,
|
isObject,
|
||||||
@@ -20,6 +21,7 @@ import {
|
|||||||
MedusaContext,
|
MedusaContext,
|
||||||
MedusaError,
|
MedusaError,
|
||||||
ModulesSdkUtils,
|
ModulesSdkUtils,
|
||||||
|
promiseAll,
|
||||||
} from "@medusajs/framework/utils"
|
} from "@medusajs/framework/utils"
|
||||||
import {
|
import {
|
||||||
Address,
|
Address,
|
||||||
@@ -357,9 +359,7 @@ export default class CartModuleService
|
|||||||
|
|
||||||
const serializedResult = await this.baseRepository_.serialize<
|
const serializedResult = await this.baseRepository_.serialize<
|
||||||
CartTypes.CartDTO[]
|
CartTypes.CartDTO[]
|
||||||
>(result, {
|
>(result)
|
||||||
populate: true,
|
|
||||||
})
|
|
||||||
|
|
||||||
return isString(dataOrIdOrSelector) ? serializedResult[0] : serializedResult
|
return isString(dataOrIdOrSelector) ? serializedResult[0] : serializedResult
|
||||||
}
|
}
|
||||||
@@ -448,10 +448,7 @@ export default class CartModuleService
|
|||||||
}
|
}
|
||||||
|
|
||||||
return await this.baseRepository_.serialize<CartTypes.CartLineItemDTO[]>(
|
return await this.baseRepository_.serialize<CartTypes.CartLineItemDTO[]>(
|
||||||
items,
|
items
|
||||||
{
|
|
||||||
populate: true,
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -557,10 +554,7 @@ export default class CartModuleService
|
|||||||
)
|
)
|
||||||
|
|
||||||
return await this.baseRepository_.serialize<CartTypes.CartLineItemDTO[]>(
|
return await this.baseRepository_.serialize<CartTypes.CartLineItemDTO[]>(
|
||||||
items,
|
items
|
||||||
{
|
|
||||||
populate: true,
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -718,7 +712,7 @@ export default class CartModuleService
|
|||||||
|
|
||||||
return await this.baseRepository_.serialize<
|
return await this.baseRepository_.serialize<
|
||||||
CartTypes.CartShippingMethodDTO[]
|
CartTypes.CartShippingMethodDTO[]
|
||||||
>(methods, { populate: true })
|
>(methods)
|
||||||
}
|
}
|
||||||
|
|
||||||
@InjectTransactionManager()
|
@InjectTransactionManager()
|
||||||
@@ -809,9 +803,79 @@ export default class CartModuleService
|
|||||||
|
|
||||||
return await this.baseRepository_.serialize<
|
return await this.baseRepository_.serialize<
|
||||||
CartTypes.LineItemAdjustmentDTO[]
|
CartTypes.LineItemAdjustmentDTO[]
|
||||||
>(addedAdjustments, {
|
>(addedAdjustments)
|
||||||
populate: true,
|
}
|
||||||
})
|
|
||||||
|
@InjectTransactionManager()
|
||||||
|
async upsertLineItemTaxLines(
|
||||||
|
taxLines: (
|
||||||
|
| CartTypes.CreateLineItemTaxLineDTO
|
||||||
|
| CartTypes.UpdateLineItemTaxLineDTO
|
||||||
|
)[],
|
||||||
|
@MedusaContext() sharedContext: Context = {}
|
||||||
|
): Promise<CartTypes.LineItemTaxLineDTO[]> {
|
||||||
|
const result = await this.lineItemTaxLineService_.upsert(
|
||||||
|
taxLines as CartTypes.UpdateLineItemTaxLineDTO[],
|
||||||
|
sharedContext
|
||||||
|
)
|
||||||
|
|
||||||
|
return await this.baseRepository_.serialize<CartTypes.LineItemTaxLineDTO[]>(
|
||||||
|
result
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
@InjectTransactionManager()
|
||||||
|
async upsertLineItemAdjustments(
|
||||||
|
adjustments: (
|
||||||
|
| CartTypes.CreateLineItemAdjustmentDTO
|
||||||
|
| CartTypes.UpdateLineItemAdjustmentDTO
|
||||||
|
)[],
|
||||||
|
@MedusaContext() sharedContext: Context = {}
|
||||||
|
): Promise<CartTypes.LineItemAdjustmentDTO[]> {
|
||||||
|
let result = await this.lineItemAdjustmentService_.upsert(
|
||||||
|
adjustments,
|
||||||
|
sharedContext
|
||||||
|
)
|
||||||
|
|
||||||
|
return await this.baseRepository_.serialize<
|
||||||
|
CartTypes.LineItemAdjustmentDTO[]
|
||||||
|
>(result)
|
||||||
|
}
|
||||||
|
|
||||||
|
@InjectTransactionManager()
|
||||||
|
async upsertShippingMethodTaxLines(
|
||||||
|
taxLines: (
|
||||||
|
| CartTypes.CreateShippingMethodTaxLineDTO
|
||||||
|
| CartTypes.UpdateShippingMethodTaxLineDTO
|
||||||
|
)[],
|
||||||
|
@MedusaContext() sharedContext: Context = {}
|
||||||
|
): Promise<CartTypes.ShippingMethodTaxLineDTO[]> {
|
||||||
|
const result = await this.shippingMethodTaxLineService_.upsert(
|
||||||
|
taxLines as UpdateShippingMethodTaxLineDTO[],
|
||||||
|
sharedContext
|
||||||
|
)
|
||||||
|
|
||||||
|
return await this.baseRepository_.serialize<
|
||||||
|
CartTypes.ShippingMethodTaxLineDTO[]
|
||||||
|
>(result)
|
||||||
|
}
|
||||||
|
|
||||||
|
@InjectTransactionManager()
|
||||||
|
async upsertShippingMethodAdjustments(
|
||||||
|
adjustments: (
|
||||||
|
| CartTypes.CreateShippingMethodAdjustmentDTO
|
||||||
|
| CartTypes.UpdateShippingMethodAdjustmentDTO
|
||||||
|
)[],
|
||||||
|
@MedusaContext() sharedContext: Context = {}
|
||||||
|
): Promise<CartTypes.ShippingMethodAdjustmentDTO[]> {
|
||||||
|
const result = await this.shippingMethodAdjustmentService_.upsert(
|
||||||
|
adjustments,
|
||||||
|
sharedContext
|
||||||
|
)
|
||||||
|
|
||||||
|
return await this.baseRepository_.serialize<
|
||||||
|
CartTypes.ShippingMethodAdjustmentDTO[]
|
||||||
|
>(result)
|
||||||
}
|
}
|
||||||
|
|
||||||
@InjectTransactionManager()
|
@InjectTransactionManager()
|
||||||
@@ -864,9 +928,7 @@ export default class CartModuleService
|
|||||||
|
|
||||||
return await this.baseRepository_.serialize<
|
return await this.baseRepository_.serialize<
|
||||||
CartTypes.LineItemAdjustmentDTO[]
|
CartTypes.LineItemAdjustmentDTO[]
|
||||||
>(result, {
|
>(result)
|
||||||
populate: true,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@InjectTransactionManager()
|
@InjectTransactionManager()
|
||||||
@@ -921,9 +983,7 @@ export default class CartModuleService
|
|||||||
|
|
||||||
return await this.baseRepository_.serialize<
|
return await this.baseRepository_.serialize<
|
||||||
CartTypes.ShippingMethodAdjustmentDTO[]
|
CartTypes.ShippingMethodAdjustmentDTO[]
|
||||||
>(result, {
|
>(result)
|
||||||
populate: true,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async addShippingMethodAdjustments(
|
async addShippingMethodAdjustments(
|
||||||
@@ -986,17 +1046,13 @@ export default class CartModuleService
|
|||||||
if (isObject(cartIdOrData)) {
|
if (isObject(cartIdOrData)) {
|
||||||
return await this.baseRepository_.serialize<CartTypes.ShippingMethodAdjustmentDTO>(
|
return await this.baseRepository_.serialize<CartTypes.ShippingMethodAdjustmentDTO>(
|
||||||
addedAdjustments[0],
|
addedAdjustments[0],
|
||||||
{
|
{}
|
||||||
populate: true,
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
return await this.baseRepository_.serialize<
|
return await this.baseRepository_.serialize<
|
||||||
CartTypes.ShippingMethodAdjustmentDTO[]
|
CartTypes.ShippingMethodAdjustmentDTO[]
|
||||||
>(addedAdjustments, {
|
>(addedAdjustments)
|
||||||
populate: true,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
addLineItemTaxLines(
|
addLineItemTaxLines(
|
||||||
@@ -1046,9 +1102,7 @@ export default class CartModuleService
|
|||||||
|
|
||||||
const serialized = await this.baseRepository_.serialize<
|
const serialized = await this.baseRepository_.serialize<
|
||||||
CartTypes.LineItemTaxLineDTO[]
|
CartTypes.LineItemTaxLineDTO[]
|
||||||
>(addedTaxLines, {
|
>(addedTaxLines)
|
||||||
populate: true,
|
|
||||||
})
|
|
||||||
|
|
||||||
if (isObject(cartIdOrData)) {
|
if (isObject(cartIdOrData)) {
|
||||||
return serialized[0]
|
return serialized[0]
|
||||||
@@ -1066,49 +1120,44 @@ export default class CartModuleService
|
|||||||
)[],
|
)[],
|
||||||
@MedusaContext() sharedContext: Context = {}
|
@MedusaContext() sharedContext: Context = {}
|
||||||
): Promise<CartTypes.LineItemTaxLineDTO[]> {
|
): Promise<CartTypes.LineItemTaxLineDTO[]> {
|
||||||
const cart = await this.retrieveCart(
|
const normalizedTaxLines = (
|
||||||
cartId,
|
taxLines as CartTypes.UpdateLineItemTaxLineDTO[]
|
||||||
{ select: ["id"], relations: ["items.tax_lines"] },
|
).map((taxLine) => {
|
||||||
sharedContext
|
// Pre generate the id so that we can optimized the actions below
|
||||||
)
|
taxLine.id = generateEntityId(taxLine.id, "calitxl")
|
||||||
|
return taxLine
|
||||||
const existingTaxLines = await this.listLineItemTaxLines(
|
|
||||||
{ item: { cart_id: cart.id } },
|
|
||||||
{ select: ["id"] },
|
|
||||||
sharedContext
|
|
||||||
)
|
|
||||||
|
|
||||||
const taxLinesSet = new Set(
|
|
||||||
taxLines
|
|
||||||
.map((taxLine) => (taxLine as CartTypes.UpdateLineItemTaxLineDTO)?.id)
|
|
||||||
.filter(Boolean)
|
|
||||||
)
|
|
||||||
|
|
||||||
const toDelete: CartTypes.LineItemTaxLineDTO[] = []
|
|
||||||
|
|
||||||
// From the existing tax lines, find the ones that are not passed in taxLines
|
|
||||||
existingTaxLines.forEach((taxLine: CartTypes.LineItemTaxLineDTO) => {
|
|
||||||
if (!taxLinesSet.has(taxLine.id)) {
|
|
||||||
toDelete.push(taxLine)
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
if (toDelete.length) {
|
const taxLineIdsSet = new Set<string>(
|
||||||
await this.lineItemTaxLineService_.softDelete(
|
normalizedTaxLines.map(
|
||||||
toDelete.map((taxLine) => taxLine!.id),
|
(taxLine) => (taxLine as CartTypes.UpdateLineItemTaxLineDTO)?.id
|
||||||
sharedContext
|
|
||||||
)
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
const deleteConstraints: {
|
||||||
|
id?: {
|
||||||
|
$nin: string[]
|
||||||
|
}
|
||||||
|
item: { cart_id: string }
|
||||||
|
} = {
|
||||||
|
item: { cart_id: cartId },
|
||||||
}
|
}
|
||||||
|
|
||||||
const result = taxLines.length
|
if (taxLineIdsSet.size) {
|
||||||
? await this.lineItemTaxLineService_.upsert(taxLines, sharedContext)
|
deleteConstraints.id = {
|
||||||
: []
|
$nin: Array.from(taxLineIdsSet),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const [result] = await promiseAll([
|
||||||
|
normalizedTaxLines.length
|
||||||
|
? this.lineItemTaxLineService_.upsert(normalizedTaxLines, sharedContext)
|
||||||
|
: [],
|
||||||
|
this.lineItemTaxLineService_.softDelete(deleteConstraints, sharedContext),
|
||||||
|
])
|
||||||
|
|
||||||
return await this.baseRepository_.serialize<CartTypes.LineItemTaxLineDTO[]>(
|
return await this.baseRepository_.serialize<CartTypes.LineItemTaxLineDTO[]>(
|
||||||
result,
|
result
|
||||||
{
|
|
||||||
populate: true,
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1159,10 +1208,7 @@ export default class CartModuleService
|
|||||||
|
|
||||||
const serialized =
|
const serialized =
|
||||||
await this.baseRepository_.serialize<CartTypes.ShippingMethodTaxLineDTO>(
|
await this.baseRepository_.serialize<CartTypes.ShippingMethodTaxLineDTO>(
|
||||||
addedTaxLines[0],
|
addedTaxLines[0]
|
||||||
{
|
|
||||||
populate: true,
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
|
|
||||||
if (isObject(cartIdOrData)) {
|
if (isObject(cartIdOrData)) {
|
||||||
@@ -1181,53 +1227,49 @@ export default class CartModuleService
|
|||||||
)[],
|
)[],
|
||||||
@MedusaContext() sharedContext: Context = {}
|
@MedusaContext() sharedContext: Context = {}
|
||||||
): Promise<CartTypes.ShippingMethodTaxLineDTO[]> {
|
): Promise<CartTypes.ShippingMethodTaxLineDTO[]> {
|
||||||
const cart = await this.retrieveCart(
|
const normalizedTaxLines = (
|
||||||
cartId,
|
taxLines as CartTypes.UpdateShippingMethodTaxLineDTO[]
|
||||||
{ select: ["id"], relations: ["shipping_methods.tax_lines"] },
|
).map((taxLine) => {
|
||||||
sharedContext
|
taxLine.id = generateEntityId(taxLine.id, "casmtxl")
|
||||||
)
|
return taxLine
|
||||||
|
|
||||||
const existingTaxLines = await this.listShippingMethodTaxLines(
|
|
||||||
{ shipping_method: { cart_id: cart.id } },
|
|
||||||
{ select: ["id"] },
|
|
||||||
sharedContext
|
|
||||||
)
|
|
||||||
|
|
||||||
const taxLinesSet = new Set(
|
|
||||||
taxLines
|
|
||||||
.map(
|
|
||||||
(taxLine) => (taxLine as CartTypes.UpdateShippingMethodTaxLineDTO)?.id
|
|
||||||
)
|
|
||||||
.filter(Boolean)
|
|
||||||
)
|
|
||||||
|
|
||||||
const toDelete: CartTypes.ShippingMethodTaxLineDTO[] = []
|
|
||||||
|
|
||||||
// From the existing tax lines, find the ones that are not passed in taxLines
|
|
||||||
existingTaxLines.forEach((taxLine: CartTypes.ShippingMethodTaxLineDTO) => {
|
|
||||||
if (!taxLinesSet.has(taxLine.id)) {
|
|
||||||
toDelete.push(taxLine)
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
if (toDelete.length) {
|
const taxLineIdsSet = new Set(
|
||||||
await this.shippingMethodTaxLineService_.softDelete(
|
normalizedTaxLines.map(
|
||||||
toDelete.map((taxLine) => taxLine!.id),
|
(taxLine) => (taxLine as CartTypes.UpdateShippingMethodTaxLineDTO)?.id
|
||||||
sharedContext
|
|
||||||
)
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
const deleteConstraints: {
|
||||||
|
id?: {
|
||||||
|
$nin: string[]
|
||||||
|
}
|
||||||
|
shipping_method: { cart_id: string }
|
||||||
|
} = {
|
||||||
|
shipping_method: { cart_id: cartId },
|
||||||
}
|
}
|
||||||
|
|
||||||
const result = taxLines.length
|
if (taxLineIdsSet.size) {
|
||||||
? await this.shippingMethodTaxLineService_.upsert(
|
deleteConstraints.id = {
|
||||||
|
$nin: Array.from(taxLineIdsSet),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const [result] = await promiseAll([
|
||||||
|
taxLines.length
|
||||||
|
? this.shippingMethodTaxLineService_.upsert(
|
||||||
taxLines as UpdateShippingMethodTaxLineDTO[],
|
taxLines as UpdateShippingMethodTaxLineDTO[],
|
||||||
sharedContext
|
sharedContext
|
||||||
)
|
)
|
||||||
: []
|
: [],
|
||||||
|
this.shippingMethodTaxLineService_.softDelete(
|
||||||
|
deleteConstraints,
|
||||||
|
sharedContext
|
||||||
|
),
|
||||||
|
])
|
||||||
|
|
||||||
return await this.baseRepository_.serialize<
|
return await this.baseRepository_.serialize<
|
||||||
CartTypes.ShippingMethodTaxLineDTO[]
|
CartTypes.ShippingMethodTaxLineDTO[]
|
||||||
>(result, {
|
>(result)
|
||||||
populate: true,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -36,8 +36,8 @@
|
|||||||
"orm:cache:clear": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm cache:clear"
|
"orm:cache:clear": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm cache:clear"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@medusajs/framework": "^2.6.0",
|
"@medusajs/framework": "2.6.0",
|
||||||
"@medusajs/test-utils": "^2.6.0",
|
"@medusajs/test-utils": "2.6.0",
|
||||||
"@mikro-orm/cli": "6.4.3",
|
"@mikro-orm/cli": "6.4.3",
|
||||||
"@mikro-orm/core": "6.4.3",
|
"@mikro-orm/core": "6.4.3",
|
||||||
"@mikro-orm/migrations": "6.4.3",
|
"@mikro-orm/migrations": "6.4.3",
|
||||||
@@ -50,7 +50,7 @@
|
|||||||
"typescript": "^5.6.2"
|
"typescript": "^5.6.2"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@medusajs/framework": "^2.4.0",
|
"@medusajs/framework": "2.6.0",
|
||||||
"@mikro-orm/core": "6.4.3",
|
"@mikro-orm/core": "6.4.3",
|
||||||
"@mikro-orm/migrations": "6.4.3",
|
"@mikro-orm/migrations": "6.4.3",
|
||||||
"@mikro-orm/postgresql": "6.4.3",
|
"@mikro-orm/postgresql": "6.4.3",
|
||||||
|
|||||||
@@ -37,8 +37,8 @@
|
|||||||
"orm:cache:clear": "MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm cache:clear"
|
"orm:cache:clear": "MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm cache:clear"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@medusajs/framework": "^2.6.0",
|
"@medusajs/framework": "2.6.0",
|
||||||
"@medusajs/test-utils": "^2.6.0",
|
"@medusajs/test-utils": "2.6.0",
|
||||||
"@mikro-orm/cli": "6.4.3",
|
"@mikro-orm/cli": "6.4.3",
|
||||||
"@mikro-orm/core": "6.4.3",
|
"@mikro-orm/core": "6.4.3",
|
||||||
"@mikro-orm/migrations": "6.4.3",
|
"@mikro-orm/migrations": "6.4.3",
|
||||||
@@ -51,7 +51,7 @@
|
|||||||
"typescript": "^5.6.2"
|
"typescript": "^5.6.2"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@medusajs/framework": "^2.4.0",
|
"@medusajs/framework": "2.6.0",
|
||||||
"@mikro-orm/core": "6.4.3",
|
"@mikro-orm/core": "6.4.3",
|
||||||
"@mikro-orm/migrations": "6.4.3",
|
"@mikro-orm/migrations": "6.4.3",
|
||||||
"@mikro-orm/postgresql": "6.4.3",
|
"@mikro-orm/postgresql": "6.4.3",
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
"author": "Medusa",
|
"author": "Medusa",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@medusajs/framework": "^2.6.0",
|
"@medusajs/framework": "2.6.0",
|
||||||
"@swc/core": "^1.7.28",
|
"@swc/core": "^1.7.28",
|
||||||
"@swc/jest": "^0.2.36",
|
"@swc/jest": "^0.2.36",
|
||||||
"jest": "^29.7.0",
|
"jest": "^29.7.0",
|
||||||
@@ -39,6 +39,6 @@
|
|||||||
"ulid": "^2.3.0"
|
"ulid": "^2.3.0"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@medusajs/framework": "^2.4.0"
|
"@medusajs/framework": "2.6.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -23,7 +23,7 @@
|
|||||||
"author": "Medusa",
|
"author": "Medusa",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@medusajs/framework": "^2.6.0",
|
"@medusajs/framework": "2.6.0",
|
||||||
"@swc/core": "^1.7.28",
|
"@swc/core": "^1.7.28",
|
||||||
"@swc/jest": "^0.2.36",
|
"@swc/jest": "^0.2.36",
|
||||||
"jest": "^29.7.0",
|
"jest": "^29.7.0",
|
||||||
@@ -40,7 +40,7 @@
|
|||||||
"ioredis": "^5.4.1"
|
"ioredis": "^5.4.1"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@medusajs/framework": "^2.4.0",
|
"@medusajs/framework": "2.6.0",
|
||||||
"awilix": "^8.0.1"
|
"awilix": "^8.0.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -36,8 +36,8 @@
|
|||||||
"orm:cache:clear": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm cache:clear"
|
"orm:cache:clear": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm cache:clear"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@medusajs/framework": "^2.6.0",
|
"@medusajs/framework": "2.6.0",
|
||||||
"@medusajs/test-utils": "^2.6.0",
|
"@medusajs/test-utils": "2.6.0",
|
||||||
"@mikro-orm/cli": "6.4.3",
|
"@mikro-orm/cli": "6.4.3",
|
||||||
"@mikro-orm/core": "6.4.3",
|
"@mikro-orm/core": "6.4.3",
|
||||||
"@mikro-orm/migrations": "6.4.3",
|
"@mikro-orm/migrations": "6.4.3",
|
||||||
@@ -50,7 +50,7 @@
|
|||||||
"typescript": "^5.6.2"
|
"typescript": "^5.6.2"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@medusajs/framework": "^2.4.0",
|
"@medusajs/framework": "2.6.0",
|
||||||
"awilix": "^8.0.1"
|
"awilix": "^8.0.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -36,8 +36,8 @@
|
|||||||
"orm:cache:clear": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm cache:clear"
|
"orm:cache:clear": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm cache:clear"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@medusajs/framework": "^2.6.0",
|
"@medusajs/framework": "2.6.0",
|
||||||
"@medusajs/test-utils": "^2.6.0",
|
"@medusajs/test-utils": "2.6.0",
|
||||||
"@mikro-orm/cli": "6.4.3",
|
"@mikro-orm/cli": "6.4.3",
|
||||||
"@mikro-orm/core": "6.4.3",
|
"@mikro-orm/core": "6.4.3",
|
||||||
"@mikro-orm/migrations": "6.4.3",
|
"@mikro-orm/migrations": "6.4.3",
|
||||||
@@ -50,7 +50,7 @@
|
|||||||
"typescript": "^5.6.2"
|
"typescript": "^5.6.2"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@medusajs/framework": "^2.4.0",
|
"@medusajs/framework": "2.6.0",
|
||||||
"@mikro-orm/core": "6.4.3",
|
"@mikro-orm/core": "6.4.3",
|
||||||
"@mikro-orm/migrations": "6.4.3",
|
"@mikro-orm/migrations": "6.4.3",
|
||||||
"@mikro-orm/postgresql": "6.4.3",
|
"@mikro-orm/postgresql": "6.4.3",
|
||||||
|
|||||||
@@ -36,8 +36,8 @@
|
|||||||
"orm:cache:clear": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm cache:clear"
|
"orm:cache:clear": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm cache:clear"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@medusajs/framework": "^2.6.0",
|
"@medusajs/framework": "2.6.0",
|
||||||
"@medusajs/test-utils": "^2.6.0",
|
"@medusajs/test-utils": "2.6.0",
|
||||||
"@mikro-orm/cli": "6.4.3",
|
"@mikro-orm/cli": "6.4.3",
|
||||||
"@mikro-orm/core": "6.4.3",
|
"@mikro-orm/core": "6.4.3",
|
||||||
"@mikro-orm/knex": "6.4.3",
|
"@mikro-orm/knex": "6.4.3",
|
||||||
@@ -51,7 +51,7 @@
|
|||||||
"typescript": "^5.6.2"
|
"typescript": "^5.6.2"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@medusajs/framework": "^2.4.0",
|
"@medusajs/framework": "2.6.0",
|
||||||
"@mikro-orm/core": "6.4.3",
|
"@mikro-orm/core": "6.4.3",
|
||||||
"@mikro-orm/knex": "6.4.3",
|
"@mikro-orm/knex": "6.4.3",
|
||||||
"@mikro-orm/migrations": "6.4.3",
|
"@mikro-orm/migrations": "6.4.3",
|
||||||
|
|||||||
@@ -23,8 +23,8 @@
|
|||||||
"author": "Medusa",
|
"author": "Medusa",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@medusajs/framework": "^2.6.0",
|
"@medusajs/framework": "2.6.0",
|
||||||
"@medusajs/test-utils": "^2.6.0",
|
"@medusajs/test-utils": "2.6.0",
|
||||||
"@mikro-orm/cli": "6.4.3",
|
"@mikro-orm/cli": "6.4.3",
|
||||||
"@mikro-orm/core": "6.4.3",
|
"@mikro-orm/core": "6.4.3",
|
||||||
"@mikro-orm/migrations": "6.4.3",
|
"@mikro-orm/migrations": "6.4.3",
|
||||||
@@ -37,7 +37,7 @@
|
|||||||
"typescript": "^5.6.2"
|
"typescript": "^5.6.2"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@medusajs/framework": "^2.4.0",
|
"@medusajs/framework": "2.6.0",
|
||||||
"@mikro-orm/core": "6.4.3",
|
"@mikro-orm/core": "6.4.3",
|
||||||
"@mikro-orm/migrations": "6.4.3",
|
"@mikro-orm/migrations": "6.4.3",
|
||||||
"@mikro-orm/postgresql": "6.4.3",
|
"@mikro-orm/postgresql": "6.4.3",
|
||||||
|
|||||||
@@ -33,8 +33,8 @@
|
|||||||
"test:integration": "jest --forceExit -- integration-tests/**/__tests__/**/*.ts"
|
"test:integration": "jest --forceExit -- integration-tests/**/__tests__/**/*.ts"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@medusajs/framework": "^2.6.0",
|
"@medusajs/framework": "2.6.0",
|
||||||
"@medusajs/test-utils": "^2.6.0",
|
"@medusajs/test-utils": "2.6.0",
|
||||||
"@mikro-orm/core": "6.4.3",
|
"@mikro-orm/core": "6.4.3",
|
||||||
"@mikro-orm/migrations": "6.4.3",
|
"@mikro-orm/migrations": "6.4.3",
|
||||||
"@mikro-orm/postgresql": "6.4.3",
|
"@mikro-orm/postgresql": "6.4.3",
|
||||||
@@ -47,7 +47,7 @@
|
|||||||
"typescript": "^5.6.2"
|
"typescript": "^5.6.2"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@medusajs/framework": "^2.4.0",
|
"@medusajs/framework": "2.6.0",
|
||||||
"@mikro-orm/core": "6.4.3",
|
"@mikro-orm/core": "6.4.3",
|
||||||
"@mikro-orm/migrations": "6.4.3",
|
"@mikro-orm/migrations": "6.4.3",
|
||||||
"@mikro-orm/postgresql": "6.4.3",
|
"@mikro-orm/postgresql": "6.4.3",
|
||||||
|
|||||||
@@ -32,8 +32,8 @@
|
|||||||
"orm:cache:clear": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm cache:clear"
|
"orm:cache:clear": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm cache:clear"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@medusajs/framework": "^2.6.0",
|
"@medusajs/framework": "2.6.0",
|
||||||
"@medusajs/test-utils": "^2.6.0",
|
"@medusajs/test-utils": "2.6.0",
|
||||||
"@mikro-orm/cli": "6.4.3",
|
"@mikro-orm/cli": "6.4.3",
|
||||||
"@mikro-orm/core": "6.4.3",
|
"@mikro-orm/core": "6.4.3",
|
||||||
"@mikro-orm/migrations": "6.4.3",
|
"@mikro-orm/migrations": "6.4.3",
|
||||||
@@ -46,7 +46,7 @@
|
|||||||
"typescript": "^5.6.2"
|
"typescript": "^5.6.2"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@medusajs/framework": "^2.4.0",
|
"@medusajs/framework": "2.6.0",
|
||||||
"@mikro-orm/core": "6.4.3",
|
"@mikro-orm/core": "6.4.3",
|
||||||
"@mikro-orm/migrations": "6.4.3",
|
"@mikro-orm/migrations": "6.4.3",
|
||||||
"@mikro-orm/postgresql": "6.4.3",
|
"@mikro-orm/postgresql": "6.4.3",
|
||||||
|
|||||||
@@ -36,8 +36,8 @@
|
|||||||
"orm:cache:clear": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm cache:clear"
|
"orm:cache:clear": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm cache:clear"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@medusajs/framework": "^2.6.0",
|
"@medusajs/framework": "2.6.0",
|
||||||
"@medusajs/test-utils": "^2.6.0",
|
"@medusajs/test-utils": "2.6.0",
|
||||||
"@mikro-orm/cli": "6.4.3",
|
"@mikro-orm/cli": "6.4.3",
|
||||||
"@mikro-orm/core": "6.4.3",
|
"@mikro-orm/core": "6.4.3",
|
||||||
"@mikro-orm/migrations": "6.4.3",
|
"@mikro-orm/migrations": "6.4.3",
|
||||||
@@ -50,7 +50,7 @@
|
|||||||
"typescript": "^5.6.2"
|
"typescript": "^5.6.2"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@medusajs/framework": "^2.4.0",
|
"@medusajs/framework": "2.6.0",
|
||||||
"@mikro-orm/core": "6.4.3",
|
"@mikro-orm/core": "6.4.3",
|
||||||
"@mikro-orm/migrations": "6.4.3",
|
"@mikro-orm/migrations": "6.4.3",
|
||||||
"@mikro-orm/postgresql": "6.4.3",
|
"@mikro-orm/postgresql": "6.4.3",
|
||||||
|
|||||||
@@ -36,8 +36,8 @@
|
|||||||
"orm:cache:clear": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm cache:clear"
|
"orm:cache:clear": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm cache:clear"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@medusajs/framework": "^2.6.0",
|
"@medusajs/framework": "2.6.0",
|
||||||
"@medusajs/test-utils": "^2.6.0",
|
"@medusajs/test-utils": "2.6.0",
|
||||||
"@mikro-orm/cli": "6.4.3",
|
"@mikro-orm/cli": "6.4.3",
|
||||||
"@mikro-orm/core": "6.4.3",
|
"@mikro-orm/core": "6.4.3",
|
||||||
"@mikro-orm/migrations": "6.4.3",
|
"@mikro-orm/migrations": "6.4.3",
|
||||||
@@ -50,7 +50,7 @@
|
|||||||
"typescript": "^5.6.2"
|
"typescript": "^5.6.2"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@medusajs/framework": "^2.4.0",
|
"@medusajs/framework": "2.6.0",
|
||||||
"@mikro-orm/core": "6.4.3",
|
"@mikro-orm/core": "6.4.3",
|
||||||
"@mikro-orm/migrations": "6.4.3",
|
"@mikro-orm/migrations": "6.4.3",
|
||||||
"@mikro-orm/postgresql": "6.4.3",
|
"@mikro-orm/postgresql": "6.4.3",
|
||||||
|
|||||||
@@ -36,8 +36,8 @@
|
|||||||
"orm:cache:clear": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm cache:clear"
|
"orm:cache:clear": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm cache:clear"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@medusajs/framework": "^2.6.0",
|
"@medusajs/framework": "2.6.0",
|
||||||
"@medusajs/test-utils": "^2.6.0",
|
"@medusajs/test-utils": "2.6.0",
|
||||||
"@mikro-orm/cli": "6.4.3",
|
"@mikro-orm/cli": "6.4.3",
|
||||||
"@mikro-orm/core": "6.4.3",
|
"@mikro-orm/core": "6.4.3",
|
||||||
"@mikro-orm/migrations": "6.4.3",
|
"@mikro-orm/migrations": "6.4.3",
|
||||||
@@ -50,7 +50,7 @@
|
|||||||
"typescript": "^5.6.2"
|
"typescript": "^5.6.2"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@medusajs/framework": "^2.4.0",
|
"@medusajs/framework": "2.6.0",
|
||||||
"@mikro-orm/core": "6.4.3",
|
"@mikro-orm/core": "6.4.3",
|
||||||
"@mikro-orm/migrations": "6.4.3",
|
"@mikro-orm/migrations": "6.4.3",
|
||||||
"@mikro-orm/postgresql": "6.4.3",
|
"@mikro-orm/postgresql": "6.4.3",
|
||||||
|
|||||||
+26
@@ -825,6 +825,32 @@ moduleIntegrationTestRunner<IPricingModuleService>({
|
|||||||
},
|
},
|
||||||
])
|
])
|
||||||
|
|
||||||
|
const events = eventBusEmitSpy.mock.calls[2][0]
|
||||||
|
expect(events).toEqual(
|
||||||
|
expect.arrayContaining([
|
||||||
|
expect.objectContaining({
|
||||||
|
name: "pricing.price-rule.created",
|
||||||
|
}),
|
||||||
|
expect.objectContaining({
|
||||||
|
name: "pricing.price-rule.created",
|
||||||
|
}),
|
||||||
|
expect.objectContaining({
|
||||||
|
name: "pricing.price.updated",
|
||||||
|
metadata: {
|
||||||
|
source: "pricing",
|
||||||
|
object: "price",
|
||||||
|
action: "updated",
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
id: "test-price-id",
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
expect.objectContaining({
|
||||||
|
name: "pricing.price-rule.deleted",
|
||||||
|
}),
|
||||||
|
])
|
||||||
|
)
|
||||||
|
|
||||||
const [priceList] = await service.listPriceLists(
|
const [priceList] = await service.listPriceLists(
|
||||||
{ id: ["price-list-1"] },
|
{ id: ["price-list-1"] },
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -36,8 +36,8 @@
|
|||||||
"orm:cache:clear": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm cache:clear"
|
"orm:cache:clear": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm cache:clear"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@medusajs/framework": "^2.6.0",
|
"@medusajs/framework": "2.6.0",
|
||||||
"@medusajs/test-utils": "^2.6.0",
|
"@medusajs/test-utils": "2.6.0",
|
||||||
"@mikro-orm/cli": "6.4.3",
|
"@mikro-orm/cli": "6.4.3",
|
||||||
"@mikro-orm/core": "6.4.3",
|
"@mikro-orm/core": "6.4.3",
|
||||||
"@mikro-orm/migrations": "6.4.3",
|
"@mikro-orm/migrations": "6.4.3",
|
||||||
@@ -50,7 +50,7 @@
|
|||||||
"typescript": "^5.6.2"
|
"typescript": "^5.6.2"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@medusajs/framework": "^2.4.0",
|
"@medusajs/framework": "2.6.0",
|
||||||
"@mikro-orm/core": "6.4.3",
|
"@mikro-orm/core": "6.4.3",
|
||||||
"@mikro-orm/migrations": "6.4.3",
|
"@mikro-orm/migrations": "6.4.3",
|
||||||
"@mikro-orm/postgresql": "6.4.3",
|
"@mikro-orm/postgresql": "6.4.3",
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ import {
|
|||||||
promiseAll,
|
promiseAll,
|
||||||
removeNullish,
|
removeNullish,
|
||||||
simpleHash,
|
simpleHash,
|
||||||
|
upperCaseFirst,
|
||||||
} from "@medusajs/framework/utils"
|
} from "@medusajs/framework/utils"
|
||||||
|
|
||||||
import {
|
import {
|
||||||
@@ -472,6 +473,7 @@ export default class PricingModuleService
|
|||||||
): Promise<PriceSetDTO>
|
): Promise<PriceSetDTO>
|
||||||
|
|
||||||
@InjectManager()
|
@InjectManager()
|
||||||
|
@EmitEvents()
|
||||||
async upsertPriceSets(
|
async upsertPriceSets(
|
||||||
data: UpsertPriceSetDTO | UpsertPriceSetDTO[],
|
data: UpsertPriceSetDTO | UpsertPriceSetDTO[],
|
||||||
@MedusaContext() sharedContext: Context = {}
|
@MedusaContext() sharedContext: Context = {}
|
||||||
@@ -513,6 +515,7 @@ export default class PricingModuleService
|
|||||||
): Promise<PriceSetDTO[]>
|
): Promise<PriceSetDTO[]>
|
||||||
|
|
||||||
@InjectManager()
|
@InjectManager()
|
||||||
|
@EmitEvents()
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
async updatePriceSets(
|
async updatePriceSets(
|
||||||
idOrSelector: string | PricingTypes.FilterablePriceSetProps,
|
idOrSelector: string | PricingTypes.FilterablePriceSetProps,
|
||||||
@@ -563,13 +566,19 @@ export default class PricingModuleService
|
|||||||
})
|
})
|
||||||
|
|
||||||
const prices = normalizedData.flatMap((priceSet) => priceSet.prices || [])
|
const prices = normalizedData.flatMap((priceSet) => priceSet.prices || [])
|
||||||
const { entities: upsertedPrices } =
|
const { entities: upsertedPrices, performedActions } =
|
||||||
await this.priceService_.upsertWithReplace(
|
await this.priceService_.upsertWithReplace(
|
||||||
prices,
|
prices,
|
||||||
{ relations: ["price_rules"] },
|
{ relations: ["price_rules"] },
|
||||||
sharedContext
|
sharedContext
|
||||||
)
|
)
|
||||||
|
|
||||||
|
composeAllEvents({
|
||||||
|
eventBuilders,
|
||||||
|
performedActions,
|
||||||
|
sharedContext,
|
||||||
|
})
|
||||||
|
|
||||||
const priceSetsToUpsert = normalizedData.map((priceSet) => {
|
const priceSetsToUpsert = normalizedData.map((priceSet) => {
|
||||||
const { prices, ...rest } = priceSet
|
const { prices, ...rest } = priceSet
|
||||||
return {
|
return {
|
||||||
@@ -594,13 +603,19 @@ export default class PricingModuleService
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const { entities: priceSets } =
|
const { entities: priceSets, performedActions: priceSetPerformedActions } =
|
||||||
await this.priceSetService_.upsertWithReplace(
|
await this.priceSetService_.upsertWithReplace(
|
||||||
priceSetsToUpsert,
|
priceSetsToUpsert,
|
||||||
{ relations: ["prices"] },
|
{ relations: ["prices"] },
|
||||||
sharedContext
|
sharedContext
|
||||||
)
|
)
|
||||||
|
|
||||||
|
composeAllEvents({
|
||||||
|
eventBuilders,
|
||||||
|
performedActions: priceSetPerformedActions,
|
||||||
|
sharedContext,
|
||||||
|
})
|
||||||
|
|
||||||
return priceSets.map((ps) => {
|
return priceSets.map((ps) => {
|
||||||
if (ps.prices) {
|
if (ps.prices) {
|
||||||
ps.prices = (ps.prices as any).filter((p) => !p.price_list_id)
|
ps.prices = (ps.prices as any).filter((p) => !p.price_list_id)
|
||||||
@@ -747,6 +762,7 @@ export default class PricingModuleService
|
|||||||
}
|
}
|
||||||
|
|
||||||
@InjectTransactionManager()
|
@InjectTransactionManager()
|
||||||
|
@EmitEvents()
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
async updatePriceLists(
|
async updatePriceLists(
|
||||||
data: PricingTypes.UpdatePriceListDTO[],
|
data: PricingTypes.UpdatePriceListDTO[],
|
||||||
@@ -760,6 +776,7 @@ export default class PricingModuleService
|
|||||||
}
|
}
|
||||||
|
|
||||||
@InjectManager()
|
@InjectManager()
|
||||||
|
@EmitEvents()
|
||||||
async updatePriceListPrices(
|
async updatePriceListPrices(
|
||||||
data: PricingTypes.UpdatePriceListPricesDTO[],
|
data: PricingTypes.UpdatePriceListPricesDTO[],
|
||||||
@MedusaContext() sharedContext: Context = {}
|
@MedusaContext() sharedContext: Context = {}
|
||||||
@@ -770,6 +787,7 @@ export default class PricingModuleService
|
|||||||
}
|
}
|
||||||
|
|
||||||
@InjectManager()
|
@InjectManager()
|
||||||
|
@EmitEvents()
|
||||||
async removePrices(
|
async removePrices(
|
||||||
ids: string[],
|
ids: string[],
|
||||||
@MedusaContext() sharedContext: Context = {}
|
@MedusaContext() sharedContext: Context = {}
|
||||||
@@ -789,6 +807,7 @@ export default class PricingModuleService
|
|||||||
}
|
}
|
||||||
|
|
||||||
@InjectManager()
|
@InjectManager()
|
||||||
|
@EmitEvents()
|
||||||
async setPriceListRules(
|
async setPriceListRules(
|
||||||
data: PricingTypes.SetPriceListRulesDTO,
|
data: PricingTypes.SetPriceListRulesDTO,
|
||||||
@MedusaContext() sharedContext: Context = {}
|
@MedusaContext() sharedContext: Context = {}
|
||||||
@@ -801,6 +820,7 @@ export default class PricingModuleService
|
|||||||
}
|
}
|
||||||
|
|
||||||
@InjectManager()
|
@InjectManager()
|
||||||
|
@EmitEvents()
|
||||||
async removePriceListRules(
|
async removePriceListRules(
|
||||||
data: PricingTypes.RemovePriceListRulesDTO,
|
data: PricingTypes.RemovePriceListRulesDTO,
|
||||||
@MedusaContext() sharedContext: Context = {}
|
@MedusaContext() sharedContext: Context = {}
|
||||||
@@ -852,6 +872,7 @@ export default class PricingModuleService
|
|||||||
): Promise<PricePreferenceDTO>
|
): Promise<PricePreferenceDTO>
|
||||||
|
|
||||||
@InjectManager()
|
@InjectManager()
|
||||||
|
@EmitEvents()
|
||||||
async upsertPricePreferences(
|
async upsertPricePreferences(
|
||||||
data: UpsertPricePreferenceDTO | UpsertPricePreferenceDTO[],
|
data: UpsertPricePreferenceDTO | UpsertPricePreferenceDTO[],
|
||||||
@MedusaContext() sharedContext: Context = {}
|
@MedusaContext() sharedContext: Context = {}
|
||||||
@@ -1081,29 +1102,10 @@ export default class PricingModuleService
|
|||||||
{ relations: ["price_rules"] },
|
{ relations: ["price_rules"] },
|
||||||
sharedContext
|
sharedContext
|
||||||
)
|
)
|
||||||
eventBuilders.createdPrice({
|
|
||||||
data: performedActions.created[Price.name] ?? [],
|
|
||||||
sharedContext,
|
|
||||||
})
|
|
||||||
eventBuilders.updatedPrice({
|
|
||||||
data: performedActions.updated[Price.name] ?? [],
|
|
||||||
sharedContext,
|
|
||||||
})
|
|
||||||
eventBuilders.deletedPrice({
|
|
||||||
data: performedActions.deleted[Price.name] ?? [],
|
|
||||||
sharedContext,
|
|
||||||
})
|
|
||||||
|
|
||||||
eventBuilders.createdPriceRule({
|
composeAllEvents({
|
||||||
data: performedActions.created[PriceRule.name] ?? [],
|
eventBuilders,
|
||||||
sharedContext,
|
performedActions,
|
||||||
})
|
|
||||||
eventBuilders.updatedPriceRule({
|
|
||||||
data: performedActions.updated[PriceRule.name] ?? [],
|
|
||||||
sharedContext,
|
|
||||||
})
|
|
||||||
eventBuilders.deletedPriceRule({
|
|
||||||
data: performedActions.deleted[PriceRule.name] ?? [],
|
|
||||||
sharedContext,
|
sharedContext,
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -1277,12 +1279,16 @@ export default class PricingModuleService
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
const { entities } = await this.priceListService_.upsertWithReplace(
|
const { entities, performedActions } =
|
||||||
normalizedData,
|
await this.priceListService_.upsertWithReplace(normalizedData, {
|
||||||
{
|
|
||||||
relations: ["price_list_rules"],
|
relations: ["price_list_rules"],
|
||||||
}
|
})
|
||||||
)
|
|
||||||
|
composeAllEvents({
|
||||||
|
eventBuilders,
|
||||||
|
performedActions,
|
||||||
|
sharedContext,
|
||||||
|
})
|
||||||
|
|
||||||
return entities
|
return entities
|
||||||
}
|
}
|
||||||
@@ -1326,12 +1332,19 @@ export default class PricingModuleService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const { entities } = await this.priceService_.upsertWithReplace(
|
const { entities, performedActions } =
|
||||||
|
await this.priceService_.upsertWithReplace(
|
||||||
pricesToUpsert,
|
pricesToUpsert,
|
||||||
{ relations: ["price_rules"] },
|
{ relations: ["price_rules"] },
|
||||||
sharedContext
|
sharedContext
|
||||||
)
|
)
|
||||||
|
|
||||||
|
composeAllEvents({
|
||||||
|
eventBuilders,
|
||||||
|
performedActions,
|
||||||
|
sharedContext,
|
||||||
|
})
|
||||||
|
|
||||||
return entities
|
return entities
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1388,29 +1401,9 @@ export default class PricingModuleService
|
|||||||
sharedContext
|
sharedContext
|
||||||
)
|
)
|
||||||
|
|
||||||
eventBuilders.createdPrice({
|
composeAllEvents({
|
||||||
data: performedActions.created[Price.name] ?? [],
|
eventBuilders,
|
||||||
sharedContext,
|
performedActions,
|
||||||
})
|
|
||||||
eventBuilders.updatedPrice({
|
|
||||||
data: performedActions.updated[Price.name] ?? [],
|
|
||||||
sharedContext,
|
|
||||||
})
|
|
||||||
eventBuilders.deletedPrice({
|
|
||||||
data: performedActions.deleted[Price.name] ?? [],
|
|
||||||
sharedContext,
|
|
||||||
})
|
|
||||||
|
|
||||||
eventBuilders.createdPriceRule({
|
|
||||||
data: performedActions.created[PriceRule.name] ?? [],
|
|
||||||
sharedContext,
|
|
||||||
})
|
|
||||||
eventBuilders.updatedPriceRule({
|
|
||||||
data: performedActions.updated[PriceRule.name] ?? [],
|
|
||||||
sharedContext,
|
|
||||||
})
|
|
||||||
eventBuilders.deletedPriceRule({
|
|
||||||
data: performedActions.deleted[PriceRule.name] ?? [],
|
|
||||||
sharedContext,
|
sharedContext,
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -1472,12 +1465,19 @@ export default class PricingModuleService
|
|||||||
})
|
})
|
||||||
.filter(Boolean)
|
.filter(Boolean)
|
||||||
|
|
||||||
const { entities } = await this.priceListService_.upsertWithReplace(
|
const { entities, performedActions } =
|
||||||
|
await this.priceListService_.upsertWithReplace(
|
||||||
priceListsUpsert,
|
priceListsUpsert,
|
||||||
{ relations: ["price_list_rules"] },
|
{ relations: ["price_list_rules"] },
|
||||||
sharedContext
|
sharedContext
|
||||||
)
|
)
|
||||||
|
|
||||||
|
composeAllEvents({
|
||||||
|
eventBuilders,
|
||||||
|
performedActions,
|
||||||
|
sharedContext,
|
||||||
|
})
|
||||||
|
|
||||||
return entities
|
return entities
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1539,12 +1539,19 @@ export default class PricingModuleService
|
|||||||
})
|
})
|
||||||
.filter(Boolean)
|
.filter(Boolean)
|
||||||
|
|
||||||
const { entities } = await this.priceListService_.upsertWithReplace(
|
const { entities, performedActions } =
|
||||||
|
await this.priceListService_.upsertWithReplace(
|
||||||
priceListsUpsert,
|
priceListsUpsert,
|
||||||
{ relations: ["price_list_rules"] },
|
{ relations: ["price_list_rules"] },
|
||||||
sharedContext
|
sharedContext
|
||||||
)
|
)
|
||||||
|
|
||||||
|
composeAllEvents({
|
||||||
|
eventBuilders,
|
||||||
|
performedActions,
|
||||||
|
sharedContext,
|
||||||
|
})
|
||||||
|
|
||||||
return entities
|
return entities
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1582,6 +1589,26 @@ export default class PricingModuleService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const composeAllEvents = ({
|
||||||
|
eventBuilders,
|
||||||
|
performedActions,
|
||||||
|
sharedContext,
|
||||||
|
}) => {
|
||||||
|
for (const action of Object.keys(performedActions)) {
|
||||||
|
for (const entity of Object.keys(performedActions[action])) {
|
||||||
|
const eventName = action + upperCaseFirst(entity)
|
||||||
|
if (!eventBuilders[eventName]) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
eventBuilders[eventName]({
|
||||||
|
data: performedActions[action][entity] ?? [],
|
||||||
|
sharedContext,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const isTaxInclusive = (
|
const isTaxInclusive = (
|
||||||
priceRules: InferEntityType<typeof PriceRule>[],
|
priceRules: InferEntityType<typeof PriceRule>[],
|
||||||
preferences: InferEntityType<typeof PricePreference>[],
|
preferences: InferEntityType<typeof PricePreference>[],
|
||||||
|
|||||||
@@ -36,11 +36,11 @@ export const eventBuilders = {
|
|||||||
object: "price_list_rule",
|
object: "price_list_rule",
|
||||||
eventName: PricingEvents.PRICE_LIST_RULE_CREATED,
|
eventName: PricingEvents.PRICE_LIST_RULE_CREATED,
|
||||||
}),
|
}),
|
||||||
attachedPriceListRule: moduleEventBuilderFactory({
|
updatedPriceSet: moduleEventBuilderFactory({
|
||||||
source: Modules.PRICING,
|
source: Modules.PRICING,
|
||||||
action: CommonEvents.ATTACHED,
|
action: CommonEvents.UPDATED,
|
||||||
object: "price_list_rule",
|
object: "price_set",
|
||||||
eventName: PricingEvents.PRICE_LIST_RULE_ATTACHED,
|
eventName: PricingEvents.PRICE_SET_UPDATED,
|
||||||
}),
|
}),
|
||||||
updatedPrice: moduleEventBuilderFactory({
|
updatedPrice: moduleEventBuilderFactory({
|
||||||
source: Modules.PRICING,
|
source: Modules.PRICING,
|
||||||
@@ -48,18 +48,48 @@ export const eventBuilders = {
|
|||||||
object: "price",
|
object: "price",
|
||||||
eventName: PricingEvents.PRICE_UPDATED,
|
eventName: PricingEvents.PRICE_UPDATED,
|
||||||
}),
|
}),
|
||||||
|
updatedPriceList: moduleEventBuilderFactory({
|
||||||
|
source: Modules.PRICING,
|
||||||
|
action: CommonEvents.UPDATED,
|
||||||
|
object: "price_list",
|
||||||
|
eventName: PricingEvents.PRICE_LIST_UPDATED,
|
||||||
|
}),
|
||||||
|
updatedPriceListRule: moduleEventBuilderFactory({
|
||||||
|
source: Modules.PRICING,
|
||||||
|
action: CommonEvents.UPDATED,
|
||||||
|
object: "price_list_rule",
|
||||||
|
eventName: PricingEvents.PRICE_LIST_RULE_UPDATED,
|
||||||
|
}),
|
||||||
updatedPriceRule: moduleEventBuilderFactory({
|
updatedPriceRule: moduleEventBuilderFactory({
|
||||||
source: Modules.PRICING,
|
source: Modules.PRICING,
|
||||||
action: CommonEvents.UPDATED,
|
action: CommonEvents.UPDATED,
|
||||||
object: "price_rule",
|
object: "price_rule",
|
||||||
eventName: PricingEvents.PRICE_RULE_UPDATED,
|
eventName: PricingEvents.PRICE_RULE_UPDATED,
|
||||||
}),
|
}),
|
||||||
|
deletedPriceSet: moduleEventBuilderFactory({
|
||||||
|
source: Modules.PRICING,
|
||||||
|
action: CommonEvents.DELETED,
|
||||||
|
object: "price_set",
|
||||||
|
eventName: PricingEvents.PRICE_SET_DELETED,
|
||||||
|
}),
|
||||||
deletedPrice: moduleEventBuilderFactory({
|
deletedPrice: moduleEventBuilderFactory({
|
||||||
source: Modules.PRICING,
|
source: Modules.PRICING,
|
||||||
action: CommonEvents.DELETED,
|
action: CommonEvents.DELETED,
|
||||||
object: "price",
|
object: "price",
|
||||||
eventName: PricingEvents.PRICE_DELETED,
|
eventName: PricingEvents.PRICE_DELETED,
|
||||||
}),
|
}),
|
||||||
|
deletedPriceList: moduleEventBuilderFactory({
|
||||||
|
source: Modules.PRICING,
|
||||||
|
action: CommonEvents.DELETED,
|
||||||
|
object: "price_list",
|
||||||
|
eventName: PricingEvents.PRICE_LIST_DELETED,
|
||||||
|
}),
|
||||||
|
deletedPriceListRule: moduleEventBuilderFactory({
|
||||||
|
source: Modules.PRICING,
|
||||||
|
action: CommonEvents.DELETED,
|
||||||
|
object: "price_list_rule",
|
||||||
|
eventName: PricingEvents.PRICE_LIST_RULE_DELETED,
|
||||||
|
}),
|
||||||
deletedPriceRule: moduleEventBuilderFactory({
|
deletedPriceRule: moduleEventBuilderFactory({
|
||||||
source: Modules.PRICING,
|
source: Modules.PRICING,
|
||||||
action: CommonEvents.DELETED,
|
action: CommonEvents.DELETED,
|
||||||
|
|||||||
@@ -36,8 +36,8 @@
|
|||||||
"orm:cache:clear": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm cache:clear"
|
"orm:cache:clear": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm cache:clear"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@medusajs/framework": "^2.6.0",
|
"@medusajs/framework": "2.6.0",
|
||||||
"@medusajs/test-utils": "^2.6.0",
|
"@medusajs/test-utils": "2.6.0",
|
||||||
"@mikro-orm/cli": "6.4.3",
|
"@mikro-orm/cli": "6.4.3",
|
||||||
"@mikro-orm/core": "6.4.3",
|
"@mikro-orm/core": "6.4.3",
|
||||||
"@mikro-orm/migrations": "6.4.3",
|
"@mikro-orm/migrations": "6.4.3",
|
||||||
@@ -51,7 +51,7 @@
|
|||||||
"typescript": "^5.6.2"
|
"typescript": "^5.6.2"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@medusajs/framework": "^2.4.0",
|
"@medusajs/framework": "2.6.0",
|
||||||
"@mikro-orm/core": "6.4.3",
|
"@mikro-orm/core": "6.4.3",
|
||||||
"@mikro-orm/migrations": "6.4.3",
|
"@mikro-orm/migrations": "6.4.3",
|
||||||
"@mikro-orm/postgresql": "6.4.3",
|
"@mikro-orm/postgresql": "6.4.3",
|
||||||
|
|||||||
@@ -36,8 +36,8 @@
|
|||||||
"orm:cache:clear": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm cache:clear"
|
"orm:cache:clear": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm cache:clear"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@medusajs/framework": "^2.6.0",
|
"@medusajs/framework": "2.6.0",
|
||||||
"@medusajs/test-utils": "^2.6.0",
|
"@medusajs/test-utils": "2.6.0",
|
||||||
"@mikro-orm/cli": "6.4.3",
|
"@mikro-orm/cli": "6.4.3",
|
||||||
"@mikro-orm/core": "6.4.3",
|
"@mikro-orm/core": "6.4.3",
|
||||||
"@mikro-orm/migrations": "6.4.3",
|
"@mikro-orm/migrations": "6.4.3",
|
||||||
@@ -50,7 +50,7 @@
|
|||||||
"typescript": "^5.6.2"
|
"typescript": "^5.6.2"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@medusajs/framework": "^2.4.0",
|
"@medusajs/framework": "2.6.0",
|
||||||
"@mikro-orm/core": "6.4.3",
|
"@mikro-orm/core": "6.4.3",
|
||||||
"@mikro-orm/migrations": "6.4.3",
|
"@mikro-orm/migrations": "6.4.3",
|
||||||
"@mikro-orm/postgresql": "6.4.3",
|
"@mikro-orm/postgresql": "6.4.3",
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
"watch": "tsc --watch"
|
"watch": "tsc --watch"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@medusajs/framework": "^2.6.0",
|
"@medusajs/framework": "2.6.0",
|
||||||
"@swc/core": "^1.7.28",
|
"@swc/core": "^1.7.28",
|
||||||
"@swc/jest": "^0.2.36",
|
"@swc/jest": "^0.2.36",
|
||||||
"jest": "^29.7.0",
|
"jest": "^29.7.0",
|
||||||
@@ -37,7 +37,7 @@
|
|||||||
"scrypt-kdf": "^2.0.1"
|
"scrypt-kdf": "^2.0.1"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@medusajs/framework": "^2.4.0"
|
"@medusajs/framework": "2.6.0"
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"medusa-provider",
|
"medusa-provider",
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
"watch": "tsc --watch"
|
"watch": "tsc --watch"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@medusajs/framework": "^2.6.0",
|
"@medusajs/framework": "2.6.0",
|
||||||
"@swc/core": "^1.7.28",
|
"@swc/core": "^1.7.28",
|
||||||
"@swc/jest": "^0.2.36",
|
"@swc/jest": "^0.2.36",
|
||||||
"jest": "^29.7.0",
|
"jest": "^29.7.0",
|
||||||
@@ -35,7 +35,7 @@
|
|||||||
"typescript": "^5.6.2"
|
"typescript": "^5.6.2"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@medusajs/framework": "^2.4.0"
|
"@medusajs/framework": "2.6.0"
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"medusa-provider",
|
"medusa-provider",
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
"watch": "tsc --watch"
|
"watch": "tsc --watch"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@medusajs/framework": "^2.6.0",
|
"@medusajs/framework": "2.6.0",
|
||||||
"@swc/core": "^1.7.28",
|
"@swc/core": "^1.7.28",
|
||||||
"@swc/jest": "^0.2.36",
|
"@swc/jest": "^0.2.36",
|
||||||
"jest": "^29.7.0",
|
"jest": "^29.7.0",
|
||||||
@@ -38,7 +38,7 @@
|
|||||||
"jsonwebtoken": "^9.0.2"
|
"jsonwebtoken": "^9.0.2"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@medusajs/framework": "^2.4.0"
|
"@medusajs/framework": "2.6.0"
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"medusa-provider",
|
"medusa-provider",
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
"watch": "tsc --watch"
|
"watch": "tsc --watch"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@medusajs/framework": "^2.6.0",
|
"@medusajs/framework": "2.6.0",
|
||||||
"@swc/core": "^1.7.28",
|
"@swc/core": "^1.7.28",
|
||||||
"@swc/jest": "^0.2.36",
|
"@swc/jest": "^0.2.36",
|
||||||
"jest": "^29.7.0",
|
"jest": "^29.7.0",
|
||||||
@@ -33,7 +33,7 @@
|
|||||||
"typescript": "^5.6.2"
|
"typescript": "^5.6.2"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@medusajs/framework": "^2.4.0"
|
"@medusajs/framework": "2.6.0"
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"medusa-plugin",
|
"medusa-plugin",
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
"watch": "tsc --watch"
|
"watch": "tsc --watch"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@medusajs/framework": "^2.6.0",
|
"@medusajs/framework": "2.6.0",
|
||||||
"@swc/core": "^1.7.28",
|
"@swc/core": "^1.7.28",
|
||||||
"@swc/jest": "^0.2.36",
|
"@swc/jest": "^0.2.36",
|
||||||
"axios": "^1.6.8",
|
"axios": "^1.6.8",
|
||||||
@@ -40,7 +40,7 @@
|
|||||||
"ulid": "^2.3.0"
|
"ulid": "^2.3.0"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@medusajs/framework": "^2.4.0"
|
"@medusajs/framework": "2.6.0"
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"medusa-plugin",
|
"medusa-plugin",
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
"watch": "tsc --watch"
|
"watch": "tsc --watch"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@medusajs/framework": "^2.6.0",
|
"@medusajs/framework": "2.6.0",
|
||||||
"@swc/core": "^1.7.28",
|
"@swc/core": "^1.7.28",
|
||||||
"@swc/jest": "^0.2.36",
|
"@swc/jest": "^0.2.36",
|
||||||
"jest": "^29.7.0",
|
"jest": "^29.7.0",
|
||||||
@@ -33,7 +33,7 @@
|
|||||||
"typescript": "^5.6.2"
|
"typescript": "^5.6.2"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@medusajs/framework": "^2.4.0"
|
"@medusajs/framework": "2.6.0"
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"medusa-plugin",
|
"medusa-plugin",
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
"author": "Medusa",
|
"author": "Medusa",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@medusajs/framework": "^2.6.0",
|
"@medusajs/framework": "2.6.0",
|
||||||
"@mikro-orm/cli": "6.4.3",
|
"@mikro-orm/cli": "6.4.3",
|
||||||
"@mikro-orm/core": "6.4.3",
|
"@mikro-orm/core": "6.4.3",
|
||||||
"@mikro-orm/migrations": "6.4.3",
|
"@mikro-orm/migrations": "6.4.3",
|
||||||
@@ -32,7 +32,7 @@
|
|||||||
"typescript": "^5.6.2"
|
"typescript": "^5.6.2"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@medusajs/framework": "^2.4.0"
|
"@medusajs/framework": "2.6.0"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"watch": "tsc --build --watch",
|
"watch": "tsc --build --watch",
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
"author": "Medusa",
|
"author": "Medusa",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@medusajs/framework": "^2.6.0",
|
"@medusajs/framework": "2.6.0",
|
||||||
"@swc/core": "^1.7.28",
|
"@swc/core": "^1.7.28",
|
||||||
"@swc/jest": "^0.2.36",
|
"@swc/jest": "^0.2.36",
|
||||||
"jest": "^29.7.0",
|
"jest": "^29.7.0",
|
||||||
@@ -28,7 +28,7 @@
|
|||||||
"typescript": "^5.6.2"
|
"typescript": "^5.6.2"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@medusajs/framework": "^2.4.0"
|
"@medusajs/framework": "2.6.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"ioredis": "^5.4.1"
|
"ioredis": "^5.4.1"
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
"watch": "tsc --watch"
|
"watch": "tsc --watch"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@medusajs/framework": "^2.6.0",
|
"@medusajs/framework": "2.6.0",
|
||||||
"@swc/core": "^1.7.28",
|
"@swc/core": "^1.7.28",
|
||||||
"@swc/jest": "^0.2.36",
|
"@swc/jest": "^0.2.36",
|
||||||
"jest": "^29.7.0",
|
"jest": "^29.7.0",
|
||||||
@@ -34,7 +34,7 @@
|
|||||||
"typescript": "^5.6.2"
|
"typescript": "^5.6.2"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@medusajs/framework": "^2.4.0"
|
"@medusajs/framework": "2.6.0"
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"medusa-provider",
|
"medusa-provider",
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
"watch": "tsc --watch"
|
"watch": "tsc --watch"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@medusajs/framework": "^2.6.0",
|
"@medusajs/framework": "2.6.0",
|
||||||
"@swc/core": "^1.7.28",
|
"@swc/core": "^1.7.28",
|
||||||
"@swc/jest": "^0.2.36",
|
"@swc/jest": "^0.2.36",
|
||||||
"jest": "^29.7.0",
|
"jest": "^29.7.0",
|
||||||
@@ -37,7 +37,7 @@
|
|||||||
"@sendgrid/mail": "^8.1.3"
|
"@sendgrid/mail": "^8.1.3"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@medusajs/framework": "^2.4.0"
|
"@medusajs/framework": "2.6.0"
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"medusa-provider",
|
"medusa-provider",
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
"watch": "tsc --watch"
|
"watch": "tsc --watch"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@medusajs/framework": "^2.6.0",
|
"@medusajs/framework": "2.6.0",
|
||||||
"@swc/core": "^1.7.28",
|
"@swc/core": "^1.7.28",
|
||||||
"@swc/jest": "^0.2.36",
|
"@swc/jest": "^0.2.36",
|
||||||
"jest": "^29.7.0",
|
"jest": "^29.7.0",
|
||||||
@@ -33,7 +33,7 @@
|
|||||||
"typescript": "^5.6.2"
|
"typescript": "^5.6.2"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@medusajs/framework": "^2.4.0",
|
"@medusajs/framework": "2.6.0",
|
||||||
"awilix": "^8.0.1"
|
"awilix": "^8.0.1"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
@@ -36,8 +36,8 @@
|
|||||||
"orm:cache:clear": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm cache:clear"
|
"orm:cache:clear": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm cache:clear"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@medusajs/framework": "^2.6.0",
|
"@medusajs/framework": "2.6.0",
|
||||||
"@medusajs/test-utils": "^2.6.0",
|
"@medusajs/test-utils": "2.6.0",
|
||||||
"@mikro-orm/cli": "6.4.3",
|
"@mikro-orm/cli": "6.4.3",
|
||||||
"@mikro-orm/core": "6.4.3",
|
"@mikro-orm/core": "6.4.3",
|
||||||
"@mikro-orm/migrations": "6.4.3",
|
"@mikro-orm/migrations": "6.4.3",
|
||||||
@@ -50,7 +50,7 @@
|
|||||||
"typescript": "^5.6.2"
|
"typescript": "^5.6.2"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@medusajs/framework": "^2.4.0",
|
"@medusajs/framework": "2.6.0",
|
||||||
"@mikro-orm/core": "6.4.3",
|
"@mikro-orm/core": "6.4.3",
|
||||||
"@mikro-orm/migrations": "6.4.3",
|
"@mikro-orm/migrations": "6.4.3",
|
||||||
"@mikro-orm/postgresql": "6.4.3",
|
"@mikro-orm/postgresql": "6.4.3",
|
||||||
|
|||||||
@@ -36,8 +36,8 @@
|
|||||||
"orm:cache:clear": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm cache:clear"
|
"orm:cache:clear": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm cache:clear"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@medusajs/framework": "^2.6.0",
|
"@medusajs/framework": "2.6.0",
|
||||||
"@medusajs/test-utils": "^2.6.0",
|
"@medusajs/test-utils": "2.6.0",
|
||||||
"@mikro-orm/cli": "6.4.3",
|
"@mikro-orm/cli": "6.4.3",
|
||||||
"@mikro-orm/core": "6.4.3",
|
"@mikro-orm/core": "6.4.3",
|
||||||
"@mikro-orm/migrations": "6.4.3",
|
"@mikro-orm/migrations": "6.4.3",
|
||||||
@@ -50,7 +50,7 @@
|
|||||||
"typescript": "^5.6.2"
|
"typescript": "^5.6.2"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@medusajs/framework": "^2.4.0",
|
"@medusajs/framework": "2.6.0",
|
||||||
"@mikro-orm/core": "6.4.3",
|
"@mikro-orm/core": "6.4.3",
|
||||||
"@mikro-orm/migrations": "6.4.3",
|
"@mikro-orm/migrations": "6.4.3",
|
||||||
"@mikro-orm/postgresql": "6.4.3",
|
"@mikro-orm/postgresql": "6.4.3",
|
||||||
|
|||||||
@@ -23,8 +23,8 @@
|
|||||||
"author": "Medusa",
|
"author": "Medusa",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@medusajs/framework": "^2.6.0",
|
"@medusajs/framework": "2.6.0",
|
||||||
"@medusajs/test-utils": "^2.6.0",
|
"@medusajs/test-utils": "2.6.0",
|
||||||
"@mikro-orm/cli": "6.4.3",
|
"@mikro-orm/cli": "6.4.3",
|
||||||
"@mikro-orm/core": "6.4.3",
|
"@mikro-orm/core": "6.4.3",
|
||||||
"@mikro-orm/migrations": "6.4.3",
|
"@mikro-orm/migrations": "6.4.3",
|
||||||
@@ -37,7 +37,7 @@
|
|||||||
"typescript": "^5.6.2"
|
"typescript": "^5.6.2"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@medusajs/framework": "^2.4.0",
|
"@medusajs/framework": "2.6.0",
|
||||||
"@mikro-orm/core": "6.4.3",
|
"@mikro-orm/core": "6.4.3",
|
||||||
"@mikro-orm/migrations": "6.4.3",
|
"@mikro-orm/migrations": "6.4.3",
|
||||||
"@mikro-orm/postgresql": "6.4.3",
|
"@mikro-orm/postgresql": "6.4.3",
|
||||||
|
|||||||
@@ -36,8 +36,8 @@
|
|||||||
"orm:cache:clear": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm cache:clear"
|
"orm:cache:clear": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm cache:clear"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@medusajs/framework": "^2.6.0",
|
"@medusajs/framework": "2.6.0",
|
||||||
"@medusajs/test-utils": "^2.6.0",
|
"@medusajs/test-utils": "2.6.0",
|
||||||
"@mikro-orm/cli": "6.4.3",
|
"@mikro-orm/cli": "6.4.3",
|
||||||
"@mikro-orm/core": "6.4.3",
|
"@mikro-orm/core": "6.4.3",
|
||||||
"@mikro-orm/migrations": "6.4.3",
|
"@mikro-orm/migrations": "6.4.3",
|
||||||
@@ -50,7 +50,7 @@
|
|||||||
"typescript": "^5.6.2"
|
"typescript": "^5.6.2"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@medusajs/framework": "^2.4.0",
|
"@medusajs/framework": "2.6.0",
|
||||||
"@mikro-orm/core": "6.4.3",
|
"@mikro-orm/core": "6.4.3",
|
||||||
"@mikro-orm/migrations": "6.4.3",
|
"@mikro-orm/migrations": "6.4.3",
|
||||||
"@mikro-orm/postgresql": "6.4.3",
|
"@mikro-orm/postgresql": "6.4.3",
|
||||||
|
|||||||
Loaded 100 of 269 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user