@xtr-dev/payload-automation 0.0.35 → 0.0.36

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 CHANGED
@@ -155,6 +155,34 @@ Use JSONPath to access workflow data:
155
155
  - Node.js ^18.20.2 || >=20.9.0
156
156
  - pnpm ^9 || ^10
157
157
 
158
+ ## Environment Variables
159
+
160
+ Control plugin logging with these environment variables:
161
+
162
+ ### `PAYLOAD_AUTOMATION_LOG_LEVEL`
163
+ Controls both configuration-time and runtime logging.
164
+ - **Values**: `silent`, `error`, `warn`, `info`, `debug`, `trace`
165
+ - **Default**: `warn`
166
+ - **Example**: `PAYLOAD_AUTOMATION_LOG_LEVEL=debug`
167
+
168
+ ### `PAYLOAD_AUTOMATION_CONFIG_LOG_LEVEL` (optional)
169
+ Override log level specifically for configuration-time logs (plugin setup).
170
+ - **Values**: Same as above
171
+ - **Default**: Falls back to `PAYLOAD_AUTOMATION_LOG_LEVEL` or `warn`
172
+ - **Example**: `PAYLOAD_AUTOMATION_CONFIG_LOG_LEVEL=silent`
173
+
174
+ ### Production Usage
175
+ For production, keep the default (`warn`) or use `error` or `silent`:
176
+ ```bash
177
+ PAYLOAD_AUTOMATION_LOG_LEVEL=error npm start
178
+ ```
179
+
180
+ ### Development Usage
181
+ For debugging, use `debug` or `info`:
182
+ ```bash
183
+ PAYLOAD_AUTOMATION_LOG_LEVEL=debug npm run dev
184
+ ```
185
+
158
186
  ## Documentation
159
187
 
160
188
  Full documentation coming soon. For now, explore the development environment in the repository for examples and patterns.
