-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
feat(workflows):product handlers should be reusable in different context #4703
Conversation
🦋 Changeset detectedLatest commit: fb70692 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm! 🔥
packages/workflows/src/handlers/product/attach-sales-channel-to-products.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we move type PartialProduct = { handle: ProductHandle; id: string }
to a type-file for reusability?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
@@ -1,17 +1,20 @@ | |||
import { ProductTypes, WorkflowTypes } from "@medusajs/types" | |||
import { WorkflowArguments } from "../../helper" | |||
|
|||
type HandlerInput = { | |||
productIds: string[] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: ids
should be fine, the handler name speaks for itself
productIds: string[] | |
ids: string[] |
I didn't because it is the handler typing, so if the handler needs to evolve and we are having a shared type, we will quickly end up composing custom stuff on top of it. I prefer if it stays to the handler as is for now. wdyt? |
Makes sense. Let's keep it as is 👍 |
What
The listProducts handler should not be specific to the workflow.
Same for the product removal, shouldn't expect an entire DTO but just a collection of object that at least contains the id.
Same principle applied to other product handlers