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:
Riqwan Thamir
2023-08-08 12:10:27 +02:00
committed by GitHub
parent a42c41e8ab
commit 281b0746cf
35 changed files with 1140 additions and 13 deletions

View File

@@ -0,0 +1,2 @@
export * from "./set-config"
export * from "./set-context"

View 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

View 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