From 3ded2314a5b56f810c8a7d6727d7cdc9ffc900d1 Mon Sep 17 00:00:00 2001 From: Shahed Nasser Date: Thu, 8 Feb 2024 11:36:45 +0200 Subject: [PATCH] fix(medusa): fix constructor container type for abstract services (#6259) --- .changeset/shy-wolves-mix.md | 5 +++++ packages/medusa/src/interfaces/file-service.ts | 4 ++-- packages/medusa/src/interfaces/fulfillment-service.ts | 4 ++-- packages/medusa/src/interfaces/notification-service.ts | 4 ++-- packages/medusa/src/interfaces/payment-processor.ts | 4 ++-- packages/medusa/src/interfaces/price-selection-strategy.ts | 4 ++-- packages/medusa/src/interfaces/tax-calculation-strategy.ts | 4 ++-- packages/medusa/src/interfaces/tax-service.ts | 4 ++-- 8 files changed, 19 insertions(+), 14 deletions(-) create mode 100644 .changeset/shy-wolves-mix.md diff --git a/.changeset/shy-wolves-mix.md b/.changeset/shy-wolves-mix.md new file mode 100644 index 0000000000..7a2a8eec03 --- /dev/null +++ b/.changeset/shy-wolves-mix.md @@ -0,0 +1,5 @@ +--- +"@medusajs/medusa": patch +--- + +fix(medusa): fix constructor container type for abstract services diff --git a/packages/medusa/src/interfaces/file-service.ts b/packages/medusa/src/interfaces/file-service.ts index 1fa77971a0..fa4543a7c5 100644 --- a/packages/medusa/src/interfaces/file-service.ts +++ b/packages/medusa/src/interfaces/file-service.ts @@ -299,7 +299,7 @@ export abstract class AbstractFileService * Additionally, if you’re creating your file 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. * - * @param {MedusaContainer} container - An instance of `MedusaContainer` that allows you to access other resources, such as services, in your Medusa backend. + * @param {Record} container - An instance of `MedusaContainer` that allows you to access other resources, such as services, in your Medusa backend. * @param {Record} config - If this file service is created in a plugin, the plugin's options are passed in this parameter. * * @example @@ -334,7 +334,7 @@ export abstract class AbstractFileService * } */ protected constructor( - protected readonly container: MedusaContainer, + protected readonly container: Record, protected readonly config?: Record // eslint-disable-next-line @typescript-eslint/no-empty-function ) { super(container, config) diff --git a/packages/medusa/src/interfaces/fulfillment-service.ts b/packages/medusa/src/interfaces/fulfillment-service.ts index 26f946d1b7..a8879b2bf3 100644 --- a/packages/medusa/src/interfaces/fulfillment-service.ts +++ b/packages/medusa/src/interfaces/fulfillment-service.ts @@ -415,7 +415,7 @@ export abstract class AbstractFulfillmentService * You can also use the constructor to initialize your integration with the third-party provider. For example, if you use a client to connect to the third-party provider’s APIs, you can initialize it in the constructor and use it in other methods in the service. * Additionally, if you’re creating your fulfillment provider 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 it in the constructor. * - * @param {MedusaContainer} container - An instance of `MedusaContainer` that allows you to access other resources, such as services, in your Medusa backend. + * @param {Record} container - An instance of `MedusaContainer` that allows you to access other resources, such as services, in your Medusa backend. * @param {Record} config - If this fulfillment provider is created in a plugin, the plugin's options are passed in this parameter. * * @example @@ -433,7 +433,7 @@ export abstract class AbstractFulfillmentService * } */ protected constructor( - protected readonly container: MedusaContainer, + protected readonly container: Record, protected readonly config?: Record // eslint-disable-next-line @typescript-eslint/no-empty-function ) { super(container, config) diff --git a/packages/medusa/src/interfaces/notification-service.ts b/packages/medusa/src/interfaces/notification-service.ts index 40ef37995f..edf62ef60d 100644 --- a/packages/medusa/src/interfaces/notification-service.ts +++ b/packages/medusa/src/interfaces/notification-service.ts @@ -234,7 +234,7 @@ export abstract class AbstractNotificationService * Additionally, if you’re creating your notification provider 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 it in the constructor. * - * @param {MedusaContainer} container - An instance of `MedusaContainer` that allows you to access other resources, such as services, in your Medusa backend. + * @param {Record} container - An instance of `MedusaContainer` that allows you to access other resources, such as services, in your Medusa backend. * @param {Record} config - If this notification provider is created in a plugin, the plugin's options are passed in this parameter. * * @example @@ -264,7 +264,7 @@ export abstract class AbstractNotificationService * export default EmailSenderService */ protected constructor( - protected readonly container: MedusaContainer, + protected readonly container: Record, protected readonly config?: Record // eslint-disable-next-line @typescript-eslint/no-empty-function ) { super(container, config) diff --git a/packages/medusa/src/interfaces/payment-processor.ts b/packages/medusa/src/interfaces/payment-processor.ts index fd6cb9ecc7..58d08e53c9 100644 --- a/packages/medusa/src/interfaces/payment-processor.ts +++ b/packages/medusa/src/interfaces/payment-processor.ts @@ -652,7 +652,7 @@ export abstract class AbstractPaymentProcessor implements PaymentProcessor { * Additionally, if you’re creating your Payment Processor 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 it in the constructor. The options are passed as a second parameter. * - * @param {MedusaContainer} container - An instance of `MedusaContainer` that allows you to access other resources, such as services, in your Medusa backend through [dependency injection](https://docs.medusajs.com/development/fundamentals/dependency-injection) + * @param {Record} container - An instance of `MedusaContainer` that allows you to access other resources, such as services, in your Medusa backend through [dependency injection](https://docs.medusajs.com/development/fundamentals/dependency-injection) * @param {Record} config - If this fulfillment provider is created in a plugin, the plugin's options are passed in this parameter. * * @example @@ -672,7 +672,7 @@ export abstract class AbstractPaymentProcessor implements PaymentProcessor { * ``` */ protected constructor( - protected readonly container: MedusaContainer, + protected readonly container: Record, protected readonly config?: Record // eslint-disable-next-line @typescript-eslint/no-empty-function ) {} diff --git a/packages/medusa/src/interfaces/price-selection-strategy.ts b/packages/medusa/src/interfaces/price-selection-strategy.ts index f621334ff8..4070c6371e 100644 --- a/packages/medusa/src/interfaces/price-selection-strategy.ts +++ b/packages/medusa/src/interfaces/price-selection-strategy.ts @@ -225,7 +225,7 @@ export abstract class AbstractPriceSelectionStrategy /** * You can use the `constructor` of your price-selection strategy to access the different services in Medusa through dependency injection. * - * @param {MedusaContainer} container - An instance of `MedusaContainer` that allows you to access other resources, such as services, in your Medusa backend. + * @param {Record} container - An instance of `MedusaContainer` that allows you to access other resources, such as services, in your Medusa backend. * @param {Record} config - If this price-selection strategy is created in a plugin, the plugin's options are passed in this parameter. * * @example @@ -254,7 +254,7 @@ export abstract class AbstractPriceSelectionStrategy * export default MyStrategy */ protected constructor( - protected readonly container: MedusaContainer, + protected readonly container: Record, protected readonly config?: Record // eslint-disable-next-line @typescript-eslint/no-empty-function ) { super(container, config) diff --git a/packages/medusa/src/interfaces/tax-calculation-strategy.ts b/packages/medusa/src/interfaces/tax-calculation-strategy.ts index 95c2cb8dcb..9ab102f5e4 100644 --- a/packages/medusa/src/interfaces/tax-calculation-strategy.ts +++ b/packages/medusa/src/interfaces/tax-calculation-strategy.ts @@ -128,7 +128,7 @@ export abstract class AbstractTaxCalculationStrategy * You can also use the constructor to initialize your integration with the third-party provider. For example, if you use a client to connect to the third-party provider’s APIs, you can initialize it in the constructor and use it in other methods in the service. * Additionally, if you’re creating your tax calculation strategy 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 it in the constructor. * - * @param {MedusaContainer} container - An instance of `MedusaContainer` that allows you to access other resources, such as services, in your Medusa backend. + * @param {Record} container - An instance of `MedusaContainer` that allows you to access other resources, such as services, in your Medusa backend. * @param {Record} config - If this tax calculation strategy is created in a plugin, the plugin's options are passed in this parameter. * * @example @@ -156,7 +156,7 @@ export abstract class AbstractTaxCalculationStrategy * export default TaxCalculationStrategy */ protected constructor( - protected readonly container: MedusaContainer, + protected readonly container: Record, protected readonly config?: Record // eslint-disable-next-line @typescript-eslint/no-empty-function ) { super(container, config) diff --git a/packages/medusa/src/interfaces/tax-service.ts b/packages/medusa/src/interfaces/tax-service.ts index c8c38e070c..c4dff54c69 100644 --- a/packages/medusa/src/interfaces/tax-service.ts +++ b/packages/medusa/src/interfaces/tax-service.ts @@ -206,7 +206,7 @@ export abstract class AbstractTaxService * You can also use the constructor to initialize your integration with the third-party provider. For example, if you use a client to connect to the third-party provider’s APIs, you can initialize it in the constructor and use it in other methods in the service. * Additionally, if you’re creating your tax provider 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 it in the constructor. * - * @param {MedusaContainer} container - An instance of `MedusaContainer` that allows you to access other resources, such as services, in your Medusa backend. + * @param {Record} container - An instance of `MedusaContainer` that allows you to access other resources, such as services, in your Medusa backend. * @param {Record} config - If this tax provider is created in a plugin, the plugin's options are passed in this parameter. * * @example @@ -235,7 +235,7 @@ export abstract class AbstractTaxService * export default MyTaxService */ protected constructor( - protected readonly container: MedusaContainer, + protected readonly container: Record, protected readonly config?: Record // eslint-disable-next-line @typescript-eslint/no-empty-function ) { super(container, config)