chore: Update modules providers configuration with 'identifier' and 'PROVIDER' (#9636)

* chore: Update modules providers configuration with 'identifier' and 'PROVIDER'

* update check

* fix tests

* type

* normalize auth provider

* emailpass

* providers

---------

Co-authored-by: Carlos R. L. Rodrigues <rodrigolr@gmail.com>
Co-authored-by: Carlos R. L. Rodrigues <37986729+carlos-r-l-rodrigues@users.noreply.github.com>
This commit is contained in:
Adrien de Peretti
2024-10-18 09:24:15 +02:00
committed by GitHub
parent 902ac12f73
commit 876d8072e7
22 changed files with 131 additions and 67 deletions

View File

@@ -4,7 +4,10 @@ import {
ModuleProvider,
ModulesSdkTypes,
} from "@medusajs/framework/types"
import { ContainerRegistrationKeys } from "@medusajs/framework/utils"
import {
ContainerRegistrationKeys,
getProviderRegistrationKey,
} from "@medusajs/framework/utils"
import { LockingProviderService } from "@services"
import {
LockingDefaultProvider,
@@ -14,10 +17,20 @@ import {
import { Lifetime, aliasTo, asFunction, asValue } from "awilix"
import { InMemoryLockingProvider } from "../providers/in-memory"
const registrationFn = async (klass, container) => {
const registrationFn = async (klass, container, { id }) => {
const key = LockingProviderService.getRegistrationIdentifier(klass)
if (!id) {
throw new Error(`No "id" provided for provider ${key}`)
}
const regKey = getProviderRegistrationKey({
providerId: id,
providerIdentifier: key,
})
container.register({
[LockingProviderRegistrationPrefix + key]: aliasTo("__providers__" + key),
[LockingProviderRegistrationPrefix + key]: aliasTo(regKey),
})
container.registerAdd(LockingIdentifiersRegistrationName, asValue(key))