chore: local workflow proxying methods to pass context (#6263)

What:
- When calling a module's method inside a Local Workflow the MedusaContext is passed as the last argument to the method if not provided
- Add `requestId` to req
- A couple of fixes on Remote Joiner and the data fetcher for internal services

Why:
- The context used to initialize the workflow has to be shared with all modules. properties like transactionId will be used to emit events and requestId to trace logs for example.
This commit is contained in:
Carlos R. L. Rodrigues authored and GitHub committed 2024-02-01 13:37:26 +00:00
1 parent a2bf6756ac
commit 45134e4d11
40 files changed
+576 -170

No files matched your search

+14 -19
View File
@@ -1,23 +1,24 @@
import jwt from "jsonwebtoken"
import {
AuthProviderDTO,
AuthTypes,
AuthUserDTO,
AuthenticationInput,
AuthenticationResponse,
AuthTypes,
Context,
CreateAuthProviderDTO,
CreateAuthUserDTO,
DAL,
FilterableAuthProviderProps,
FilterableAuthUserProps,
FindConfig,
InternalModuleDeclaration,
JWTGenerationOptions,
MedusaContainer,
ModuleJoinerConfig,
JWTGenerationOptions,
UpdateAuthUserDTO,
} from "@medusajs/types"
import { AuthProvider, AuthUser } from "@models"
import { joinerConfig } from "../joiner-config"
import { AuthProviderService, AuthUserService } from "@services"
import {
AbstractAuthModuleProvider,
InjectManager,
@@ -25,16 +26,10 @@ import {
MedusaContext,
MedusaError,
} from "@medusajs/utils"
import {
AuthProviderDTO,
AuthUserDTO,
CreateAuthProviderDTO,
CreateAuthUserDTO,
FilterableAuthProviderProps,
FilterableAuthUserProps,
UpdateAuthUserDTO,
} from "@medusajs/types"
import { AuthProvider, AuthUser } from "@models"
import { AuthProviderService, AuthUserService } from "@services"
import { ServiceTypes } from "@types"
import { joinerConfig } from "../joiner-config"
type AuthModuleOptions = {
jwt_secret: string
@@ -90,7 +85,7 @@ export default class AuthModuleService<
async retrieveAuthProvider(
provider: string,
config: FindConfig<AuthProviderDTO> = {},
sharedContext: Context = {}
@MedusaContext() sharedContext: Context = {}
): Promise<AuthProviderDTO> {
const authProvider = await this.authProviderService_.retrieve(
provider,
@@ -107,7 +102,7 @@ export default class AuthModuleService<
async listAuthProviders(
filters: FilterableAuthProviderProps = {},
config: FindConfig<AuthProviderDTO> = {},
sharedContext: Context = {}
@MedusaContext() sharedContext: Context = {}
): Promise<AuthProviderDTO[]> {
const authProviders = await this.authProviderService_.list(
filters,