-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Conversation
🦋 Changeset detectedLatest commit: 2bc06f1 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
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 ↗︎
2 Ignored Deployments
|
8429f88
to
1aa5fd1
Compare
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.
Nice work 🔥
packages/utils/src/modules-sdk/abstract-module-service-factory.ts
Outdated
Show resolved
Hide resolved
packages/utils/src/modules-sdk/abstract-module-service-factory.ts
Outdated
Show resolved
Hide resolved
} & { | ||
[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"][]> | ||
} | ||
} |
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.
todo:we should add the overload as per our convention
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.
Will you add the single data along side the array data?
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.
I did already, should be in the new commit
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 other than Adrien's comments
Co-authored-by: Adrien de Peretti <[email protected]>
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.
Very nice @riqwan!
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.
In the above example, only a create method will be generated, but the update will be skipped.