fix: wrap ModuleImplementations so that all methods are async (#9012)
This commit is contained in:
1 parent
72f7ff882d
commit
20545b194e
2 files changed
+8
-1
No files matched your search
@@ -312,3 +312,9 @@ export type QueryConfig<TEntity extends BaseEntity> = {
|
|||||||
defaultLimit?: number
|
defaultLimit?: number
|
||||||
isList?: boolean
|
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 { createMedusaContainer } from "@medusajs/utils"
|
||||||
import { AwilixContainer, ResolveOptions } from "awilix"
|
import { AwilixContainer, ResolveOptions } from "awilix"
|
||||||
|
import { TransformObjectMethodToAsync } from "@medusajs/types";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The following interface acts as a bucket that other modules or the
|
* 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
|
* The Medusa Container extends [Awilix](https://github.com/jeffijoe/awilix) to
|
||||||
* provide dependency injection functionalities.
|
* provide dependency injection functionalities.
|
||||||
*/
|
*/
|
||||||
export type MedusaContainer<Cradle extends object = ModuleImplementations> =
|
export type MedusaContainer<Cradle extends object = TransformObjectMethodToAsync<ModuleImplementations>> =
|
||||||
Omit<AwilixContainer, "resolve"> & {
|
Omit<AwilixContainer, "resolve"> & {
|
||||||
resolve<K extends keyof Cradle>(
|
resolve<K extends keyof Cradle>(
|
||||||
key: K,
|
key: K,
|
||||||
|
|||||||
Reference in new issue
Block a user