forked from medusajs/medusa
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(core-flows,types): improve tsdocs of workflows [1] (medusajs#10940
- Loading branch information
1 parent
b7a3759
commit 60dc8f6
Showing
27 changed files
with
1,076 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
import { AdditionalData, CreateCustomerDTO } from "@medusajs/framework/types" | ||
import { CustomerWorkflowEvents } from "@medusajs/framework/utils" | ||
import { | ||
WorkflowData, | ||
WorkflowResponse, | ||
createHook, | ||
createWorkflow, | ||
|
@@ -10,17 +9,50 @@ import { | |
import { emitEventStep } from "../../common/steps/emit-event" | ||
import { createCustomersStep } from "../steps" | ||
|
||
/** | ||
* The data to create one or more customers, along with custom data that's passed to the workflow's hooks. | ||
*/ | ||
export type CreateCustomersWorkflowInput = { | ||
/** | ||
* The customers to create. | ||
*/ | ||
customersData: CreateCustomerDTO[] | ||
} & AdditionalData | ||
|
||
export const createCustomersWorkflowId = "create-customers" | ||
/** | ||
* This workflow creates one or more customers. | ||
* This workflow creates one or more customers. It's used by the [Create Customer Admin API Route](https://docs.medusajs.com/api/admin#customers_postcustomers). | ||
* | ||
* This workflow has a hook that allows you to perform custom actions on the created customer. You can see an example in [this guide](https://docs.medusajs.com/resources/commerce-modules/customer/extend). | ||
* | ||
* You can also use this workflow within your own custom workflows, allowing you to wrap custom logic around creating customers. | ||
* | ||
* @example | ||
* const { result } = await createCustomersWorkflow(container) | ||
* .run({ | ||
* input: { | ||
* customersData: [ | ||
* { | ||
* first_name: "John", | ||
* last_name: "Doe", | ||
* email: "[email protected]", | ||
* }, | ||
* ], | ||
* additional_data: { | ||
* position_name: "Editor", | ||
* } | ||
* } | ||
* }) | ||
* | ||
* @summary | ||
* | ||
* Create one or more customers. | ||
* | ||
* @property hooks.customersCreated - This hook is executed after the customers are created. You can consume this hook to perform custom actions on the created customers. | ||
*/ | ||
export const createCustomersWorkflow = createWorkflow( | ||
createCustomersWorkflowId, | ||
(input: WorkflowData<CreateCustomersWorkflowInput>) => { | ||
(input: CreateCustomersWorkflowInput) => { | ||
const createdCustomers = createCustomersStep(input.customersData) | ||
const customersCreated = createHook("customersCreated", { | ||
customers: createdCustomers, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.