Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] develop from medusajs:develop #17

Merged
merged 8 commits into from
Jan 15, 2025
5 changes: 5 additions & 0 deletions .changeset/gorgeous-comics-compete.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@medusajs/core-flows": patch
---

fix(core-flows): process payment capture condition
7 changes: 7 additions & 0 deletions .changeset/six-bears-vanish.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@medusajs/medusa": patch
"@medusajs/framework": patch
"@medusajs/cli": patch
---

feat(core, medusa, cli): Enable migration scripts
6 changes: 6 additions & 0 deletions .changeset/weak-poems-run.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@medusajs/icons": patch
"@medusajs/dashboard": patch
---

chore(icons,dashboard): Pull latest icons and update branch icon in category tree
10 changes: 5 additions & 5 deletions .github/workflows/test-cli-with-database.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
node-version: 20

- name: Install Medusa cli
run: npm i -g @medusajs/cli@preview
run: npm i -g @medusajs/cli@latest

- name: Create Medusa project
run: |
Expand All @@ -59,22 +59,22 @@ jobs:
working-directory: ../cli-test

- name: Run migrations
run: medusa db:migrate
run: npx medusa db:migrate
working-directory: ../cli-test

- name: Create admin user
run: medusa user -e [email protected] -p password -i admin_123
run: npx medusa user -e [email protected] -p password -i admin_123
working-directory: ../cli-test

- name: Run development server
run: medusa develop &
run: npx medusa develop &
working-directory: ../cli-test

- name: Testing development server
uses: ./.github/actions/test-server

- name: Starting medusa
run: medusa start &
run: npx medusa start &
working-directory: ../cli-test

