fix: wrap ModuleImplementations so that all methods are async (#9012)
This commit is contained in:
@@ -312,3 +312,9 @@ export type QueryConfig<TEntity extends BaseEntity> = {
|
||||
defaultLimit?: number
|
||||
isList?: boolean
|
||||
}
|
||||
|
||||
export type TransformObjectMethodToAsync<T extends object> = {
|
||||
[K in keyof T]: T[K] extends (...args: infer A) => infer R
|
||||
? (...args: A) => Promise<Awaited<R>>
|
||||
: T[K] extends object ? TransformObjectMethodToAsync<T[K]> : T[K];
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { createMedusaContainer } from "@medusajs/utils"
|
||||
import { AwilixContainer, ResolveOptions } from "awilix"
|
||||
import { TransformObjectMethodToAsync } from "@medusajs/types";
|
||||
|
||||
/**
|
||||
* The following interface acts as a bucket that other modules or the
|
||||
@@ -11,7 +12,7 @@ export interface ModuleImplementations {}
|
||||
* The Medusa Container extends [Awilix](https://github.com/jeffijoe/awilix) to
|
||||
* provide dependency injection functionalities.
|
||||
*/
|
||||
export type MedusaContainer<Cradle extends object = ModuleImplementations> =
|
||||
export type MedusaContainer<Cradle extends object = TransformObjectMethodToAsync<ModuleImplementations>> =
|
||||
Omit<AwilixContainer, "resolve"> & {
|
||||
resolve<K extends keyof Cradle>(
|
||||
key: K,
|
||||
|
||||
Reference in New Issue
Block a user