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

fix(core-flows): update cart promotion data usage #9456

Merged
merged 1 commit into from
Oct 4, 2024

Conversation

adrien2p
Copy link
Member

@adrien2p adrien2p commented Oct 3, 2024

What
The nullish coalescing can't really work since we are using proxies under the hood which is present

Copy link

vercel bot commented Oct 3, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
medusa-dashboard ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 3, 2024 5:34pm
6 Skipped Deployments
Name Status Preview Comments Updated (UTC)
api-reference ⬜️ Ignored (Inspect) Oct 3, 2024 5:34pm
api-reference-v2 ⬜️ Ignored (Inspect) Oct 3, 2024 5:34pm
docs-ui ⬜️ Ignored (Inspect) Oct 3, 2024 5:34pm
docs-v2 ⬜️ Ignored (Inspect) Oct 3, 2024 5:34pm
medusa-docs ⬜️ Ignored (Inspect) Oct 3, 2024 5:34pm
resources-docs ⬜️ Ignored (Inspect) Oct 3, 2024 5:34pm

Copy link

changeset-bot bot commented Oct 3, 2024

⚠️ No Changeset found

Latest commit: a7f76be

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@adrien2p adrien2p marked this pull request as ready for review October 3, 2024 17:34
@adrien2p adrien2p requested a review from a team as a code owner October 3, 2024 17:34
@adrien2p
Copy link
Member Author

adrien2p commented Oct 3, 2024

@shahednasser did we documented that? The fact that when you want to use data in workflows you are not really manipulating them but rather manipulating proxies under the hood, so nullishcoalescing and ternary like that can't work. Instead users should rely on transformers

@shahednasser
Copy link
Member

No not aware of this. I can document it tomorrow

Copy link
Contributor

@olivermrbl olivermrbl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect we might be doing this more places, I recently found a similar pattern in a cart workflow

@adrien2p
Copy link
Member Author

adrien2p commented Oct 3, 2024

I suspect we might be doing this more places, I recently found a similar pattern in a cart workflow

Humm, but I was sure we share that internally and the same about data manipulation in general in workflow. It is just a composer basically to organize steps and stuff in the order they should be executed and we allow through utils to have places to manipulate the data to be ingested by steps and sub workflows

@adrien2p
Copy link
Member Author

adrien2p commented Oct 3, 2024

No not aware of this. I can document it tomorrow

Basically the composer function only serves to compose a flow with a certain order of execution and configuration. Then we have utils like transform which allow to manipulate data if needed and then those are resolved when we reach a strp or workflow consuming it.

Cc @carlos-r-l-rodrigues we might write again about it wdyt?

Copy link
Contributor

@riqwan riqwan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this might be a long stretch, but can we detect if we're doing this within the proxies and throw an error?

In hindsight, I knew this wasn't correct, but because I'm writing in "JS", it was just intuitive to continue along. 😅

@adrien2p
Copy link
Member Author

adrien2p commented Oct 3, 2024

I know this might be a long stretch, but can we detect if we're doing this within the proxies and throw an error?

In hindsight, I knew this wasn't correct, but because I'm writing in "JS", it was just intuitive to continue along. 😅

🤣 unfortunately there is no way for us to know unless we do a static analysis of the composer function. The proxies are around the object so that when you access a prop it generates a transformer for you instead.

const promotionCodesToApply = getPromotionCodesToApply({
cart: cart,
promo_codes: input.promo_codes ?? [],
action: input.action || PromotionActions.ADD,
promo_codes,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

on another note, this could probably also be handled by the step itself, so that it is more resuable

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes 100% but it is also handled I believe

@kodiakhq kodiakhq bot merged commit 5a57392 into develop Oct 4, 2024
23 checks passed
@kodiakhq kodiakhq bot deleted the fix/prodmotion-workflow-data-usage branch October 4, 2024 07:19
panalgin pushed a commit to vennyx-org/medusa that referenced this pull request Oct 7, 2024
**What**
The nullish coalescing can't really work since we are using proxies under the hood which is present
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants