@xtr-dev/payload-automation 0.0.38 → 0.0.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -1
- package/dist/collections/Workflow.js +2 -4
- package/dist/collections/Workflow.js.map +1 -1
- package/dist/components/WorkflowBuilder/StepConfigurationForm.js +316 -0
- package/dist/components/WorkflowBuilder/StepConfigurationForm.js.map +1 -0
- package/dist/components/WorkflowBuilder/WorkflowBuilder.js +211 -0
- package/dist/components/WorkflowBuilder/WorkflowBuilder.js.map +1 -0
- package/dist/components/WorkflowBuilder/WorkflowToolbar.js +107 -0
- package/dist/components/WorkflowBuilder/WorkflowToolbar.js.map +1 -0
- package/dist/components/WorkflowBuilder/index.js +6 -0
- package/dist/components/WorkflowBuilder/index.js.map +1 -0
- package/dist/components/WorkflowBuilder/nodes/StepNode.js +139 -0
- package/dist/components/WorkflowBuilder/nodes/StepNode.js.map +1 -0
- package/dist/core/workflow-executor.js +150 -116
- package/dist/core/workflow-executor.js.map +1 -1
- package/dist/fields/WorkflowBuilderField.js +119 -0
- package/dist/fields/WorkflowBuilderField.js.map +1 -0
- package/dist/plugin/collection-hook.js +34 -0
- package/dist/plugin/collection-hook.js.map +1 -1
- package/package.json +4 -3
- package/dist/collections/Workflow.d.ts +0 -3
- package/dist/collections/WorkflowRuns.d.ts +0 -2
- package/dist/components/ErrorDisplay.d.ts +0 -9
- package/dist/components/StatusCell.d.ts +0 -6
- package/dist/core/trigger-custom-workflow.d.ts +0 -52
- package/dist/core/workflow-executor.d.ts +0 -90
- package/dist/exports/client.d.ts +0 -2
- package/dist/exports/fields.d.ts +0 -1
- package/dist/exports/rsc.d.ts +0 -1
- package/dist/exports/server.d.ts +0 -5
- package/dist/exports/views.d.ts +0 -1
- package/dist/fields/parameter.d.ts +0 -4
- package/dist/index.d.ts +0 -2
- package/dist/plugin/collection-hook.d.ts +0 -1
- package/dist/plugin/config-types.d.ts +0 -18
- package/dist/plugin/global-hook.d.ts +0 -1
- package/dist/plugin/index.d.ts +0 -4
- package/dist/plugin/logger.d.ts +0 -20
- package/dist/steps/create-document-handler.d.ts +0 -2
- package/dist/steps/create-document.d.ts +0 -46
- package/dist/steps/delete-document-handler.d.ts +0 -2
- package/dist/steps/delete-document.d.ts +0 -39
- package/dist/steps/http-request-handler.d.ts +0 -2
- package/dist/steps/http-request.d.ts +0 -155
- package/dist/steps/index.d.ts +0 -12
- package/dist/steps/read-document-handler.d.ts +0 -2
- package/dist/steps/read-document.d.ts +0 -46
- package/dist/steps/send-email-handler.d.ts +0 -2
- package/dist/steps/send-email.d.ts +0 -44
- package/dist/steps/update-document-handler.d.ts +0 -2
- package/dist/steps/update-document.d.ts +0 -46
- package/dist/test/basic.test.js +0 -14
- package/dist/test/basic.test.js.map +0 -1
- package/dist/test/create-document-step.test.js +0 -378
- package/dist/test/create-document-step.test.js.map +0 -1
- package/dist/test/http-request-step.test.js +0 -361
- package/dist/test/http-request-step.test.js.map +0 -1
- package/dist/test/workflow-executor.test.js +0 -530
- package/dist/test/workflow-executor.test.js.map +0 -1
- package/dist/triggers/collection-trigger.d.ts +0 -2
- package/dist/triggers/global-trigger.d.ts +0 -2
- package/dist/triggers/index.d.ts +0 -2
- package/dist/triggers/types.d.ts +0 -5
- package/dist/types/index.d.ts +0 -31
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import Handlebars from 'handlebars';
|
|
2
2
|
export class WorkflowExecutor {
|
|
3
3
|
payload;
|
|
4
4
|
logger;
|
|
@@ -7,6 +7,72 @@ export class WorkflowExecutor {
|
|
|
7
7
|
this.logger = logger;
|
|
8
8
|
}
|
|
9
9
|
/**
|
|
10
|
+
* Convert string values to appropriate types based on common patterns
|
|
11
|
+
*/ convertValueType(value, key) {
|
|
12
|
+
if (typeof value !== 'string') {
|
|
13
|
+
return value;
|
|
14
|
+
}
|
|
15
|
+
// Type conversion patterns based on field names and values
|
|
16
|
+
const numericFields = [
|
|
17
|
+
'timeout',
|
|
18
|
+
'retries',
|
|
19
|
+
'delay',
|
|
20
|
+
'port',
|
|
21
|
+
'limit',
|
|
22
|
+
'offset',
|
|
23
|
+
'count',
|
|
24
|
+
'max',
|
|
25
|
+
'min'
|
|
26
|
+
];
|
|
27
|
+
const booleanFields = [
|
|
28
|
+
'enabled',
|
|
29
|
+
'required',
|
|
30
|
+
'active',
|
|
31
|
+
'success',
|
|
32
|
+
'failed',
|
|
33
|
+
'complete'
|
|
34
|
+
];
|
|
35
|
+
// Convert numeric fields
|
|
36
|
+
if (numericFields.some((field)=>key.toLowerCase().includes(field))) {
|
|
37
|
+
const numValue = Number(value);
|
|
38
|
+
if (!isNaN(numValue)) {
|
|
39
|
+
this.logger.debug({
|
|
40
|
+
key,
|
|
41
|
+
originalValue: value,
|
|
42
|
+
convertedValue: numValue
|
|
43
|
+
}, 'Auto-converted field to number');
|
|
44
|
+
return numValue;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
// Convert boolean fields
|
|
48
|
+
if (booleanFields.some((field)=>key.toLowerCase().includes(field))) {
|
|
49
|
+
if (value === 'true') return true;
|
|
50
|
+
if (value === 'false') return false;
|
|
51
|
+
}
|
|
52
|
+
// Try to parse as number if it looks numeric
|
|
53
|
+
if (/^\d+$/.test(value)) {
|
|
54
|
+
const numValue = parseInt(value, 10);
|
|
55
|
+
this.logger.debug({
|
|
56
|
+
key,
|
|
57
|
+
originalValue: value,
|
|
58
|
+
convertedValue: numValue
|
|
59
|
+
}, 'Auto-converted numeric string to number');
|
|
60
|
+
return numValue;
|
|
61
|
+
}
|
|
62
|
+
// Try to parse as float if it looks like a decimal
|
|
63
|
+
if (/^\d+\.\d+$/.test(value)) {
|
|
64
|
+
const floatValue = parseFloat(value);
|
|
65
|
+
this.logger.debug({
|
|
66
|
+
key,
|
|
67
|
+
originalValue: value,
|
|
68
|
+
convertedValue: floatValue
|
|
69
|
+
}, 'Auto-converted decimal string to number');
|
|
70
|
+
return floatValue;
|
|
71
|
+
}
|
|
72
|
+
// Return as string if no conversion applies
|
|
73
|
+
return value;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
10
76
|
* Classifies error types based on error messages
|
|
11
77
|
*/ classifyErrorType(errorMessage) {
|
|
12
78
|
if (errorMessage.includes('timeout') || errorMessage.includes('ETIMEDOUT')) {
|
|
@@ -104,36 +170,10 @@ export class WorkflowExecutor {
|
|
|
104
170
|
// Move taskSlug declaration outside try block so it's accessible in catch
|
|
105
171
|
const taskSlug = step.type;
|
|
106
172
|
try {
|
|
107
|
-
//
|
|
108
|
-
const
|
|
109
|
-
//
|
|
110
|
-
const
|
|
111
|
-
'step',
|
|
112
|
-
'name',
|
|
113
|
-
'dependencies',
|
|
114
|
-
'condition',
|
|
115
|
-
'type',
|
|
116
|
-
'id',
|
|
117
|
-
'parameters'
|
|
118
|
-
];
|
|
119
|
-
for (const [key, value] of Object.entries(step)){
|
|
120
|
-
if (!coreFields.includes(key)) {
|
|
121
|
-
// Handle flattened parameters (remove 'parameter' prefix)
|
|
122
|
-
if (key.startsWith('parameter')) {
|
|
123
|
-
const cleanKey = key.replace('parameter', '');
|
|
124
|
-
const properKey = cleanKey.charAt(0).toLowerCase() + cleanKey.slice(1);
|
|
125
|
-
inputFields[properKey] = value;
|
|
126
|
-
} else {
|
|
127
|
-
inputFields[key] = value;
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
// Also extract from nested parameters object if it exists
|
|
132
|
-
if (step.parameters && typeof step.parameters === 'object') {
|
|
133
|
-
Object.assign(inputFields, step.parameters);
|
|
134
|
-
}
|
|
135
|
-
// Resolve input data using JSONPath
|
|
136
|
-
const resolvedInput = this.resolveStepInput(inputFields, context);
|
|
173
|
+
// Get input configuration from the step
|
|
174
|
+
const inputConfig = step.input || {};
|
|
175
|
+
// Resolve input data using Handlebars templates
|
|
176
|
+
const resolvedInput = this.resolveStepInput(inputConfig, context, taskSlug);
|
|
137
177
|
context.steps[stepName].input = resolvedInput;
|
|
138
178
|
if (!taskSlug) {
|
|
139
179
|
throw new Error(`Step ${stepName} is missing a task type`);
|
|
@@ -353,32 +393,6 @@ export class WorkflowExecutor {
|
|
|
353
393
|
}
|
|
354
394
|
}
|
|
355
395
|
/**
|
|
356
|
-
* Parse a condition value (string literal, number, boolean, or JSONPath)
|
|
357
|
-
*/ parseConditionValue(expr, context) {
|
|
358
|
-
// Handle string literals
|
|
359
|
-
if (expr.startsWith('"') && expr.endsWith('"') || expr.startsWith("'") && expr.endsWith("'")) {
|
|
360
|
-
return expr.slice(1, -1) // Remove quotes
|
|
361
|
-
;
|
|
362
|
-
}
|
|
363
|
-
// Handle boolean literals
|
|
364
|
-
if (expr === 'true') {
|
|
365
|
-
return true;
|
|
366
|
-
}
|
|
367
|
-
if (expr === 'false') {
|
|
368
|
-
return false;
|
|
369
|
-
}
|
|
370
|
-
// Handle number literals
|
|
371
|
-
if (/^-?\d+(?:\.\d+)?$/.test(expr)) {
|
|
372
|
-
return Number(expr);
|
|
373
|
-
}
|
|
374
|
-
// Handle JSONPath expressions
|
|
375
|
-
if (expr.startsWith('$')) {
|
|
376
|
-
return this.resolveJSONPathValue(expr, context);
|
|
377
|
-
}
|
|
378
|
-
// Return as string if nothing else matches
|
|
379
|
-
return expr;
|
|
380
|
-
}
|
|
381
|
-
/**
|
|
382
396
|
* Resolve step execution order based on dependencies
|
|
383
397
|
*/ resolveExecutionOrder(steps) {
|
|
384
398
|
const stepMap = new Map();
|
|
@@ -428,59 +442,48 @@ export class WorkflowExecutor {
|
|
|
428
442
|
return executionBatches;
|
|
429
443
|
}
|
|
430
444
|
/**
|
|
431
|
-
* Resolve
|
|
432
|
-
*/
|
|
433
|
-
if (expr.startsWith('$')) {
|
|
434
|
-
const result = JSONPath({
|
|
435
|
-
json: context,
|
|
436
|
-
path: expr,
|
|
437
|
-
wrap: false
|
|
438
|
-
});
|
|
439
|
-
// Return first result if array, otherwise the result itself
|
|
440
|
-
return Array.isArray(result) && result.length > 0 ? result[0] : result;
|
|
441
|
-
}
|
|
442
|
-
return expr;
|
|
443
|
-
}
|
|
444
|
-
/**
|
|
445
|
-
* Resolve step input using JSONPath expressions
|
|
446
|
-
*/ resolveStepInput(config, context) {
|
|
445
|
+
* Resolve step input using Handlebars templates with automatic type conversion
|
|
446
|
+
*/ resolveStepInput(config, context, stepType) {
|
|
447
447
|
const resolved = {};
|
|
448
448
|
this.logger.debug({
|
|
449
449
|
configKeys: Object.keys(config),
|
|
450
450
|
contextSteps: Object.keys(context.steps),
|
|
451
|
-
triggerType: context.trigger?.type
|
|
452
|
-
|
|
451
|
+
triggerType: context.trigger?.type,
|
|
452
|
+
stepType
|
|
453
|
+
}, 'Starting step input resolution with Handlebars');
|
|
453
454
|
for (const [key, value] of Object.entries(config)){
|
|
454
|
-
if (typeof value === 'string'
|
|
455
|
-
//
|
|
456
|
-
|
|
457
|
-
key,
|
|
458
|
-
jsonPath: value,
|
|
459
|
-
availableSteps: Object.keys(context.steps),
|
|
460
|
-
hasTriggerData: !!context.trigger?.data,
|
|
461
|
-
hasTriggerDoc: !!context.trigger?.doc
|
|
462
|
-
}, 'Resolving JSONPath expression');
|
|
463
|
-
try {
|
|
464
|
-
const result = JSONPath({
|
|
465
|
-
json: context,
|
|
466
|
-
path: value,
|
|
467
|
-
wrap: false
|
|
468
|
-
});
|
|
455
|
+
if (typeof value === 'string') {
|
|
456
|
+
// Check if the string contains Handlebars templates
|
|
457
|
+
if (value.includes('{{') && value.includes('}}')) {
|
|
469
458
|
this.logger.debug({
|
|
470
459
|
key,
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
460
|
+
template: value,
|
|
461
|
+
availableSteps: Object.keys(context.steps),
|
|
462
|
+
hasTriggerData: !!context.trigger?.data,
|
|
463
|
+
hasTriggerDoc: !!context.trigger?.doc
|
|
464
|
+
}, 'Processing Handlebars template');
|
|
465
|
+
try {
|
|
466
|
+
const template = Handlebars.compile(value);
|
|
467
|
+
const result = template(context);
|
|
468
|
+
this.logger.debug({
|
|
469
|
+
key,
|
|
470
|
+
template: value,
|
|
471
|
+
result: JSON.stringify(result).substring(0, 200),
|
|
472
|
+
resultType: typeof result
|
|
473
|
+
}, 'Handlebars template resolved successfully');
|
|
474
|
+
resolved[key] = this.convertValueType(result, key);
|
|
475
|
+
} catch (error) {
|
|
476
|
+
this.logger.warn({
|
|
477
|
+
error: error instanceof Error ? error.message : 'Unknown error',
|
|
478
|
+
key,
|
|
479
|
+
template: value,
|
|
480
|
+
contextSnapshot: JSON.stringify(context).substring(0, 500)
|
|
481
|
+
}, 'Failed to resolve Handlebars template');
|
|
482
|
+
resolved[key] = value; // Keep original value if resolution fails
|
|
483
|
+
}
|
|
484
|
+
} else {
|
|
485
|
+
// Regular string, apply type conversion
|
|
486
|
+
resolved[key] = this.convertValueType(value, key);
|
|
484
487
|
}
|
|
485
488
|
} else if (typeof value === 'object' && value !== null) {
|
|
486
489
|
// Recursively resolve nested objects
|
|
@@ -488,7 +491,7 @@ export class WorkflowExecutor {
|
|
|
488
491
|
key,
|
|
489
492
|
nestedKeys: Object.keys(value)
|
|
490
493
|
}, 'Recursively resolving nested object');
|
|
491
|
-
resolved[key] = this.resolveStepInput(value, context);
|
|
494
|
+
resolved[key] = this.resolveStepInput(value, context, stepType);
|
|
492
495
|
} else {
|
|
493
496
|
// Keep literal values as-is
|
|
494
497
|
resolved[key] = value;
|
|
@@ -558,7 +561,7 @@ export class WorkflowExecutor {
|
|
|
558
561
|
});
|
|
559
562
|
}
|
|
560
563
|
/**
|
|
561
|
-
* Evaluate a condition using
|
|
564
|
+
* Evaluate a condition using Handlebars templates and comparison operators
|
|
562
565
|
*/ evaluateCondition(condition, context) {
|
|
563
566
|
this.logger.debug({
|
|
564
567
|
condition,
|
|
@@ -572,10 +575,10 @@ export class WorkflowExecutor {
|
|
|
572
575
|
const comparisonMatch = condition.match(/^(.+?)\s*(==|!=|>|<|>=|<=)\s*(.+)$/);
|
|
573
576
|
if (comparisonMatch) {
|
|
574
577
|
const [, leftExpr, operator, rightExpr] = comparisonMatch;
|
|
575
|
-
// Evaluate left side (
|
|
576
|
-
const leftValue = this.
|
|
577
|
-
//
|
|
578
|
-
const rightValue = this.
|
|
578
|
+
// Evaluate left side (could be Handlebars template or JSONPath)
|
|
579
|
+
const leftValue = this.resolveConditionValue(leftExpr.trim(), context);
|
|
580
|
+
// Evaluate right side (could be Handlebars template, JSONPath, or literal)
|
|
581
|
+
const rightValue = this.resolveConditionValue(rightExpr.trim(), context);
|
|
579
582
|
this.logger.debug({
|
|
580
583
|
condition,
|
|
581
584
|
leftExpr: leftExpr.trim(),
|
|
@@ -619,18 +622,14 @@ export class WorkflowExecutor {
|
|
|
619
622
|
}, 'Comparison condition evaluation completed');
|
|
620
623
|
return result;
|
|
621
624
|
} else {
|
|
622
|
-
// Treat as
|
|
623
|
-
const result =
|
|
624
|
-
json: context,
|
|
625
|
-
path: condition,
|
|
626
|
-
wrap: false
|
|
627
|
-
});
|
|
625
|
+
// Treat as template or JSONPath boolean evaluation
|
|
626
|
+
const result = this.resolveConditionValue(condition, context);
|
|
628
627
|
this.logger.debug({
|
|
629
628
|
condition,
|
|
630
629
|
result,
|
|
631
630
|
resultType: Array.isArray(result) ? 'array' : typeof result,
|
|
632
631
|
resultLength: Array.isArray(result) ? result.length : undefined
|
|
633
|
-
}, '
|
|
632
|
+
}, 'Boolean evaluation result');
|
|
634
633
|
// Handle different result types
|
|
635
634
|
let finalResult;
|
|
636
635
|
if (Array.isArray(result)) {
|
|
@@ -656,6 +655,41 @@ export class WorkflowExecutor {
|
|
|
656
655
|
}
|
|
657
656
|
}
|
|
658
657
|
/**
|
|
658
|
+
* Resolve a condition value using Handlebars templates or JSONPath
|
|
659
|
+
*/ resolveConditionValue(expr, context) {
|
|
660
|
+
// Handle string literals
|
|
661
|
+
if (expr.startsWith('"') && expr.endsWith('"') || expr.startsWith("'") && expr.endsWith("'")) {
|
|
662
|
+
return expr.slice(1, -1) // Remove quotes
|
|
663
|
+
;
|
|
664
|
+
}
|
|
665
|
+
// Handle boolean literals
|
|
666
|
+
if (expr === 'true') {
|
|
667
|
+
return true;
|
|
668
|
+
}
|
|
669
|
+
if (expr === 'false') {
|
|
670
|
+
return false;
|
|
671
|
+
}
|
|
672
|
+
// Handle number literals
|
|
673
|
+
if (/^-?\d+(?:\.\d+)?$/.test(expr)) {
|
|
674
|
+
return Number(expr);
|
|
675
|
+
}
|
|
676
|
+
// Handle Handlebars templates
|
|
677
|
+
if (expr.includes('{{') && expr.includes('}}')) {
|
|
678
|
+
try {
|
|
679
|
+
const template = Handlebars.compile(expr);
|
|
680
|
+
return template(context);
|
|
681
|
+
} catch (error) {
|
|
682
|
+
this.logger.warn({
|
|
683
|
+
error: error instanceof Error ? error.message : 'Unknown error',
|
|
684
|
+
expr
|
|
685
|
+
}, 'Failed to resolve Handlebars condition');
|
|
686
|
+
return false;
|
|
687
|
+
}
|
|
688
|
+
}
|
|
689
|
+
// Return as string if nothing else matches
|
|
690
|
+
return expr;
|
|
691
|
+
}
|
|
692
|
+
/**
|
|
659
693
|
* Execute a workflow with the given context
|
|
660
694
|
*/ async execute(workflow, context, req) {
|
|
661
695
|
this.logger.info({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/core/workflow-executor.ts"],"sourcesContent":["import type { Payload, PayloadRequest } from 'payload'\n\n// We need to reference the generated types dynamically since they're not available at build time\n// Using generic types and casting where necessary\nexport type PayloadWorkflow = {\n id: number\n name: string\n description?: null | string\n triggers?: Array<{\n type?: null | string\n condition?: null | string\n parameters?: {\n collectionSlug?: null | string\n operation?: null | string\n global?: null | string\n globalOperation?: null | string\n [key: string]: unknown\n } | null\n [key: string]: unknown\n }> | null\n steps?: Array<{\n step?: null | string\n name?: null | string\n input?: unknown\n dependencies?: null | string[]\n condition?: null | string\n [key: string]: unknown\n }> | null\n [key: string]: unknown\n}\n\nimport { JSONPath } from 'jsonpath-plus'\n\n// Helper type to extract workflow step data from the generated types\nexport type WorkflowStep = {\n name: string // Ensure name is always present for our execution logic\n} & NonNullable<PayloadWorkflow['steps']>[0]\n\n// Helper type to extract workflow trigger data from the generated types\nexport type WorkflowTrigger = {\n type: string // Ensure type is always present for our execution logic\n} & NonNullable<PayloadWorkflow['triggers']>[0]\n\nexport interface ExecutionContext {\n steps: Record<string, any>\n trigger: Record<string, any>\n}\n\nexport class WorkflowExecutor {\n constructor(\n private payload: Payload,\n private logger: Payload['logger']\n ) {}\n\n /**\n * Classifies error types based on error messages\n */\n private classifyErrorType(errorMessage: string): string {\n if (errorMessage.includes('timeout') || errorMessage.includes('ETIMEDOUT')) {\n return 'timeout'\n }\n if (errorMessage.includes('ENOTFOUND') || errorMessage.includes('getaddrinfo')) {\n return 'dns'\n }\n if (errorMessage.includes('ECONNREFUSED') || errorMessage.includes('ECONNRESET')) {\n return 'connection'\n }\n if (errorMessage.includes('network') || errorMessage.includes('fetch')) {\n return 'network'\n }\n return 'unknown'\n }\n\n /**\n * Evaluate a step condition using JSONPath\n */\n private evaluateStepCondition(condition: string, context: ExecutionContext): boolean {\n return this.evaluateCondition(condition, context)\n }\n\n /**\n * Execute a single workflow step\n */\n private async executeStep(\n step: WorkflowStep,\n stepIndex: number,\n context: ExecutionContext,\n req: PayloadRequest,\n workflowRunId?: number | string\n ): Promise<void> {\n const stepName = step.name || 'step-' + stepIndex\n\n this.logger.info({\n hasStep: 'step' in step,\n step: JSON.stringify(step),\n stepName\n }, 'Executing step')\n\n // Check step condition if present\n if (step.condition) {\n this.logger.debug({\n condition: step.condition,\n stepName,\n availableSteps: Object.keys(context.steps),\n completedSteps: Object.entries(context.steps)\n .filter(([_, s]) => s.state === 'succeeded')\n .map(([name]) => name),\n triggerType: context.trigger?.type\n }, 'Evaluating step condition')\n\n const conditionMet = this.evaluateStepCondition(step.condition, context)\n\n if (!conditionMet) {\n this.logger.info({\n condition: step.condition,\n stepName,\n contextSnapshot: JSON.stringify({\n stepOutputs: Object.entries(context.steps).reduce((acc, [name, step]) => {\n acc[name] = { state: step.state, hasOutput: !!step.output }\n return acc\n }, {} as Record<string, any>),\n triggerData: context.trigger?.data ? 'present' : 'absent'\n })\n }, 'Step condition not met, skipping')\n\n // Mark step as completed but skipped\n context.steps[stepName] = {\n error: undefined,\n input: undefined,\n output: { reason: 'Condition not met', skipped: true },\n state: 'succeeded'\n }\n\n // Update workflow run context if needed\n if (workflowRunId) {\n await this.updateWorkflowRunContext(workflowRunId, context, req)\n }\n\n return\n }\n\n this.logger.info({\n condition: step.condition,\n stepName,\n contextSnapshot: JSON.stringify({\n stepOutputs: Object.entries(context.steps).reduce((acc, [name, step]) => {\n acc[name] = { state: step.state, hasOutput: !!step.output }\n return acc\n }, {} as Record<string, any>),\n triggerData: context.trigger?.data ? 'present' : 'absent'\n })\n }, 'Step condition met, proceeding with execution')\n }\n\n // Initialize step context\n context.steps[stepName] = {\n error: undefined,\n input: undefined,\n output: undefined,\n state: 'running',\n _startTime: Date.now() // Track execution start time for independent duration tracking\n }\n\n // Move taskSlug declaration outside try block so it's accessible in catch\n const taskSlug = step.type as string\n\n try {\n // Extract input data from step - PayloadCMS flattens inputSchema fields to step level\n const inputFields: Record<string, unknown> = {}\n\n // Get all fields except the core step fields\n const coreFields = ['step', 'name', 'dependencies', 'condition', 'type', 'id', 'parameters']\n for (const [key, value] of Object.entries(step)) {\n if (!coreFields.includes(key)) {\n // Handle flattened parameters (remove 'parameter' prefix)\n if (key.startsWith('parameter')) {\n const cleanKey = key.replace('parameter', '')\n const properKey = cleanKey.charAt(0).toLowerCase() + cleanKey.slice(1)\n inputFields[properKey] = value\n } else {\n inputFields[key] = value\n }\n }\n }\n\n // Also extract from nested parameters object if it exists\n if (step.parameters && typeof step.parameters === 'object') {\n Object.assign(inputFields, step.parameters)\n }\n\n // Resolve input data using JSONPath\n const resolvedInput = this.resolveStepInput(inputFields, context)\n context.steps[stepName].input = resolvedInput\n\n if (!taskSlug) {\n throw new Error(`Step ${stepName} is missing a task type`)\n }\n\n this.logger.info({\n hasInput: !!resolvedInput,\n hasReq: !!req,\n stepName,\n taskSlug\n }, 'Queueing task')\n\n const job = await this.payload.jobs.queue({\n input: resolvedInput,\n req,\n task: taskSlug\n })\n\n // Run the specific job immediately and wait for completion\n this.logger.info({ jobId: job.id }, 'Running job immediately using runByID')\n const runResults = await this.payload.jobs.runByID({\n id: job.id,\n req\n })\n\n this.logger.info({\n jobId: job.id,\n runResult: runResults,\n hasResult: !!runResults\n }, 'Job run completed')\n\n // Give a small delay to ensure job is fully processed\n await new Promise(resolve => setTimeout(resolve, 100))\n\n // Get the job result\n const completedJob = await this.payload.findByID({\n id: job.id,\n collection: 'payload-jobs',\n req\n })\n\n this.logger.info({\n jobId: job.id,\n totalTried: completedJob.totalTried,\n hasError: completedJob.hasError,\n taskStatus: completedJob.taskStatus ? Object.keys(completedJob.taskStatus) : 'null'\n }, 'Retrieved job results')\n\n const taskStatus = completedJob.taskStatus?.[completedJob.taskSlug]?.[completedJob.totalTried]\n const isComplete = taskStatus?.complete === true\n const hasError = completedJob.hasError || !isComplete\n\n // Extract error information from job if available\n let errorMessage: string | undefined\n if (hasError) {\n // Try to get error from the latest log entry\n if (completedJob.log && completedJob.log.length > 0) {\n const latestLog = completedJob.log[completedJob.log.length - 1]\n errorMessage = latestLog.error?.message || latestLog.error\n }\n\n // Fallback to top-level error\n if (!errorMessage && completedJob.error) {\n errorMessage = completedJob.error.message || completedJob.error\n }\n\n // Try to get error from task output if available\n if (!errorMessage && taskStatus?.output?.error) {\n errorMessage = taskStatus.output.error\n }\n\n // Check if task handler returned with state='failed'\n if (!errorMessage && taskStatus?.state === 'failed') {\n errorMessage = 'Task handler returned a failed state'\n // Try to get more specific error from output\n if (taskStatus.output?.error) {\n errorMessage = taskStatus.output.error\n }\n }\n\n // Check for network errors in the job data\n if (!errorMessage && completedJob.result) {\n const result = completedJob.result\n if (result.error) {\n errorMessage = result.error\n }\n }\n\n // Final fallback to generic message with more detail\n if (!errorMessage) {\n const jobDetails = {\n taskSlug,\n hasError: completedJob.hasError,\n taskStatus: taskStatus?.complete,\n totalTried: completedJob.totalTried\n }\n errorMessage = `Task ${taskSlug} failed without detailed error information. Job details: ${JSON.stringify(jobDetails)}`\n }\n }\n\n const result: {\n error: string | undefined\n output: unknown\n state: 'failed' | 'succeeded'\n } = {\n error: errorMessage,\n output: taskStatus?.output || {},\n state: isComplete ? 'succeeded' : 'failed'\n }\n\n // Store the output and error\n context.steps[stepName].output = result.output\n context.steps[stepName].state = result.state\n if (result.error) {\n context.steps[stepName].error = result.error\n }\n\n // Independent execution tracking (not dependent on PayloadCMS task status)\n context.steps[stepName].executionInfo = {\n completed: true, // Step execution completed (regardless of success/failure)\n success: result.state === 'succeeded',\n executedAt: new Date().toISOString(),\n duration: Date.now() - (context.steps[stepName]._startTime || Date.now())\n }\n\n // For failed steps, try to extract detailed error information from the job logs\n // This approach is more reliable than external storage and persists with the workflow\n if (result.state === 'failed') {\n const errorDetails = this.extractErrorDetailsFromJob(completedJob, context.steps[stepName], stepName)\n if (errorDetails) {\n context.steps[stepName].errorDetails = errorDetails\n\n this.logger.info({\n stepName,\n errorType: errorDetails.errorType,\n duration: errorDetails.duration,\n attempts: errorDetails.attempts\n }, 'Extracted detailed error information for failed step')\n }\n }\n\n this.logger.debug({context}, 'Step execution context')\n\n if (result.state !== 'succeeded') {\n throw new Error(result.error || `Step ${stepName} failed`)\n }\n\n this.logger.info({\n output: result.output,\n stepName\n }, 'Step completed')\n\n // Update workflow run with current step results if workflowRunId is provided\n if (workflowRunId) {\n await this.updateWorkflowRunContext(workflowRunId, context, req)\n }\n\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : 'Unknown error'\n context.steps[stepName].state = 'failed'\n context.steps[stepName].error = errorMessage\n\n // Independent execution tracking for failed steps\n context.steps[stepName].executionInfo = {\n completed: true, // Execution attempted and completed (even if it failed)\n success: false,\n executedAt: new Date().toISOString(),\n duration: Date.now() - (context.steps[stepName]._startTime || Date.now()),\n failureReason: errorMessage\n }\n\n this.logger.error({\n error: errorMessage,\n input: context.steps[stepName].input,\n stepName,\n taskSlug\n }, 'Step execution failed')\n\n // Update workflow run with current step results if workflowRunId is provided\n if (workflowRunId) {\n try {\n await this.updateWorkflowRunContext(workflowRunId, context, req)\n } catch (updateError) {\n this.logger.error({\n error: updateError instanceof Error ? updateError.message : 'Unknown error',\n stepName\n }, 'Failed to update workflow run context after step failure')\n }\n }\n\n throw error\n }\n }\n\n /**\n * Extracts detailed error information from job logs and input\n */\n private extractErrorDetailsFromJob(job: any, stepContext: any, stepName: string) {\n try {\n // Get error information from multiple sources\n const input = stepContext.input || {}\n const logs = job.log || []\n const latestLog = logs[logs.length - 1]\n\n // Extract error message from job error or log\n const errorMessage = job.error?.message || latestLog?.error?.message || 'Unknown error'\n\n // For timeout scenarios, check if it's a timeout based on duration and timeout setting\n let errorType = this.classifyErrorType(errorMessage)\n\n // Special handling for HTTP timeouts - if task failed and duration exceeds timeout, it's likely a timeout\n if (errorType === 'unknown' && input.timeout && stepContext.executionInfo?.duration) {\n const timeoutMs = parseInt(input.timeout) || 30000\n const actualDuration = stepContext.executionInfo.duration\n\n // If execution duration is close to or exceeds timeout, classify as timeout\n if (actualDuration >= (timeoutMs * 0.9)) { // 90% of timeout threshold\n errorType = 'timeout'\n this.logger.debug({\n timeoutMs,\n actualDuration,\n stepName\n }, 'Classified error as timeout based on duration analysis')\n }\n }\n\n // Calculate duration from execution info if available\n const duration = stepContext.executionInfo?.duration || 0\n\n // Extract attempt count from logs\n const attempts = job.totalTried || 1\n\n return {\n stepId: `${stepName}-${Date.now()}`,\n errorType,\n duration,\n attempts,\n finalError: errorMessage,\n context: {\n url: input.url,\n method: input.method,\n timeout: input.timeout,\n statusCode: latestLog?.output?.status,\n headers: input.headers\n },\n timestamp: new Date().toISOString()\n }\n } catch (error) {\n this.logger.warn({\n error: error instanceof Error ? error.message : 'Unknown error',\n stepName\n }, 'Failed to extract error details from job')\n return null\n }\n }\n\n /**\n * Parse a condition value (string literal, number, boolean, or JSONPath)\n */\n private parseConditionValue(expr: string, context: ExecutionContext): any {\n // Handle string literals\n if ((expr.startsWith('\"') && expr.endsWith('\"')) || (expr.startsWith(\"'\") && expr.endsWith(\"'\"))) {\n return expr.slice(1, -1) // Remove quotes\n }\n\n // Handle boolean literals\n if (expr === 'true') {return true}\n if (expr === 'false') {return false}\n\n // Handle number literals\n if (/^-?\\d+(?:\\.\\d+)?$/.test(expr)) {\n return Number(expr)\n }\n\n // Handle JSONPath expressions\n if (expr.startsWith('$')) {\n return this.resolveJSONPathValue(expr, context)\n }\n\n // Return as string if nothing else matches\n return expr\n }\n\n /**\n * Resolve step execution order based on dependencies\n */\n private resolveExecutionOrder(steps: WorkflowStep[]): WorkflowStep[][] {\n const stepMap = new Map<string, WorkflowStep>()\n const dependencyGraph = new Map<string, string[]>()\n const indegree = new Map<string, number>()\n\n // Build the step map and dependency graph\n for (const step of steps) {\n const stepName = step.name || `step-${steps.indexOf(step)}`\n const dependencies = step.dependencies || []\n\n stepMap.set(stepName, { ...step, name: stepName, dependencies })\n dependencyGraph.set(stepName, dependencies)\n indegree.set(stepName, dependencies.length)\n }\n\n // Topological sort to determine execution batches\n const executionBatches: WorkflowStep[][] = []\n const processed = new Set<string>()\n\n while (processed.size < steps.length) {\n const currentBatch: WorkflowStep[] = []\n\n // Find all steps with no remaining dependencies\n for (const [stepName, inDegree] of indegree.entries()) {\n if (inDegree === 0 && !processed.has(stepName)) {\n const step = stepMap.get(stepName)\n if (step) {\n currentBatch.push(step)\n }\n }\n }\n\n if (currentBatch.length === 0) {\n throw new Error('Circular dependency detected in workflow steps')\n }\n\n executionBatches.push(currentBatch)\n\n // Update indegrees for next iteration\n for (const step of currentBatch) {\n processed.add(step.name)\n\n // Reduce indegree for steps that depend on completed steps\n for (const [otherStepName, dependencies] of dependencyGraph.entries()) {\n if (dependencies.includes(step.name) && !processed.has(otherStepName)) {\n indegree.set(otherStepName, (indegree.get(otherStepName) || 0) - 1)\n }\n }\n }\n }\n\n return executionBatches\n }\n\n /**\n * Resolve a JSONPath value from the context\n */\n private resolveJSONPathValue(expr: string, context: ExecutionContext): any {\n if (expr.startsWith('$')) {\n const result = JSONPath({\n json: context,\n path: expr,\n wrap: false\n })\n // Return first result if array, otherwise the result itself\n return Array.isArray(result) && result.length > 0 ? result[0] : result\n }\n return expr\n }\n\n /**\n * Resolve step input using JSONPath expressions\n */\n private resolveStepInput(config: Record<string, unknown>, context: ExecutionContext): Record<string, unknown> {\n const resolved: Record<string, unknown> = {}\n\n this.logger.debug({\n configKeys: Object.keys(config),\n contextSteps: Object.keys(context.steps),\n triggerType: context.trigger?.type\n }, 'Starting step input resolution')\n\n for (const [key, value] of Object.entries(config)) {\n if (typeof value === 'string' && value.startsWith('$')) {\n // This is a JSONPath expression\n this.logger.debug({\n key,\n jsonPath: value,\n availableSteps: Object.keys(context.steps),\n hasTriggerData: !!context.trigger?.data,\n hasTriggerDoc: !!context.trigger?.doc\n }, 'Resolving JSONPath expression')\n\n try {\n const result = JSONPath({\n json: context,\n path: value,\n wrap: false\n })\n\n this.logger.debug({\n key,\n jsonPath: value,\n result: JSON.stringify(result).substring(0, 200),\n resultType: Array.isArray(result) ? 'array' : typeof result\n }, 'JSONPath resolved successfully')\n\n resolved[key] = result\n } catch (error) {\n this.logger.warn({\n error: error instanceof Error ? error.message : 'Unknown error',\n key,\n path: value,\n contextSnapshot: JSON.stringify(context).substring(0, 500)\n }, 'Failed to resolve JSONPath')\n resolved[key] = value // Keep original value if resolution fails\n }\n } else if (typeof value === 'object' && value !== null) {\n // Recursively resolve nested objects\n this.logger.debug({\n key,\n nestedKeys: Object.keys(value as Record<string, unknown>)\n }, 'Recursively resolving nested object')\n\n resolved[key] = this.resolveStepInput(value as Record<string, unknown>, context)\n } else {\n // Keep literal values as-is\n resolved[key] = value\n }\n }\n\n this.logger.debug({\n resolvedKeys: Object.keys(resolved),\n originalKeys: Object.keys(config)\n }, 'Step input resolution completed')\n\n return resolved\n }\n\n /**\n * Safely serialize an object, handling circular references and non-serializable values\n */\n private safeSerialize(obj: unknown): unknown {\n const seen = new WeakSet()\n\n const serialize = (value: unknown): unknown => {\n if (value === null || typeof value !== 'object') {\n return value\n }\n\n if (seen.has(value)) {\n return '[Circular Reference]'\n }\n\n seen.add(value)\n\n if (Array.isArray(value)) {\n return value.map(serialize)\n }\n\n const result: Record<string, unknown> = {}\n for (const [key, val] of Object.entries(value as Record<string, unknown>)) {\n try {\n // Skip non-serializable properties that are likely internal database objects\n if (key === 'table' || key === 'schema' || key === '_' || key === '__') {\n continue\n }\n result[key] = serialize(val)\n } catch {\n // Skip properties that can't be accessed or serialized\n result[key] = '[Non-serializable]'\n }\n }\n\n return result\n }\n\n return serialize(obj)\n }\n\n /**\n * Update workflow run with current context\n */\n private async updateWorkflowRunContext(\n workflowRunId: number | string,\n context: ExecutionContext,\n req: PayloadRequest\n ): Promise<void> {\n const serializeContext = () => ({\n steps: this.safeSerialize(context.steps),\n trigger: {\n type: context.trigger.type,\n collection: context.trigger.collection,\n data: this.safeSerialize(context.trigger.data),\n doc: this.safeSerialize(context.trigger.doc),\n operation: context.trigger.operation,\n previousDoc: this.safeSerialize(context.trigger.previousDoc),\n triggeredAt: context.trigger.triggeredAt,\n user: context.trigger.req?.user\n }\n })\n\n await this.payload.update({\n id: workflowRunId,\n collection: 'workflow-runs',\n data: {\n context: serializeContext()\n },\n req\n })\n }\n\n /**\n * Evaluate a condition using JSONPath and comparison operators\n */\n public evaluateCondition(condition: string, context: ExecutionContext): boolean {\n this.logger.debug({\n condition,\n contextKeys: Object.keys(context),\n triggerType: context.trigger?.type,\n triggerData: context.trigger?.data,\n triggerDoc: context.trigger?.doc ? 'present' : 'absent'\n }, 'Starting condition evaluation')\n\n try {\n // Check if this is a comparison expression\n const comparisonMatch = condition.match(/^(.+?)\\s*(==|!=|>|<|>=|<=)\\s*(.+)$/)\n\n if (comparisonMatch) {\n const [, leftExpr, operator, rightExpr] = comparisonMatch\n\n // Evaluate left side (should be JSONPath)\n const leftValue = this.resolveJSONPathValue(leftExpr.trim(), context)\n\n // Parse right side (could be string, number, boolean, or JSONPath)\n const rightValue = this.parseConditionValue(rightExpr.trim(), context)\n\n this.logger.debug({\n condition,\n leftExpr: leftExpr.trim(),\n leftValue,\n operator,\n rightExpr: rightExpr.trim(),\n rightValue,\n leftType: typeof leftValue,\n rightType: typeof rightValue\n }, 'Evaluating comparison condition')\n\n // Perform comparison\n let result: boolean\n switch (operator) {\n case '!=':\n result = leftValue !== rightValue\n break\n case '<':\n result = Number(leftValue) < Number(rightValue)\n break\n case '<=':\n result = Number(leftValue) <= Number(rightValue)\n break\n case '==':\n result = leftValue === rightValue\n break\n case '>':\n result = Number(leftValue) > Number(rightValue)\n break\n case '>=':\n result = Number(leftValue) >= Number(rightValue)\n break\n default:\n throw new Error(`Unknown comparison operator: ${operator}`)\n }\n\n this.logger.debug({\n condition,\n result,\n leftValue,\n rightValue,\n operator\n }, 'Comparison condition evaluation completed')\n\n return result\n } else {\n // Treat as simple JSONPath boolean evaluation\n const result = JSONPath({\n json: context,\n path: condition,\n wrap: false\n })\n\n this.logger.debug({\n condition,\n result,\n resultType: Array.isArray(result) ? 'array' : typeof result,\n resultLength: Array.isArray(result) ? result.length : undefined\n }, 'JSONPath boolean evaluation result')\n\n // Handle different result types\n let finalResult: boolean\n if (Array.isArray(result)) {\n finalResult = result.length > 0 && Boolean(result[0])\n } else {\n finalResult = Boolean(result)\n }\n\n this.logger.debug({\n condition,\n finalResult,\n originalResult: result\n }, 'Boolean condition evaluation completed')\n\n return finalResult\n }\n } catch (error) {\n this.logger.warn({\n condition,\n error: error instanceof Error ? error.message : 'Unknown error',\n errorStack: error instanceof Error ? error.stack : undefined\n }, 'Failed to evaluate condition')\n\n // If condition evaluation fails, assume false\n return false\n }\n }\n\n /**\n * Execute a workflow with the given context\n */\n async execute(workflow: PayloadWorkflow, context: ExecutionContext, req: PayloadRequest): Promise<void> {\n this.logger.info({\n workflowId: workflow.id,\n workflowName: workflow.name\n }, 'Starting workflow execution')\n\n const serializeContext = () => ({\n steps: this.safeSerialize(context.steps),\n trigger: {\n type: context.trigger.type,\n collection: context.trigger.collection,\n data: this.safeSerialize(context.trigger.data),\n doc: this.safeSerialize(context.trigger.doc),\n operation: context.trigger.operation,\n previousDoc: this.safeSerialize(context.trigger.previousDoc),\n triggeredAt: context.trigger.triggeredAt,\n user: context.trigger.req?.user\n }\n })\n\n this.logger.info({\n workflowId: workflow.id,\n workflowName: workflow.name,\n contextSummary: {\n triggerType: context.trigger.type,\n triggerCollection: context.trigger.collection,\n triggerOperation: context.trigger.operation,\n hasDoc: !!context.trigger.doc,\n userEmail: context.trigger.req?.user?.email\n }\n }, 'About to create workflow run record')\n\n // Create a workflow run record\n let workflowRun;\n try {\n workflowRun = await this.payload.create({\n collection: 'workflow-runs',\n data: {\n context: serializeContext(),\n startedAt: new Date().toISOString(),\n status: 'running',\n triggeredBy: context.trigger.req?.user?.email || 'system',\n workflow: workflow.id,\n workflowVersion: 1 // Default version since generated type doesn't have _version field\n },\n req\n })\n\n this.logger.info({\n workflowRunId: workflowRun.id,\n workflowId: workflow.id,\n workflowName: workflow.name\n }, 'Workflow run record created successfully')\n } catch (error) {\n this.logger.error({\n error: error instanceof Error ? error.message : 'Unknown error',\n errorStack: error instanceof Error ? error.stack : undefined,\n workflowId: workflow.id,\n workflowName: workflow.name\n }, 'Failed to create workflow run record')\n throw error\n }\n\n try {\n // Resolve execution order based on dependencies\n const executionBatches = this.resolveExecutionOrder(workflow.steps as WorkflowStep[] || [])\n\n this.logger.info({\n batchSizes: executionBatches.map(batch => batch.length),\n totalBatches: executionBatches.length\n }, 'Resolved step execution order')\n\n // Execute each batch in sequence, but steps within each batch in parallel\n for (let batchIndex = 0; batchIndex < executionBatches.length; batchIndex++) {\n const batch = executionBatches[batchIndex]\n\n this.logger.info({\n batchIndex,\n stepCount: batch.length,\n stepNames: batch.map(s => s.name)\n }, 'Executing batch')\n\n // Execute all steps in this batch in parallel\n const batchPromises = batch.map((step, stepIndex) =>\n this.executeStep(step, stepIndex, context, req, workflowRun.id)\n )\n\n // Wait for all steps in the current batch to complete\n await Promise.all(batchPromises)\n\n this.logger.info({\n batchIndex,\n stepCount: batch.length\n }, 'Batch completed')\n }\n\n // Update workflow run as completed\n await this.payload.update({\n id: workflowRun.id,\n collection: 'workflow-runs',\n data: {\n completedAt: new Date().toISOString(),\n context: serializeContext(),\n status: 'completed'\n },\n req\n })\n\n this.logger.info({\n runId: workflowRun.id,\n workflowId: workflow.id,\n workflowName: workflow.name\n }, 'Workflow execution completed')\n\n } catch (error) {\n // Update workflow run as failed\n await this.payload.update({\n id: workflowRun.id,\n collection: 'workflow-runs',\n data: {\n completedAt: new Date().toISOString(),\n context: serializeContext(),\n error: error instanceof Error ? error.message : 'Unknown error',\n status: 'failed'\n },\n req\n })\n\n this.logger.error({\n error: error instanceof Error ? error.message : 'Unknown error',\n runId: workflowRun.id,\n workflowId: workflow.id,\n workflowName: workflow.name\n }, 'Workflow execution failed')\n\n throw error\n }\n }\n}\n"],"names":["JSONPath","WorkflowExecutor","payload","logger","classifyErrorType","errorMessage","includes","evaluateStepCondition","condition","context","evaluateCondition","executeStep","step","stepIndex","req","workflowRunId","stepName","name","info","hasStep","JSON","stringify","debug","availableSteps","Object","keys","steps","completedSteps","entries","filter","_","s","state","map","triggerType","trigger","type","conditionMet","contextSnapshot","stepOutputs","reduce","acc","hasOutput","output","triggerData","data","error","undefined","input","reason","skipped","updateWorkflowRunContext","_startTime","Date","now","taskSlug","inputFields","coreFields","key","value","startsWith","cleanKey","replace","properKey","charAt","toLowerCase","slice","parameters","assign","resolvedInput","resolveStepInput","Error","hasInput","hasReq","job","jobs","queue","task","jobId","id","runResults","runByID","runResult","hasResult","Promise","resolve","setTimeout","completedJob","findByID","collection","totalTried","hasError","taskStatus","isComplete","complete","log","length","latestLog","message","result","jobDetails","executionInfo","completed","success","executedAt","toISOString","duration","errorDetails","extractErrorDetailsFromJob","errorType","attempts","failureReason","updateError","stepContext","logs","timeout","timeoutMs","parseInt","actualDuration","stepId","finalError","url","method","statusCode","status","headers","timestamp","warn","parseConditionValue","expr","endsWith","test","Number","resolveJSONPathValue","resolveExecutionOrder","stepMap","Map","dependencyGraph","indegree","indexOf","dependencies","set","executionBatches","processed","Set","size","currentBatch","inDegree","has","get","push","add","otherStepName","json","path","wrap","Array","isArray","config","resolved","configKeys","contextSteps","jsonPath","hasTriggerData","hasTriggerDoc","doc","substring","resultType","nestedKeys","resolvedKeys","originalKeys","safeSerialize","obj","seen","WeakSet","serialize","val","serializeContext","operation","previousDoc","triggeredAt","user","update","contextKeys","triggerDoc","comparisonMatch","match","leftExpr","operator","rightExpr","leftValue","trim","rightValue","leftType","rightType","resultLength","finalResult","Boolean","originalResult","errorStack","stack","execute","workflow","workflowId","workflowName","contextSummary","triggerCollection","triggerOperation","hasDoc","userEmail","email","workflowRun","create","startedAt","triggeredBy","workflowVersion","batchSizes","batch","totalBatches","batchIndex","stepCount","stepNames","batchPromises","all","completedAt","runId"],"mappings":"AA+BA,SAASA,QAAQ,QAAQ,gBAAe;AAiBxC,OAAO,MAAMC;;;IACX,YACE,AAAQC,OAAgB,EACxB,AAAQC,MAAyB,CACjC;aAFQD,UAAAA;aACAC,SAAAA;IACP;IAEH;;GAEC,GACD,AAAQC,kBAAkBC,YAAoB,EAAU;QACtD,IAAIA,aAAaC,QAAQ,CAAC,cAAcD,aAAaC,QAAQ,CAAC,cAAc;YAC1E,OAAO;QACT;QACA,IAAID,aAAaC,QAAQ,CAAC,gBAAgBD,aAAaC,QAAQ,CAAC,gBAAgB;YAC9E,OAAO;QACT;QACA,IAAID,aAAaC,QAAQ,CAAC,mBAAmBD,aAAaC,QAAQ,CAAC,eAAe;YAChF,OAAO;QACT;QACA,IAAID,aAAaC,QAAQ,CAAC,cAAcD,aAAaC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YAAYpI,EAAE;gBACrB4H,YAAYD,SAAS3H,EAAE;gBACvB6H,cAAcF,SAASzL,IAAI;YAC7B,GAAG;YAEH,MAAM6B;QACR;IACF;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../src/core/workflow-executor.ts"],"sourcesContent":["import type { Payload, PayloadRequest } from 'payload'\n\n// We need to reference the generated types dynamically since they're not available at build time\n// Using generic types and casting where necessary\nexport type PayloadWorkflow = {\n id: number\n name: string\n description?: null | string\n triggers?: Array<{\n type?: null | string\n condition?: null | string\n parameters?: {\n collectionSlug?: null | string\n operation?: null | string\n global?: null | string\n globalOperation?: null | string\n [key: string]: unknown\n } | null\n [key: string]: unknown\n }> | null\n steps?: Array<{\n type?: null | string\n name?: null | string\n input?: unknown\n dependencies?: null | string[]\n condition?: null | string\n [key: string]: unknown\n }> | null\n [key: string]: unknown\n}\n\nimport Handlebars from 'handlebars'\n\n// Helper type to extract workflow step data from the generated types\nexport type WorkflowStep = {\n name: string // Ensure name is always present for our execution logic\n} & NonNullable<PayloadWorkflow['steps']>[0]\n\n// Helper type to extract workflow trigger data from the generated types\nexport type WorkflowTrigger = {\n type: string // Ensure type is always present for our execution logic\n} & NonNullable<PayloadWorkflow['triggers']>[0]\n\nexport interface ExecutionContext {\n steps: Record<string, any>\n trigger: Record<string, any>\n}\n\nexport class WorkflowExecutor {\n constructor(\n private payload: Payload,\n private logger: Payload['logger']\n ) {}\n\n /**\n * Convert string values to appropriate types based on common patterns\n */\n private convertValueType(value: unknown, key: string): unknown {\n if (typeof value !== 'string') {\n return value\n }\n\n // Type conversion patterns based on field names and values\n const numericFields = ['timeout', 'retries', 'delay', 'port', 'limit', 'offset', 'count', 'max', 'min']\n const booleanFields = ['enabled', 'required', 'active', 'success', 'failed', 'complete']\n\n // Convert numeric fields\n if (numericFields.some(field => key.toLowerCase().includes(field))) {\n const numValue = Number(value)\n if (!isNaN(numValue)) {\n this.logger.debug({\n key,\n originalValue: value,\n convertedValue: numValue\n }, 'Auto-converted field to number')\n return numValue\n }\n }\n\n // Convert boolean fields\n if (booleanFields.some(field => key.toLowerCase().includes(field))) {\n if (value === 'true') return true\n if (value === 'false') return false\n }\n\n // Try to parse as number if it looks numeric\n if (/^\\d+$/.test(value)) {\n const numValue = parseInt(value, 10)\n this.logger.debug({\n key,\n originalValue: value,\n convertedValue: numValue\n }, 'Auto-converted numeric string to number')\n return numValue\n }\n\n // Try to parse as float if it looks like a decimal\n if (/^\\d+\\.\\d+$/.test(value)) {\n const floatValue = parseFloat(value)\n this.logger.debug({\n key,\n originalValue: value,\n convertedValue: floatValue\n }, 'Auto-converted decimal string to number')\n return floatValue\n }\n\n // Return as string if no conversion applies\n return value\n }\n\n /**\n * Classifies error types based on error messages\n */\n private classifyErrorType(errorMessage: string): string {\n if (errorMessage.includes('timeout') || errorMessage.includes('ETIMEDOUT')) {\n return 'timeout'\n }\n if (errorMessage.includes('ENOTFOUND') || errorMessage.includes('getaddrinfo')) {\n return 'dns'\n }\n if (errorMessage.includes('ECONNREFUSED') || errorMessage.includes('ECONNRESET')) {\n return 'connection'\n }\n if (errorMessage.includes('network') || errorMessage.includes('fetch')) {\n return 'network'\n }\n return 'unknown'\n }\n\n /**\n * Evaluate a step condition using JSONPath\n */\n private evaluateStepCondition(condition: string, context: ExecutionContext): boolean {\n return this.evaluateCondition(condition, context)\n }\n\n /**\n * Execute a single workflow step\n */\n private async executeStep(\n step: WorkflowStep,\n stepIndex: number,\n context: ExecutionContext,\n req: PayloadRequest,\n workflowRunId?: number | string\n ): Promise<void> {\n const stepName = step.name || 'step-' + stepIndex\n\n this.logger.info({\n hasStep: 'step' in step,\n step: JSON.stringify(step),\n stepName\n }, 'Executing step')\n\n // Check step condition if present\n if (step.condition) {\n this.logger.debug({\n condition: step.condition,\n stepName,\n availableSteps: Object.keys(context.steps),\n completedSteps: Object.entries(context.steps)\n .filter(([_, s]) => s.state === 'succeeded')\n .map(([name]) => name),\n triggerType: context.trigger?.type\n }, 'Evaluating step condition')\n\n const conditionMet = this.evaluateStepCondition(step.condition, context)\n\n if (!conditionMet) {\n this.logger.info({\n condition: step.condition,\n stepName,\n contextSnapshot: JSON.stringify({\n stepOutputs: Object.entries(context.steps).reduce((acc, [name, step]) => {\n acc[name] = { state: step.state, hasOutput: !!step.output }\n return acc\n }, {} as Record<string, any>),\n triggerData: context.trigger?.data ? 'present' : 'absent'\n })\n }, 'Step condition not met, skipping')\n\n // Mark step as completed but skipped\n context.steps[stepName] = {\n error: undefined,\n input: undefined,\n output: { reason: 'Condition not met', skipped: true },\n state: 'succeeded'\n }\n\n // Update workflow run context if needed\n if (workflowRunId) {\n await this.updateWorkflowRunContext(workflowRunId, context, req)\n }\n\n return\n }\n\n this.logger.info({\n condition: step.condition,\n stepName,\n contextSnapshot: JSON.stringify({\n stepOutputs: Object.entries(context.steps).reduce((acc, [name, step]) => {\n acc[name] = { state: step.state, hasOutput: !!step.output }\n return acc\n }, {} as Record<string, any>),\n triggerData: context.trigger?.data ? 'present' : 'absent'\n })\n }, 'Step condition met, proceeding with execution')\n }\n\n // Initialize step context\n context.steps[stepName] = {\n error: undefined,\n input: undefined,\n output: undefined,\n state: 'running',\n _startTime: Date.now() // Track execution start time for independent duration tracking\n }\n\n // Move taskSlug declaration outside try block so it's accessible in catch\n const taskSlug = step.type as string\n\n try {\n // Get input configuration from the step\n const inputConfig = (step.input as Record<string, unknown>) || {}\n\n // Resolve input data using Handlebars templates\n const resolvedInput = this.resolveStepInput(inputConfig, context, taskSlug)\n context.steps[stepName].input = resolvedInput\n\n if (!taskSlug) {\n throw new Error(`Step ${stepName} is missing a task type`)\n }\n\n this.logger.info({\n hasInput: !!resolvedInput,\n hasReq: !!req,\n stepName,\n taskSlug\n }, 'Queueing task')\n\n const job = await this.payload.jobs.queue({\n input: resolvedInput,\n req,\n task: taskSlug\n })\n\n // Run the specific job immediately and wait for completion\n this.logger.info({ jobId: job.id }, 'Running job immediately using runByID')\n const runResults = await this.payload.jobs.runByID({\n id: job.id,\n req\n })\n\n this.logger.info({\n jobId: job.id,\n runResult: runResults,\n hasResult: !!runResults\n }, 'Job run completed')\n\n // Give a small delay to ensure job is fully processed\n await new Promise(resolve => setTimeout(resolve, 100))\n\n // Get the job result\n const completedJob = await this.payload.findByID({\n id: job.id,\n collection: 'payload-jobs',\n req\n })\n\n this.logger.info({\n jobId: job.id,\n totalTried: completedJob.totalTried,\n hasError: completedJob.hasError,\n taskStatus: completedJob.taskStatus ? Object.keys(completedJob.taskStatus) : 'null'\n }, 'Retrieved job results')\n\n const taskStatus = completedJob.taskStatus?.[completedJob.taskSlug]?.[completedJob.totalTried]\n const isComplete = taskStatus?.complete === true\n const hasError = completedJob.hasError || !isComplete\n\n // Extract error information from job if available\n let errorMessage: string | undefined\n if (hasError) {\n // Try to get error from the latest log entry\n if (completedJob.log && completedJob.log.length > 0) {\n const latestLog = completedJob.log[completedJob.log.length - 1]\n errorMessage = latestLog.error?.message || latestLog.error\n }\n\n // Fallback to top-level error\n if (!errorMessage && completedJob.error) {\n errorMessage = completedJob.error.message || completedJob.error\n }\n\n // Try to get error from task output if available\n if (!errorMessage && taskStatus?.output?.error) {\n errorMessage = taskStatus.output.error\n }\n\n // Check if task handler returned with state='failed'\n if (!errorMessage && taskStatus?.state === 'failed') {\n errorMessage = 'Task handler returned a failed state'\n // Try to get more specific error from output\n if (taskStatus.output?.error) {\n errorMessage = taskStatus.output.error\n }\n }\n\n // Check for network errors in the job data\n if (!errorMessage && completedJob.result) {\n const result = completedJob.result\n if (result.error) {\n errorMessage = result.error\n }\n }\n\n // Final fallback to generic message with more detail\n if (!errorMessage) {\n const jobDetails = {\n taskSlug,\n hasError: completedJob.hasError,\n taskStatus: taskStatus?.complete,\n totalTried: completedJob.totalTried\n }\n errorMessage = `Task ${taskSlug} failed without detailed error information. Job details: ${JSON.stringify(jobDetails)}`\n }\n }\n\n const result: {\n error: string | undefined\n output: unknown\n state: 'failed' | 'succeeded'\n } = {\n error: errorMessage,\n output: taskStatus?.output || {},\n state: isComplete ? 'succeeded' : 'failed'\n }\n\n // Store the output and error\n context.steps[stepName].output = result.output\n context.steps[stepName].state = result.state\n if (result.error) {\n context.steps[stepName].error = result.error\n }\n\n // Independent execution tracking (not dependent on PayloadCMS task status)\n context.steps[stepName].executionInfo = {\n completed: true, // Step execution completed (regardless of success/failure)\n success: result.state === 'succeeded',\n executedAt: new Date().toISOString(),\n duration: Date.now() - (context.steps[stepName]._startTime || Date.now())\n }\n\n // For failed steps, try to extract detailed error information from the job logs\n // This approach is more reliable than external storage and persists with the workflow\n if (result.state === 'failed') {\n const errorDetails = this.extractErrorDetailsFromJob(completedJob, context.steps[stepName], stepName)\n if (errorDetails) {\n context.steps[stepName].errorDetails = errorDetails\n\n this.logger.info({\n stepName,\n errorType: errorDetails.errorType,\n duration: errorDetails.duration,\n attempts: errorDetails.attempts\n }, 'Extracted detailed error information for failed step')\n }\n }\n\n this.logger.debug({context}, 'Step execution context')\n\n if (result.state !== 'succeeded') {\n throw new Error(result.error || `Step ${stepName} failed`)\n }\n\n this.logger.info({\n output: result.output,\n stepName\n }, 'Step completed')\n\n // Update workflow run with current step results if workflowRunId is provided\n if (workflowRunId) {\n await this.updateWorkflowRunContext(workflowRunId, context, req)\n }\n\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : 'Unknown error'\n context.steps[stepName].state = 'failed'\n context.steps[stepName].error = errorMessage\n\n // Independent execution tracking for failed steps\n context.steps[stepName].executionInfo = {\n completed: true, // Execution attempted and completed (even if it failed)\n success: false,\n executedAt: new Date().toISOString(),\n duration: Date.now() - (context.steps[stepName]._startTime || Date.now()),\n failureReason: errorMessage\n }\n\n this.logger.error({\n error: errorMessage,\n input: context.steps[stepName].input,\n stepName,\n taskSlug\n }, 'Step execution failed')\n\n // Update workflow run with current step results if workflowRunId is provided\n if (workflowRunId) {\n try {\n await this.updateWorkflowRunContext(workflowRunId, context, req)\n } catch (updateError) {\n this.logger.error({\n error: updateError instanceof Error ? updateError.message : 'Unknown error',\n stepName\n }, 'Failed to update workflow run context after step failure')\n }\n }\n\n throw error\n }\n }\n\n /**\n * Extracts detailed error information from job logs and input\n */\n private extractErrorDetailsFromJob(job: any, stepContext: any, stepName: string) {\n try {\n // Get error information from multiple sources\n const input = stepContext.input || {}\n const logs = job.log || []\n const latestLog = logs[logs.length - 1]\n\n // Extract error message from job error or log\n const errorMessage = job.error?.message || latestLog?.error?.message || 'Unknown error'\n\n // For timeout scenarios, check if it's a timeout based on duration and timeout setting\n let errorType = this.classifyErrorType(errorMessage)\n\n // Special handling for HTTP timeouts - if task failed and duration exceeds timeout, it's likely a timeout\n if (errorType === 'unknown' && input.timeout && stepContext.executionInfo?.duration) {\n const timeoutMs = parseInt(input.timeout) || 30000\n const actualDuration = stepContext.executionInfo.duration\n\n // If execution duration is close to or exceeds timeout, classify as timeout\n if (actualDuration >= (timeoutMs * 0.9)) { // 90% of timeout threshold\n errorType = 'timeout'\n this.logger.debug({\n timeoutMs,\n actualDuration,\n stepName\n }, 'Classified error as timeout based on duration analysis')\n }\n }\n\n // Calculate duration from execution info if available\n const duration = stepContext.executionInfo?.duration || 0\n\n // Extract attempt count from logs\n const attempts = job.totalTried || 1\n\n return {\n stepId: `${stepName}-${Date.now()}`,\n errorType,\n duration,\n attempts,\n finalError: errorMessage,\n context: {\n url: input.url,\n method: input.method,\n timeout: input.timeout,\n statusCode: latestLog?.output?.status,\n headers: input.headers\n },\n timestamp: new Date().toISOString()\n }\n } catch (error) {\n this.logger.warn({\n error: error instanceof Error ? error.message : 'Unknown error',\n stepName\n }, 'Failed to extract error details from job')\n return null\n }\n }\n\n\n /**\n * Resolve step execution order based on dependencies\n */\n private resolveExecutionOrder(steps: WorkflowStep[]): WorkflowStep[][] {\n const stepMap = new Map<string, WorkflowStep>()\n const dependencyGraph = new Map<string, string[]>()\n const indegree = new Map<string, number>()\n\n // Build the step map and dependency graph\n for (const step of steps) {\n const stepName = step.name || `step-${steps.indexOf(step)}`\n const dependencies = step.dependencies || []\n\n stepMap.set(stepName, { ...step, name: stepName, dependencies })\n dependencyGraph.set(stepName, dependencies)\n indegree.set(stepName, dependencies.length)\n }\n\n // Topological sort to determine execution batches\n const executionBatches: WorkflowStep[][] = []\n const processed = new Set<string>()\n\n while (processed.size < steps.length) {\n const currentBatch: WorkflowStep[] = []\n\n // Find all steps with no remaining dependencies\n for (const [stepName, inDegree] of indegree.entries()) {\n if (inDegree === 0 && !processed.has(stepName)) {\n const step = stepMap.get(stepName)\n if (step) {\n currentBatch.push(step)\n }\n }\n }\n\n if (currentBatch.length === 0) {\n throw new Error('Circular dependency detected in workflow steps')\n }\n\n executionBatches.push(currentBatch)\n\n // Update indegrees for next iteration\n for (const step of currentBatch) {\n processed.add(step.name)\n\n // Reduce indegree for steps that depend on completed steps\n for (const [otherStepName, dependencies] of dependencyGraph.entries()) {\n if (dependencies.includes(step.name) && !processed.has(otherStepName)) {\n indegree.set(otherStepName, (indegree.get(otherStepName) || 0) - 1)\n }\n }\n }\n }\n\n return executionBatches\n }\n\n\n /**\n * Resolve step input using Handlebars templates with automatic type conversion\n */\n private resolveStepInput(config: Record<string, unknown>, context: ExecutionContext, stepType?: string): Record<string, unknown> {\n const resolved: Record<string, unknown> = {}\n\n this.logger.debug({\n configKeys: Object.keys(config),\n contextSteps: Object.keys(context.steps),\n triggerType: context.trigger?.type,\n stepType\n }, 'Starting step input resolution with Handlebars')\n\n for (const [key, value] of Object.entries(config)) {\n if (typeof value === 'string') {\n // Check if the string contains Handlebars templates\n if (value.includes('{{') && value.includes('}}')) {\n this.logger.debug({\n key,\n template: value,\n availableSteps: Object.keys(context.steps),\n hasTriggerData: !!context.trigger?.data,\n hasTriggerDoc: !!context.trigger?.doc\n }, 'Processing Handlebars template')\n\n try {\n const template = Handlebars.compile(value)\n const result = template(context)\n\n this.logger.debug({\n key,\n template: value,\n result: JSON.stringify(result).substring(0, 200),\n resultType: typeof result\n }, 'Handlebars template resolved successfully')\n\n resolved[key] = this.convertValueType(result, key)\n } catch (error) {\n this.logger.warn({\n error: error instanceof Error ? error.message : 'Unknown error',\n key,\n template: value,\n contextSnapshot: JSON.stringify(context).substring(0, 500)\n }, 'Failed to resolve Handlebars template')\n resolved[key] = value // Keep original value if resolution fails\n }\n } else {\n // Regular string, apply type conversion\n resolved[key] = this.convertValueType(value, key)\n }\n } else if (typeof value === 'object' && value !== null) {\n // Recursively resolve nested objects\n this.logger.debug({\n key,\n nestedKeys: Object.keys(value as Record<string, unknown>)\n }, 'Recursively resolving nested object')\n\n resolved[key] = this.resolveStepInput(value as Record<string, unknown>, context, stepType)\n } else {\n // Keep literal values as-is\n resolved[key] = value\n }\n }\n\n this.logger.debug({\n resolvedKeys: Object.keys(resolved),\n originalKeys: Object.keys(config)\n }, 'Step input resolution completed')\n\n return resolved\n }\n\n /**\n * Safely serialize an object, handling circular references and non-serializable values\n */\n private safeSerialize(obj: unknown): unknown {\n const seen = new WeakSet()\n\n const serialize = (value: unknown): unknown => {\n if (value === null || typeof value !== 'object') {\n return value\n }\n\n if (seen.has(value)) {\n return '[Circular Reference]'\n }\n\n seen.add(value)\n\n if (Array.isArray(value)) {\n return value.map(serialize)\n }\n\n const result: Record<string, unknown> = {}\n for (const [key, val] of Object.entries(value as Record<string, unknown>)) {\n try {\n // Skip non-serializable properties that are likely internal database objects\n if (key === 'table' || key === 'schema' || key === '_' || key === '__') {\n continue\n }\n result[key] = serialize(val)\n } catch {\n // Skip properties that can't be accessed or serialized\n result[key] = '[Non-serializable]'\n }\n }\n\n return result\n }\n\n return serialize(obj)\n }\n\n /**\n * Update workflow run with current context\n */\n private async updateWorkflowRunContext(\n workflowRunId: number | string,\n context: ExecutionContext,\n req: PayloadRequest\n ): Promise<void> {\n const serializeContext = () => ({\n steps: this.safeSerialize(context.steps),\n trigger: {\n type: context.trigger.type,\n collection: context.trigger.collection,\n data: this.safeSerialize(context.trigger.data),\n doc: this.safeSerialize(context.trigger.doc),\n operation: context.trigger.operation,\n previousDoc: this.safeSerialize(context.trigger.previousDoc),\n triggeredAt: context.trigger.triggeredAt,\n user: context.trigger.req?.user\n }\n })\n\n await this.payload.update({\n id: workflowRunId,\n collection: 'workflow-runs',\n data: {\n context: serializeContext()\n },\n req\n })\n }\n\n /**\n * Evaluate a condition using Handlebars templates and comparison operators\n */\n public evaluateCondition(condition: string, context: ExecutionContext): boolean {\n this.logger.debug({\n condition,\n contextKeys: Object.keys(context),\n triggerType: context.trigger?.type,\n triggerData: context.trigger?.data,\n triggerDoc: context.trigger?.doc ? 'present' : 'absent'\n }, 'Starting condition evaluation')\n\n try {\n // Check if this is a comparison expression\n const comparisonMatch = condition.match(/^(.+?)\\s*(==|!=|>|<|>=|<=)\\s*(.+)$/)\n\n if (comparisonMatch) {\n const [, leftExpr, operator, rightExpr] = comparisonMatch\n\n // Evaluate left side (could be Handlebars template or JSONPath)\n const leftValue = this.resolveConditionValue(leftExpr.trim(), context)\n\n // Evaluate right side (could be Handlebars template, JSONPath, or literal)\n const rightValue = this.resolveConditionValue(rightExpr.trim(), context)\n\n this.logger.debug({\n condition,\n leftExpr: leftExpr.trim(),\n leftValue,\n operator,\n rightExpr: rightExpr.trim(),\n rightValue,\n leftType: typeof leftValue,\n rightType: typeof rightValue\n }, 'Evaluating comparison condition')\n\n // Perform comparison\n let result: boolean\n switch (operator) {\n case '!=':\n result = leftValue !== rightValue\n break\n case '<':\n result = Number(leftValue) < Number(rightValue)\n break\n case '<=':\n result = Number(leftValue) <= Number(rightValue)\n break\n case '==':\n result = leftValue === rightValue\n break\n case '>':\n result = Number(leftValue) > Number(rightValue)\n break\n case '>=':\n result = Number(leftValue) >= Number(rightValue)\n break\n default:\n throw new Error(`Unknown comparison operator: ${operator}`)\n }\n\n this.logger.debug({\n condition,\n result,\n leftValue,\n rightValue,\n operator\n }, 'Comparison condition evaluation completed')\n\n return result\n } else {\n // Treat as template or JSONPath boolean evaluation\n const result = this.resolveConditionValue(condition, context)\n\n this.logger.debug({\n condition,\n result,\n resultType: Array.isArray(result) ? 'array' : typeof result,\n resultLength: Array.isArray(result) ? result.length : undefined\n }, 'Boolean evaluation result')\n\n // Handle different result types\n let finalResult: boolean\n if (Array.isArray(result)) {\n finalResult = result.length > 0 && Boolean(result[0])\n } else {\n finalResult = Boolean(result)\n }\n\n this.logger.debug({\n condition,\n finalResult,\n originalResult: result\n }, 'Boolean condition evaluation completed')\n\n return finalResult\n }\n } catch (error) {\n this.logger.warn({\n condition,\n error: error instanceof Error ? error.message : 'Unknown error',\n errorStack: error instanceof Error ? error.stack : undefined\n }, 'Failed to evaluate condition')\n\n // If condition evaluation fails, assume false\n return false\n }\n }\n\n /**\n * Resolve a condition value using Handlebars templates or JSONPath\n */\n private resolveConditionValue(expr: string, context: ExecutionContext): any {\n // Handle string literals\n if ((expr.startsWith('\"') && expr.endsWith('\"')) || (expr.startsWith(\"'\") && expr.endsWith(\"'\"))) {\n return expr.slice(1, -1) // Remove quotes\n }\n\n // Handle boolean literals\n if (expr === 'true') {return true}\n if (expr === 'false') {return false}\n\n // Handle number literals\n if (/^-?\\d+(?:\\.\\d+)?$/.test(expr)) {\n return Number(expr)\n }\n\n // Handle Handlebars templates\n if (expr.includes('{{') && expr.includes('}}')) {\n try {\n const template = Handlebars.compile(expr)\n return template(context)\n } catch (error) {\n this.logger.warn({\n error: error instanceof Error ? error.message : 'Unknown error',\n expr\n }, 'Failed to resolve Handlebars condition')\n return false\n }\n }\n\n\n // Return as string if nothing else matches\n return expr\n }\n\n /**\n * Execute a workflow with the given context\n */\n async execute(workflow: PayloadWorkflow, context: ExecutionContext, req: PayloadRequest): Promise<void> {\n this.logger.info({\n workflowId: workflow.id,\n workflowName: workflow.name\n }, 'Starting workflow execution')\n\n const serializeContext = () => ({\n steps: this.safeSerialize(context.steps),\n trigger: {\n type: context.trigger.type,\n collection: context.trigger.collection,\n data: this.safeSerialize(context.trigger.data),\n doc: this.safeSerialize(context.trigger.doc),\n operation: context.trigger.operation,\n previousDoc: this.safeSerialize(context.trigger.previousDoc),\n triggeredAt: context.trigger.triggeredAt,\n user: context.trigger.req?.user\n }\n })\n\n this.logger.info({\n workflowId: workflow.id,\n workflowName: workflow.name,\n contextSummary: {\n triggerType: context.trigger.type,\n triggerCollection: context.trigger.collection,\n triggerOperation: context.trigger.operation,\n hasDoc: !!context.trigger.doc,\n userEmail: context.trigger.req?.user?.email\n }\n }, 'About to create workflow run record')\n\n // Create a workflow run record\n let workflowRun;\n try {\n workflowRun = await this.payload.create({\n collection: 'workflow-runs',\n data: {\n context: serializeContext(),\n startedAt: new Date().toISOString(),\n status: 'running',\n triggeredBy: context.trigger.req?.user?.email || 'system',\n workflow: workflow.id,\n workflowVersion: 1 // Default version since generated type doesn't have _version field\n },\n req\n })\n\n this.logger.info({\n workflowRunId: workflowRun.id,\n workflowId: workflow.id,\n workflowName: workflow.name\n }, 'Workflow run record created successfully')\n } catch (error) {\n this.logger.error({\n error: error instanceof Error ? error.message : 'Unknown error',\n errorStack: error instanceof Error ? error.stack : undefined,\n workflowId: workflow.id,\n workflowName: workflow.name\n }, 'Failed to create workflow run record')\n throw error\n }\n\n try {\n // Resolve execution order based on dependencies\n const executionBatches = this.resolveExecutionOrder(workflow.steps as WorkflowStep[] || [])\n\n this.logger.info({\n batchSizes: executionBatches.map(batch => batch.length),\n totalBatches: executionBatches.length\n }, 'Resolved step execution order')\n\n // Execute each batch in sequence, but steps within each batch in parallel\n for (let batchIndex = 0; batchIndex < executionBatches.length; batchIndex++) {\n const batch = executionBatches[batchIndex]\n\n this.logger.info({\n batchIndex,\n stepCount: batch.length,\n stepNames: batch.map(s => s.name)\n }, 'Executing batch')\n\n // Execute all steps in this batch in parallel\n const batchPromises = batch.map((step, stepIndex) =>\n this.executeStep(step, stepIndex, context, req, workflowRun.id)\n )\n\n // Wait for all steps in the current batch to complete\n await Promise.all(batchPromises)\n\n this.logger.info({\n batchIndex,\n stepCount: batch.length\n }, 'Batch completed')\n }\n\n // Update workflow run as completed\n await this.payload.update({\n id: workflowRun.id,\n collection: 'workflow-runs',\n data: {\n completedAt: new Date().toISOString(),\n context: serializeContext(),\n status: 'completed'\n },\n req\n })\n\n this.logger.info({\n runId: workflowRun.id,\n workflowId: workflow.id,\n workflowName: workflow.name\n }, 'Workflow execution completed')\n\n } catch (error) {\n // Update workflow run as failed\n await this.payload.update({\n id: workflowRun.id,\n collection: 'workflow-runs',\n data: {\n completedAt: new Date().toISOString(),\n context: serializeContext(),\n error: error instanceof Error ? error.message : 'Unknown error',\n status: 'failed'\n },\n req\n })\n\n this.logger.error({\n error: error instanceof Error ? error.message : 'Unknown error',\n runId: workflowRun.id,\n workflowId: workflow.id,\n workflowName: workflow.name\n }, 'Workflow execution failed')\n\n throw error\n }\n }\n}\n"],"names":["Handlebars","WorkflowExecutor","payload","logger","convertValueType","value","key","numericFields","booleanFields","some","field","toLowerCase","includes","numValue","Number","isNaN","debug","originalValue","convertedValue","test","parseInt","floatValue","parseFloat","classifyErrorType","errorMessage","evaluateStepCondition","condition","context","evaluateCondition","executeStep","step","stepIndex","req","workflowRunId","stepName","name","info","hasStep","JSON","stringify","availableSteps","Object","keys","steps","completedSteps","entries","filter","_","s","state","map","triggerType","trigger","type","conditionMet","contextSnapshot","stepOutputs","reduce","acc","hasOutput","output","triggerData","data","error","undefined","input","reason","skipped","updateWorkflowRunContext","_startTime","Date","now","taskSlug","inputConfig","resolvedInput","resolveStepInput","Error","hasInput","hasReq","job","jobs","queue","task","jobId","id","runResults","runByID","runResult","hasResult","Promise","resolve","setTimeout","completedJob","findByID","collection","totalTried","hasError","taskStatus","isComplete","complete","log","length","latestLog","message","result","jobDetails","executionInfo","completed","success","executedAt","toISOString","duration","errorDetails","extractErrorDetailsFromJob","errorType","attempts","failureReason","updateError","stepContext","logs","timeout","timeoutMs","actualDuration","stepId","finalError","url","method","statusCode","status","headers","timestamp","warn","resolveExecutionOrder","stepMap","Map","dependencyGraph","indegree","indexOf","dependencies","set","executionBatches","processed","Set","size","currentBatch","inDegree","has","get","push","add","otherStepName","config","stepType","resolved","configKeys","contextSteps","template","hasTriggerData","hasTriggerDoc","doc","compile","substring","resultType","nestedKeys","resolvedKeys","originalKeys","safeSerialize","obj","seen","WeakSet","serialize","Array","isArray","val","serializeContext","operation","previousDoc","triggeredAt","user","update","contextKeys","triggerDoc","comparisonMatch","match","leftExpr","operator","rightExpr","leftValue","resolveConditionValue","trim","rightValue","leftType","rightType","resultLength","finalResult","Boolean","originalResult","errorStack","stack","expr","startsWith","endsWith","slice","execute","workflow","workflowId","workflowName","contextSummary","triggerCollection","triggerOperation","hasDoc","userEmail","email","workflowRun","create","startedAt","triggeredBy","workflowVersion","batchSizes","batch","totalBatches","batchIndex","stepCount","stepNames","batchPromises","all","completedAt","runId"],"mappings":"AA+BA,OAAOA,gBAAgB,aAAY;AAiBnC,OAAO,MAAMC;;;IACX,YACE,AAAQC,OAAgB,EACxB,AAAQC,MAAyB,CACjC;aAFQD,UAAAA;aACAC,SAAAA;IACP;IAEH;;GAEC,GACD,AAAQC,iBAAiBC,KAAc,EAAEC,GAAW,EAAW;QAC7D,IAAI,OAAOD,UAAU,UAAU;YAC7B,OAAOA;QACT;QAEA,2DAA2D;QAC3D,MAAME,gBAAgB;YAAC;YAAW;YAAW;YAAS;YAAQ;YAAS;YAAU;YAAS;YAAO;SAAM;QACvG,MAAMC,gBAAgB;YAAC;YAAW;YAAY;YAAU;YAAW;YAAU;SAAW;QAExF,yBAAyB;QACzB,IAAID,cAAcE,IAAI,CAACC,CAAAA,QAASJ,IAAIK,WAAW,GAAGC,QAAQ,CAACF,SAAS;YAClE,MAAMG,WAAWC,OAAOT;YACxB,IAAI,CAACU,MAAMF,WAAW;gBACpB,IAAI,CAACV,MAAM,CAACa,KAAK,CAAC;oBAChBV;oBACAW,eAAeZ;oBACfa,gBAAgBL;gBAClB,GAAG;gBACH,OAAOA;YACT;QACF;QAEA,yBAAyB;QACzB,IAAIL,cAAcC,IAAI,CAACC,CAAAA,QAASJ,IAAIK,WAAW,GAAGC,QAAQ,CAACF,SAAS;YAClE,IAAIL,UAAU,QAAQ,OAAO;YAC7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