- name: Testing server
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
DotsSix,
FolderIllustration,
FolderOpenIllustration,
Swatch,
TagIllustration,
TriangleRightMini,
} from "@medusajs/icons"
import { Badge, clx, IconButton } from "@medusajs/ui"
Expand Down Expand Up @@ -136,7 +136,7 @@ const Icon = ({ childrenCount, collapsed, clone }: IconProps) => {
<FolderIllustration />
)
) : (
<Swatch className="text-ui-fg-muted" />
<TagIllustration />
)}
</div>
)
Expand Down
4 changes: 4 additions & 0 deletions packages/cli/medusa-cli/src/create-cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,10 @@ function buildLocalCommands(cli, isLocalProject) {
command: "db:migrate",
desc: "Migrate the database by executing pending migrations",
builder: (builder) => {
builder.option("skip-scripts", {
type: "boolean",
describe: "Do not run migration scripts",
})
builder.option("skip-links", {
type: "boolean",
describe: "Do not sync links",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export const createCartWorkflowId = "create-cart"
*
* This workflow has a hook that allows you to perform custom actions on the created cart. You can see an example in [this guide](https://docs.medusajs.com/resources/commerce-modules/cart/extend#step-4-consume-cartcreated-workflow-hook).
*
* You can also use this workflow within your own custom workflows, allowing you to wrap custom logic around cart creation.
* You can also use this workflow within your customizations or your own custom workflows, allowing you to wrap custom logic around cart creation.
*
* @example
* const { result } = await createCartWorkflow(container)
Expand Down
2 changes: 1 addition & 1 deletion packages/core/core-flows/src/cart/workflows/update-cart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export const updateCartWorkflowId = "update-cart"
* This workflow has a hook that allows you to perform custom actions on the updated cart. For example, you can pass custom data under the `additional_data` property of the Update Cart API route,
* then update any associated details related to the cart in the workflow's hook.
*
* You can also use this workflow within your own custom workflows, allowing you to wrap custom logic around updating a cart.
* You can also use this workflow within your customizations or your own custom workflows, allowing you to wrap custom logic around updating a cart.
*
* @example
* const { result } = await updateCartWorkflow(container)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const createCustomerAddressesWorkflowId = "create-customer-addresses"
* This workflow has a hook that allows you to perform custom actions on the created customer addresses. For example, you can pass under `additional_data` custom data that
* allows you to create custom data models linked to the addresses.
*
* You can also use this workflow within your own custom workflows, allowing you to wrap custom logic around creating customer addresses.
* You can also use this workflow within your customizations or your own custom workflows, allowing you to wrap custom logic around creating customer addresses.
*
* @example
* const { result } = await createCustomerAddressesWorkflow(container)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const createCustomersWorkflowId = "create-customers"
*
* This workflow has a hook that allows you to perform custom actions on the created customer. You can see an example in [this guide](https://docs.medusajs.com/resources/commerce-modules/customer/extend).
*
* You can also use this workflow within your own custom workflows, allowing you to wrap custom logic around creating customers.
* You can also use this workflow within your customizations or your own custom workflows, allowing you to wrap custom logic around creating customers.
*
* @example
* const { result } = await createCustomersWorkflow(container)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export const updateCustomerAddressesWorkflowId = "update-customer-addresses"
* This workflow has a hook that allows you to perform custom actions on the updated customer addresses. For example, you can pass under `additional_data` custom data that
* allows you to update custom data models linked to the addresses.
*
* You can also use this workflow within your own custom workflows, allowing you to wrap custom logic around updating customer addresses.
* You can also use this workflow within your customizations or your own custom workflows, allowing you to wrap custom logic around updating customer addresses.
*
* @example
* const { result } = await updateCustomerAddressesWorkflow(container)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const updateCustomersWorkflowId = "update-customers"
* This workflow has a hook that allows you to perform custom actions on the updated customer. For example, you can pass under `additional_data` custom data to update
* custom data models linked to the customers.
*
* You can also use this workflow within your own custom workflows, allowing you to wrap custom logic around updating customers.
* You can also use this workflow within your customizations or your own custom workflows, allowing you to wrap custom logic around updating customers.
*
* @example
* const { result } = await updateCustomersWorkflow(container)
Expand Down
14 changes: 12 additions & 2 deletions packages/core/core-flows/src/order/steps/add-order-transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,24 @@ import { CreateOrderTransactionDTO } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
import { StepResponse, createStep } from "@medusajs/framework/workflows-sdk"

/**
* The transaction(s) to add to the order.
*/
export type AddOrderTransactionStepInput = CreateOrderTransactionDTO | CreateOrderTransactionDTO[]

/**
* The added order transaction(s).
*/
export type AddOrderTransactionStepOutput = CreateOrderTransactionDTO | CreateOrderTransactionDTO[]

export const addOrderTransactionStepId = "add-order-transaction"
/**
* This step creates order transactions.
*/
export const addOrderTransactionStep = createStep(
addOrderTransactionStepId,
async (
data: CreateOrderTransactionDTO | CreateOrderTransactionDTO[],
data: AddOrderTransactionStepInput,
{ container }
) => {
const service = container.resolve(Modules.ORDER)
Expand All @@ -36,7 +46,7 @@ export const addOrderTransactionStep = createStep(
const created = await service.addOrderTransactions(trxsData)

return new StepResponse(
Array.isArray(data) ? created : created[0],
(Array.isArray(data) ? created : created[0]) as AddOrderTransactionStepOutput,
created.map((c) => c.id)
)
},
Expand Down
6 changes: 6 additions & 0 deletions packages/core/core-flows/src/order/steps/archive-orders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@ import { IOrderModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
import { createStep, StepResponse } from "@medusajs/framework/workflows-sdk"

/**
* The details of archiving the orders.
*/
export type ArchiveOrdersStepInput = {
/**
* The IDs of the orders to archive.
*/
orderIds: string[]
}

Expand Down
11 changes: 11 additions & 0 deletions packages/core/core-flows/src/order/steps/cancel-fulfillment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,17 @@ import { StepResponse, createStep } from "@medusajs/framework/workflows-sdk"
export const cancelOrderFulfillmentStepId = "cancel-order-fulfillment"
/**
* This step cancels an order's fulfillment.
*
* @example
* const data = cancelOrderFulfillmentStep({
* order_id: "order_123",
* items: [
* {
* id: "item_123",
* quantity: 1
* }
* ]
* })
*/
export const cancelOrderFulfillmentStep = createStep(
cancelOrderFulfillmentStepId,
Expand Down
9 changes: 9 additions & 0 deletions packages/core/core-flows/src/order/steps/cancel-orders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,17 @@ import { IOrderModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
import { createStep, StepResponse } from "@medusajs/framework/workflows-sdk"

/**
* The details of canceling the orders.
*/
export type CancelOrdersStepInput = {
/**
* The IDs of the orders to cancel.
*/
orderIds: string[]
/**
* The ID of the user canceling the orders.
*/
canceled_by?: string
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,40 @@ import {
import { ChangeActionType, Modules } from "@medusajs/framework/utils"
import { StepResponse, createStep } from "@medusajs/framework/workflows-sdk"

/**
* The details of creating the claim items from a change action.
*/
export type CreateOrderClaimItemsFromActionsInput = {
/**
* The change actions to create claim items from.
*/
changes: OrderChangeActionDTO[]
/**
* The ID of the claim to create the items for.
*/
claimId: string
}

/**
* This step creates claim items from a change action.
*
* :::note
*
* You can retrieve an order change action details using [Query](https://docs.medusajs.com/learn/fundamentals/module-links/query),
* or [useQueryGraphStep](https://docs.medusajs.com/resources/references/medusa-workflows/steps/useQueryGraphStep).
*
* :::
*
* @example
* const data = createOrderClaimItemsFromActionsStep({
* claimId: "claim_123",
* changes: [
* {
* id: "orchact_123",
* // other order change action details...
* }
* ]
* })
*/
export const createOrderClaimItemsFromActionsStep = createStep(
"create-claim-items-from-change-actions",
Expand Down
12 changes: 11 additions & 1 deletion packages/core/core-flows/src/order/steps/claim/delete-claims.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,23 @@ import { IOrderModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
import { createStep, StepResponse } from "@medusajs/framework/workflows-sdk"

/**
* The details of deleting one or more claims.
*/
export type DeleteOrderClaimsInput = {
/**
* The IDs of the claims to delete.
*/
ids: string[]
}

export const deleteClaimsStepId = "delete-claims"
/**
* This step deletes one or more order claims.
*/
export const deleteClaimsStep = createStep(
deleteClaimsStepId,
async (data: { ids: string[] }, { container }) => {
async (data: DeleteOrderClaimsInput, { container }) => {
const service = container.resolve<IOrderModuleService>(Modules.ORDER)

const deleted = await service.softDeleteOrderClaims(data.ids)
Expand Down
6 changes: 6 additions & 0 deletions packages/core/core-flows/src/order/steps/complete-orders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@ import { IOrderModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
import { createStep, StepResponse } from "@medusajs/framework/workflows-sdk"

/**
* The details of completing the orders.
*/
export type CompleteOrdersStepInput = {
/**
* The IDs of the orders to complete.
*/
orderIds: string[]
}

Expand Down
12 changes: 12 additions & 0 deletions packages/core/core-flows/src/order/steps/confirm-order-changes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,21 @@ import { OrderChangeDTO } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
import { createStep, StepResponse } from "@medusajs/framework/workflows-sdk"

/**
* The input for the confirm order changes step.
*/
export type ConfirmOrderChangesInput = {
/**
* The ID of the order to confirm changes for.
*/
orderId: string
/**
* The changes to confirm.
*/
changes: OrderChangeDTO[]
/**
* The ID of the user confirming the changes.
*/
confirmed_by?: string
}

Expand Down
19 changes: 19 additions & 0 deletions packages/core/core-flows/src/order/steps/create-line-items.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,32 @@ import { CreateOrderLineItemDTO } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
import { StepResponse, createStep } from "@medusajs/framework/workflows-sdk"

/**
* The details of creating order line items.
*/
export interface CreateOrderLineItemsStepInput {
/**
* The items to create.
*/
items: CreateOrderLineItemDTO[]
}

export const createOrderLineItemsStepId = "create-order-line-items-step"
/**
* This step creates order line items.
*
* @example
* const data = createOrderLineItemsStep({
* items: [
* {
* variant_id: "variant_123",
* quantity: 1,
* unit_price: 10,
* title: "Shirt",
* order_id: "order_123"
* }
* ]
* })
*/
export const createOrderLineItemsStep = createStep(
createOrderLineItemsStepId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@ import {
import { Modules } from "@medusajs/framework/utils"
import { StepResponse, createStep } from "@medusajs/framework/workflows-sdk"

/**
* The details of creating order shipping methods.
*/
export interface CreateOrderShippingMethodsStepInput {
/**
* The shipping methods to create.
*/
shipping_methods: CreateOrderShippingMethodDTO[]
}

Expand Down
Loading
Loading