feat: loosely typed container
This commit is contained in:
1 parent
2d956931b3
commit
11528526fa
41 files changed
+255
-114
No files matched your search
@@ -1,5 +1,5 @@
|
|||||||
import { ModuleRegistrationName } from "@medusajs/modules-sdk"
|
import { ModuleRegistrationName } from "@medusajs/modules-sdk"
|
||||||
import { CreateStoreDTO, IStoreModuleService } from "@medusajs/types"
|
import { CreateStoreDTO, IStoreModuleService, StoreDTO } from "@medusajs/types"
|
||||||
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
||||||
import { createStoresWorkflow } from "../../store"
|
import { createStoresWorkflow } from "../../store"
|
||||||
|
|
||||||
@@ -16,8 +16,13 @@ export const createDefaultStoreStep = createStep(
|
|||||||
let shouldDelete = false
|
let shouldDelete = false
|
||||||
let [store] = await storeService.list({}, { take: 1 })
|
let [store] = await storeService.list({}, { take: 1 })
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @todo
|
||||||
|
* Seems like we are missing an integration test when the
|
||||||
|
* following conditional as true.
|
||||||
|
*/
|
||||||
if (!store) {
|
if (!store) {
|
||||||
store = await createStoresWorkflow(container).run({
|
const stores = await createStoresWorkflow(container).run({
|
||||||
input: {
|
input: {
|
||||||
stores: [
|
stores: [
|
||||||
{
|
{
|
||||||
@@ -30,6 +35,12 @@ export const createDefaultStoreStep = createStep(
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
/**
|
||||||
|
* As per types, the result from "createStoresWorkflow.run" was
|
||||||
|
* an array of "StoreDTO". But at runtime it turns out to be
|
||||||
|
* a "StoreDTO"
|
||||||
|
*/
|
||||||
|
store = stores as unknown as StoreDTO
|
||||||
shouldDelete = true
|
shouldDelete = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -83,6 +83,7 @@ export const updateCartPromotionsStep = createStep(
|
|||||||
: []
|
: []
|
||||||
|
|
||||||
return new StepResponse(null, {
|
return new StepResponse(null, {
|
||||||
|
// @ts-expect-error
|
||||||
createdLinkIds: createdLinks.map((link) => link.id),
|
createdLinkIds: createdLinks.map((link) => link.id),
|
||||||
dismissedLinks: linksToDismiss,
|
dismissedLinks: linksToDismiss,
|
||||||
})
|
})
|
||||||
@@ -95,6 +96,7 @@ export const updateCartPromotionsStep = createStep(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (revertData?.createdLinkIds?.length) {
|
if (revertData?.createdLinkIds?.length) {
|
||||||
|
// @ts-expect-error
|
||||||
await remoteLink.delete(revertData.createdLinkIds)
|
await remoteLink.delete(revertData.createdLinkIds)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,6 +42,20 @@ export const adjustInventoryLevelsStep = createStep(
|
|||||||
|
|
||||||
const inventoryService = container.resolve(ModuleRegistrationName.INVENTORY)
|
const inventoryService = container.resolve(ModuleRegistrationName.INVENTORY)
|
||||||
|
|
||||||
await inventoryService.adjustInventory(adjustedLevels)
|
/**
|
||||||
|
* @todo
|
||||||
|
* The method "adjustInventory" was broken, it was receiving the
|
||||||
|
* "inventoryItemId" and "locationId" as snake case, whereas
|
||||||
|
* the expected object needed these properties as camelCase
|
||||||
|
*/
|
||||||
|
await inventoryService.adjustInventory(
|
||||||
|
adjustedLevels.map((level) => {
|
||||||
|
return {
|
||||||
|
inventoryItemId: level.inventory_item_id,
|
||||||
|
locationId: level.location_id,
|
||||||
|
adjustment: level.adjustment,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@@ -20,7 +20,7 @@ export const attachInventoryItemToVariants = createStep(
|
|||||||
.filter(({ tag }) => !!tag)
|
.filter(({ tag }) => !!tag)
|
||||||
.map(({ inventoryItemId, tag }) => ({
|
.map(({ inventoryItemId, tag }) => ({
|
||||||
productService: {
|
productService: {
|
||||||
variant_id: tag,
|
variant_id: tag!,
|
||||||
},
|
},
|
||||||
inventoryService: {
|
inventoryService: {
|
||||||
inventory_item_id: inventoryItemId,
|
inventory_item_id: inventoryItemId,
|
||||||
|
|||||||
+6
-10
@@ -1,11 +1,5 @@
|
|||||||
import {
|
import { ContainerRegistrationKeys, MedusaError } from "@medusajs/utils"
|
||||||
ContainerRegistrationKeys,
|
|
||||||
MedusaError,
|
|
||||||
remoteQueryObjectFromString,
|
|
||||||
} from "@medusajs/utils"
|
|
||||||
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
||||||
|
|
||||||
import { InventoryNext } from "@medusajs/types"
|
|
||||||
import { Modules } from "@medusajs/modules-sdk"
|
import { Modules } from "@medusajs/modules-sdk"
|
||||||
|
|
||||||
export const validateInventoryItemsForCreateStepId =
|
export const validateInventoryItemsForCreateStepId =
|
||||||
@@ -25,7 +19,7 @@ export const validateInventoryItemsForCreate = createStep(
|
|||||||
"variant_id",
|
"variant_id",
|
||||||
Modules.INVENTORY,
|
Modules.INVENTORY,
|
||||||
"inventory_item_id"
|
"inventory_item_id"
|
||||||
)
|
)!
|
||||||
|
|
||||||
const existingItems = await linkService.list(
|
const existingItems = await linkService.list(
|
||||||
{ variant_id: input.map((i) => i.tag) },
|
{ variant_id: input.map((i) => i.tag) },
|
||||||
@@ -33,10 +27,12 @@ export const validateInventoryItemsForCreate = createStep(
|
|||||||
)
|
)
|
||||||
|
|
||||||
if (existingItems.length) {
|
if (existingItems.length) {
|
||||||
|
// @ts-expect-error
|
||||||
|
const ids = existingItems.map((i) => i.variant_id).join(", ")
|
||||||
|
|
||||||
throw new MedusaError(
|
throw new MedusaError(
|
||||||
MedusaError.Types.NOT_ALLOWED,
|
MedusaError.Types.NOT_ALLOWED,
|
||||||
"Inventory items already exist for variants with ids: " +
|
`Inventory items already exist for variants with ids: ${ids}`
|
||||||
existingItems.map((i) => i.variant_id).join(", ")
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -26,12 +26,15 @@ export const getVariantPricingLinkStep = createStep(
|
|||||||
"variant_id",
|
"variant_id",
|
||||||
Modules.PRICING,
|
Modules.PRICING,
|
||||||
"price_set_id"
|
"price_set_id"
|
||||||
)
|
)!
|
||||||
|
|
||||||
const existingItems = await linkService.list(
|
const existingItems = (await linkService.list(
|
||||||
{ variant_id: data.ids },
|
{ variant_id: data.ids },
|
||||||
{ select: ["variant_id", "price_set_id"] }
|
{ select: ["variant_id", "price_set_id"] }
|
||||||
)
|
)) as {
|
||||||
|
variant_id: string
|
||||||
|
price_set_id: string
|
||||||
|
}[]
|
||||||
|
|
||||||
if (existingItems.length !== data.ids.length) {
|
if (existingItems.length !== data.ids.length) {
|
||||||
const missing = arrayDifference(
|
const missing = arrayDifference(
|
||||||
|
|||||||
@@ -78,16 +78,22 @@ export const updateProductVariantsWorkflow = createWorkflow(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ("product_variants" in data.input) {
|
if ("product_variants" in data.input) {
|
||||||
return data.variantPriceSetLinks.map((link) => {
|
return data.variantPriceSetLinks
|
||||||
const variant = (data.input as any).product_variants.find(
|
.map((link) => {
|
||||||
(v) => v.id === link.variant_id
|
if (!("product_variants" in data.input)) {
|
||||||
)
|
return
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
const variant = data.input.product_variants.find(
|
||||||
id: link.price_set_id,
|
(v) => v.id === link.variant_id
|
||||||
prices: variant.prices,
|
)!
|
||||||
} as PricingTypes.UpsertPriceSetDTO
|
|
||||||
})
|
return {
|
||||||
|
id: link.price_set_id,
|
||||||
|
prices: variant.prices,
|
||||||
|
} as PricingTypes.UpsertPriceSetDTO
|
||||||
|
})
|
||||||
|
.filter(Boolean)
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
import { Modules } from "@medusajs/modules-sdk"
|
import { Modules, RemoteLink } from "@medusajs/modules-sdk"
|
||||||
import { ContainerRegistrationKeys } from "@medusajs/utils"
|
import { ContainerRegistrationKeys } from "@medusajs/utils"
|
||||||
import { createStep, StepResponse } from "@medusajs/workflows-sdk"
|
import { createStep, StepResponse } from "@medusajs/workflows-sdk"
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,6 @@ export const createUsersStep = createStep(
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
const service = container.resolve(ModuleRegistrationName.USER)
|
const service = container.resolve(ModuleRegistrationName.USER)
|
||||||
await service.delete(createdUsers)
|
await service.delete(createdUsers.map((user) => user.id))
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
import {
|
import {
|
||||||
Constructor,
|
Constructor,
|
||||||
|
IModuleService,
|
||||||
InternalModuleDeclaration,
|
InternalModuleDeclaration,
|
||||||
Logger,
|
Logger,
|
||||||
MedusaContainer,
|
MedusaContainer,
|
||||||
@@ -158,9 +159,9 @@ export async function loadInternalModule(
|
|||||||
|
|
||||||
if (loaderOnly) {
|
if (loaderOnly) {
|
||||||
// The expectation is only to run the loader as standalone, so we do not need to register the service and we need to cleanup all services
|
// The expectation is only to run the loader as standalone, so we do not need to register the service and we need to cleanup all services
|
||||||
const service = container.resolve(registrationName)
|
const service = container.resolve<IModuleService>(registrationName)
|
||||||
await service.__hooks?.onApplicationPrepareShutdown()
|
await service.__hooks?.onApplicationPrepareShutdown?.()
|
||||||
await service.__hooks?.onApplicationShutdown()
|
await service.__hooks?.onApplicationShutdown?.()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,13 @@
|
|||||||
|
import type { Knex } from "knex"
|
||||||
import { mergeTypeDefs } from "@graphql-tools/merge"
|
import { mergeTypeDefs } from "@graphql-tools/merge"
|
||||||
import { makeExecutableSchema } from "@graphql-tools/schema"
|
import { makeExecutableSchema } from "@graphql-tools/schema"
|
||||||
import { RemoteFetchDataCallback } from "@medusajs/orchestration"
|
import { RemoteFetchDataCallback } from "@medusajs/orchestration"
|
||||||
import {
|
import type {
|
||||||
|
ConfigModule,
|
||||||
ExternalModuleDeclaration,
|
ExternalModuleDeclaration,
|
||||||
InternalModuleDeclaration,
|
InternalModuleDeclaration,
|
||||||
LoadedModule,
|
LoadedModule,
|
||||||
|
Logger,
|
||||||
MedusaContainer,
|
MedusaContainer,
|
||||||
ModuleDefinition,
|
ModuleDefinition,
|
||||||
ModuleExports,
|
ModuleExports,
|
||||||
@@ -36,6 +39,16 @@ import { cleanGraphQLSchema } from "./utils"
|
|||||||
|
|
||||||
const LinkModulePackage = MODULE_PACKAGE_NAMES[Modules.LINK]
|
const LinkModulePackage = MODULE_PACKAGE_NAMES[Modules.LINK]
|
||||||
|
|
||||||
|
declare module "@medusajs/types" {
|
||||||
|
export interface ModuleImplementations {
|
||||||
|
[ContainerRegistrationKeys.REMOTE_LINK]: RemoteLink
|
||||||
|
[ContainerRegistrationKeys.CONFIG_MODULE]: ConfigModule
|
||||||
|
[ContainerRegistrationKeys.PG_CONNECTION]: Knex<any>
|
||||||
|
[ContainerRegistrationKeys.REMOTE_QUERY]: RemoteQueryFunction
|
||||||
|
[ContainerRegistrationKeys.LOGGER]: Logger
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export type RunMigrationFn = (
|
export type RunMigrationFn = (
|
||||||
options?: ModuleServiceInitializeOptions,
|
options?: ModuleServiceInitializeOptions,
|
||||||
injectedDependencies?: Record<any, any>
|
injectedDependencies?: Record<any, any>
|
||||||
|
|||||||
@@ -29,3 +29,4 @@ export * as TaxTypes from "./tax"
|
|||||||
export * as TransactionBaseTypes from "./transaction-base"
|
export * as TransactionBaseTypes from "./transaction-base"
|
||||||
export * as UserTypes from "./user"
|
export * as UserTypes from "./user"
|
||||||
export * as WorkflowTypes from "./workflow"
|
export * as WorkflowTypes from "./workflow"
|
||||||
|
export * as WorkflowsSdkTypes from "./workflows-sdk"
|
||||||
@@ -1,19 +1,32 @@
|
|||||||
import { AwilixContainer } from "awilix"
|
import { AwilixContainer, ResolveOptions } from "awilix"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Medusa Container extends [Awilix](https://github.com/jeffijoe/awilix) to
|
* The following interface acts as a bucket that other modules or the
|
||||||
|
* utils package can fill using declaration merging
|
||||||
|
*/
|
||||||
|
export interface ModuleImplementations {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Medusa Container extends [Awilix](https://github.com/jeffijoe/awilix) to
|
||||||
* provide dependency injection functionalities.
|
* provide dependency injection functionalities.
|
||||||
*/
|
*/
|
||||||
export type MedusaContainer = AwilixContainer & {
|
export type MedusaContainer<Cradle extends object = ModuleImplementations> =
|
||||||
/**
|
Omit<AwilixContainer, "resolve"> & {
|
||||||
* @ignore
|
resolve<K extends keyof Cradle>(
|
||||||
*/
|
key: K,
|
||||||
registerAdd: <T>(name: string, registration: T) => MedusaContainer
|
resolveOptions?: ResolveOptions
|
||||||
/**
|
): Cradle[K]
|
||||||
* @ignore
|
resolve<T>(key: string, resolveOptions?: ResolveOptions): T
|
||||||
*/
|
|
||||||
createScope: () => MedusaContainer
|
/**
|
||||||
}
|
* @ignore
|
||||||
|
*/
|
||||||
|
registerAdd: <T>(name: string, registration: T) => MedusaContainer
|
||||||
|
/**
|
||||||
|
* @ignore
|
||||||
|
*/
|
||||||
|
createScope: () => MedusaContainer
|
||||||
|
}
|
||||||
|
|
||||||
export type ContainerLike = {
|
export type ContainerLike = {
|
||||||
resolve<T = unknown>(key: string): T
|
resolve<T = unknown>(key: string): T
|
||||||
|
|||||||
@@ -40,3 +40,4 @@ export * from "./transaction-base"
|
|||||||
export * from "./user"
|
export * from "./user"
|
||||||
export * from "./workflow"
|
export * from "./workflow"
|
||||||
export * from "./workflows"
|
export * from "./workflows"
|
||||||
|
export * from "./workflows-sdk"
|
||||||
@@ -282,7 +282,7 @@ export interface IStockLocationServiceNext extends IModuleService {
|
|||||||
* @example
|
* @example
|
||||||
* await stockLocationModuleService.delete("sloc_123")
|
* await stockLocationModuleService.delete("sloc_123")
|
||||||
*/
|
*/
|
||||||
delete(id: string, context?: Context): Promise<void>
|
delete(id: string | string[], context?: Context): Promise<void>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method soft deletes stock locations by their IDs.
|
* This method soft deletes stock locations by their IDs.
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ import { IModuleService } from "../modules-sdk"
|
|||||||
export interface IUserModuleService extends IModuleService {
|
export interface IUserModuleService extends IModuleService {
|
||||||
/**
|
/**
|
||||||
* This method validates that a token belongs to an invite and returns that invite.
|
* This method validates that a token belongs to an invite and returns that invite.
|
||||||
*
|
*
|
||||||
* An error is thrown if the invite has expired or no invite matches the token.
|
* An error is thrown if the invite has expired or no invite matches the token.
|
||||||
*
|
*
|
||||||
* @param {string} token - The token to validate
|
* @param {string} token - The token to validate
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
import { BaseFilterable, OperatorMap } from "@medusajs/types"
|
import { BaseFilterable, OperatorMap } from "../dal"
|
||||||
|
|
||||||
export interface WorkflowExecutionDTO {
|
export interface WorkflowExecutionDTO {
|
||||||
id: string
|
id: string
|
||||||
File renamed without changes.
File renamed without changes.
+4
-15
@@ -1,10 +1,6 @@
|
|||||||
import {
|
import { ContainerLike, FindConfig } from "../common"
|
||||||
ContainerLike,
|
import { IModuleService } from "../modules-sdk"
|
||||||
Context,
|
import { Context } from "../shared-context"
|
||||||
FindConfig,
|
|
||||||
IModuleService,
|
|
||||||
} from "@medusajs/types"
|
|
||||||
import { ReturnWorkflow, UnwrapWorkflowInputDataType } from "../utils/composer"
|
|
||||||
import {
|
import {
|
||||||
FilterableWorkflowExecutionProps,
|
FilterableWorkflowExecutionProps,
|
||||||
WorkflowExecutionDTO,
|
WorkflowExecutionDTO,
|
||||||
@@ -55,14 +51,7 @@ export interface IWorkflowEngineService extends IModuleService {
|
|||||||
sharedContext?: Context
|
sharedContext?: Context
|
||||||
): Promise<[WorkflowExecutionDTO[], number]>
|
): Promise<[WorkflowExecutionDTO[], number]>
|
||||||
|
|
||||||
run<
|
run(
|
||||||
TWorkflow extends ReturnWorkflow<any, any, any> = ReturnWorkflow<
|
|
||||||
any,
|
|
||||||
any,
|
|
||||||
any
|
|
||||||
>,
|
|
||||||
TData = UnwrapWorkflowInputDataType<TWorkflow>
|
|
||||||
>(
|
|
||||||
workflowId: string,
|
workflowId: string,
|
||||||
options?: WorkflowOrchestratorRunDTO,
|
options?: WorkflowOrchestratorRunDTO,
|
||||||
sharedContext?: Context
|
sharedContext?: Context
|
||||||
@@ -6,4 +6,4 @@ export const ContainerRegistrationKeys = {
|
|||||||
REMOTE_QUERY: "remoteQuery",
|
REMOTE_QUERY: "remoteQuery",
|
||||||
REMOTE_LINK: "remoteLink",
|
REMOTE_LINK: "remoteLink",
|
||||||
FEATURE_FLAG_ROUTER: "featureFlagRouter",
|
FEATURE_FLAG_ROUTER: "featureFlagRouter",
|
||||||
}
|
} as const
|
||||||
@@ -1,3 +1,29 @@
|
|||||||
|
import type {
|
||||||
|
IApiKeyModuleService,
|
||||||
|
IAuthModuleService,
|
||||||
|
ICacheService,
|
||||||
|
ICartModuleService,
|
||||||
|
ICurrencyModuleService,
|
||||||
|
ICustomerModuleService,
|
||||||
|
IEventBusModuleService,
|
||||||
|
IFileModuleService,
|
||||||
|
IFulfillmentModuleService,
|
||||||
|
IInventoryServiceNext,
|
||||||
|
INotificationModuleService,
|
||||||
|
IOrderModuleService,
|
||||||
|
IPaymentModuleService,
|
||||||
|
IPricingModuleService,
|
||||||
|
IProductModuleService,
|
||||||
|
IPromotionModuleService,
|
||||||
|
IRegionModuleService,
|
||||||
|
ISalesChannelModuleService,
|
||||||
|
IStockLocationServiceNext,
|
||||||
|
IStoreModuleService,
|
||||||
|
ITaxModuleService,
|
||||||
|
IUserModuleService,
|
||||||
|
IWorkflowEngineService,
|
||||||
|
} from "@medusajs/types"
|
||||||
|
|
||||||
export enum Modules {
|
export enum Modules {
|
||||||
AUTH = "auth",
|
AUTH = "auth",
|
||||||
CACHE = "cacheService",
|
CACHE = "cacheService",
|
||||||
@@ -24,3 +50,57 @@ export enum Modules {
|
|||||||
FILE = "file",
|
FILE = "file",
|
||||||
NOTIFICATION = "notification",
|
NOTIFICATION = "notification",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export enum ModuleRegistrationName {
|
||||||
|
AUTH = "authModuleService",
|
||||||
|
CACHE = "cacheService",
|
||||||
|
CART = "cartModuleService",
|
||||||
|
CUSTOMER = "customerModuleService",
|
||||||
|
EVENT_BUS = "eventBusModuleService",
|
||||||
|
INVENTORY = "inventoryService",
|
||||||
|
PAYMENT = "paymentModuleService",
|
||||||
|
PRICING = "pricingModuleService",
|
||||||
|
PRODUCT = "productModuleService",
|
||||||
|
PROMOTION = "promotionModuleService",
|
||||||
|
SALES_CHANNEL = "salesChannelModuleService",
|
||||||
|
FULFILLMENT = "fulfillmentModuleService",
|
||||||
|
STOCK_LOCATION = "stockLocationService",
|
||||||
|
TAX = "taxModuleService",
|
||||||
|
USER = "userModuleService",
|
||||||
|
WORKFLOW_ENGINE = "workflowsModuleService",
|
||||||
|
REGION = "regionModuleService",
|
||||||
|
ORDER = "orderModuleService",
|
||||||
|
API_KEY = "apiKeyModuleService",
|
||||||
|
STORE = "storeModuleService",
|
||||||
|
CURRENCY = "currencyModuleService",
|
||||||
|
FILE = "fileModuleService",
|
||||||
|
NOTIFICATION = "notificationModuleService",
|
||||||
|
}
|
||||||
|
|
||||||
|
declare module "@medusajs/types" {
|
||||||
|
export interface ModuleImplementations {
|
||||||
|
[ModuleRegistrationName.AUTH]: IAuthModuleService
|
||||||
|
[ModuleRegistrationName.CACHE]: ICacheService
|
||||||
|
[ModuleRegistrationName.CART]: ICartModuleService
|
||||||
|
[ModuleRegistrationName.CUSTOMER]: ICustomerModuleService
|
||||||
|
[ModuleRegistrationName.EVENT_BUS]: IEventBusModuleService
|
||||||
|
[ModuleRegistrationName.INVENTORY]: IInventoryServiceNext
|
||||||
|
[ModuleRegistrationName.PAYMENT]: IPaymentModuleService
|
||||||
|
[ModuleRegistrationName.PRICING]: IPricingModuleService
|
||||||
|
[ModuleRegistrationName.PRODUCT]: IProductModuleService
|
||||||
|
[ModuleRegistrationName.PROMOTION]: IPromotionModuleService
|
||||||
|
[ModuleRegistrationName.SALES_CHANNEL]: ISalesChannelModuleService
|
||||||
|
[ModuleRegistrationName.TAX]: ITaxModuleService
|
||||||
|
[ModuleRegistrationName.FULFILLMENT]: IFulfillmentModuleService
|
||||||
|
[ModuleRegistrationName.STOCK_LOCATION]: IStockLocationServiceNext
|
||||||
|
[ModuleRegistrationName.USER]: IUserModuleService
|
||||||
|
[ModuleRegistrationName.WORKFLOW_ENGINE]: IWorkflowEngineService
|
||||||
|
[ModuleRegistrationName.REGION]: IRegionModuleService
|
||||||
|
[ModuleRegistrationName.ORDER]: IOrderModuleService
|
||||||
|
[ModuleRegistrationName.API_KEY]: IApiKeyModuleService
|
||||||
|
[ModuleRegistrationName.STORE]: IStoreModuleService
|
||||||
|
[ModuleRegistrationName.CURRENCY]: ICurrencyModuleService
|
||||||
|
[ModuleRegistrationName.FILE]: IFileModuleService
|
||||||
|
[ModuleRegistrationName.NOTIFICATION]: INotificationModuleService
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,4 @@
|
|||||||
export * from "./helper"
|
export * from "./helper"
|
||||||
export * from "./medusa-workflow"
|
export * from "./medusa-workflow"
|
||||||
export * as WorkflowOrchestratorTypes from "./types"
|
|
||||||
export { IWorkflowEngineService } from "./types/service"
|
|
||||||
export * from "./utils/composer"
|
export * from "./utils/composer"
|
||||||
export * as Composer from "./utils/composer"
|
export * as Composer from "./utils/composer"
|
||||||
@@ -107,6 +107,7 @@ export const refetchBatchProducts = async (
|
|||||||
fields: remapKeysForProduct(fields ?? []),
|
fields: remapKeysForProduct(fields ?? []),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// @ts-expect-error "Remote query can return null"
|
||||||
created = remoteQuery(createdQuery)
|
created = remoteQuery(createdQuery)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -119,6 +120,7 @@ export const refetchBatchProducts = async (
|
|||||||
fields: remapKeysForProduct(fields ?? []),
|
fields: remapKeysForProduct(fields ?? []),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// @ts-expect-error "Remote query can return null"
|
||||||
updated = remoteQuery(updatedQuery)
|
updated = remoteQuery(updatedQuery)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -148,6 +150,7 @@ export const refetchBatchVariants = async (
|
|||||||
fields: remapKeysForVariant(fields ?? []),
|
fields: remapKeysForVariant(fields ?? []),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// @ts-expect-error "Remote query can return null"
|
||||||
created = remoteQuery(createdQuery)
|
created = remoteQuery(createdQuery)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -160,6 +163,7 @@ export const refetchBatchVariants = async (
|
|||||||
fields: remapKeysForVariant(fields ?? []),
|
fields: remapKeysForVariant(fields ?? []),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// @ts-expect-error "Remote query can return null"
|
||||||
updated = remoteQuery(updatedQuery)
|
updated = remoteQuery(updatedQuery)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ export const refetchBatchRules = async (
|
|||||||
fields: fields,
|
fields: fields,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// @ts-expect-error "Remote query can return null"
|
||||||
created = remoteQuery(createdQuery)
|
created = remoteQuery(createdQuery)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -54,6 +55,7 @@ export const refetchBatchRules = async (
|
|||||||
fields: fields,
|
fields: fields,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// @ts-expect-error "Remote query can return null"
|
||||||
updated = remoteQuery(updatedQuery)
|
updated = remoteQuery(updatedQuery)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ export const refetchBatchRules = async (
|
|||||||
fields: fields,
|
fields: fields,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// @ts-expect-error "Remote query can return null"
|
||||||
created = remoteQuery(createdQuery)
|
created = remoteQuery(createdQuery)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -57,6 +58,7 @@ export const refetchBatchRules = async (
|
|||||||
fields: fields,
|
fields: fields,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// @ts-expect-error "Remote query can return null"
|
||||||
updated = remoteQuery(updatedQuery)
|
updated = remoteQuery(updatedQuery)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -1,9 +1,9 @@
|
|||||||
|
import { IWorkflowEngineService } from "@medusajs/types"
|
||||||
import {
|
import {
|
||||||
AuthenticatedMedusaRequest,
|
AuthenticatedMedusaRequest,
|
||||||
MedusaResponse,
|
MedusaResponse,
|
||||||
} from "../../../../../../../types/routing"
|
} from "../../../../../../../types/routing"
|
||||||
|
|
||||||
import { IWorkflowEngineService } from "@medusajs/workflows-sdk"
|
|
||||||
import { ModuleRegistrationName } from "@medusajs/modules-sdk"
|
import { ModuleRegistrationName } from "@medusajs/modules-sdk"
|
||||||
|
|
||||||
export const GET = async (
|
export const GET = async (
|
||||||
|
|||||||
@@ -4,9 +4,8 @@ import {
|
|||||||
} from "../../../../../types/routing"
|
} from "../../../../../types/routing"
|
||||||
import {
|
import {
|
||||||
IWorkflowEngineService,
|
IWorkflowEngineService,
|
||||||
WorkflowOrchestratorTypes,
|
WorkflowOrchestratorRunDTO,
|
||||||
} from "@medusajs/workflows-sdk"
|
} from "@medusajs/types"
|
||||||
|
|
||||||
import { ModuleRegistrationName } from "@medusajs/modules-sdk"
|
import { ModuleRegistrationName } from "@medusajs/modules-sdk"
|
||||||
import { AdminCreateWorkflowsRunType } from "../../validators"
|
import { AdminCreateWorkflowsRunType } from "../../validators"
|
||||||
|
|
||||||
@@ -28,7 +27,7 @@ export const POST = async (
|
|||||||
context: {
|
context: {
|
||||||
requestId: req.requestId,
|
requestId: req.requestId,
|
||||||
},
|
},
|
||||||
} as WorkflowOrchestratorTypes.WorkflowOrchestratorRunDTO
|
} as WorkflowOrchestratorRunDTO
|
||||||
|
|
||||||
const { acknowledgement } = await workflowEngineService.run(
|
const { acknowledgement } = await workflowEngineService.run(
|
||||||
workflow_id,
|
workflow_id,
|
||||||
|
|||||||
+2
-1
@@ -2,11 +2,12 @@ import {
|
|||||||
AuthenticatedMedusaRequest,
|
AuthenticatedMedusaRequest,
|
||||||
MedusaResponse,
|
MedusaResponse,
|
||||||
} from "../../../../../../types/routing"
|
} from "../../../../../../types/routing"
|
||||||
import { IWorkflowEngineService, StepResponse } from "@medusajs/workflows-sdk"
|
import { StepResponse } from "@medusajs/workflows-sdk"
|
||||||
import { TransactionHandlerType, isDefined } from "@medusajs/utils"
|
import { TransactionHandlerType, isDefined } from "@medusajs/utils"
|
||||||
|
|
||||||
import { ModuleRegistrationName } from "@medusajs/modules-sdk"
|
import { ModuleRegistrationName } from "@medusajs/modules-sdk"
|
||||||
import { AdminCreateWorkflowsAsyncResponseType } from "../../../validators"
|
import { AdminCreateWorkflowsAsyncResponseType } from "../../../validators"
|
||||||
|
import { IWorkflowEngineService } from "@medusajs/types"
|
||||||
|
|
||||||
export const POST = async (
|
export const POST = async (
|
||||||
req: AuthenticatedMedusaRequest<AdminCreateWorkflowsAsyncResponseType>,
|
req: AuthenticatedMedusaRequest<AdminCreateWorkflowsAsyncResponseType>,
|
||||||
|
|||||||
+2
-1
@@ -2,11 +2,12 @@ import {
|
|||||||
AuthenticatedMedusaRequest,
|
AuthenticatedMedusaRequest,
|
||||||
MedusaResponse,
|
MedusaResponse,
|
||||||
} from "../../../../../../types/routing"
|
} from "../../../../../../types/routing"
|
||||||
import { IWorkflowEngineService, StepResponse } from "@medusajs/workflows-sdk"
|
import { StepResponse } from "@medusajs/workflows-sdk"
|
||||||
import { TransactionHandlerType, isDefined } from "@medusajs/utils"
|
import { TransactionHandlerType, isDefined } from "@medusajs/utils"
|
||||||
|
|
||||||
import { ModuleRegistrationName } from "@medusajs/modules-sdk"
|
import { ModuleRegistrationName } from "@medusajs/modules-sdk"
|
||||||
import { AdminCreateWorkflowsAsyncResponseType } from "../../../validators"
|
import { AdminCreateWorkflowsAsyncResponseType } from "../../../validators"
|
||||||
|
import { IWorkflowEngineService } from "@medusajs/types"
|
||||||
|
|
||||||
export const POST = async (
|
export const POST = async (
|
||||||
req: AuthenticatedMedusaRequest<AdminCreateWorkflowsAsyncResponseType>,
|
req: AuthenticatedMedusaRequest<AdminCreateWorkflowsAsyncResponseType>,
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
|
import { IWorkflowEngineService } from "@medusajs/types"
|
||||||
import {
|
import {
|
||||||
AuthenticatedMedusaRequest,
|
AuthenticatedMedusaRequest,
|
||||||
MedusaResponse,
|
MedusaResponse,
|
||||||
} from "../../../../../types/routing"
|
} from "../../../../../types/routing"
|
||||||
|
|
||||||
import { IWorkflowEngineService } from "@medusajs/workflows-sdk"
|
|
||||||
import { ModuleRegistrationName } from "@medusajs/modules-sdk"
|
import { ModuleRegistrationName } from "@medusajs/modules-sdk"
|
||||||
|
|
||||||
export const GET = async (
|
export const GET = async (
|
||||||
|
|||||||
@@ -62,7 +62,9 @@ export const GET = async (req: MedusaRequest, res: MedusaResponse) => {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
// @ts-expect-error
|
||||||
secret: jwtSecret,
|
secret: jwtSecret,
|
||||||
|
// @ts-expect-error
|
||||||
expiresIn: jwtExpiresIn,
|
expiresIn: jwtExpiresIn,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -69,7 +69,9 @@ export const GET = async (req: MedusaRequest, res: MedusaResponse) => {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
// @ts-expect-error
|
||||||
secret: jwtSecret,
|
secret: jwtSecret,
|
||||||
|
// @ts-expect-error
|
||||||
expiresIn: jwtExpiresIn,
|
expiresIn: jwtExpiresIn,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ export const POST = async (req: MedusaRequest, res: MedusaResponse) => {
|
|||||||
const { provider } = req.params
|
const { provider } = req.params
|
||||||
|
|
||||||
const options: PaymentModuleOptions =
|
const options: PaymentModuleOptions =
|
||||||
|
// @ts-expect-error "Not sure if .options exists on a module"
|
||||||
req.scope.resolve(ModuleRegistrationName.PAYMENT).options || {}
|
req.scope.resolve(ModuleRegistrationName.PAYMENT).options || {}
|
||||||
|
|
||||||
const event = {
|
const event = {
|
||||||
|
|||||||
@@ -160,6 +160,7 @@ export default async ({
|
|||||||
|
|
||||||
await promiseAll([
|
await promiseAll([
|
||||||
container.dispose(),
|
container.dispose(),
|
||||||
|
// @ts-expect-error "Do we want to call `client.destroy` "
|
||||||
pgConnection?.context?.destroy(),
|
pgConnection?.context?.destroy(),
|
||||||
entrypointsShutdown(),
|
entrypointsShutdown(),
|
||||||
])
|
])
|
||||||
|
|||||||
@@ -13,10 +13,9 @@ export default async ({
|
|||||||
// TODO: Add default logger to the container when running tests
|
// TODO: Add default logger to the container when running tests
|
||||||
const logger =
|
const logger =
|
||||||
container.resolve<Logger>(ContainerRegistrationKeys.LOGGER) ?? console
|
container.resolve<Logger>(ContainerRegistrationKeys.LOGGER) ?? console
|
||||||
const {
|
const { currencyService_ } = container.resolve<{
|
||||||
currencyService_,
|
currencyService_: ModulesSdkTypes.InternalModuleService<Currency>
|
||||||
}: { currencyService_: ModulesSdkTypes.InternalModuleService<Currency> } =
|
}>(ModuleRegistrationName.CURRENCY)
|
||||||
container.resolve(ModuleRegistrationName.CURRENCY)
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const normalizedCurrencies = Object.values(defaultCurrencies).map((c) => ({
|
const normalizedCurrencies = Object.values(defaultCurrencies).map((c) => ({
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
import {
|
import { CreatePaymentProviderDTO, LoaderOptions } from "@medusajs/types"
|
||||||
CreatePaymentProviderDTO,
|
import { PaymentProviderService } from "@services"
|
||||||
LoaderOptions
|
|
||||||
} from "@medusajs/types"
|
|
||||||
|
|
||||||
export default async ({ container }: LoaderOptions): Promise<void> => {
|
export default async ({ container }: LoaderOptions): Promise<void> => {
|
||||||
const providersToLoad = container.resolve("payment_providers")
|
const providersToLoad = container.resolve<string[]>("payment_providers")
|
||||||
const paymentProviderService = container.resolve("paymentProviderService")
|
const paymentProviderService = container.resolve<PaymentProviderService>(
|
||||||
|
"paymentProviderService"
|
||||||
|
)
|
||||||
|
|
||||||
const providers = await paymentProviderService.list({
|
const providers = await paymentProviderService.list({
|
||||||
id: providersToLoad,
|
id: providersToLoad,
|
||||||
|
|||||||
@@ -57,8 +57,8 @@ export default class PaymentProviderService {
|
|||||||
|
|
||||||
@InjectManager("paymentProviderRepository_")
|
@InjectManager("paymentProviderRepository_")
|
||||||
async list(
|
async list(
|
||||||
filters: FilterablePaymentProviderProps,
|
filters?: FilterablePaymentProviderProps,
|
||||||
config: FindConfig<PaymentProviderDTO>,
|
config?: FindConfig<PaymentProviderDTO>,
|
||||||
@MedusaContext() sharedContext?: Context
|
@MedusaContext() sharedContext?: Context
|
||||||
): Promise<PaymentProvider[]> {
|
): Promise<PaymentProvider[]> {
|
||||||
const queryOptions = ModulesSdkUtils.buildQuery<PaymentProvider>(
|
const queryOptions = ModulesSdkUtils.buildQuery<PaymentProvider>(
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import {
|
|||||||
ModuleJoinerConfig,
|
ModuleJoinerConfig,
|
||||||
StockLocationAddressInput,
|
StockLocationAddressInput,
|
||||||
StockLocationTypes,
|
StockLocationTypes,
|
||||||
UpdateStockLocationInput,
|
|
||||||
ModulesSdkTypes,
|
ModulesSdkTypes,
|
||||||
DAL,
|
DAL,
|
||||||
IStockLocationServiceNext,
|
IStockLocationServiceNext,
|
||||||
|
|||||||
@@ -2,9 +2,11 @@ import {
|
|||||||
Context,
|
Context,
|
||||||
DAL,
|
DAL,
|
||||||
FindConfig,
|
FindConfig,
|
||||||
|
IWorkflowEngineService,
|
||||||
InternalModuleDeclaration,
|
InternalModuleDeclaration,
|
||||||
ModuleJoinerConfig,
|
ModuleJoinerConfig,
|
||||||
ModulesSdkTypes,
|
ModulesSdkTypes,
|
||||||
|
WorkflowsSdkTypes,
|
||||||
} from "@medusajs/types"
|
} from "@medusajs/types"
|
||||||
import {
|
import {
|
||||||
InjectManager,
|
InjectManager,
|
||||||
@@ -14,10 +16,8 @@ import {
|
|||||||
MedusaError,
|
MedusaError,
|
||||||
} from "@medusajs/utils"
|
} from "@medusajs/utils"
|
||||||
import type {
|
import type {
|
||||||
IWorkflowEngineService,
|
|
||||||
ReturnWorkflow,
|
ReturnWorkflow,
|
||||||
UnwrapWorkflowInputDataType,
|
UnwrapWorkflowInputDataType,
|
||||||
WorkflowOrchestratorTypes,
|
|
||||||
} from "@medusajs/workflows-sdk"
|
} from "@medusajs/workflows-sdk"
|
||||||
import { WorkflowOrchestratorService } from "@services"
|
import { WorkflowOrchestratorService } from "@services"
|
||||||
import { joinerConfig } from "../joiner-config"
|
import { joinerConfig } from "../joiner-config"
|
||||||
@@ -58,9 +58,9 @@ export class WorkflowsModuleService implements IWorkflowEngineService {
|
|||||||
workflow_id: string
|
workflow_id: string
|
||||||
transaction_id: string
|
transaction_id: string
|
||||||
},
|
},
|
||||||
config: FindConfig<WorkflowOrchestratorTypes.WorkflowExecutionDTO> = {},
|
config: FindConfig<WorkflowsSdkTypes.WorkflowExecutionDTO> = {},
|
||||||
@MedusaContext() sharedContext: Context = {}
|
@MedusaContext() sharedContext: Context = {}
|
||||||
): Promise<WorkflowOrchestratorTypes.WorkflowExecutionDTO> {
|
): Promise<WorkflowsSdkTypes.WorkflowExecutionDTO> {
|
||||||
const objValue = isString(idOrObject)
|
const objValue = isString(idOrObject)
|
||||||
? { id: idOrObject }
|
? { id: idOrObject }
|
||||||
: {
|
: {
|
||||||
@@ -84,7 +84,7 @@ export class WorkflowsModuleService implements IWorkflowEngineService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line max-len
|
// eslint-disable-next-line max-len
|
||||||
return await this.baseRepository_.serialize<WorkflowOrchestratorTypes.WorkflowExecutionDTO>(
|
return await this.baseRepository_.serialize<WorkflowsSdkTypes.WorkflowExecutionDTO>(
|
||||||
wfExecution[0],
|
wfExecution[0],
|
||||||
{
|
{
|
||||||
populate: true,
|
populate: true,
|
||||||
@@ -94,10 +94,10 @@ export class WorkflowsModuleService implements IWorkflowEngineService {
|
|||||||
|
|
||||||
@InjectManager("baseRepository_")
|
@InjectManager("baseRepository_")
|
||||||
async listWorkflowExecution(
|
async listWorkflowExecution(
|
||||||
filters: WorkflowOrchestratorTypes.FilterableWorkflowExecutionProps = {},
|
filters: WorkflowsSdkTypes.FilterableWorkflowExecutionProps = {},
|
||||||
config: FindConfig<WorkflowOrchestratorTypes.WorkflowExecutionDTO> = {},
|
config: FindConfig<WorkflowsSdkTypes.WorkflowExecutionDTO> = {},
|
||||||
@MedusaContext() sharedContext: Context = {}
|
@MedusaContext() sharedContext: Context = {}
|
||||||
): Promise<WorkflowOrchestratorTypes.WorkflowExecutionDTO[]> {
|
): Promise<WorkflowsSdkTypes.WorkflowExecutionDTO[]> {
|
||||||
if (filters.transaction_id) {
|
if (filters.transaction_id) {
|
||||||
if (Array.isArray(filters.transaction_id)) {
|
if (Array.isArray(filters.transaction_id)) {
|
||||||
filters.transaction_id = {
|
filters.transaction_id = {
|
||||||
@@ -121,7 +121,7 @@ export class WorkflowsModuleService implements IWorkflowEngineService {
|
|||||||
)
|
)
|
||||||
|
|
||||||
return await this.baseRepository_.serialize<
|
return await this.baseRepository_.serialize<
|
||||||
WorkflowOrchestratorTypes.WorkflowExecutionDTO[]
|
WorkflowsSdkTypes.WorkflowExecutionDTO[]
|
||||||
>(wfExecutions, {
|
>(wfExecutions, {
|
||||||
populate: true,
|
populate: true,
|
||||||
})
|
})
|
||||||
@@ -129,10 +129,10 @@ export class WorkflowsModuleService implements IWorkflowEngineService {
|
|||||||
|
|
||||||
@InjectManager("baseRepository_")
|
@InjectManager("baseRepository_")
|
||||||
async listAndCountWorkflowExecution(
|
async listAndCountWorkflowExecution(
|
||||||
filters: WorkflowOrchestratorTypes.FilterableWorkflowExecutionProps = {},
|
filters: WorkflowsSdkTypes.FilterableWorkflowExecutionProps = {},
|
||||||
config: FindConfig<WorkflowOrchestratorTypes.WorkflowExecutionDTO> = {},
|
config: FindConfig<WorkflowsSdkTypes.WorkflowExecutionDTO> = {},
|
||||||
@MedusaContext() sharedContext: Context = {}
|
@MedusaContext() sharedContext: Context = {}
|
||||||
): Promise<[WorkflowOrchestratorTypes.WorkflowExecutionDTO[], number]> {
|
): Promise<[WorkflowsSdkTypes.WorkflowExecutionDTO[], number]> {
|
||||||
if (filters.transaction_id) {
|
if (filters.transaction_id) {
|
||||||
if (Array.isArray(filters.transaction_id)) {
|
if (Array.isArray(filters.transaction_id)) {
|
||||||
filters.transaction_id = {
|
filters.transaction_id = {
|
||||||
@@ -158,7 +158,7 @@ export class WorkflowsModuleService implements IWorkflowEngineService {
|
|||||||
|
|
||||||
return [
|
return [
|
||||||
await this.baseRepository_.serialize<
|
await this.baseRepository_.serialize<
|
||||||
WorkflowOrchestratorTypes.WorkflowExecutionDTO[]
|
WorkflowsSdkTypes.WorkflowExecutionDTO[]
|
||||||
>(wfExecutions, {
|
>(wfExecutions, {
|
||||||
populate: true,
|
populate: true,
|
||||||
}),
|
}),
|
||||||
@@ -169,7 +169,7 @@ export class WorkflowsModuleService implements IWorkflowEngineService {
|
|||||||
@InjectSharedContext()
|
@InjectSharedContext()
|
||||||
async run<TWorkflow extends string | ReturnWorkflow<any, any, any>>(
|
async run<TWorkflow extends string | ReturnWorkflow<any, any, any>>(
|
||||||
workflowIdOrWorkflow: TWorkflow,
|
workflowIdOrWorkflow: TWorkflow,
|
||||||
options: WorkflowOrchestratorTypes.WorkflowOrchestratorRunDTO<
|
options: WorkflowsSdkTypes.WorkflowOrchestratorRunDTO<
|
||||||
TWorkflow extends ReturnWorkflow<any, any, any>
|
TWorkflow extends ReturnWorkflow<any, any, any>
|
||||||
? UnwrapWorkflowInputDataType<TWorkflow>
|
? UnwrapWorkflowInputDataType<TWorkflow>
|
||||||
: unknown
|
: unknown
|
||||||
|
|||||||
@@ -2,9 +2,11 @@ import {
|
|||||||
Context,
|
Context,
|
||||||
DAL,
|
DAL,
|
||||||
FindConfig,
|
FindConfig,
|
||||||
|
IWorkflowEngineService,
|
||||||
InternalModuleDeclaration,
|
InternalModuleDeclaration,
|
||||||
ModuleJoinerConfig,
|
ModuleJoinerConfig,
|
||||||
ModulesSdkTypes,
|
ModulesSdkTypes,
|
||||||
|
WorkflowsSdkTypes,
|
||||||
} from "@medusajs/types"
|
} from "@medusajs/types"
|
||||||
import {
|
import {
|
||||||
InjectManager,
|
InjectManager,
|
||||||
@@ -14,10 +16,8 @@ import {
|
|||||||
isString,
|
isString,
|
||||||
} from "@medusajs/utils"
|
} from "@medusajs/utils"
|
||||||
import type {
|
import type {
|
||||||
IWorkflowEngineService,
|
|
||||||
ReturnWorkflow,
|
ReturnWorkflow,
|
||||||
UnwrapWorkflowInputDataType,
|
UnwrapWorkflowInputDataType,
|
||||||
WorkflowOrchestratorTypes,
|
|
||||||
} from "@medusajs/workflows-sdk"
|
} from "@medusajs/workflows-sdk"
|
||||||
import { WorkflowOrchestratorService } from "@services"
|
import { WorkflowOrchestratorService } from "@services"
|
||||||
import { joinerConfig } from "../joiner-config"
|
import { joinerConfig } from "../joiner-config"
|
||||||
@@ -72,9 +72,9 @@ export class WorkflowsModuleService implements IWorkflowEngineService {
|
|||||||
workflow_id: string
|
workflow_id: string
|
||||||
transaction_id: string
|
transaction_id: string
|
||||||
},
|
},
|
||||||
config: FindConfig<WorkflowOrchestratorTypes.WorkflowExecutionDTO> = {},
|
config: FindConfig<WorkflowsSdkTypes.WorkflowExecutionDTO> = {},
|
||||||
@MedusaContext() sharedContext: Context = {}
|
@MedusaContext() sharedContext: Context = {}
|
||||||
): Promise<WorkflowOrchestratorTypes.WorkflowExecutionDTO> {
|
): Promise<WorkflowsSdkTypes.WorkflowExecutionDTO> {
|
||||||
const objValue = isString(idOrObject)
|
const objValue = isString(idOrObject)
|
||||||
? { id: idOrObject }
|
? { id: idOrObject }
|
||||||
: {
|
: {
|
||||||
@@ -98,7 +98,7 @@ export class WorkflowsModuleService implements IWorkflowEngineService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line max-len
|
// eslint-disable-next-line max-len
|
||||||
return await this.baseRepository_.serialize<WorkflowOrchestratorTypes.WorkflowExecutionDTO>(
|
return await this.baseRepository_.serialize<WorkflowsSdkTypes.WorkflowExecutionDTO>(
|
||||||
wfExecution[0],
|
wfExecution[0],
|
||||||
{
|
{
|
||||||
populate: true,
|
populate: true,
|
||||||
@@ -108,10 +108,10 @@ export class WorkflowsModuleService implements IWorkflowEngineService {
|
|||||||
|
|
||||||
@InjectManager("baseRepository_")
|
@InjectManager("baseRepository_")
|
||||||
async listWorkflowExecution(
|
async listWorkflowExecution(
|
||||||
filters: WorkflowOrchestratorTypes.FilterableWorkflowExecutionProps = {},
|
filters: WorkflowsSdkTypes.FilterableWorkflowExecutionProps = {},
|
||||||
config: FindConfig<WorkflowOrchestratorTypes.WorkflowExecutionDTO> = {},
|
config: FindConfig<WorkflowsSdkTypes.WorkflowExecutionDTO> = {},
|
||||||
@MedusaContext() sharedContext: Context = {}
|
@MedusaContext() sharedContext: Context = {}
|
||||||
): Promise<WorkflowOrchestratorTypes.WorkflowExecutionDTO[]> {
|
): Promise<WorkflowsSdkTypes.WorkflowExecutionDTO[]> {
|
||||||
if (filters.transaction_id) {
|
if (filters.transaction_id) {
|
||||||
if (Array.isArray(filters.transaction_id)) {
|
if (Array.isArray(filters.transaction_id)) {
|
||||||
filters.transaction_id = {
|
filters.transaction_id = {
|
||||||
@@ -135,7 +135,7 @@ export class WorkflowsModuleService implements IWorkflowEngineService {
|
|||||||
)
|
)
|
||||||
|
|
||||||
return await this.baseRepository_.serialize<
|
return await this.baseRepository_.serialize<
|
||||||
WorkflowOrchestratorTypes.WorkflowExecutionDTO[]
|
WorkflowsSdkTypes.WorkflowExecutionDTO[]
|
||||||
>(wfExecutions, {
|
>(wfExecutions, {
|
||||||
populate: true,
|
populate: true,
|
||||||
})
|
})
|
||||||
@@ -143,10 +143,10 @@ export class WorkflowsModuleService implements IWorkflowEngineService {
|
|||||||
|
|
||||||
@InjectManager("baseRepository_")
|
@InjectManager("baseRepository_")
|
||||||
async listAndCountWorkflowExecution(
|
async listAndCountWorkflowExecution(
|
||||||
filters: WorkflowOrchestratorTypes.FilterableWorkflowExecutionProps = {},
|
filters: WorkflowsSdkTypes.FilterableWorkflowExecutionProps = {},
|
||||||
config: FindConfig<WorkflowOrchestratorTypes.WorkflowExecutionDTO> = {},
|
config: FindConfig<WorkflowsSdkTypes.WorkflowExecutionDTO> = {},
|
||||||
@MedusaContext() sharedContext: Context = {}
|
@MedusaContext() sharedContext: Context = {}
|
||||||
): Promise<[WorkflowOrchestratorTypes.WorkflowExecutionDTO[], number]> {
|
): Promise<[WorkflowsSdkTypes.WorkflowExecutionDTO[], number]> {
|
||||||
if (filters.transaction_id) {
|
if (filters.transaction_id) {
|
||||||
if (Array.isArray(filters.transaction_id)) {
|
if (Array.isArray(filters.transaction_id)) {
|
||||||
filters.transaction_id = {
|
filters.transaction_id = {
|
||||||
@@ -172,7 +172,7 @@ export class WorkflowsModuleService implements IWorkflowEngineService {
|
|||||||
|
|
||||||
return [
|
return [
|
||||||
await this.baseRepository_.serialize<
|
await this.baseRepository_.serialize<
|
||||||
WorkflowOrchestratorTypes.WorkflowExecutionDTO[]
|
WorkflowsSdkTypes.WorkflowExecutionDTO[]
|
||||||
>(wfExecutions, {
|
>(wfExecutions, {
|
||||||
populate: true,
|
populate: true,
|
||||||
}),
|
}),
|
||||||
@@ -183,7 +183,7 @@ export class WorkflowsModuleService implements IWorkflowEngineService {
|
|||||||
@InjectSharedContext()
|
@InjectSharedContext()
|
||||||
async run<TWorkflow extends string | ReturnWorkflow<any, any, any>>(
|
async run<TWorkflow extends string | ReturnWorkflow<any, any, any>>(
|
||||||
workflowIdOrWorkflow: TWorkflow,
|
workflowIdOrWorkflow: TWorkflow,
|
||||||
options: WorkflowOrchestratorTypes.WorkflowOrchestratorRunDTO<
|
options: WorkflowsSdkTypes.WorkflowOrchestratorRunDTO<
|
||||||
TWorkflow extends ReturnWorkflow<any, any, any>
|
TWorkflow extends ReturnWorkflow<any, any, any>
|
||||||
? UnwrapWorkflowInputDataType<TWorkflow>
|
? UnwrapWorkflowInputDataType<TWorkflow>
|
||||||
: unknown
|
: unknown
|
||||||
|
|||||||
Reference in new issue
Block a user