Skip to content

chore: Refactor and improve abstract module service factory #7688

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

Merged
merged 16 commits into from
Jun 13, 2024

Conversation

adrien2p
Copy link
Member

@adrien2p adrien2p commented Jun 12, 2024

What
Refactor and cleanup the modules service API

NOTE
Fix create/update mapped types not working, now they are working but the API must be generic any as not all modules follow the same convention and that can't be define through the types currently

NOTE 2
We have to add back the ts-ignore now that the types have been fixed and therefore we get back to the known ts issue about mapped types instance method of dynamic classes (microsoft/TypeScript#48125)

FIXES CORE-2294

Copy link

vercel bot commented Jun 12, 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 Jun 13, 2024 10:32am
3 Ignored Deployments
Name Status Preview Comments Updated (UTC)
api-reference ⬜️ Ignored (Inspect) Jun 13, 2024 10:32am
docs-ui ⬜️ Ignored (Inspect) Visit Preview Jun 13, 2024 10:32am
medusa-docs ⬜️ Ignored (Inspect) Visit Preview Jun 13, 2024 10:32am

Copy link

changeset-bot bot commented Jun 12, 2024

⚠️ No Changeset found

Latest commit: c0a218e

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 June 13, 2024 07:58
@adrien2p adrien2p requested a review from a team as a code owner June 13, 2024 07:58
@adrien2p
Copy link
Member Author

@sradevski @thetutlage @olivermrbl should be good to review and merge, then I can open the other pr with the fondational changes

@thetutlage
Copy link
Contributor

Looks pretty neat to me!

@adrien2p
Copy link
Member Author

@shahednasser just for info here how it will look like for simple users, some more changes will come soon though

export class TestModel {
  id: string
}

export class OtherModel {
  title: string
  id: string
}

class Service extends MedusaService(TestModel, { OtherModel }) {
  constructor(container: InjectedDependencies) {
    super(container)
  }

  async test() {
    const entities = await super.listOtherModels()
    const id = entities[0].title
  }
}

@shahednasser
Copy link
Member

@adrien2p looks much cleaner 😄 can you let me know when it's ok to update the docs with this change? (as in, when it's ok for users to use this).

Also, do we not need type arguments anymore?

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.

Sublime work!

@olivermrbl
Copy link
Contributor

cc @VariableVic

@adrien2p
Copy link
Member Author

@adrien2p looks much cleaner 😄 can you let me know when it's ok to update the docs with this change? (as in, when it's ok for users to use this).

Also, do we not need type arguments anymore?

Yes i let you know, yes the template args are not required but can be used if you want to specify a specific dto for example

@adrien2p adrien2p merged commit d2a5201 into develop Jun 13, 2024
20 checks passed
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.

5 participants