mirror of
https://github.com/xtr-dev/payload-automation.git
synced 2025-12-12 09:43:22 +00:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 59a97e519e | |||
| b3d2877f0a | |||
| c050ee835a | |||
| 1f80028042 |
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "@xtr-dev/payload-workflows",
|
"name": "@xtr-dev/payload-workflows",
|
||||||
"version": "0.0.32",
|
"version": "0.0.34",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "@xtr-dev/payload-workflows",
|
"name": "@xtr-dev/payload-workflows",
|
||||||
"version": "0.0.32",
|
"version": "0.0.34",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"jsonpath-plus": "^10.3.0",
|
"jsonpath-plus": "^10.3.0",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@xtr-dev/payload-automation",
|
"name": "@xtr-dev/payload-automation",
|
||||||
"version": "0.0.32",
|
"version": "0.0.34",
|
||||||
"description": "PayloadCMS Automation Plugin - Comprehensive workflow automation system with visual workflow building, execution tracking, and step types",
|
"description": "PayloadCMS Automation Plugin - Comprehensive workflow automation system with visual workflow building, execution tracking, and step types",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
|
|||||||
@@ -1029,17 +1029,24 @@ export class WorkflowExecutor {
|
|||||||
}
|
}
|
||||||
}>
|
}>
|
||||||
|
|
||||||
this.logger.debug({
|
this.logger.info({
|
||||||
workflowId: workflow.id,
|
workflowId: workflow.id,
|
||||||
workflowName: workflow.name,
|
workflowName: workflow.name,
|
||||||
triggerCount: triggers?.length || 0,
|
triggerCount: triggers?.length || 0,
|
||||||
triggers: triggers?.map(t => ({
|
triggers: triggers?.map(t => ({
|
||||||
type: t.type,
|
type: t.type,
|
||||||
|
parameters: t.parameters,
|
||||||
collection: t.parameters?.collection,
|
collection: t.parameters?.collection,
|
||||||
collectionSlug: t.parameters?.collectionSlug,
|
collectionSlug: t.parameters?.collectionSlug,
|
||||||
operation: t.parameters?.operation
|
operation: t.parameters?.operation,
|
||||||
}))
|
// Debug matching criteria
|
||||||
}, 'Checking workflow triggers')
|
typeMatch: t.type === 'collection-trigger',
|
||||||
|
collectionMatch: (t.parameters?.collection === collection || t.parameters?.collectionSlug === collection),
|
||||||
|
operationMatch: t.parameters?.operation === operation
|
||||||
|
})),
|
||||||
|
targetCollection: collection,
|
||||||
|
targetOperation: operation
|
||||||
|
}, 'Checking workflow triggers with detailed matching info')
|
||||||
|
|
||||||
const matchingTriggers = triggers?.filter(trigger =>
|
const matchingTriggers = triggers?.filter(trigger =>
|
||||||
trigger.type === 'collection-trigger' &&
|
trigger.type === 'collection-trigger' &&
|
||||||
@@ -1083,7 +1090,7 @@ export class WorkflowExecutor {
|
|||||||
|
|
||||||
// Check trigger condition if present
|
// Check trigger condition if present
|
||||||
if (trigger.condition) {
|
if (trigger.condition) {
|
||||||
this.logger.debug({
|
this.logger.info({
|
||||||
collection,
|
collection,
|
||||||
operation,
|
operation,
|
||||||
condition: trigger.condition,
|
condition: trigger.condition,
|
||||||
@@ -1091,8 +1098,10 @@ export class WorkflowExecutor {
|
|||||||
docFields: doc ? Object.keys(doc) : [],
|
docFields: doc ? Object.keys(doc) : [],
|
||||||
previousDocId: (previousDoc as any)?.id,
|
previousDocId: (previousDoc as any)?.id,
|
||||||
workflowId: workflow.id,
|
workflowId: workflow.id,
|
||||||
workflowName: workflow.name
|
workflowName: workflow.name,
|
||||||
}, 'Evaluating collection trigger condition')
|
docStatus: (doc as any)?.status,
|
||||||
|
previousDocStatus: (previousDoc as any)?.status
|
||||||
|
}, 'Evaluating trigger condition before execution')
|
||||||
|
|
||||||
const conditionMet = this.evaluateCondition(trigger.condition, context)
|
const conditionMet = this.evaluateCondition(trigger.condition, context)
|
||||||
|
|
||||||
|
|||||||
@@ -159,7 +159,7 @@ export const workflowsPlugin =
|
|||||||
}
|
}
|
||||||
|
|
||||||
const collection = config.collections[collectionIndex]
|
const collection = config.collections[collectionIndex]
|
||||||
logger.info(`Found collection '${triggerSlug}' - modifying its hooks...`)
|
logger.debug(`Found collection '${triggerSlug}' - modifying its hooks...`)
|
||||||
|
|
||||||
// Initialize hooks if needed
|
// Initialize hooks if needed
|
||||||
if (!collection.hooks) {
|
if (!collection.hooks) {
|
||||||
@@ -266,7 +266,7 @@ export const workflowsPlugin =
|
|||||||
|
|
||||||
// Add the hook to the collection config
|
// Add the hook to the collection config
|
||||||
collection.hooks.afterChange.push(automationHook)
|
collection.hooks.afterChange.push(automationHook)
|
||||||
logger.info(`Added automation hook to '${triggerSlug}' - hook count: ${collection.hooks.afterChange.length}`)
|
logger.debug(`Added automation hook to '${triggerSlug}' - hook count: ${collection.hooks.afterChange.length}`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -275,7 +275,7 @@ export const workflowsPlugin =
|
|||||||
}
|
}
|
||||||
|
|
||||||
const configLogger = getConfigLogger()
|
const configLogger = getConfigLogger()
|
||||||
configLogger.info(`Configuring workflow plugin with ${Object.keys(pluginOptions.collectionTriggers || {}).length} collection triggers`)
|
configLogger.debug(`Configuring workflow plugin with ${Object.keys(pluginOptions.collectionTriggers || {}).length} collection triggers`)
|
||||||
|
|
||||||
// Generate cron tasks for workflows with cron triggers
|
// Generate cron tasks for workflows with cron triggers
|
||||||
generateCronTasks(config)
|
generateCronTasks(config)
|
||||||
|
|||||||
Reference in New Issue
Block a user