feat(medusa,workflows) Create cart workflow (#4685)
* chore: add baseline test for create cart * chore: add basic paths into handlers + make first tests pass * chore: move input alias to cart specific workflow * chore: move data around into buckets * chore: normalize handlers and introduce types * chore: move aliases to handlers concern * chore: add compensation step for create cart * chore: merge with latest develop * chore: handle error manually + type inputs * chore: handle error manually * chore: added types for each handler * chore: remove addresses * chore: added changset * chore: undo package changes * chore: added config settings to retreieve, cleanup of types * chore: capitalize cart handlers * chore: rename todo * chore: add feature flag for workflow * chore: reorder handlers * chore: add logger to route handler * chore: removed weird vscode moving around things * chore: refactor handlers * chore: refactor compensate step * chore: changed poistion * chore: aggregate config data * chore: moved handlers to their own domain + pr review addressing * chore: address pr reviews * chore: move types to type package * chore: update type to include config * chore: remove error scoping
This commit is contained in:
2
packages/workflows/src/handlers/common/index.ts
Normal file
2
packages/workflows/src/handlers/common/index.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
export * from "./set-config"
|
||||
export * from "./set-context"
|
||||
31
packages/workflows/src/handlers/common/set-config.ts
Normal file
31
packages/workflows/src/handlers/common/set-config.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
import { WorkflowArguments } from "../../helper"
|
||||
|
||||
type ConfigDTO = {
|
||||
retrieveConfig?: {
|
||||
select?: string[]
|
||||
relations?: string[]
|
||||
}
|
||||
}
|
||||
|
||||
enum Aliases {
|
||||
Config = "config",
|
||||
}
|
||||
|
||||
type HandlerInputData = {
|
||||
config: {
|
||||
retrieveConfig?: {
|
||||
select?: string[]
|
||||
relations?: string[]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export async function setConfig({
|
||||
data,
|
||||
}: WorkflowArguments<HandlerInputData>): Promise<ConfigDTO> {
|
||||
return {
|
||||
retrieveConfig: data[Aliases.Config].retrieveConfig,
|
||||
}
|
||||
}
|
||||
|
||||
setConfig.aliases = Aliases
|
||||
27
packages/workflows/src/handlers/common/set-context.ts
Normal file
27
packages/workflows/src/handlers/common/set-context.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import { WorkflowArguments } from "../../helper"
|
||||
|
||||
type ContextDTO = {
|
||||
context?: Record<any, any>
|
||||
}
|
||||
|
||||
enum Aliases {
|
||||
Context = "context",
|
||||
}
|
||||
|
||||
type HandlerInputData = {
|
||||
context: {
|
||||
context?: Record<any, any>
|
||||
}
|
||||
}
|
||||
|
||||
export async function setContext({
|
||||
data,
|
||||
}: WorkflowArguments<HandlerInputData>): Promise<ContextDTO> {
|
||||
const contextDTO: ContextDTO = {
|
||||
context: data[Aliases.Context].context,
|
||||
}
|
||||
|
||||
return contextDTO
|
||||
}
|
||||
|
||||
setContext.aliases = Aliases
|
||||
Reference in New Issue
Block a user