feat(medusa): workflow engine api (#6330)

What:

   Workflow Engine API.
   Endpoints for:
     - List workflow executions
     - Run a workflow
     - Set async steps as success or failure
     - Retrieve the details of a workflow run
This commit is contained in:
Carlos R. L. Rodrigues
2024-02-13 15:19:10 +00:00
committed by GitHub
parent 59ab66a773
commit 0c2a460751
44 changed files with 1425 additions and 80 deletions
+1
View File
@@ -1,5 +1,6 @@
export * from "./helper"
export * from "./medusa-workflow"
export * as WorkflowOrchestratorTypes from "./types"
export { IWorkflowEngineService } from "./types/service"
export * from "./utils/composer"
export * as Composer from "./utils/composer"
+5 -5
View File
@@ -1,4 +1,4 @@
import { BaseFilterable } from "@medusajs/types"
import { BaseFilterable, OperatorMap } from "@medusajs/types"
export interface WorkflowExecutionDTO {
id: string
@@ -14,8 +14,8 @@ export interface WorkflowExecutionDTO {
export interface FilterableWorkflowExecutionProps
extends BaseFilterable<FilterableWorkflowExecutionProps> {
id?: string[]
workflow_id?: string[]
transaction_id?: string[]
state?: any[]
id?: string | string[] | OperatorMap<string>
workflow_id?: string | string[] | OperatorMap<string>
transaction_id?: string | string[] | OperatorMap<string>
state?: string | string[] | OperatorMap<string>
}
+13 -2
View File
@@ -31,7 +31,18 @@ export type IdempotencyKeyParts = {
action: "invoke" | "compensate"
}
export interface IWorkflowsModuleService extends IModuleService {
export interface IWorkflowEngineService extends IModuleService {
retrieveWorkflowExecution(
idOrObject:
| string
| {
workflow_id: string
transaction_id: string
},
config?: FindConfig<WorkflowExecutionDTO>,
sharedContext?: Context
): Promise<WorkflowExecutionDTO>
listWorkflowExecution(
filters?: FilterableWorkflowExecutionProps,
config?: FindConfig<WorkflowExecutionDTO>,
@@ -88,7 +99,7 @@ export interface IWorkflowsModuleService extends IModuleService {
stepResponse,
options,
}: {
idempotencyKey: string | object
idempotencyKey: string | IdempotencyKeyParts
stepResponse: unknown
options?: Record<string, any>
},