feat: loosely typed container
This commit is contained in:
@@ -1,6 +1,4 @@
|
||||
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"
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
import { BaseFilterable, OperatorMap } from "@medusajs/types"
|
||||
|
||||
export interface WorkflowExecutionDTO {
|
||||
id: string
|
||||
workflow_id: string
|
||||
transaction_id: string
|
||||
execution: string
|
||||
context: string
|
||||
state: any
|
||||
created_at: Date
|
||||
updated_at: Date
|
||||
deleted_at: Date
|
||||
}
|
||||
|
||||
export interface FilterableWorkflowExecutionProps
|
||||
extends BaseFilterable<FilterableWorkflowExecutionProps> {
|
||||
id?: string | string[] | OperatorMap<string>
|
||||
workflow_id?: string | string[] | OperatorMap<string>
|
||||
transaction_id?: string | string[] | OperatorMap<string>
|
||||
state?: string | string[] | OperatorMap<string>
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
export * from "./common"
|
||||
export * from "./mutations"
|
||||
export * from "./service"
|
||||
@@ -1,7 +0,0 @@
|
||||
export interface UpsertWorkflowExecutionDTO {
|
||||
workflow_id: string
|
||||
transaction_id: string
|
||||
execution: Record<string, unknown>
|
||||
context: Record<string, unknown>
|
||||
state: any
|
||||
}
|
||||
@@ -1,127 +0,0 @@
|
||||
import {
|
||||
ContainerLike,
|
||||
Context,
|
||||
FindConfig,
|
||||
IModuleService,
|
||||
} from "@medusajs/types"
|
||||
import { ReturnWorkflow, UnwrapWorkflowInputDataType } from "../utils/composer"
|
||||
import {
|
||||
FilterableWorkflowExecutionProps,
|
||||
WorkflowExecutionDTO,
|
||||
} from "./common"
|
||||
|
||||
type FlowRunOptions<TData = unknown> = {
|
||||
input?: TData
|
||||
context?: Context
|
||||
resultFrom?: string | string[] | Symbol
|
||||
throwOnError?: boolean
|
||||
events?: Record<string, Function>
|
||||
}
|
||||
|
||||
export interface WorkflowOrchestratorRunDTO<T = unknown>
|
||||
extends FlowRunOptions<T> {
|
||||
transactionId?: string
|
||||
container?: ContainerLike
|
||||
}
|
||||
|
||||
export type IdempotencyKeyParts = {
|
||||
workflowId: string
|
||||
transactionId: string
|
||||
stepId: string
|
||||
action: "invoke" | "compensate"
|
||||
}
|
||||
|
||||
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>,
|
||||
sharedContext?: Context
|
||||
): Promise<WorkflowExecutionDTO[]>
|
||||
|
||||
listAndCountWorkflowExecution(
|
||||
filters?: FilterableWorkflowExecutionProps,
|
||||
config?: FindConfig<WorkflowExecutionDTO>,
|
||||
sharedContext?: Context
|
||||
): Promise<[WorkflowExecutionDTO[], number]>
|
||||
|
||||
run<
|
||||
TWorkflow extends ReturnWorkflow<any, any, any> = ReturnWorkflow<
|
||||
any,
|
||||
any,
|
||||
any
|
||||
>,
|
||||
TData = UnwrapWorkflowInputDataType<TWorkflow>
|
||||
>(
|
||||
workflowId: string,
|
||||
options?: WorkflowOrchestratorRunDTO,
|
||||
sharedContext?: Context
|
||||
): Promise<{
|
||||
errors: Error[]
|
||||
transaction: object
|
||||
result: any
|
||||
acknowledgement: object
|
||||
}>
|
||||
|
||||
getRunningTransaction(
|
||||
workflowId: string,
|
||||
transactionId: string,
|
||||
options?: Record<string, any>,
|
||||
sharedContext?: Context
|
||||
): Promise<unknown>
|
||||
|
||||
setStepSuccess(
|
||||
{
|
||||
idempotencyKey,
|
||||
stepResponse,
|
||||
options,
|
||||
}: {
|
||||
idempotencyKey: string | IdempotencyKeyParts
|
||||
stepResponse: unknown
|
||||
options?: Record<string, any>
|
||||
},
|
||||
sharedContext?: Context
|
||||
)
|
||||
|
||||
setStepFailure(
|
||||
{
|
||||
idempotencyKey,
|
||||
stepResponse,
|
||||
options,
|
||||
}: {
|
||||
idempotencyKey: string | IdempotencyKeyParts
|
||||
stepResponse: unknown
|
||||
options?: Record<string, any>
|
||||
},
|
||||
sharedContext?: Context
|
||||
)
|
||||
|
||||
subscribe(
|
||||
args: {
|
||||
workflowId: string
|
||||
transactionId?: string
|
||||
subscriber: Function
|
||||
subscriberId?: string
|
||||
},
|
||||
sharedContext?: Context
|
||||
): Promise<void>
|
||||
|
||||
unsubscribe(
|
||||
args: {
|
||||
workflowId: string
|
||||
transactionId?: string
|
||||
subscriberOrId: string | Function
|
||||
},
|
||||
sharedContext?: Context
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user