-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
chore(utils): Update internal service update input validation #8265
chore(utils): Update internal service update input validation #8265
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
6 Skipped Deployments
|
|
I am also trying to improve the base API in a separate pr @olivermrbl, though, I ll have to ts expect error in many services because they override the base method with a different API which is not supposed to happen, but I can ignore them for now until the full modules API is settled and in any case those override normalize their input to be consumed by the base methods |
@@ -252,12 +252,22 @@ export function MedusaInternalService< | |||
input: any | any[] | SelectorAndData | SelectorAndData[], | |||
@MedusaContext() sharedContext: Context = {} | |||
): Promise<InferEntityType<TEntity> | InferEntityType<TEntity>[]> { | |||
if (!isDefined(input) || (Array.isArray(input) && input.length === 0)) { | |||
if ( |
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.
can we use isPresent
here?
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.
yes you are right 👍 much better, I ll add that in
@@ -252,12 +252,22 @@ export function MedusaInternalService< | |||
input: any | any[] | SelectorAndData | SelectorAndData[], |
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.
thought: @shahednasser, do we have a reference for the internal module services? If not, would it make sense to have such that we can provide a link in the error message?
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.
Not a reference, but we have examples here: https://docs.medusajs.com/v2/advanced-development/modules/service-factory#generated-methods
We can generate a reference if we find it necessary, but the reason I didn't is I imagine the typings being confusing. We can alternatively have a document that provides more advanced / realistic examples
@olivermrbl I will stop this pr for now as it is still documented. But it require a much broader work on aligning the different API's the modules are defining VS what the internal service is provided. There is too much discrepancies for now and I d like to finalise my other tasks. wdyt? thought, I ll keep this pr open for reference in case I get back to this one later |
Yeah, let's do that for now. We can pick it up as part of our polishing phase. |
This PR is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days. |
This PR was closed because it has been stalled for 5 days with no activity. |
What
Add more validation to the update input arguments to catch wrong usage
FIXES TRI-64