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

feat(utils): autogenerates create and update methods when dto is provided #6751

Merged
merged 11 commits into from
Mar 20, 2024

Conversation

riqwan
Copy link
Contributor

@riqwan riqwan commented Mar 20, 2024

what:

when you provide an optional create_dto or update_dto to the model factory types, the abstract service will generate a simple service method for the public services of the modules.

MoneyAmount: {
  dto: PricingTypes.MoneyAmountDTO
  create_dto: PricingTypes.CreateMoneyAmountDTO
}

In the above example, only a create method will be generated, but the update will be skipped.

Copy link

changeset-bot bot commented Mar 20, 2024

🦋 Changeset detected

Latest commit: 2bc06f1

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@medusajs/utils Patch
@medusajs/promotion Patch

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

Copy link

vercel bot commented Mar 20, 2024

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

Name Status Preview Comments Updated (UTC)
api-reference 🔄 Building (Inspect) Visit Preview Mar 20, 2024 1:50pm
medusa-dashboard ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 20, 2024 1:50pm
2 Ignored Deployments
Name Status Preview Comments Updated (UTC)
docs-ui ⬜️ Ignored (Inspect) Visit Preview Mar 20, 2024 1:50pm
medusa-docs ⬜️ Ignored (Inspect) Visit Preview Mar 20, 2024 1:50pm

Copy link
Member

@adrien2p adrien2p left a comment

Choose a reason for hiding this comment

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

Nice work 🔥

Comment on lines 182 to 202
} & {
[ModelName in keyof ModelsConfig as CreateMethodName<
ModelsConfig,
ModelName
>]: {
(
data: ModelsConfig[ModelName]["create_dto"][],
sharedContext?: Context
): Promise<ModelsConfig[ModelName]["dto"][]>
}
} & {
[ModelName in keyof ModelsConfig as UpdateMethodName<
ModelsConfig,
ModelName
>]: {
(
data: ModelsConfig[ModelName]["update_dto"][],
sharedContext?: Context
): Promise<ModelsConfig[ModelName]["dto"][]>
}
}
Copy link
Member

Choose a reason for hiding this comment

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

todo:we should add the overload as per our convention

Copy link
Member

Choose a reason for hiding this comment

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

Will you add the single data along side the array data?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I did already, should be in the new commit

Copy link
Member

@sradevski sradevski left a comment

Choose a reason for hiding this comment

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

LGTM other than Adrien's comments

riqwan and others added 2 commits March 20, 2024 11:50
@riqwan riqwan requested a review from a team as a code owner March 20, 2024 12:54
@riqwan riqwan changed the title chore: simple create/update factories for public services feat(utils): autogenerates create and update methods when dto is provided Mar 20, 2024
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.

Very nice @riqwan!

@kodiakhq kodiakhq bot merged commit 4974f5e into develop Mar 20, 2024
18 checks passed
@kodiakhq kodiakhq bot deleted the feat/create-update-factory branch March 20, 2024 14:33
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