fix: medusa service should infer names when not provided (#7818)
* fix: medusa service should infer names when not provided * fix types * fix typings
This commit is contained in:
@@ -68,8 +68,10 @@ type ModelConfigurationsToConfigTemplate<T extends TEntityEntries> = {
|
|||||||
dto: T[Key] extends Constructor<any> ? InstanceType<T[Key]> : any
|
dto: T[Key] extends Constructor<any> ? InstanceType<T[Key]> : any
|
||||||
create: any
|
create: any
|
||||||
update: any
|
update: any
|
||||||
singular: T[Key] extends { singular: string } ? T[Key]["singular"] : string
|
singular: T[Key] extends { singular: string } ? T[Key]["singular"] : Key
|
||||||
plural: T[Key] extends { plural: string } ? T[Key]["plural"] : string
|
plural: T[Key] extends { plural: string }
|
||||||
|
? T[Key]["plural"]
|
||||||
|
: Pluralize<Key & string>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -107,7 +109,7 @@ type ExtractKeysFromConfig<EntitiesConfig> = EntitiesConfig extends {
|
|||||||
: keyof EntitiesConfig
|
: keyof EntitiesConfig
|
||||||
|
|
||||||
export type AbstractModuleService<
|
export type AbstractModuleService<
|
||||||
TEntitiesDtoConfig extends EntitiesConfigTemplate
|
TEntitiesDtoConfig extends Record<string, any>
|
||||||
> = {
|
> = {
|
||||||
[TEntityName in keyof TEntitiesDtoConfig as `retrieve${ExtractSingularName<
|
[TEntityName in keyof TEntitiesDtoConfig as `retrieve${ExtractSingularName<
|
||||||
TEntitiesDtoConfig,
|
TEntitiesDtoConfig,
|
||||||
|
|||||||
Reference in New Issue
Block a user