diff --git a/packages/core/utils/src/event-bus/index.ts b/packages/core/utils/src/event-bus/index.ts index 999575da7df63..c10a4de9d0989 100644 --- a/packages/core/utils/src/event-bus/index.ts +++ b/packages/core/utils/src/event-bus/index.ts @@ -1,8 +1,4 @@ -import { - EventBusTypes, - InternalModuleDeclaration, - MedusaContainer, -} from "@medusajs/types" +import { EventBusTypes, InternalModuleDeclaration } from "@medusajs/types" import { ulid } from "ulid" export abstract class AbstractEventBusModuleService @@ -23,7 +19,7 @@ export abstract class AbstractEventBusModuleService } protected constructor( - container: MedusaContainer, + cradle: Record, moduleOptions = {}, moduleDeclaration: InternalModuleDeclaration ) { diff --git a/packages/core/utils/src/payment/abstract-payment-provider.ts b/packages/core/utils/src/payment/abstract-payment-provider.ts index 32aaec9b4bae6..1633fbfe851be 100644 --- a/packages/core/utils/src/payment/abstract-payment-provider.ts +++ b/packages/core/utils/src/payment/abstract-payment-provider.ts @@ -1,7 +1,6 @@ import { CreatePaymentProviderSession, IPaymentProvider, - MedusaContainer, PaymentProviderError, PaymentProviderSessionResponse, PaymentSessionStatus, @@ -13,14 +12,15 @@ import { export abstract class AbstractPaymentProvider> implements IPaymentProvider { + protected readonly container: Record /** * This method validates the options of the provider set in `medusa-config.ts`. * Implementing this method is optional. It's useful if your provider requires custom validation. - * + * * If the options aren't valid, throw an error. - * + * * @param options - The provider's options. - * + * * @example * class MyPaymentProviderService extends AbstractPaymentProvider { * static validateOptions(options: Record) { @@ -43,7 +43,7 @@ export abstract class AbstractPaymentProvider> * * The provider can also access the module's options as a second parameter. * - * @param {MedusaContainer} container - The module's container used to resolve resources. + * @param {Record} cradle - The module's container cradle used to resolve resources. * @param {Record} config - The options passed to the payment module provider. * * @example @@ -92,9 +92,11 @@ export abstract class AbstractPaymentProvider> * ``` */ protected constructor( - protected readonly container: MedusaContainer, + cradle: Record, protected readonly config: TConfig = {} as TConfig // eslint-disable-next-line @typescript-eslint/no-empty-function - ) {} + ) { + this.container = cradle + } /** * @ignore @@ -110,7 +112,7 @@ export abstract class AbstractPaymentProvider> /** * Each payment provider has a unique identifier defined in its class. The provider's ID - * will be stored as `pp_{identifier}_{id}`, where `{id}` is the provider's `id` + * will be stored as `pp_{identifier}_{id}`, where `{id}` is the provider's `id` * property in the `medusa-config.ts`. * * @example diff --git a/packages/core/utils/src/search/abstract-service.ts b/packages/core/utils/src/search/abstract-service.ts index e32e23760d5cf..b64efa0f0dad1 100644 --- a/packages/core/utils/src/search/abstract-service.ts +++ b/packages/core/utils/src/search/abstract-service.ts @@ -116,7 +116,7 @@ export abstract class AbstractSearchService * Additionally, if you’re creating your search service as an external plugin to be installed on any Medusa backend and you want to access the options added for the plugin, * you can access them in the constructor. The default constructor already sets the value of the class proeprty `options_` to the passed options. * - * @param {MedusaContainer} container - An instance of `MedusaContainer` that allows you to access other resources, such as services, in your Medusa backend. + * @param {Record} cradle - An container cradle that allows you to access other resources, such as services, in your Medusa backend. * @param {Record} options - If this search service is created in a plugin, the plugin's options are passed in this parameter. * * @example @@ -144,7 +144,7 @@ export abstract class AbstractSearchService * // ... * } */ - protected constructor(container, options) { + protected constructor(cradle, options) { this.options_ = options } diff --git a/packages/modules/providers/payment-stripe/src/core/stripe-base.ts b/packages/modules/providers/payment-stripe/src/core/stripe-base.ts index 9c1cc73f8d600..cd0631db00cb0 100644 --- a/packages/modules/providers/payment-stripe/src/core/stripe-base.ts +++ b/packages/modules/providers/payment-stripe/src/core/stripe-base.ts @@ -4,7 +4,6 @@ import Stripe from "stripe" import { CreatePaymentProviderSession, - MedusaContainer, PaymentProviderError, PaymentProviderSessionResponse, ProviderWebhookPayload, @@ -34,7 +33,7 @@ import { abstract class StripeBase extends AbstractPaymentProvider { protected readonly options_: StripeOptions protected stripe_: Stripe - protected container_: MedusaContainer + protected container_: Record static validateOptions(options: StripeOptions): void { if (!isDefined(options.apiKey)) { @@ -42,11 +41,14 @@ abstract class StripeBase extends AbstractPaymentProvider { } } - protected constructor(container: MedusaContainer, options: StripeOptions) { + protected constructor( + cradle: Record, + options: StripeOptions + ) { // @ts-ignore super(...arguments) - this.container_ = container + this.container_ = cradle this.options_ = options this.stripe_ = new Stripe(options.apiKey)