@@ -113,7 +113,6 @@ export const workflowsPlugin = (pluginOptions)=>(config)=>{
113
113
  // CRITICAL: Modify existing collection configs BEFORE PayloadCMS processes them
114
114
  // This is the ONLY time we can add hooks that will actually work
115
115
  const logger = getConfigLogger();
116
- logger.debug('Modifying collection configs...');
117
116
  if (config.collections && pluginOptions.collectionTriggers) {
118
117
  for (const [triggerSlug, triggerConfig] of Object.entries(pluginOptions.collectionTriggers)){
119
118
  if (!triggerConfig) {
@@ -126,7 +125,6 @@ export const workflowsPlugin = (pluginOptions)=>(config)=>{
126
125
  continue;
127
126
  }
128
127
  const collection = config.collections[collectionIndex];
129
- logger.debug(`Found collection '${triggerSlug}' - modifying its hooks...`);
130
128
  // Initialize hooks if needed
131
129
  if (!collection.hooks) {
132
130
  collection.hooks = {};
@@ -209,7 +207,6 @@ export const workflowsPlugin = (pluginOptions)=>(config)=>{
209
207
  });
210
208
  // Add the hook to the collection config
211
209
  collection.hooks.afterChange.push(automationHook);
212
- logger.debug(`Added automation hook to '${triggerSlug}' - hook count: ${collection.hooks.afterChange.length}`);
213
210
  }
214
211
  }
215
212
  if (!config.jobs) {
@@ -218,15 +215,11 @@ export const workflowsPlugin = (pluginOptions)=>(config)=>{
218
215
  };
219
216
  }
220
217
  const configLogger = getConfigLogger();
221
- configLogger.debug(`Configuring workflow plugin with ${Object.keys(pluginOptions.collectionTriggers || {}).length} collection triggers`);
222
218
  // Generate cron tasks for workflows with cron triggers
223
219
  generateCronTasks(config);
224
220
  for (const step of pluginOptions.steps){
225
221
  if (!config.jobs?.tasks?.find((task)=>task.slug === step.slug)) {
226
- configLogger.debug(`Registering task: ${step.slug}`);
227
222
  config.jobs?.tasks?.push(step);
228
- } else {
229
- configLogger.debug(`Task ${step.slug} already registered, skipping`);
230
223
  }
231
224
  }
232
225
  // Initialize webhook endpoint
@@ -234,10 +227,8 @@ export const workflowsPlugin = (pluginOptions)=>(config)=>{
234
227
  // Set up onInit to register collection hooks and initialize features
235
228
  const incomingOnInit = config.onInit;
236
229
  config.onInit = async (payload)=>{
237
- configLogger.info(`onInit called - collections: ${Object.keys(payload.collections).length}`);
238
230
  // Execute any existing onInit functions first
239
231
  if (incomingOnInit) {
240
- configLogger.debug('Executing existing onInit function');
241
232
  await incomingOnInit(payload);
242
233
  }
243
234
  // Initialize the logger with the payload instance
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/plugin/index.ts"],"sourcesContent":["import type {Config} from 'payload'\n\nimport type {CollectionTriggerConfigCrud, WorkflowsPluginConfig} from \"./config-types.js\"\n\nimport {createWorkflowCollection} from '../collections/Workflow.js'\nimport {WorkflowRunsCollection} from '../collections/WorkflowRuns.js'\nimport {WorkflowExecutor} from '../core/workflow-executor.js'\nimport {generateCronTasks, registerCronJobs} from './cron-scheduler.js'\nimport {initCollectionHooks} from \"./init-collection-hooks.js\"\nimport {initGlobalHooks} from \"./init-global-hooks.js\"\nimport {initStepTasks} from \"./init-step-tasks.js\"\nimport {initWebhookEndpoint} from \"./init-webhook.js\"\nimport {initWorkflowHooks} from './init-workflow-hooks.js'\nimport {getConfigLogger, initializeLogger} from './logger.js'\n\nexport {getLogger} from './logger.js'\n\n// Improved executor registry with proper error handling and logging\ninterface ExecutorRegistry {\n executor: null | WorkflowExecutor\n isInitialized: boolean\n logger: any | null\n}\n\nconst executorRegistry: ExecutorRegistry = {\n executor: null,\n isInitialized: false,\n logger: null\n}\n\nconst setWorkflowExecutor = (executor: WorkflowExecutor, logger: any) => {\n executorRegistry.executor = executor\n executorRegistry.logger = logger\n executorRegistry.isInitialized = true\n\n logger.info('Workflow executor initialized and registered successfully')\n}\n\nconst getExecutorRegistry = (): ExecutorRegistry => {\n return executorRegistry\n}\n\n// Helper function to create failed workflow runs for tracking errors\nconst createFailedWorkflowRun = async (args: any, errorMessage: string, logger: any) => {\n try {\n // Only create failed workflow runs if we have enough context\n if (!args?.req?.payload || !args?.collection?.slug) {\n return\n }\n\n // Find workflows that should have been triggered\n const workflows = await args.req.payload.find({\n collection: 'workflows',\n limit: 10,\n req: args.req,\n where: {\n 'triggers.collectionSlug': {\n equals: args.collection.slug\n },\n 'triggers.operation': {\n equals: args.operation\n },\n 'triggers.type': {\n equals: 'collection-trigger'\n }\n }\n })\n\n // Create failed workflow runs for each matching workflow\n for (const workflow of workflows.docs) {\n await args.req.payload.create({\n collection: 'workflow-runs',\n data: {\n completedAt: new Date().toISOString(),\n context: {\n steps: {},\n trigger: {\n type: 'collection',\n collection: args.collection.slug,\n doc: args.doc,\n operation: args.operation,\n previousDoc: args.previousDoc,\n triggeredAt: new Date().toISOString()\n }\n },\n error: `Hook execution failed: ${errorMessage}`,\n inputs: {},\n logs: [{\n level: 'error',\n message: `Hook execution failed: ${errorMessage}`,\n timestamp: new Date().toISOString()\n }],\n outputs: {},\n startedAt: new Date().toISOString(),\n status: 'failed',\n steps: [],\n triggeredBy: args?.req?.user?.email || 'system',\n workflow: workflow.id,\n workflowVersion: 1\n },\n req: args.req\n })\n }\n\n if (workflows.docs.length > 0) {\n logger.info({\n errorMessage,\n workflowCount: workflows.docs.length\n }, 'Created failed workflow runs for hook execution error')\n }\n\n } catch (error) {\n // Don't let workflow run creation failures break the original operation\n logger.warn({\n error: error instanceof Error ? error.message : 'Unknown error'\n }, 'Failed to create failed workflow run record')\n }\n}\n\nconst applyCollectionsConfig = <T extends string>(pluginOptions: WorkflowsPluginConfig<T>, config: Config) => {\n // Add workflow collections\n if (!config.collections) {\n config.collections = []\n }\n\n config.collections.push(\n createWorkflowCollection(pluginOptions),\n WorkflowRunsCollection\n )\n}\n\n// Removed config-phase hook registration - user collections don't exist during config phase\n\n\nexport const workflowsPlugin =\n <TSlug extends string>(pluginOptions: WorkflowsPluginConfig<TSlug>) =>\n (config: Config): Config => {\n // If the plugin is disabled, return config unchanged\n if (pluginOptions.enabled === false) {\n return config\n }\n\n applyCollectionsConfig<TSlug>(pluginOptions, config)\n\n // CRITICAL: Modify existing collection configs BEFORE PayloadCMS processes them\n // This is the ONLY time we can add hooks that will actually work\n const logger = getConfigLogger()\n logger.debug('Modifying collection configs...')\n\n if (config.collections && pluginOptions.collectionTriggers) {\n for (const [triggerSlug, triggerConfig] of Object.entries(pluginOptions.collectionTriggers)) {\n if (!triggerConfig) {continue}\n\n // Find the collection config that matches\n const collectionIndex = config.collections.findIndex(c => c.slug === triggerSlug)\n if (collectionIndex === -1) {\n logger.warn(`Collection '${triggerSlug}' not found in config.collections`)\n continue\n }\n\n const collection = config.collections[collectionIndex]\n logger.debug(`Found collection '${triggerSlug}' - modifying its hooks...`)\n\n // Initialize hooks if needed\n if (!collection.hooks) {\n collection.hooks = {}\n }\n if (!collection.hooks.afterChange) {\n collection.hooks.afterChange = []\n }\n\n // Create a reliable hook function with proper dependency injection\n const automationHook = Object.assign(\n async function payloadAutomationHook(args: any) {\n const registry = getExecutorRegistry()\n\n // Use proper logger if available, fallback to args.req.payload.logger\n const logger = registry.logger || args?.req?.payload?.logger || console\n\n try {\n logger.info({\n collection: args?.collection?.slug,\n docId: args?.doc?.id,\n hookType: 'automation',\n operation: args?.operation\n }, 'Collection automation hook triggered')\n\n if (!registry.isInitialized) {\n logger.warn('Workflow executor not yet initialized, attempting lazy initialization')\n \n try {\n // Try to create executor if we have a payload instance\n if (args.req?.payload) {\n logger.info('Creating workflow executor via lazy initialization')\n const { WorkflowExecutor } = await import('../core/workflow-executor.js')\n const executor = new WorkflowExecutor(args.req.payload, logger)\n setWorkflowExecutor(executor, logger)\n logger.info('Lazy initialization successful')\n } else {\n logger.error('Cannot lazy initialize - no payload instance available')\n await createFailedWorkflowRun(args, 'Workflow executor not initialized and lazy initialization failed - no payload instance', logger)\n return undefined\n }\n } catch (error) {\n logger.error('Lazy initialization failed:', error)\n const errorMessage = error instanceof Error ? error.message : String(error)\n await createFailedWorkflowRun(args, `Workflow executor lazy initialization failed: ${errorMessage}`, logger)\n return undefined\n }\n }\n\n // Re-check registry after potential lazy initialization\n const updatedRegistry = getExecutorRegistry()\n if (!updatedRegistry.executor) {\n logger.error('Workflow executor is null despite being marked as initialized')\n // Create a failed workflow run to track this issue\n await createFailedWorkflowRun(args, 'Executor not available after initialization', logger)\n return undefined\n }\n\n logger.debug('Executing triggered workflows...')\n await updatedRegistry.executor.executeTriggeredWorkflows(\n args.collection.slug,\n args.operation,\n args.doc,\n args.previousDoc,\n args.req\n )\n\n logger.info({\n collection: args?.collection?.slug,\n docId: args?.doc?.id,\n operation: args?.operation\n }, 'Workflow execution completed successfully')\n\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : 'Unknown error'\n\n logger.error({\n collection: args?.collection?.slug,\n docId: args?.doc?.id,\n error: errorMessage,\n errorStack: error instanceof Error ? error.stack : undefined,\n operation: args?.operation\n }, 'Hook execution failed')\n\n // Create a failed workflow run to track this error\n try {\n await createFailedWorkflowRun(args, errorMessage, logger)\n } catch (createError) {\n logger.error({\n error: createError instanceof Error ? createError.message : 'Unknown error'\n }, 'Failed to create workflow run for hook error')\n }\n\n // Don't throw to prevent breaking the original operation\n }\n\n return undefined\n },\n {\n __isAutomationHook: true,\n __version: '0.0.22'\n }\n )\n\n // Add the hook to the collection config\n collection.hooks.afterChange.push(automationHook)\n logger.debug(`Added automation hook to '${triggerSlug}' - hook count: ${collection.hooks.afterChange.length}`)\n }\n }\n\n if (!config.jobs) {\n config.jobs = {tasks: []}\n }\n\n const configLogger = getConfigLogger()\n configLogger.debug(`Configuring workflow plugin with ${Object.keys(pluginOptions.collectionTriggers || {}).length} collection triggers`)\n\n // Generate cron tasks for workflows with cron triggers\n generateCronTasks(config)\n\n for (const step of pluginOptions.steps) {\n if (!config.jobs?.tasks?.find(task => task.slug === step.slug)) {\n configLogger.debug(`Registering task: ${step.slug}`)\n config.jobs?.tasks?.push(step)\n } else {\n configLogger.debug(`Task ${step.slug} already registered, skipping`)\n }\n }\n\n // Initialize webhook endpoint\n initWebhookEndpoint(config, pluginOptions.webhookPrefix || 'webhook')\n\n // Set up onInit to register collection hooks and initialize features\n const incomingOnInit = config.onInit\n config.onInit = async (payload) => {\n configLogger.info(`onInit called - collections: ${Object.keys(payload.collections).length}`)\n\n // Execute any existing onInit functions first\n if (incomingOnInit) {\n configLogger.debug('Executing existing onInit function')\n await incomingOnInit(payload)\n }\n\n // Initialize the logger with the payload instance\n const logger = initializeLogger(payload)\n logger.info('Logger initialized with payload instance')\n\n // Log collection trigger configuration\n logger.info(`Plugin configuration: ${Object.keys(pluginOptions.collectionTriggers || {}).length} collection triggers, ${pluginOptions.steps?.length || 0} steps`)\n\n // Create workflow executor instance\n logger.debug('Creating workflow executor instance')\n const executor = new WorkflowExecutor(payload, logger)\n\n // Register executor with proper dependency injection\n setWorkflowExecutor(executor, logger)\n\n // Hooks are now registered during config phase - just log status\n logger.info('Hooks were registered during config phase - executor now available')\n\n logger.info('Initializing global hooks...')\n initGlobalHooks(payload, logger, executor)\n\n logger.info('Initializing workflow hooks...')\n initWorkflowHooks(payload, logger)\n\n logger.info('Initializing step tasks...')\n initStepTasks(pluginOptions, payload, logger)\n\n // Register cron jobs for workflows with cron triggers\n logger.info('Registering cron jobs...')\n await registerCronJobs(payload, logger)\n\n logger.info('Plugin initialized successfully - all hooks registered')\n }\n\n return config\n }\n"],"names":["createWorkflowCollection","WorkflowRunsCollection","WorkflowExecutor","generateCronTasks","registerCronJobs","initGlobalHooks","initStepTasks","initWebhookEndpoint","initWorkflowHooks","getConfigLogger","initializeLogger","getLogger","executorRegistry","executor","isInitialized","logger","setWorkflowExecutor","info","getExecutorRegistry","createFailedWorkflowRun","args","errorMessage","req","payload","collection","slug","workflows","find","limit","where","equals","operation","workflow","docs","create","data","completedAt","Date","toISOString","context","steps","trigger","type","doc","previousDoc","triggeredAt","error","inputs","logs","level","message","timestamp","outputs","startedAt","status","triggeredBy","user","email","id","workflowVersion","length","workflowCount","warn","Error","applyCollectionsConfig","pluginOptions","config","collections","push","workflowsPlugin","enabled","debug","collectionTriggers","triggerSlug","triggerConfig","Object","entries","collectionIndex","findIndex","c","hooks","afterChange","automationHook","assign","payloadAutomationHook","registry","console","docId","hookType","undefined","String","updatedRegistry","executeTriggeredWorkflows","errorStack","stack","createError","__isAutomationHook","__version","jobs","tasks","configLogger","keys","step","task","webhookPrefix","incomingOnInit","onInit"],"mappings":"AAIA,SAAQA,wBAAwB,QAAO,6BAA4B;AACnE,SAAQC,sBAAsB,QAAO,iCAAgC;AACrE,SAAQC,gBAAgB,QAAO,+BAA8B;AAC7D,SAAQC,iBAAiB,EA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QAEA,OAAOiD;IACT,EAAC"}
1
+ {"version":3,"sources":["../../src/plugin/index.ts"],"sourcesContent":["import type {Config} from 'payload'\n\nimport type {CollectionTriggerConfigCrud, WorkflowsPluginConfig} from \"./config-types.js\"\n\nimport {createWorkflowCollection} from '../collections/Workflow.js'\nimport {WorkflowRunsCollection} from '../collections/WorkflowRuns.js'\nimport {WorkflowExecutor} from '../core/workflow-executor.js'\nimport {generateCronTasks, registerCronJobs} from './cron-scheduler.js'\nimport {initCollectionHooks} from \"./init-collection-hooks.js\"\nimport {initGlobalHooks} from \"./init-global-hooks.js\"\nimport {initStepTasks} from \"./init-step-tasks.js\"\nimport {initWebhookEndpoint} from \"./init-webhook.js\"\nimport {initWorkflowHooks} from './init-workflow-hooks.js'\nimport {getConfigLogger, initializeLogger} from './logger.js'\n\nexport {getLogger} from './logger.js'\n\n// Improved executor registry with proper error handling and logging\ninterface ExecutorRegistry {\n executor: null | WorkflowExecutor\n isInitialized: boolean\n logger: any | null\n}\n\nconst executorRegistry: ExecutorRegistry = {\n executor: null,\n isInitialized: false,\n logger: null\n}\n\nconst setWorkflowExecutor = (executor: WorkflowExecutor, logger: any) => {\n executorRegistry.executor = executor\n executorRegistry.logger = logger\n executorRegistry.isInitialized = true\n\n logger.info('Workflow executor initialized and registered successfully')\n}\n\nconst getExecutorRegistry = (): ExecutorRegistry => {\n return executorRegistry\n}\n\n// Helper function to create failed workflow runs for tracking errors\nconst createFailedWorkflowRun = async (args: any, errorMessage: string, logger: any) => {\n try {\n // Only create failed workflow runs if we have enough context\n if (!args?.req?.payload || !args?.collection?.slug) {\n return\n }\n\n // Find workflows that should have been triggered\n const workflows = await args.req.payload.find({\n collection: 'workflows',\n limit: 10,\n req: args.req,\n where: {\n 'triggers.collectionSlug': {\n equals: args.collection.slug\n },\n 'triggers.operation': {\n equals: args.operation\n },\n 'triggers.type': {\n equals: 'collection-trigger'\n }\n }\n })\n\n // Create failed workflow runs for each matching workflow\n for (const workflow of workflows.docs) {\n await args.req.payload.create({\n collection: 'workflow-runs',\n data: {\n completedAt: new Date().toISOString(),\n context: {\n steps: {},\n trigger: {\n type: 'collection',\n collection: args.collection.slug,\n doc: args.doc,\n operation: args.operation,\n previousDoc: args.previousDoc,\n triggeredAt: new Date().toISOString()\n }\n },\n error: `Hook execution failed: ${errorMessage}`,\n inputs: {},\n logs: [{\n level: 'error',\n message: `Hook execution failed: ${errorMessage}`,\n timestamp: new Date().toISOString()\n }],\n outputs: {},\n startedAt: new Date().toISOString(),\n status: 'failed',\n steps: [],\n triggeredBy: args?.req?.user?.email || 'system',\n workflow: workflow.id,\n workflowVersion: 1\n },\n req: args.req\n })\n }\n\n if (workflows.docs.length > 0) {\n logger.info({\n errorMessage,\n workflowCount: workflows.docs.length\n }, 'Created failed workflow runs for hook execution error')\n }\n\n } catch (error) {\n // Don't let workflow run creation failures break the original operation\n logger.warn({\n error: error instanceof Error ? error.message : 'Unknown error'\n }, 'Failed to create failed workflow run record')\n }\n}\n\nconst applyCollectionsConfig = <T extends string>(pluginOptions: WorkflowsPluginConfig<T>, config: Config) => {\n // Add workflow collections\n if (!config.collections) {\n config.collections = []\n }\n\n config.collections.push(\n createWorkflowCollection(pluginOptions),\n WorkflowRunsCollection\n )\n}\n\n// Removed config-phase hook registration - user collections don't exist during config phase\n\n\nexport const workflowsPlugin =\n <TSlug extends string>(pluginOptions: WorkflowsPluginConfig<TSlug>) =>\n (config: Config): Config => {\n // If the plugin is disabled, return config unchanged\n if (pluginOptions.enabled === false) {\n return config\n }\n\n applyCollectionsConfig<TSlug>(pluginOptions, config)\n\n // CRITICAL: Modify existing collection configs BEFORE PayloadCMS processes them\n // This is the ONLY time we can add hooks that will actually work\n const logger = getConfigLogger()\n\n if (config.collections && pluginOptions.collectionTriggers) {\n for (const [triggerSlug, triggerConfig] of Object.entries(pluginOptions.collectionTriggers)) {\n if (!triggerConfig) {continue}\n\n // Find the collection config that matches\n const collectionIndex = config.collections.findIndex(c => c.slug === triggerSlug)\n if (collectionIndex === -1) {\n logger.warn(`Collection '${triggerSlug}' not found in config.collections`)\n continue\n }\n\n const collection = config.collections[collectionIndex]\n\n // Initialize hooks if needed\n if (!collection.hooks) {\n collection.hooks = {}\n }\n if (!collection.hooks.afterChange) {\n collection.hooks.afterChange = []\n }\n\n // Create a reliable hook function with proper dependency injection\n const automationHook = Object.assign(\n async function payloadAutomationHook(args: any) {\n const registry = getExecutorRegistry()\n\n // Use proper logger if available, fallback to args.req.payload.logger\n const logger = registry.logger || args?.req?.payload?.logger || console\n\n try {\n logger.info({\n collection: args?.collection?.slug,\n docId: args?.doc?.id,\n hookType: 'automation',\n operation: args?.operation\n }, 'Collection automation hook triggered')\n\n if (!registry.isInitialized) {\n logger.warn('Workflow executor not yet initialized, attempting lazy initialization')\n \n try {\n // Try to create executor if we have a payload instance\n if (args.req?.payload) {\n logger.info('Creating workflow executor via lazy initialization')\n const { WorkflowExecutor } = await import('../core/workflow-executor.js')\n const executor = new WorkflowExecutor(args.req.payload, logger)\n setWorkflowExecutor(executor, logger)\n logger.info('Lazy initialization successful')\n } else {\n logger.error('Cannot lazy initialize - no payload instance available')\n await createFailedWorkflowRun(args, 'Workflow executor not initialized and lazy initialization failed - no payload instance', logger)\n return undefined\n }\n } catch (error) {\n logger.error('Lazy initialization failed:', error)\n const errorMessage = error instanceof Error ? error.message : String(error)\n await createFailedWorkflowRun(args, `Workflow executor lazy initialization failed: ${errorMessage}`, logger)\n return undefined\n }\n }\n\n // Re-check registry after potential lazy initialization\n const updatedRegistry = getExecutorRegistry()\n if (!updatedRegistry.executor) {\n logger.error('Workflow executor is null despite being marked as initialized')\n // Create a failed workflow run to track this issue\n await createFailedWorkflowRun(args, 'Executor not available after initialization', logger)\n return undefined\n }\n\n logger.debug('Executing triggered workflows...')\n await updatedRegistry.executor.executeTriggeredWorkflows(\n args.collection.slug,\n args.operation,\n args.doc,\n args.previousDoc,\n args.req\n )\n\n logger.info({\n collection: args?.collection?.slug,\n docId: args?.doc?.id,\n operation: args?.operation\n }, 'Workflow execution completed successfully')\n\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : 'Unknown error'\n\n logger.error({\n collection: args?.collection?.slug,\n docId: args?.doc?.id,\n error: errorMessage,\n errorStack: error instanceof Error ? error.stack : undefined,\n operation: args?.operation\n }, 'Hook execution failed')\n\n // Create a failed workflow run to track this error\n try {\n await createFailedWorkflowRun(args, errorMessage, logger)\n } catch (createError) {\n logger.error({\n error: createError instanceof Error ? createError.message : 'Unknown error'\n }, 'Failed to create workflow run for hook error')\n }\n\n // Don't throw to prevent breaking the original operation\n }\n\n return undefined\n },\n {\n __isAutomationHook: true,\n __version: '0.0.22'\n }\n )\n\n // Add the hook to the collection config\n collection.hooks.afterChange.push(automationHook)\n }\n }\n\n if (!config.jobs) {\n config.jobs = {tasks: []}\n }\n\n const configLogger = getConfigLogger()\n\n // Generate cron tasks for workflows with cron triggers\n generateCronTasks(config)\n\n for (const step of pluginOptions.steps) {\n if (!config.jobs?.tasks?.find(task => task.slug === step.slug)) {\n config.jobs?.tasks?.push(step)\n }\n }\n\n // Initialize webhook endpoint\n initWebhookEndpoint(config, pluginOptions.webhookPrefix || 'webhook')\n\n // Set up onInit to register collection hooks and initialize features\n const incomingOnInit = config.onInit\n config.onInit = async (payload) => {\n\n // Execute any existing onInit functions first\n if (incomingOnInit) {\n await incomingOnInit(payload)\n }\n\n // Initialize the logger with the payload instance\n const logger = initializeLogger(payload)\n logger.info('Logger initialized with payload instance')\n\n // Log collection trigger configuration\n logger.info(`Plugin configuration: ${Object.keys(pluginOptions.collectionTriggers || {}).length} collection triggers, ${pluginOptions.steps?.length || 0} steps`)\n\n // Create workflow executor instance\n logger.debug('Creating workflow executor instance')\n const executor = new WorkflowExecutor(payload, logger)\n\n // Register executor with proper dependency injection\n setWorkflowExecutor(executor, logger)\n\n // Hooks are now registered during config phase - just log status\n logger.info('Hooks were registered during config phase - executor now available')\n\n logger.info('Initializing global hooks...')\n initGlobalHooks(payload, logger, executor)\n\n logger.info('Initializing workflow hooks...')\n initWorkflowHooks(payload, logger)\n\n logger.info('Initializing step tasks...')\n initStepTasks(pluginOptions, payload, logger)\n\n // Register cron jobs for workflows with cron triggers\n logger.info('Registering cron jobs...')\n await registerCronJobs(payload, logger)\n\n logger.info('Plugin initialized successfully - all hooks registered')\n }\n\n return config\n }\n"],"names":["createWorkflowCollection","WorkflowRunsCollection","WorkflowExecutor","generateCronTasks","registerCronJobs","initGlobalHooks","initStepTasks","initWebhookEndpoint","initWorkflowHooks","getConfigLogger","initializeLogger","getLogger","executorRegistry","executor","isInitialized","logger","setWorkflowExecutor","info","getExecutorRegistry","createFailedWorkflowRun","args","errorMessage","req","payload","collection","slug","workflows","find","limit","where","equals","operation","workflow","docs","create","data","completedAt","Date","toISOString","context","steps","trigger","type","doc","previousDoc","triggeredAt","error","inputs","logs","level","message","timestamp","outputs","startedAt","status","triggeredBy","user","email","id","workflowVersion","length","workflowCount","warn","Error","applyCollectionsConfig","pluginOptions","config","collections","push","workflowsPlugin","enabled","collectionTriggers","triggerSlug","triggerConfig","Object","entries","collectionIndex","findIndex","c","hooks","afterChange","automationHook","assign","payloadAutomationHook","registry","console","docId","hookType","undefined","String","updatedRegistry","debug","executeTriggeredWorkflows","errorStack","stack","createError","__isAutomationHook","__version","jobs","tasks","configLogger","step","task","webhookPrefix","incomingOnInit","onInit","keys"],"mappings":"AAIA,SAAQA,wBAAwB,QAAO,6BAA4B;AACnE,SAAQC,sBAAsB,QAAO,iCAAgC;AACrE,SAAQC,gBAAgB,QAAO,+BAA8B;AAC7D,SAAQC,iBAAiB,EAAEC,gBAAgB,QAAO,sBAAqB;AAEvE,SAAQC,eAAe,QAAO,yBAAwB;AACtD,SAAQC,aAAa,QAAO,uBAAsB;AAClD,SAAQC,mBAAmB,QAAO,oBAAmB;AACrD,SAAQC,iBAAiB,QAAO,2BAA0B;AAC1D,SAAQC,eAAe,EAAEC,gBAAgB,QAAO,cAAa;AAE7D,SAAQC,SAAS,QAAO,cAAa;AASrC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E;YAE9B,iEAAiE;YACjEA,OAAOE,IAAI,CAAC;YAEZF,OAAOE,IAAI,CAAC;YACZZ,gBAAgBkB,SAASR,QAAQF;YAEjCE,OAAOE,IAAI,CAAC;YACZT,kBAAkBe,SAASR;YAE3BA,OAAOE,IAAI,CAAC;YACZX,cAAc2D,eAAe1C,SAASR;YAEtC,sDAAsD;YACtDA,OAAOE,IAAI,CAAC;YACZ,MAAMb,iBAAiBmB,SAASR;YAEhCA,OAAOE,IAAI,CAAC;QACd;QAEA,OAAOiD;IACT,EAAC"}
@@ -4,7 +4,6 @@ export function initWebhookEndpoint(config, webhookPrefix = 'webhook') {
4
4
  const logger = getConfigLogger();
5
5
  // Ensure the prefix starts with a slash
6
6
  const normalizedPrefix = webhookPrefix.startsWith('/') ? webhookPrefix : `/${webhookPrefix}`;
7
- logger.debug(`Adding webhook endpoint: ${normalizedPrefix}`);
8
7
  // Define webhook endpoint
9
8
  const webhookEndpoint = {
10
9
  handler: async (req)=>{
@@ -153,10 +152,6 @@ export function initWebhookEndpoint(config, webhookPrefix = 'webhook') {
153
152
  ...config.endpoints || [],
154
153
  webhookEndpoint
155
154
  ];
156
- logger.debug(`Webhook endpoint added at path: ${webhookEndpoint.path}`);
157
- logger.debug('Webhook endpoint added');
158
- } else {
159
- logger.debug(`Webhook endpoint already exists at path: ${webhookEndpoint.path}`);
160
155
  }
161
156
  }
162
157
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/plugin/init-webhook.ts"],"sourcesContent":["import type {Config, PayloadRequest} from 'payload'\n\nimport {type PayloadWorkflow, WorkflowExecutor} from '../core/workflow-executor.js'\nimport {getConfigLogger, initializeLogger} from './logger.js'\n\nexport function initWebhookEndpoint(config: Config, webhookPrefix = 'webhook'): void {\n const logger = getConfigLogger()\n // Ensure the prefix starts with a slash\n const normalizedPrefix = webhookPrefix.startsWith('/') ? webhookPrefix : `/${webhookPrefix}`\n logger.debug(`Adding webhook endpoint: ${normalizedPrefix}`)\n\n // Define webhook endpoint\n const webhookEndpoint = {\n handler: async (req: PayloadRequest) => {\n const {path} = req.routeParams as { path: string }\n const webhookData = req.body || {}\n\n logger.debug('Webhook endpoint handler called, path: ' + path)\n\n try {\n // Find workflows with matching webhook triggers\n const workflows = await req.payload.find({\n collection: 'workflows',\n depth: 2,\n limit: 100,\n req,\n where: {\n 'triggers.type': {\n equals: 'webhook-trigger'\n },\n 'triggers.webhookPath': {\n equals: path\n }\n }\n })\n\n if (workflows.docs.length === 0) {\n return new Response(\n JSON.stringify({error: 'No workflows found for this webhook path'}),\n {\n headers: {'Content-Type': 'application/json'},\n status: 404\n }\n )\n }\n\n // Create a workflow executor for this request\n const logger = initializeLogger(req.payload)\n const executor = new WorkflowExecutor(req.payload, logger)\n\n const executionPromises = workflows.docs.map(async (workflow) => {\n try {\n // Create execution context for the webhook trigger\n const context = {\n steps: {},\n trigger: {\n type: 'webhook',\n data: webhookData,\n headers: Object.fromEntries(req.headers?.entries() || []),\n path,\n req\n }\n }\n\n // Find the matching trigger and check its condition if present\n const triggers = workflow.triggers as Array<{\n condition?: string\n type: string\n parameters?: {\n webhookPath?: string\n [key: string]: any\n }\n }>\n\n const matchingTrigger = triggers?.find(trigger =>\n trigger.type === 'webhook-trigger' &&\n trigger.parameters?.webhookPath === path\n )\n\n // Check trigger condition if present\n if (matchingTrigger?.condition) {\n logger.debug({\n condition: matchingTrigger.condition,\n path,\n webhookData: JSON.stringify(webhookData).substring(0, 200),\n headers: Object.keys(context.trigger.headers || {}),\n workflowId: workflow.id,\n workflowName: workflow.name\n }, 'Evaluating webhook trigger condition')\n\n const conditionMet = executor.evaluateCondition(matchingTrigger.condition, context)\n\n if (!conditionMet) {\n logger.info({\n condition: matchingTrigger.condition,\n path,\n webhookDataSnapshot: JSON.stringify(webhookData).substring(0, 200),\n workflowId: workflow.id,\n workflowName: workflow.name\n }, 'Webhook trigger condition not met, skipping workflow')\n\n return { reason: 'Condition not met', status: 'skipped', workflowId: workflow.id }\n }\n\n logger.info({\n condition: matchingTrigger.condition,\n path,\n webhookDataSnapshot: JSON.stringify(webhookData).substring(0, 200),\n workflowId: workflow.id,\n workflowName: workflow.name\n }, 'Webhook trigger condition met')\n }\n\n // Execute the workflow\n await executor.execute(workflow as PayloadWorkflow, context, req)\n\n return { status: 'triggered', workflowId: workflow.id }\n } catch (error) {\n return {\n error: error instanceof Error ? error.message : 'Unknown error',\n status: 'failed',\n workflowId: workflow.id\n }\n }\n })\n\n const results = await Promise.allSettled(executionPromises)\n const resultsData = results.map((result, index) => {\n const baseResult = { workflowId: workflows.docs[index].id }\n if (result.status === 'fulfilled') {\n return { ...baseResult, ...result.value }\n } else {\n return { ...baseResult, error: result.reason, status: 'failed' }\n }\n })\n\n return new Response(\n JSON.stringify({\n message: `Triggered ${workflows.docs.length} workflow(s)`,\n results: resultsData\n }),\n {\n headers: { 'Content-Type': 'application/json' },\n status: 200\n }\n )\n\n } catch (error) {\n return new Response(\n JSON.stringify({\n details: error instanceof Error ? error.message : 'Unknown error',\n error: 'Failed to process webhook'\n }),\n {\n headers: { 'Content-Type': 'application/json' },\n status: 500\n }\n )\n }\n },\n method: 'post' as const,\n path: `${normalizedPrefix}/:path`\n }\n\n // Check if the webhook endpoint already exists to avoid duplicates\n const existingEndpoint = config.endpoints?.find(endpoint =>\n endpoint.path === webhookEndpoint.path && endpoint.method === webhookEndpoint.method\n )\n\n if (!existingEndpoint) {\n // Combine existing endpoints with the webhook endpoint\n config.endpoints = [...(config.endpoints || []), webhookEndpoint]\n logger.debug(`Webhook endpoint added at path: ${webhookEndpoint.path}`)\n logger.debug('Webhook endpoint added')\n } else {\n logger.debug(`Webhook endpoint already exists at path: ${webhookEndpoint.path}`)\n }\n}\n"],"names":["WorkflowExecutor","getConfigLogger","initializeLogger","initWebhookEndpoint","config","webhookPrefix","logger","normalizedPrefix","startsWith","debug","webhookEndpoint","handler","req","path","routeParams","webhookData","body","workflows","payload","find","collection","depth","limit","where","equals","docs","length","Response","JSON","stringify","error","headers","status","executor","executionPromises","map","workflow","context","steps","trigger","type","data","Object","fromEntries","entries","triggers","matchingTrigger","parameters","webhookPath","condition","substring","keys","workflowId","id","workflowName","name","conditionMet","evaluateCondition","info","webhookDataSnapshot","reason","execute","Error","message","results","Promise","allSettled","resultsData","result","index","baseResult","value","details","method","existingEndpoint","endpoints","endpoint"],"mappings":"AAEA,SAA8BA,gBAAgB,QAAO,+BAA8B;AACnF,SAAQC,eAAe,EAAEC,gBAAgB,QAAO,cAAa;AAE7D,OAAO,SAASC,oBAAoBC,MAAc,EAAEC,gBAAgB,SAAS;IAC3E,MAAMC,SAASL;IACf,wCAAwC;IACxC,MAAMM,mBAAmBF,cAAcG,UAAU,CAAC,OAAOH,gBAAgB,CAAC,CAAC,EAAEA,eAAe;IAC5FC,OAAOG,KAAK,CAAC,CAAC,yBAAyB,EAAEF,kBAAkB;IAE3D,0BAA0B;IAC1B,MAAMG,kBAAkB;QACtBC,SAAS,OAAOC;YACd,MAAM,EAACC,IAAI,EAAC,GAAGD,IAAIE,WAAW;YAC9B,MAAMC,cAAcH,IAAII,IAAI,IAAI,CAAC;YAEjCV,OAAOG,KAAK,CAAC,4CAA4CI;YAEzD,IAAI;gBACF,gDAAgD;gBAChD,MAAMI,YAAY,MAAML,IAAIM,OAAO,CAACC,IAAI,CAAC;oBACvCC,YAAY;oBACZC,OAAO;oBACPC,OAAO;oBACPV;oBACAW,OAAO;wBACL,iBAAiB;4BACfC,QAAQ;wBACV;wBACA,wBAAwB;4BACtBA,QAAQX;wBACV;oBACF;gBACF;gBAEA,IAAII,UAAUQ,IAAI,CAACC,MAAM,KAAK,GAAG;oBAC/B,OAAO,IAAIC,SACTC,KAAKC,SAAS,CAAC;wBAACC,OAAO;oBAA0C,IACjE;wBACEC,SAAS;4BAAC,gBAAgB;wBAAkB;wBAC5CC,QAAQ;oBACV;gBAEJ;gBAEA,8CAA8C;gBAC9C,MAAM1B,SAASJ,iBAAiBU,IAAIM,OAAO;gBAC3C,MAAMe,WAAW,IAAIjC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AAG;oBAClDjC,OAAO;gBACT,IACA;oBACEC,SAAS;wBAAE,gBAAgB;oBAAmB;oBAC9CC,QAAQ;gBACV;YAEJ;QACF;QACAyC,QAAQ;QACR5D,MAAM,GAAGN,iBAAiB,MAAM,CAAC;IACnC;IAEA,mEAAmE;IACnE,MAAMmE,mBAAmBtE,OAAOuE,SAAS,EAAExD,KAAKyD,CAAAA,WAC9CA,SAAS/D,IAAI,KAAKH,gBAAgBG,IAAI,IAAI+D,SAASH,MAAM,KAAK/D,gBAAgB+D,MAAM;IAGtF,IAAI,CAACC,kBAAkB;QACrB,uDAAuD;QACvDtE,OAAOuE,SAAS,GAAG;eAAKvE,OAAOuE,SAAS,IAAI,EAAE;YAAGjE;SAAgB;QACjEJ,OAAOG,KAAK,CAAC,CAAC,gCAAgC,EAAEC,gBAAgBG,IAAI,EAAE;QACtEP,OAAOG,KAAK,CAAC;IACf,OAAO;QACLH,OAAOG,KAAK,CAAC,CAAC,yCAAyC,EAAEC,gBAAgBG,IAAI,EAAE;IACjF;AACF"}
1
+ {"version":3,"sources":["../../src/plugin/init-webhook.ts"],"sourcesContent":["import type {Config, PayloadRequest} from 'payload'\n\nimport {type PayloadWorkflow, WorkflowExecutor} from '../core/workflow-executor.js'\nimport {getConfigLogger, initializeLogger} from './logger.js'\n\nexport function initWebhookEndpoint(config: Config, webhookPrefix = 'webhook'): void {\n const logger = getConfigLogger()\n // Ensure the prefix starts with a slash\n const normalizedPrefix = webhookPrefix.startsWith('/') ? webhookPrefix : `/${webhookPrefix}`\n\n // Define webhook endpoint\n const webhookEndpoint = {\n handler: async (req: PayloadRequest) => {\n const {path} = req.routeParams as { path: string }\n const webhookData = req.body || {}\n\n logger.debug('Webhook endpoint handler called, path: ' + path)\n\n try {\n // Find workflows with matching webhook triggers\n const workflows = await req.payload.find({\n collection: 'workflows',\n depth: 2,\n limit: 100,\n req,\n where: {\n 'triggers.type': {\n equals: 'webhook-trigger'\n },\n 'triggers.webhookPath': {\n equals: path\n }\n }\n })\n\n if (workflows.docs.length === 0) {\n return new Response(\n JSON.stringify({error: 'No workflows found for this webhook path'}),\n {\n headers: {'Content-Type': 'application/json'},\n status: 404\n }\n )\n }\n\n // Create a workflow executor for this request\n const logger = initializeLogger(req.payload)\n const executor = new WorkflowExecutor(req.payload, logger)\n\n const executionPromises = workflows.docs.map(async (workflow) => {\n try {\n // Create execution context for the webhook trigger\n const context = {\n steps: {},\n trigger: {\n type: 'webhook',\n data: webhookData,\n headers: Object.fromEntries(req.headers?.entries() || []),\n path,\n req\n }\n }\n\n // Find the matching trigger and check its condition if present\n const triggers = workflow.triggers as Array<{\n condition?: string\n type: string\n parameters?: {\n webhookPath?: string\n [key: string]: any\n }\n }>\n\n const matchingTrigger = triggers?.find(trigger =>\n trigger.type === 'webhook-trigger' &&\n trigger.parameters?.webhookPath === path\n )\n\n // Check trigger condition if present\n if (matchingTrigger?.condition) {\n logger.debug({\n condition: matchingTrigger.condition,\n path,\n webhookData: JSON.stringify(webhookData).substring(0, 200),\n headers: Object.keys(context.trigger.headers || {}),\n workflowId: workflow.id,\n workflowName: workflow.name\n }, 'Evaluating webhook trigger condition')\n\n const conditionMet = executor.evaluateCondition(matchingTrigger.condition, context)\n\n if (!conditionMet) {\n logger.info({\n condition: matchingTrigger.condition,\n path,\n webhookDataSnapshot: JSON.stringify(webhookData).substring(0, 200),\n workflowId: workflow.id,\n workflowName: workflow.name\n }, 'Webhook trigger condition not met, skipping workflow')\n\n return { reason: 'Condition not met', status: 'skipped', workflowId: workflow.id }\n }\n\n logger.info({\n condition: matchingTrigger.condition,\n path,\n webhookDataSnapshot: JSON.stringify(webhookData).substring(0, 200),\n workflowId: workflow.id,\n workflowName: workflow.name\n }, 'Webhook trigger condition met')\n }\n\n // Execute the workflow\n await executor.execute(workflow as PayloadWorkflow, context, req)\n\n return { status: 'triggered', workflowId: workflow.id }\n } catch (error) {\n return {\n error: error instanceof Error ? error.message : 'Unknown error',\n status: 'failed',\n workflowId: workflow.id\n }\n }\n })\n\n const results = await Promise.allSettled(executionPromises)\n const resultsData = results.map((result, index) => {\n const baseResult = { workflowId: workflows.docs[index].id }\n if (result.status === 'fulfilled') {\n return { ...baseResult, ...result.value }\n } else {\n return { ...baseResult, error: result.reason, status: 'failed' }\n }\n })\n\n return new Response(\n JSON.stringify({\n message: `Triggered ${workflows.docs.length} workflow(s)`,\n results: resultsData\n }),\n {\n headers: { 'Content-Type': 'application/json' },\n status: 200\n }\n )\n\n } catch (error) {\n return new Response(\n JSON.stringify({\n details: error instanceof Error ? error.message : 'Unknown error',\n error: 'Failed to process webhook'\n }),\n {\n headers: { 'Content-Type': 'application/json' },\n status: 500\n }\n )\n }\n },\n method: 'post' as const,\n path: `${normalizedPrefix}/:path`\n }\n\n // Check if the webhook endpoint already exists to avoid duplicates\n const existingEndpoint = config.endpoints?.find(endpoint =>\n endpoint.path === webhookEndpoint.path && endpoint.method === webhookEndpoint.method\n )\n\n if (!existingEndpoint) {\n // Combine existing endpoints with the webhook endpoint\n config.endpoints = [...(config.endpoints || []), webhookEndpoint]\n }\n}\n"],"names":["WorkflowExecutor","getConfigLogger","initializeLogger","initWebhookEndpoint","config","webhookPrefix","logger","normalizedPrefix","startsWith","webhookEndpoint","handler","req","path","routeParams","webhookData","body","debug","workflows","payload","find","collection","depth","limit","where","equals","docs","length","Response","JSON","stringify","error","headers","status","executor","executionPromises","map","workflow","context","steps","trigger","type","data","Object","fromEntries","entries","triggers","matchingTrigger","parameters","webhookPath","condition","substring","keys","workflowId","id","workflowName","name","conditionMet","evaluateCondition","info","webhookDataSnapshot","reason","execute","Error","message","results","Promise","allSettled","resultsData","result","index","baseResult","value","details","method","existingEndpoint","endpoints","endpoint"],"mappings":"AAEA,SAA8BA,gBAAgB,QAAO,+BAA8B;AACnF,SAAQC,eAAe,EAAEC,gBAAgB,QAAO,cAAa;AAE7D,OAAO,SAASC,oBAAoBC,MAAc,EAAEC,gBAAgB,SAAS;IAC3E,MAAMC,SAASL;IACf,wCAAwC;IACxC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YAAGlE;SAAgB;IACnE;AACF"}
@@ -1,29 +1,41 @@
1
1
  // Global logger instance - use Payload's logger type
2
2
  let pluginLogger = null;
3
+ /**
4
+ * Get the configured log level from environment variables
5
+ * Supports: PAYLOAD_AUTOMATION_LOG_LEVEL for unified control
6
+ * Or separate: PAYLOAD_AUTOMATION_CONFIG_LOG_LEVEL and PAYLOAD_AUTOMATION_LOG_LEVEL
7
+ */ function getConfigLogLevel() {
8
+ return process.env.PAYLOAD_AUTOMATION_CONFIG_LOG_LEVEL || process.env.PAYLOAD_AUTOMATION_LOG_LEVEL || 'warn' // Default to warn level for production
9
+ ;
10
+ }
3
11
  /**
4
12
  * Simple config-time logger for use during plugin configuration
5
13
  * Uses console with plugin prefix since Payload logger isn't available yet
6
14
  */ const configLogger = {
7
15
  debug: (message, ...args)=>{
8
- if (!process.env.PAYLOAD_AUTOMATION_CONFIG_LOGGING) {
16
+ const level = getConfigLogLevel();
17
+ if (level === 'silent' || level !== 'debug' && level !== 'trace') {
9
18
  return;
10
19
  }
11
- console.log(`[payload-automation] ${message}`, ...args);
20
+ console.debug(`[payload-automation] ${message}`, ...args);
12
21
  },
13
22
  error: (message, ...args)=>{
14
- if (!process.env.PAYLOAD_AUTOMATION_CONFIG_LOGGING) {
23
+ const level = getConfigLogLevel();
24
+ if (level === 'silent') {
15
25
  return;
16
26
  }
17
27
  console.error(`[payload-automation] ${message}`, ...args);
18
28
  },
19
29
  info: (message, ...args)=>{
20
- if (!process.env.PAYLOAD_AUTOMATION_CONFIG_LOGGING) {
30
+ const level = getConfigLogLevel();
31
+ if (level === 'silent' || level === 'error' || level === 'warn') {
21
32
  return;
22
33
  }
23
- console.log(`[payload-automation] ${message}`, ...args);
34
+ console.info(`[payload-automation] ${message}`, ...args);
24
35
  },
25
36
  warn: (message, ...args)=>{
26
- if (!process.env.PAYLOAD_AUTOMATION_CONFIG_LOGGING) {
37
+ const level = getConfigLogLevel();
38
+ if (level === 'silent' || level === 'error') {
27
39
  return;
28
40
  }
29
41
  console.warn(`[payload-automation] ${message}`, ...args);
@@ -39,8 +51,12 @@ let pluginLogger = null;
39
51
  * This creates a child logger with plugin identification
40
52
  */ export function initializeLogger(payload) {
41
53
  // Create a child logger with plugin identification
54
+ // Use PAYLOAD_AUTOMATION_LOG_LEVEL as the primary env var
55
+ const logLevel = process.env.PAYLOAD_AUTOMATION_LOG_LEVEL || process.env.PAYLOAD_AUTOMATION_LOGGING || // Legacy support
56
+ 'warn' // Default to warn level for production
57
+ ;
42
58
  pluginLogger = payload.logger.child({
43
- level: process.env.PAYLOAD_AUTOMATION_LOGGING || 'silent',
59
+ level: logLevel,
44
60
  plugin: '@xtr-dev/payload-automation'
45
61
  });
46
62
  return pluginLogger;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/plugin/logger.ts"],"sourcesContent":["import type { Payload } from 'payload'\n\n// Global logger instance - use Payload's logger type\nlet pluginLogger: null | Payload['logger'] = null\n\n/**\n * Simple config-time logger for use during plugin configuration\n * Uses console with plugin prefix since Payload logger isn't available yet\n */\nconst configLogger = {\n debug: <T>(message: string, ...args: T[]) => {\n if (!process.env.PAYLOAD_AUTOMATION_CONFIG_LOGGING) {return}\n console.log(`[payload-automation] ${message}`, ...args)\n },\n error: <T>(message: string, ...args: T[]) => {\n if (!process.env.PAYLOAD_AUTOMATION_CONFIG_LOGGING) {return}\n console.error(`[payload-automation] ${message}`, ...args)\n },\n info: <T>(message: string, ...args: T[]) => {\n if (!process.env.PAYLOAD_AUTOMATION_CONFIG_LOGGING) {return}\n console.log(`[payload-automation] ${message}`, ...args)\n },\n warn: <T>(message: string, ...args: T[]) => {\n if (!process.env.PAYLOAD_AUTOMATION_CONFIG_LOGGING) {return}\n console.warn(`[payload-automation] ${message}`, ...args)\n }\n}\n\n/**\n * Get a logger for config-time use (before Payload initialization)\n */\nexport function getConfigLogger() {\n return configLogger\n}\n\n/**\n * Initialize the plugin logger using Payload's Pino instance\n * This creates a child logger with plugin identification\n */\nexport function initializeLogger(payload: Payload): Payload['logger'] {\n // Create a child logger with plugin identification\n pluginLogger = payload.logger.child({\n level: process.env.PAYLOAD_AUTOMATION_LOGGING || 'silent',\n plugin: '@xtr-dev/payload-automation'\n })\n return pluginLogger\n}\n\n/**\n * Get the plugin logger instance\n * Throws error if not initialized\n */\nexport function getLogger(): Payload['logger'] {\n if (!pluginLogger) {\n throw new Error('@xtr-dev/payload-automation: Logger not initialized. Make sure the plugin is properly configured.')\n }\n\n return pluginLogger\n}\n"],"names":["pluginLogger","configLogger","debug","message","args","process","env","PAYLOAD_AUTOMATION_CONFIG_LOGGING","console","log","error","info","warn","getConfigLogger","initializeLogger","payload","logger","child","level","PAYLOAD_AUTOMATION_LOGGING","plugin","getLogger","Error"],"mappings":"AAEA,qDAAqD;AACrD,IAAIA,eAAyC;AAE7C;;;CAGC,GACD,MAAMC,eAAe;IACnBC,OAAO,CAAIC,SAAiB,GAAGC;QAC7B,IAAI,CAACC,QAAQC,GAAG,CAACC,iCAAiC,EAAE;YAAC;QAAM;QAC3DC,QAAQC,GAAG,CAAC,CAAC,qBAAqB,EAAEN,SAAS,KAAKC;IACpD;IACAM,OAAO,CAAIP,SAAiB,GAAGC;QAC7B,IAAI,CAACC,QAAQC,GAAG,CAACC,iCAAiC,EAAE;YAAC;QAAM;QAC3DC,QAAQE,KAAK,CAAC,CAAC,qBAAqB,EAAEP,SAAS,KAAKC;IACtD;IACAO,MAAM,CAAIR,SAAiB,GAAGC;QAC5B,IAAI,CAACC,QAAQC,GAAG,CAACC,iCAAiC,EAAE;YAAC;QAAM;QAC3DC,QAAQC,GAAG,CAAC,CAAC,qBAAqB,EAAEN,SAAS,KAAKC;IACpD;IACAQ,MAAM,CAAIT,SAAiB,GAAGC;QAC5B,IAAI,CAACC,QAAQC,GAAG,CAACC,iCAAiC,EAAE;YAAC;QAAM;QAC3DC,QAAQI,IAAI,CAAC,CAAC,qBAAqB,EAAET,SAAS,KAAKC;IACrD;AACF;AAEA;;CAEC,GACD,OAAO,SAASS;IACd,OAAOZ;AACT;AAEA;;;CAGC,GACD,OAAO,SAASa,iBAAiBC,OAAgB;IAC/C,mDAAmD;IACnDf,eAAee,QAAQC,MAAM,CAACC,KAAK,CAAC;QAClCC,OAAOb,QAAQC,GAAG,CAACa,0BAA0B,IAAI;QACjDC,QAAQ;IACV;IACA,OAAOpB;AACT;AAEA;;;CAGC,GACD,OAAO,SAASqB;IACd,IAAI,CAACrB,cAAc;QACjB,MAAM,IAAIsB,MAAM;IAClB;IAEA,OAAOtB;AACT"}
1
+ {"version":3,"sources":["../../src/plugin/logger.ts"],"sourcesContent":["import type { Payload } from 'payload'\n\n// Global logger instance - use Payload's logger type\nlet pluginLogger: null | Payload['logger'] = null\n\n/**\n * Get the configured log level from environment variables\n * Supports: PAYLOAD_AUTOMATION_LOG_LEVEL for unified control\n * Or separate: PAYLOAD_AUTOMATION_CONFIG_LOG_LEVEL and PAYLOAD_AUTOMATION_LOG_LEVEL\n */\nfunction getConfigLogLevel(): string {\n return process.env.PAYLOAD_AUTOMATION_CONFIG_LOG_LEVEL || \n process.env.PAYLOAD_AUTOMATION_LOG_LEVEL || \n 'warn' // Default to warn level for production\n}\n\n/**\n * Simple config-time logger for use during plugin configuration\n * Uses console with plugin prefix since Payload logger isn't available yet\n */\nconst configLogger = {\n debug: <T>(message: string, ...args: T[]) => {\n const level = getConfigLogLevel()\n if (level === 'silent' || (level !== 'debug' && level !== 'trace')) {return}\n console.debug(`[payload-automation] ${message}`, ...args)\n },\n error: <T>(message: string, ...args: T[]) => {\n const level = getConfigLogLevel()\n if (level === 'silent') {return}\n console.error(`[payload-automation] ${message}`, ...args)\n },\n info: <T>(message: string, ...args: T[]) => {\n const level = getConfigLogLevel()\n if (level === 'silent' || level === 'error' || level === 'warn') {return}\n console.info(`[payload-automation] ${message}`, ...args)\n },\n warn: <T>(message: string, ...args: T[]) => {\n const level = getConfigLogLevel()\n if (level === 'silent' || level === 'error') {return}\n console.warn(`[payload-automation] ${message}`, ...args)\n }\n}\n\n/**\n * Get a logger for config-time use (before Payload initialization)\n */\nexport function getConfigLogger() {\n return configLogger\n}\n\n/**\n * Initialize the plugin logger using Payload's Pino instance\n * This creates a child logger with plugin identification\n */\nexport function initializeLogger(payload: Payload): Payload['logger'] {\n // Create a child logger with plugin identification\n // Use PAYLOAD_AUTOMATION_LOG_LEVEL as the primary env var\n const logLevel = process.env.PAYLOAD_AUTOMATION_LOG_LEVEL || \n process.env.PAYLOAD_AUTOMATION_LOGGING || // Legacy support\n 'warn' // Default to warn level for production\n \n pluginLogger = payload.logger.child({\n level: logLevel,\n plugin: '@xtr-dev/payload-automation'\n })\n return pluginLogger\n}\n\n/**\n * Get the plugin logger instance\n * Throws error if not initialized\n */\nexport function getLogger(): Payload['logger'] {\n if (!pluginLogger) {\n throw new Error('@xtr-dev/payload-automation: Logger not initialized. Make sure the plugin is properly configured.')\n }\n\n return pluginLogger\n}\n"],"names":["pluginLogger","getConfigLogLevel","process","env","PAYLOAD_AUTOMATION_CONFIG_LOG_LEVEL","PAYLOAD_AUTOMATION_LOG_LEVEL","configLogger","debug","message","args","level","console","error","info","warn","getConfigLogger","initializeLogger","payload","logLevel","PAYLOAD_AUTOMATION_LOGGING","logger","child","plugin","getLogger","Error"],"mappings":"AAEA,qDAAqD;AACrD,IAAIA,eAAyC;AAE7C;;;;CAIC,GACD,SAASC;IACP,OAAOC,QAAQC,GAAG,CAACC,mCAAmC,IAC/CF,QAAQC,GAAG,CAACE,4BAA4B,IACxC,OAAO,uCAAuC;;AACvD;AAEA;;;CAGC,GACD,MAAMC,eAAe;IACnBC,OAAO,CAAIC,SAAiB,GAAGC;QAC7B,MAAMC,QAAQT;QACd,IAAIS,UAAU,YAAaA,UAAU,WAAWA,UAAU,SAAU;YAAC;QAAM;QAC3EC,QAAQJ,KAAK,CAAC,CAAC,qBAAqB,EAAEC,SAAS,KAAKC;IACtD;IACAG,OAAO,CAAIJ,SAAiB,GAAGC;QAC7B,MAAMC,QAAQT;QACd,IAAIS,UAAU,UAAU;YAAC;QAAM;QAC/BC,QAAQC,KAAK,CAAC,CAAC,qBAAqB,EAAEJ,SAAS,KAAKC;IACtD;IACAI,MAAM,CAAIL,SAAiB,GAAGC;QAC5B,MAAMC,QAAQT;QACd,IAAIS,UAAU,YAAYA,UAAU,WAAWA,UAAU,QAAQ;YAAC;QAAM;QACxEC,QAAQE,IAAI,CAAC,CAAC,qBAAqB,EAAEL,SAAS,KAAKC;IACrD;IACAK,MAAM,CAAIN,SAAiB,GAAGC;QAC5B,MAAMC,QAAQT;QACd,IAAIS,UAAU,YAAYA,UAAU,SAAS;YAAC;QAAM;QACpDC,QAAQG,IAAI,CAAC,CAAC,qBAAqB,EAAEN,SAAS,KAAKC;IACrD;AACF;AAEA;;CAEC,GACD,OAAO,SAASM;IACd,OAAOT;AACT;AAEA;;;CAGC,GACD,OAAO,SAASU,iBAAiBC,OAAgB;IAC/C,mDAAmD;IACnD,0DAA0D;IAC1D,MAAMC,WAAWhB,QAAQC,GAAG,CAACE,4BAA4B,IACxCH,QAAQC,GAAG,CAACgB,0BAA0B,IAAI,iBAAiB;IAC3D,OAAO,uCAAuC;;IAE/DnB,eAAeiB,QAAQG,MAAM,CAACC,KAAK,CAAC;QAClCX,OAAOQ;QACPI,QAAQ;IACV;IACA,OAAOtB;AACT;AAEA;;;CAGC,GACD,OAAO,SAASuB;IACd,IAAI,CAACvB,cAAc;QACjB,MAAM,IAAIwB,MAAM;IAClB;IAEA,OAAOxB;AACT"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xtr-dev/payload-automation",
3
- "version": "0.0.35",
3
+ "version": "0.0.36",
4
4
  "description": "PayloadCMS Automation Plugin - Comprehensive workflow automation system with visual workflow building, execution tracking, and step types",
5
5
  "license": "MIT",
6
6
  "type": "module",