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:
Adrien de Peretti
2024-06-24 16:35:44 +02:00
committed by GitHub
parent aee75f6ba0
commit 021f5ea016

View File

@@ -68,8 +68,10 @@ type ModelConfigurationsToConfigTemplate<T extends TEntityEntries> = {
dto: T[Key] extends Constructor<any> ? InstanceType<T[Key]> : any
create: any
update: any
singular: T[Key] extends { singular: string } ? T[Key]["singular"] : string
plural: T[Key] extends { plural: string } ? T[Key]["plural"] : string
singular: T[Key] extends { singular: string } ? T[Key]["singular"] : Key
plural: T[Key] extends { plural: string }
? T[Key]["plural"]
: Pluralize<Key & string>
}
}
@@ -107,7 +109,7 @@ type ExtractKeysFromConfig<EntitiesConfig> = EntitiesConfig extends {
: keyof EntitiesConfig
export type AbstractModuleService<
TEntitiesDtoConfig extends EntitiesConfigTemplate
TEntitiesDtoConfig extends Record<string, any>
> = {
[TEntityName in keyof TEntitiesDtoConfig as `retrieve${ExtractSingularName<
TEntitiesDtoConfig,