fix: wrap ModuleImplementations so that all methods are async (#9012)

This commit is contained in:
Alexander Nortung
2024-09-06 12:59:52 +02:00
committed by GitHub
parent 72f7ff882d
commit 20545b194e
2 changed files with 8 additions and 1 deletions
+6
View File
@@ -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,