feat(workflows-sdk): additional properties to context (#6760)
This commit is contained in:
committed by
GitHub
parent
20243e22ee
commit
3ca957ec0f
5
.changeset/violet-bikes-develop.md
Normal file
5
.changeset/violet-bikes-develop.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@medusajs/workflows-sdk": patch
|
||||
---
|
||||
|
||||
Added idempotencyKey to workflow step context
|
||||
@@ -122,6 +122,11 @@ function applyStep<
|
||||
const handler = {
|
||||
invoke: async (transactionContext) => {
|
||||
const executionContext: StepExecutionContext = {
|
||||
workflowId: transactionContext.model_id,
|
||||
stepName: transactionContext.action,
|
||||
action: "invoke",
|
||||
idempotencyKey: transactionContext.idempotency_key,
|
||||
attempt: transactionContext.attempt,
|
||||
container: transactionContext.container,
|
||||
metadata: transactionContext.metadata,
|
||||
context: transactionContext.context,
|
||||
@@ -148,6 +153,11 @@ function applyStep<
|
||||
compensate: compensateFn
|
||||
? async (transactionContext) => {
|
||||
const executionContext: StepExecutionContext = {
|
||||
workflowId: transactionContext.model_id,
|
||||
stepName: transactionContext.action,
|
||||
action: "compensate",
|
||||
idempotencyKey: transactionContext.idempotency_key,
|
||||
attempt: transactionContext.attempt,
|
||||
container: transactionContext.container,
|
||||
metadata: transactionContext.metadata,
|
||||
context: transactionContext.context,
|
||||
|
||||
@@ -110,6 +110,11 @@ export function hook<TOutput>(
|
||||
return {
|
||||
__value: async function (transactionContext) {
|
||||
const executionContext: StepExecutionContext = {
|
||||
workflowId: transactionContext.model_id,
|
||||
stepName: transactionContext.action,
|
||||
action: transactionContext.action_type,
|
||||
idempotencyKey: transactionContext.idempotency_key,
|
||||
attempt: transactionContext.attempt,
|
||||
container: transactionContext.container,
|
||||
metadata: transactionContext.metadata,
|
||||
context: transactionContext.context,
|
||||
|
||||
@@ -86,6 +86,31 @@ export type CreateWorkflowComposerContext = {
|
||||
* The step's context.
|
||||
*/
|
||||
export interface StepExecutionContext {
|
||||
/**
|
||||
* The ID of the workflow.
|
||||
*/
|
||||
workflowId: string
|
||||
|
||||
/**
|
||||
* The attempt number of the step.
|
||||
*/
|
||||
attempt: number
|
||||
|
||||
/**
|
||||
* The idempoency key of the step.
|
||||
*/
|
||||
idempotencyKey: string
|
||||
|
||||
/**
|
||||
* The name of the step.
|
||||
*/
|
||||
stepName: string
|
||||
|
||||
/**
|
||||
* The action of the step.
|
||||
*/
|
||||
action: "invoke" | "compensate"
|
||||
|
||||
/**
|
||||
* The container used to access resources, such as services, in the step.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user