@xtr-dev/payload-automation 0.0.28 → 0.0.30

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.
@@ -36,7 +36,7 @@ export const createWorkflowCollection = ({ collectionTriggers, steps, triggers }
36
36
  type: 'ui',
37
37
  admin: {
38
38
  components: {
39
- Field: '@/components/WorkflowExecutionStatus'
39
+ Field: '@xtr-dev/payload-automation/client#WorkflowExecutionStatus'
40
40
  },
41
41
  condition: (data)=>!!data?.id // Only show for existing workflows
42
42
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/collections/Workflow.ts"],"sourcesContent":["import type {CollectionConfig, Field} from 'payload'\n\nimport type {WorkflowsPluginConfig} from \"../plugin/config-types.js\"\n\nexport const createWorkflowCollection: <T extends string>(options: WorkflowsPluginConfig<T>) => CollectionConfig = ({\n collectionTriggers,\n steps,\n triggers\n }) => ({\n slug: 'workflows',\n access: {\n create: () => true,\n delete: () => true,\n read: () => true,\n update: () => true,\n },\n admin: {\n defaultColumns: ['name', 'updatedAt'],\n description: 'Create and manage automated workflows.',\n group: 'Automation',\n useAsTitle: 'name',\n },\n fields: [\n {\n name: 'name',\n type: 'text',\n admin: {\n description: 'Human-readable name for the workflow',\n },\n required: true,\n },\n {\n name: 'description',\n type: 'textarea',\n admin: {\n description: 'Optional description of what this workflow does',\n },\n },\n {\n name: 'executionStatus',\n type: 'ui',\n admin: {\n components: {\n Field: '@/components/WorkflowExecutionStatus'\n },\n condition: (data) => !!data?.id // Only show for existing workflows\n }\n },\n {\n name: 'triggers',\n type: 'array',\n fields: [\n {\n name: 'type',\n type: 'select',\n options: [\n 'collection-trigger',\n 'webhook-trigger',\n 'global-trigger',\n 'cron-trigger',\n ...(triggers || []).map(t => t.slug)\n ]\n },\n {\n name: 'parameters',\n type: 'json',\n admin: {\n hidden: true,\n },\n defaultValue: {}\n },\n // Virtual fields for collection trigger\n {\n name: '__builtin_collectionSlug',\n type: 'select',\n admin: {\n condition: (_, siblingData) => siblingData?.type === 'collection-trigger',\n description: 'Collection that triggers the workflow',\n },\n hooks: {\n afterRead: [\n ({ siblingData }) => {\n return siblingData?.parameters?.collectionSlug || undefined\n }\n ],\n beforeChange: [\n ({ siblingData, value }) => {\n if (!siblingData.parameters) {siblingData.parameters = {}}\n siblingData.parameters.collectionSlug = value\n return undefined // Virtual field, don't store directly\n }\n ]\n },\n options: Object.keys(collectionTriggers || {}),\n virtual: true,\n },\n {\n name: '__builtin_operation',\n type: 'select',\n admin: {\n condition: (_, siblingData) => siblingData?.type === 'collection-trigger',\n description: 'Collection operation that triggers the workflow',\n },\n hooks: {\n afterRead: [\n ({ siblingData }) => {\n return siblingData?.parameters?.operation || undefined\n }\n ],\n beforeChange: [\n ({ siblingData, value }) => {\n if (!siblingData.parameters) {siblingData.parameters = {}}\n siblingData.parameters.operation = value\n return undefined // Virtual field, don't store directly\n }\n ]\n },\n options: [\n 'create',\n 'delete',\n 'read',\n 'update',\n ],\n virtual: true,\n },\n // Virtual fields for webhook trigger\n {\n name: '__builtin_webhookPath',\n type: 'text',\n admin: {\n condition: (_, siblingData) => siblingData?.type === 'webhook-trigger',\n description: 'URL path for the webhook (e.g., \"my-webhook\"). Full URL will be /api/workflows-webhook/my-webhook',\n },\n hooks: {\n afterRead: [\n ({ siblingData }) => {\n return siblingData?.parameters?.webhookPath || undefined\n }\n ],\n beforeChange: [\n ({ siblingData, value }) => {\n if (!siblingData.parameters) {siblingData.parameters = {}}\n siblingData.parameters.webhookPath = value\n return undefined // Virtual field, don't store directly\n }\n ]\n },\n validate: (value: any, {siblingData}: any) => {\n if (siblingData?.type === 'webhook-trigger' && !value && !siblingData?.parameters?.webhookPath) {\n return 'Webhook path is required for webhook triggers'\n }\n return true\n },\n virtual: true,\n },\n // Virtual fields for global trigger\n {\n name: '__builtin_global',\n type: 'select',\n admin: {\n condition: (_, siblingData) => siblingData?.type === 'global-trigger',\n description: 'Global that triggers the workflow',\n },\n hooks: {\n afterRead: [\n ({ siblingData }) => {\n return siblingData?.parameters?.global || undefined\n }\n ],\n beforeChange: [\n ({ siblingData, value }) => {\n if (!siblingData.parameters) {siblingData.parameters = {}}\n siblingData.parameters.global = value\n return undefined // Virtual field, don't store directly\n }\n ]\n },\n options: [], // Will be populated dynamically based on available globals\n virtual: true,\n },\n {\n name: '__builtin_globalOperation',\n type: 'select',\n admin: {\n condition: (_, siblingData) => siblingData?.type === 'global-trigger',\n description: 'Global operation that triggers the workflow',\n },\n hooks: {\n afterRead: [\n ({ siblingData }) => {\n return siblingData?.parameters?.globalOperation || undefined\n }\n ],\n beforeChange: [\n ({ siblingData, value }) => {\n if (!siblingData.parameters) {siblingData.parameters = {}}\n siblingData.parameters.globalOperation = value\n return undefined // Virtual field, don't store directly\n }\n ]\n },\n options: [\n 'update'\n ],\n virtual: true,\n },\n // Virtual fields for cron trigger\n {\n name: '__builtin_cronExpression',\n type: 'text',\n admin: {\n condition: (_, siblingData) => siblingData?.type === 'cron-trigger',\n description: 'Cron expression for scheduled execution (e.g., \"0 0 * * *\" for daily at midnight)',\n placeholder: '0 0 * * *'\n },\n hooks: {\n afterRead: [\n ({ siblingData }) => {\n return siblingData?.parameters?.cronExpression || undefined\n }\n ],\n beforeChange: [\n ({ siblingData, value }) => {\n if (!siblingData.parameters) {siblingData.parameters = {}}\n siblingData.parameters.cronExpression = value\n return undefined // Virtual field, don't store directly\n }\n ]\n },\n validate: (value: any, {siblingData}: any) => {\n const cronValue = value || siblingData?.parameters?.cronExpression\n if (siblingData?.type === 'cron-trigger' && !cronValue) {\n return 'Cron expression is required for cron triggers'\n }\n\n // Validate cron expression format if provided\n if (siblingData?.type === 'cron-trigger' && cronValue) {\n // Basic format validation - should be 5 parts separated by spaces\n const cronParts = cronValue.trim().split(/\\s+/)\n if (cronParts.length !== 5) {\n return 'Invalid cron expression format. Expected 5 parts: \"minute hour day month weekday\" (e.g., \"0 9 * * 1\")'\n }\n\n // Additional validation could use node-cron but we avoid dynamic imports here\n // The main validation happens at runtime in the cron scheduler\n }\n\n return true\n },\n virtual: true,\n },\n {\n name: '__builtin_timezone',\n type: 'text',\n admin: {\n condition: (_, siblingData) => siblingData?.type === 'cron-trigger',\n description: 'Timezone for cron execution (e.g., \"America/New_York\", \"Europe/London\"). Defaults to UTC.',\n placeholder: 'UTC'\n },\n defaultValue: 'UTC',\n hooks: {\n afterRead: [\n ({ siblingData }) => {\n return siblingData?.parameters?.timezone || 'UTC'\n }\n ],\n beforeChange: [\n ({ siblingData, value }) => {\n if (!siblingData.parameters) {siblingData.parameters = {}}\n siblingData.parameters.timezone = value || 'UTC'\n return undefined // Virtual field, don't store directly\n }\n ]\n },\n validate: (value: any, {siblingData}: any) => {\n const tzValue = value || siblingData?.parameters?.timezone\n if (siblingData?.type === 'cron-trigger' && tzValue) {\n try {\n // Test if timezone is valid by trying to create a date with it\n new Intl.DateTimeFormat('en', {timeZone: tzValue})\n return true\n } catch {\n return `Invalid timezone: ${tzValue}. Please use a valid IANA timezone identifier (e.g., \"America/New_York\", \"Europe/London\")`\n }\n }\n return true\n },\n virtual: true,\n },\n {\n name: 'condition',\n type: 'text',\n admin: {\n description: 'JSONPath expression that must evaluate to true for this trigger to execute the workflow (e.g., \"$.trigger.doc.status == \\'published\\'\")'\n },\n required: false\n },\n // Virtual fields for custom triggers\n // Note: Custom trigger fields from trigger-helpers already have unique names\n // We just need to pass them through without modification\n ...(triggers || []).flatMap(t => (t.inputs || []))\n ]\n },\n {\n name: 'steps',\n type: 'array',\n fields: [\n {\n type: 'row',\n fields: [\n {\n name: 'step',\n type: 'select',\n options: steps.map(t => t.slug)\n },\n {\n name: 'name',\n type: 'text',\n }\n ]\n },\n ...(steps || []).flatMap(step => (step.inputSchema || []).map(field => ({\n ...field,\n admin: {\n ...(field.admin || {}),\n condition: (...args) => args[1]?.step === step.slug && (\n field.admin?.condition ?\n field.admin.condition.call(this, ...args) :\n true\n ),\n },\n } as Field))),\n {\n name: 'dependencies',\n type: 'text',\n admin: {\n description: 'Step names that must complete before this step can run'\n },\n hasMany: true,\n required: false\n },\n {\n name: 'condition',\n type: 'text',\n admin: {\n description: 'JSONPath expression that must evaluate to true for this step to execute (e.g., \"$.trigger.doc.status == \\'published\\'\")'\n },\n required: false\n },\n ],\n }\n ],\n versions: {\n drafts: {\n autosave: false,\n },\n maxPerDoc: 10,\n },\n})\n"],"names":["createWorkflowCollection","collectionTriggers","steps","triggers","slug","access","create","delete","read","update","admin","defaultColumns","description","group","useAsTitle","fields","name","type","required","components","Field","condition","data","id","options","map","t","hidden","defaultValue","_","siblingData","hooks","afterRead","parameters","collectionSlug","undefined","beforeChange","value","Object","keys","virtual","operation","webhookPath","validate","global","globalOperation","placeholder","cronExpression","cronValue","cronParts","trim","split","length","timezone","tzValue","Intl","DateTimeFormat","timeZone","flatMap","inputs","step","inputSchema","field","args","call","hasMany","versions","drafts","autosave","maxPerDoc"],"mappings":"AAIA,OAAO,MAAMA,2BAAsG,CAAC,EACZC,kBAAkB,EAClBC,KAAK,EACLC,QAAQ,EACT,GAAM,CAAA;QAC3GC,MAAM;QACNC,QAAQ;YACNC,QAAQ,IAAM;YACdC,QAAQ,IAAM;YACdC,MAAM,IAAM;YACZC,QAAQ,IAAM;QAChB;QACAC,OAAO;YACLC,gBAAgB;gBAAC;gBAAQ;aAAY;YACrCC,aAAa;YACbC,OAAO;YACPC,YAAY;QACd;QACAC,QAAQ;YACN;gBACEC,MAAM;gBACNC,MAAM;gBACNP,OAAO;oBACLE,aAAa;gBACf;gBACAM,UAAU;YACZ;YACA;gBACEF,MAAM;gBACNC,MAAM;gBACNP,OAAO;oBACLE,aAAa;gBACf;YACF;YACA;gBACEI,MAAM;gBACNC,MAAM;gBACNP,OAAO;oBACLS,YAAY;wBACVC,OAAO;oBACT;oBACAC,WAAW,CAACC,OAAS,CAAC,CAACA,MAAMC,GAAG,mCAAmC;gBACrE;YACF;YACA;gBACEP,MAAM;gBACNC,MAAM;gBACNF,QAAQ;oBACN;wBACEC,MAAM;wBACNC,MAA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;iBACjD;YACH;YACA;gBACE3C,MAAM;gBACNC,MAAM;gBACNF,QAAQ;oBACN;wBACEE,MAAM;wBACNF,QAAQ;4BACN;gCACEC,MAAM;gCACNC,MAAM;gCACNO,SAAStB,MAAMuB,GAAG,CAACC,CAAAA,IAAKA,EAAEtB,IAAI;4BAChC;4BACA;gCACEY,MAAM;gCACNC,MAAM;4BACR;yBACD;oBACH;uBACG,AAACf,CAAAA,SAAS,EAAE,AAAD,EAAGwD,OAAO,CAACE,CAAAA,OAAQ,AAACA,CAAAA,KAAKC,WAAW,IAAI,EAAE,AAAD,EAAGpC,GAAG,CAACqC,CAAAA,QAAU,CAAA;gCACtE,GAAGA,KAAK;gCACRpD,OAAO;oCACL,GAAIoD,MAAMpD,KAAK,IAAI,CAAC,CAAC;oCACrBW,WAAW,CAAC,GAAG0C,OAASA,IAAI,CAAC,EAAE,EAAEH,SAASA,KAAKxD,IAAI,IACjD0D,CAAAA,MAAMpD,KAAK,EAAEW,YACXyC,MAAMpD,KAAK,CAACW,SAAS,CAAC2C,IAAI,CAAC,IAAI,KAAKD,QACpC,IAAG;gCAET;4BACF,CAAA;oBACA;wBACE/C,MAAM;wBACNC,MAAM;wBACNP,OAAO;4BACLE,aAAa;wBACf;wBACAqD,SAAS;wBACT/C,UAAU;oBACZ;oBACA;wBACEF,MAAM;wBACNC,MAAM;wBACNP,OAAO;4BACLE,aAAa;wBACf;wBACAM,UAAU;oBACZ;iBACD;YACH;SACD;QACDgD,UAAU;YACRC,QAAQ;gBACNC,UAAU;YACZ;YACAC,WAAW;QACb;IACF,CAAA,EAAE"}
1
+ {"version":3,"sources":["../../src/collections/Workflow.ts"],"sourcesContent":["import type {CollectionConfig, Field} from 'payload'\n\nimport type {WorkflowsPluginConfig} from \"../plugin/config-types.js\"\n\nexport const createWorkflowCollection: <T extends string>(options: WorkflowsPluginConfig<T>) => CollectionConfig = ({\n collectionTriggers,\n steps,\n triggers\n }) => ({\n slug: 'workflows',\n access: {\n create: () => true,\n delete: () => true,\n read: () => true,\n update: () => true,\n },\n admin: {\n defaultColumns: ['name', 'updatedAt'],\n description: 'Create and manage automated workflows.',\n group: 'Automation',\n useAsTitle: 'name',\n },\n fields: [\n {\n name: 'name',\n type: 'text',\n admin: {\n description: 'Human-readable name for the workflow',\n },\n required: true,\n },\n {\n name: 'description',\n type: 'textarea',\n admin: {\n description: 'Optional description of what this workflow does',\n },\n },\n {\n name: 'executionStatus',\n type: 'ui',\n admin: {\n components: {\n Field: '@xtr-dev/payload-automation/client#WorkflowExecutionStatus'\n },\n condition: (data) => !!data?.id // Only show for existing workflows\n }\n },\n {\n name: 'triggers',\n type: 'array',\n fields: [\n {\n name: 'type',\n type: 'select',\n options: [\n 'collection-trigger',\n 'webhook-trigger',\n 'global-trigger',\n 'cron-trigger',\n ...(triggers || []).map(t => t.slug)\n ]\n },\n {\n name: 'parameters',\n type: 'json',\n admin: {\n hidden: true,\n },\n defaultValue: {}\n },\n // Virtual fields for collection trigger\n {\n name: '__builtin_collectionSlug',\n type: 'select',\n admin: {\n condition: (_, siblingData) => siblingData?.type === 'collection-trigger',\n description: 'Collection that triggers the workflow',\n },\n hooks: {\n afterRead: [\n ({ siblingData }) => {\n return siblingData?.parameters?.collectionSlug || undefined\n }\n ],\n beforeChange: [\n ({ siblingData, value }) => {\n if (!siblingData.parameters) {siblingData.parameters = {}}\n siblingData.parameters.collectionSlug = value\n return undefined // Virtual field, don't store directly\n }\n ]\n },\n options: Object.keys(collectionTriggers || {}),\n virtual: true,\n },\n {\n name: '__builtin_operation',\n type: 'select',\n admin: {\n condition: (_, siblingData) => siblingData?.type === 'collection-trigger',\n description: 'Collection operation that triggers the workflow',\n },\n hooks: {\n afterRead: [\n ({ siblingData }) => {\n return siblingData?.parameters?.operation || undefined\n }\n ],\n beforeChange: [\n ({ siblingData, value }) => {\n if (!siblingData.parameters) {siblingData.parameters = {}}\n siblingData.parameters.operation = value\n return undefined // Virtual field, don't store directly\n }\n ]\n },\n options: [\n 'create',\n 'delete',\n 'read',\n 'update',\n ],\n virtual: true,\n },\n // Virtual fields for webhook trigger\n {\n name: '__builtin_webhookPath',\n type: 'text',\n admin: {\n condition: (_, siblingData) => siblingData?.type === 'webhook-trigger',\n description: 'URL path for the webhook (e.g., \"my-webhook\"). Full URL will be /api/workflows-webhook/my-webhook',\n },\n hooks: {\n afterRead: [\n ({ siblingData }) => {\n return siblingData?.parameters?.webhookPath || undefined\n }\n ],\n beforeChange: [\n ({ siblingData, value }) => {\n if (!siblingData.parameters) {siblingData.parameters = {}}\n siblingData.parameters.webhookPath = value\n return undefined // Virtual field, don't store directly\n }\n ]\n },\n validate: (value: any, {siblingData}: any) => {\n if (siblingData?.type === 'webhook-trigger' && !value && !siblingData?.parameters?.webhookPath) {\n return 'Webhook path is required for webhook triggers'\n }\n return true\n },\n virtual: true,\n },\n // Virtual fields for global trigger\n {\n name: '__builtin_global',\n type: 'select',\n admin: {\n condition: (_, siblingData) => siblingData?.type === 'global-trigger',\n description: 'Global that triggers the workflow',\n },\n hooks: {\n afterRead: [\n ({ siblingData }) => {\n return siblingData?.parameters?.global || undefined\n }\n ],\n beforeChange: [\n ({ siblingData, value }) => {\n if (!siblingData.parameters) {siblingData.parameters = {}}\n siblingData.parameters.global = value\n return undefined // Virtual field, don't store directly\n }\n ]\n },\n options: [], // Will be populated dynamically based on available globals\n virtual: true,\n },\n {\n name: '__builtin_globalOperation',\n type: 'select',\n admin: {\n condition: (_, siblingData) => siblingData?.type === 'global-trigger',\n description: 'Global operation that triggers the workflow',\n },\n hooks: {\n afterRead: [\n ({ siblingData }) => {\n return siblingData?.parameters?.globalOperation || undefined\n }\n ],\n beforeChange: [\n ({ siblingData, value }) => {\n if (!siblingData.parameters) {siblingData.parameters = {}}\n siblingData.parameters.globalOperation = value\n return undefined // Virtual field, don't store directly\n }\n ]\n },\n options: [\n 'update'\n ],\n virtual: true,\n },\n // Virtual fields for cron trigger\n {\n name: '__builtin_cronExpression',\n type: 'text',\n admin: {\n condition: (_, siblingData) => siblingData?.type === 'cron-trigger',\n description: 'Cron expression for scheduled execution (e.g., \"0 0 * * *\" for daily at midnight)',\n placeholder: '0 0 * * *'\n },\n hooks: {\n afterRead: [\n ({ siblingData }) => {\n return siblingData?.parameters?.cronExpression || undefined\n }\n ],\n beforeChange: [\n ({ siblingData, value }) => {\n if (!siblingData.parameters) {siblingData.parameters = {}}\n siblingData.parameters.cronExpression = value\n return undefined // Virtual field, don't store directly\n }\n ]\n },\n validate: (value: any, {siblingData}: any) => {\n const cronValue = value || siblingData?.parameters?.cronExpression\n if (siblingData?.type === 'cron-trigger' && !cronValue) {\n return 'Cron expression is required for cron triggers'\n }\n\n // Validate cron expression format if provided\n if (siblingData?.type === 'cron-trigger' && cronValue) {\n // Basic format validation - should be 5 parts separated by spaces\n const cronParts = cronValue.trim().split(/\\s+/)\n if (cronParts.length !== 5) {\n return 'Invalid cron expression format. Expected 5 parts: \"minute hour day month weekday\" (e.g., \"0 9 * * 1\")'\n }\n\n // Additional validation could use node-cron but we avoid dynamic imports here\n // The main validation happens at runtime in the cron scheduler\n }\n\n return true\n },\n virtual: true,\n },\n {\n name: '__builtin_timezone',\n type: 'text',\n admin: {\n condition: (_, siblingData) => siblingData?.type === 'cron-trigger',\n description: 'Timezone for cron execution (e.g., \"America/New_York\", \"Europe/London\"). Defaults to UTC.',\n placeholder: 'UTC'\n },\n defaultValue: 'UTC',\n hooks: {\n afterRead: [\n ({ siblingData }) => {\n return siblingData?.parameters?.timezone || 'UTC'\n }\n ],\n beforeChange: [\n ({ siblingData, value }) => {\n if (!siblingData.parameters) {siblingData.parameters = {}}\n siblingData.parameters.timezone = value || 'UTC'\n return undefined // Virtual field, don't store directly\n }\n ]\n },\n validate: (value: any, {siblingData}: any) => {\n const tzValue = value || siblingData?.parameters?.timezone\n if (siblingData?.type === 'cron-trigger' && tzValue) {\n try {\n // Test if timezone is valid by trying to create a date with it\n new Intl.DateTimeFormat('en', {timeZone: tzValue})\n return true\n } catch {\n return `Invalid timezone: ${tzValue}. Please use a valid IANA timezone identifier (e.g., \"America/New_York\", \"Europe/London\")`\n }\n }\n return true\n },\n virtual: true,\n },\n {\n name: 'condition',\n type: 'text',\n admin: {\n description: 'JSONPath expression that must evaluate to true for this trigger to execute the workflow (e.g., \"$.trigger.doc.status == \\'published\\'\")'\n },\n required: false\n },\n // Virtual fields for custom triggers\n // Note: Custom trigger fields from trigger-helpers already have unique names\n // We just need to pass them through without modification\n ...(triggers || []).flatMap(t => (t.inputs || []))\n ]\n },\n {\n name: 'steps',\n type: 'array',\n fields: [\n {\n type: 'row',\n fields: [\n {\n name: 'step',\n type: 'select',\n options: steps.map(t => t.slug)\n },\n {\n name: 'name',\n type: 'text',\n }\n ]\n },\n ...(steps || []).flatMap(step => (step.inputSchema || []).map(field => ({\n ...field,\n admin: {\n ...(field.admin || {}),\n condition: (...args) => args[1]?.step === step.slug && (\n field.admin?.condition ?\n field.admin.condition.call(this, ...args) :\n true\n ),\n },\n } as Field))),\n {\n name: 'dependencies',\n type: 'text',\n admin: {\n description: 'Step names that must complete before this step can run'\n },\n hasMany: true,\n required: false\n },\n {\n name: 'condition',\n type: 'text',\n admin: {\n description: 'JSONPath expression that must evaluate to true for this step to execute (e.g., \"$.trigger.doc.status == \\'published\\'\")'\n },\n required: false\n },\n ],\n }\n ],\n versions: {\n drafts: {\n autosave: false,\n },\n maxPerDoc: 10,\n },\n})\n"],"names":["createWorkflowCollection","collectionTriggers","steps","triggers","slug","access","create","delete","read","update","admin","defaultColumns","description","group","useAsTitle","fields","name","type","required","components","Field","condition","data","id","options","map","t","hidden","defaultValue","_","siblingData","hooks","afterRead","parameters","collectionSlug","undefined","beforeChange","value","Object","keys","virtual","operation","webhookPath","validate","global","globalOperation","placeholder","cronExpression","cronValue","cronParts","trim","split","length","timezone","tzValue","Intl","DateTimeFormat","timeZone","flatMap","inputs","step","inputSchema","field","args","call","hasMany","versions","drafts","autosave","maxPerDoc"],"mappings":"AAIA,OAAO,MAAMA,2BAAsG,CAA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MAAMpD,KAAK,EAAEW,YACXyC,MAAMpD,KAAK,CAACW,SAAS,CAAC2C,IAAI,CAAC,IAAI,KAAKD,QACpC,IAAG;gCAET;4BACF,CAAA;oBACA;wBACE/C,MAAM;wBACNC,MAAM;wBACNP,OAAO;4BACLE,aAAa;wBACf;wBACAqD,SAAS;wBACT/C,UAAU;oBACZ;oBACA;wBACEF,MAAM;wBACNC,MAAM;wBACNP,OAAO;4BACLE,aAAa;wBACf;wBACAM,UAAU;oBACZ;iBACD;YACH;SACD;QACDgD,UAAU;YACRC,QAAQ;gBACNC,UAAU;YACZ;YACAC,WAAW;QACb;IACF,CAAA,EAAE"}
@@ -44,7 +44,7 @@ export const WorkflowRunsCollection = {
44
44
  admin: {
45
45
  description: 'Current execution status',
46
46
  components: {
47
- Cell: '@/components/StatusCell'
47
+ Cell: '@xtr-dev/payload-automation/client#StatusCell'
48
48
  }
49
49
  },
50
50
  defaultValue: 'pending',
@@ -145,7 +145,7 @@ export const WorkflowRunsCollection = {
145
145
  description: 'Error message if workflow execution failed',
146
146
  condition: (_, siblingData)=>siblingData?.status === 'failed',
147
147
  components: {
148
- Field: '@/components/ErrorDisplay'
148
+ Field: '@xtr-dev/payload-automation/client#ErrorDisplay'
149
149
  }
150
150
  }
151
151
  },
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/collections/WorkflowRuns.ts"],"sourcesContent":["import type { CollectionConfig } from 'payload'\n\nexport const WorkflowRunsCollection: CollectionConfig = {\n slug: 'workflow-runs',\n access: {\n create: () => true,\n delete: () => true,\n read: () => true,\n update: () => true,\n },\n admin: {\n defaultColumns: ['workflow', 'status', 'triggeredBy', 'startedAt', 'duration'],\n group: 'Automation',\n pagination: {\n defaultLimit: 50,\n },\n useAsTitle: 'id',\n },\n fields: [\n {\n name: 'workflow',\n type: 'relationship',\n admin: {\n description: 'Reference to the workflow that was executed',\n },\n relationTo: 'workflows',\n required: true,\n },\n {\n name: 'workflowVersion',\n type: 'number',\n admin: {\n description: 'Version of the workflow that was executed',\n },\n required: true,\n },\n {\n name: 'status',\n type: 'select',\n admin: {\n description: 'Current execution status',\n components: {\n Cell: '@/components/StatusCell'\n }\n },\n defaultValue: 'pending',\n options: [\n {\n label: '⏳ Pending',\n value: 'pending',\n },\n {\n label: '🔄 Running',\n value: 'running',\n },\n {\n label: '✅ Completed',\n value: 'completed',\n },\n {\n label: '❌ Failed',\n value: 'failed',\n },\n {\n label: '⏹️ Cancelled',\n value: 'cancelled',\n },\n ],\n required: true,\n },\n {\n name: 'startedAt',\n type: 'date',\n admin: {\n date: {\n displayFormat: 'yyyy-MM-dd HH:mm:ss',\n },\n description: 'When execution began',\n },\n required: true,\n },\n {\n name: 'completedAt',\n type: 'date',\n admin: {\n date: {\n displayFormat: 'yyyy-MM-dd HH:mm:ss',\n },\n description: 'When execution finished',\n },\n },\n {\n name: 'duration',\n type: 'number',\n admin: {\n description: 'Total execution time in milliseconds',\n readOnly: true,\n },\n },\n {\n name: 'context',\n type: 'json'\n },\n {\n name: 'inputs',\n type: 'json',\n admin: {\n description: 'Input data provided when the workflow was triggered',\n },\n defaultValue: {},\n required: true,\n },\n {\n name: 'outputs',\n type: 'json',\n admin: {\n description: 'Final output data from completed steps',\n },\n },\n {\n name: 'triggeredBy',\n type: 'text',\n admin: {\n description: 'User, system, or trigger type that initiated execution',\n },\n required: true,\n },\n {\n name: 'steps',\n type: 'json',\n admin: {\n description: 'Array of step execution results',\n },\n defaultValue: [],\n required: true,\n },\n {\n name: 'error',\n type: 'textarea',\n admin: {\n description: 'Error message if workflow execution failed',\n condition: (_, siblingData) => siblingData?.status === 'failed',\n components: {\n Field: '@/components/ErrorDisplay'\n }\n },\n },\n {\n name: 'logs',\n type: 'json',\n admin: {\n description: 'Detailed execution logs',\n },\n defaultValue: [],\n required: true,\n },\n ],\n}\n"],"names":["WorkflowRunsCollection","slug","access","create","delete","read","update","admin","defaultColumns","group","pagination","defaultLimit","useAsTitle","fields","name","type","description","relationTo","required","components","Cell","defaultValue","options","label","value","date","displayFormat","readOnly","condition","_","siblingData","status","Field"],"mappings":"AAEA,OAAO,MAAMA,yBAA2C;IACtDC,MAAM;IACNC,QAAQ;QACNC,QAAQ,IAAM;QACdC,QAAQ,IAAM;QACdC,MAAM,IAAM;QACZC,QAAQ,IAAM;IAChB;IACAC,OAAO;QACLC,gBAAgB;YAAC;YAAY;YAAU;YAAe;YAAa;SAAW;QAC9EC,OAAO;QACPC,YAAY;YACVC,cAAc;QAChB;QACAC,YAAY;IACd;IACAC,QAAQ;QACN;YACEC,MAAM;YACNC,MAAM;YACNR,OAAO;gBACLS,aAAa;YACf;YACAC,YAAY;YACZC,UAAU;QACZ;QACA;YACEJ,MAAM;YACNC,MAAM;YACNR,OAAO;gBACLS,aAAa;YACf;YACAE,UAAU;QACZ;QACA;YACEJ,MAAM;YACNC,MAAM;YACNR,OAAO;gBACLS,aAAa;gBACbG,YAAY;oBACVC,MAAM;gBACR;YACF;YACAC,cAAc;YACdC,SAAS;gBACP;oBACEC,OAAO;oBACPC,OAAO;gBACT;gBACA;oBACED,OAAO;oBACPC,OAAO;gBACT;gBACA;oBACED,OAAO;oBACPC,OAAO;gBACT;gBACA;oBACED,OAAO;oBACPC,OAAO;gBACT;gBACA;oBACED,OAAO;oBACPC,OAAO;gBACT;aACD;YACDN,UAAU;QACZ;QACA;YACEJ,MAAM;YACNC,MAAM;YACNR,OAAO;gBACLkB,MAAM;oBACJC,eAAe;gBACjB;gBACAV,aAAa;YACf;YACAE,UAAU;QACZ;QACA;YACEJ,MAAM;YACNC,MAAM;YACNR,OAAO;gBACLkB,MAAM;oBACJC,eAAe;gBACjB;gBACAV,aAAa;YACf;QACF;QACA;YACEF,MAAM;YACNC,MAAM;YACNR,OAAO;gBACLS,aAAa;gBACbW,UAAU;YACZ;QACF;QACA;YACEb,MAAM;YACNC,MAAM;QACR;QACA;YACED,MAAM;YACNC,MAAM;YACNR,OAAO;gBACLS,aAAa;YACf;YACAK,cAAc,CAAC;YACfH,UAAU;QACZ;QACA;YACEJ,MAAM;YACNC,MAAM;YACNR,OAAO;gBACLS,aAAa;YACf;QACF;QACA;YACEF,MAAM;YACNC,MAAM;YACNR,OAAO;gBACLS,aAAa;YACf;YACAE,UAAU;QACZ;QACA;YACEJ,MAAM;YACNC,MAAM;YACNR,OAAO;gBACLS,aAAa;YACf;YACAK,cAAc,EAAE;YAChBH,UAAU;QACZ;QACA;YACEJ,MAAM;YACNC,MAAM;YACNR,OAAO;gBACLS,aAAa;gBACbY,WAAW,CAACC,GAAGC,cAAgBA,aAAaC,WAAW;gBACvDZ,YAAY;oBACVa,OAAO;gBACT;YACF;QACF;QACA;YACElB,MAAM;YACNC,MAAM;YACNR,OAAO;gBACLS,aAAa;YACf;YACAK,cAAc,EAAE;YAChBH,UAAU;QACZ;KACD;AACH,EAAC"}
1
+ {"version":3,"sources":["../../src/collections/WorkflowRuns.ts"],"sourcesContent":["import type { CollectionConfig } from 'payload'\n\nexport const WorkflowRunsCollection: CollectionConfig = {\n slug: 'workflow-runs',\n access: {\n create: () => true,\n delete: () => true,\n read: () => true,\n update: () => true,\n },\n admin: {\n defaultColumns: ['workflow', 'status', 'triggeredBy', 'startedAt', 'duration'],\n group: 'Automation',\n pagination: {\n defaultLimit: 50,\n },\n useAsTitle: 'id',\n },\n fields: [\n {\n name: 'workflow',\n type: 'relationship',\n admin: {\n description: 'Reference to the workflow that was executed',\n },\n relationTo: 'workflows',\n required: true,\n },\n {\n name: 'workflowVersion',\n type: 'number',\n admin: {\n description: 'Version of the workflow that was executed',\n },\n required: true,\n },\n {\n name: 'status',\n type: 'select',\n admin: {\n description: 'Current execution status',\n components: {\n Cell: '@xtr-dev/payload-automation/client#StatusCell'\n }\n },\n defaultValue: 'pending',\n options: [\n {\n label: '⏳ Pending',\n value: 'pending',\n },\n {\n label: '🔄 Running',\n value: 'running',\n },\n {\n label: '✅ Completed',\n value: 'completed',\n },\n {\n label: '❌ Failed',\n value: 'failed',\n },\n {\n label: '⏹️ Cancelled',\n value: 'cancelled',\n },\n ],\n required: true,\n },\n {\n name: 'startedAt',\n type: 'date',\n admin: {\n date: {\n displayFormat: 'yyyy-MM-dd HH:mm:ss',\n },\n description: 'When execution began',\n },\n required: true,\n },\n {\n name: 'completedAt',\n type: 'date',\n admin: {\n date: {\n displayFormat: 'yyyy-MM-dd HH:mm:ss',\n },\n description: 'When execution finished',\n },\n },\n {\n name: 'duration',\n type: 'number',\n admin: {\n description: 'Total execution time in milliseconds',\n readOnly: true,\n },\n },\n {\n name: 'context',\n type: 'json'\n },\n {\n name: 'inputs',\n type: 'json',\n admin: {\n description: 'Input data provided when the workflow was triggered',\n },\n defaultValue: {},\n required: true,\n },\n {\n name: 'outputs',\n type: 'json',\n admin: {\n description: 'Final output data from completed steps',\n },\n },\n {\n name: 'triggeredBy',\n type: 'text',\n admin: {\n description: 'User, system, or trigger type that initiated execution',\n },\n required: true,\n },\n {\n name: 'steps',\n type: 'json',\n admin: {\n description: 'Array of step execution results',\n },\n defaultValue: [],\n required: true,\n },\n {\n name: 'error',\n type: 'textarea',\n admin: {\n description: 'Error message if workflow execution failed',\n condition: (_, siblingData) => siblingData?.status === 'failed',\n components: {\n Field: '@xtr-dev/payload-automation/client#ErrorDisplay'\n }\n },\n },\n {\n name: 'logs',\n type: 'json',\n admin: {\n description: 'Detailed execution logs',\n },\n defaultValue: [],\n required: true,\n },\n ],\n}\n"],"names":["WorkflowRunsCollection","slug","access","create","delete","read","update","admin","defaultColumns","group","pagination","defaultLimit","useAsTitle","fields","name","type","description","relationTo","required","components","Cell","defaultValue","options","label","value","date","displayFormat","readOnly","condition","_","siblingData","status","Field"],"mappings":"AAEA,OAAO,MAAMA,yBAA2C;IACtDC,MAAM;IACNC,QAAQ;QACNC,QAAQ,IAAM;QACdC,QAAQ,IAAM;QACdC,MAAM,IAAM;QACZC,QAAQ,IAAM;IAChB;IACAC,OAAO;QACLC,gBAAgB;YAAC;YAAY;YAAU;YAAe;YAAa;SAAW;QAC9EC,OAAO;QACPC,YAAY;YACVC,cAAc;QAChB;QACAC,YAAY;IACd;IACAC,QAAQ;QACN;YACEC,MAAM;YACNC,MAAM;YACNR,OAAO;gBACLS,aAAa;YACf;YACAC,YAAY;YACZC,UAAU;QACZ;QACA;YACEJ,MAAM;YACNC,MAAM;YACNR,OAAO;gBACLS,aAAa;YACf;YACAE,UAAU;QACZ;QACA;YACEJ,MAAM;YACNC,MAAM;YACNR,OAAO;gBACLS,aAAa;gBACbG,YAAY;oBACVC,MAAM;gBACR;YACF;YACAC,cAAc;YACdC,SAAS;gBACP;oBACEC,OAAO;oBACPC,OAAO;gBACT;gBACA;oBACED,OAAO;oBACPC,OAAO;gBACT;gBACA;oBACED,OAAO;oBACPC,OAAO;gBACT;gBACA;oBACED,OAAO;oBACPC,OAAO;gBACT;gBACA;oBACED,OAAO;oBACPC,OAAO;gBACT;aACD;YACDN,UAAU;QACZ;QACA;YACEJ,MAAM;YACNC,MAAM;YACNR,OAAO;gBACLkB,MAAM;oBACJC,eAAe;gBACjB;gBACAV,aAAa;YACf;YACAE,UAAU;QACZ;QACA;YACEJ,MAAM;YACNC,MAAM;YACNR,OAAO;gBACLkB,MAAM;oBACJC,eAAe;gBACjB;gBACAV,aAAa;YACf;QACF;QACA;YACEF,MAAM;YACNC,MAAM;YACNR,OAAO;gBACLS,aAAa;gBACbW,UAAU;YACZ;QACF;QACA;YACEb,MAAM;YACNC,MAAM;QACR;QACA;YACED,MAAM;YACNC,MAAM;YACNR,OAAO;gBACLS,aAAa;YACf;YACAK,cAAc,CAAC;YACfH,UAAU;QACZ;QACA;YACEJ,MAAM;YACNC,MAAM;YACNR,OAAO;gBACLS,aAAa;YACf;QACF;QACA;YACEF,MAAM;YACNC,MAAM;YACNR,OAAO;gBACLS,aAAa;YACf;YACAE,UAAU;QACZ;QACA;YACEJ,MAAM;YACNC,MAAM;YACNR,OAAO;gBACLS,aAAa;YACf;YACAK,cAAc,EAAE;YAChBH,UAAU;QACZ;QACA;YACEJ,MAAM;YACNC,MAAM;YACNR,OAAO;gBACLS,aAAa;gBACbY,WAAW,CAACC,GAAGC,cAAgBA,aAAaC,WAAW;gBACvDZ,YAAY;oBACVa,OAAO;gBACT;YACF;QACF;QACA;YACElB,MAAM;YACNC,MAAM;YACNR,OAAO;gBACLS,aAAa;YACf;YACAK,cAAc,EAAE;YAChBH,UAAU;QACZ;KACD;AACH,EAAC"}
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ interface ErrorDisplayProps {
3
+ value?: string;
4
+ onChange?: (value: string) => void;
5
+ readOnly?: boolean;
6
+ path?: string;
7
+ }
8
+ export declare const ErrorDisplay: React.FC<ErrorDisplayProps>;
9
+ export {};
@@ -0,0 +1,307 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
+ import React, { useState } from 'react';
4
+ import { Button } from '@payloadcms/ui';
5
+ export const ErrorDisplay = ({ value, onChange, readOnly = false })=>{
6
+ const [expanded, setExpanded] = useState(false);
7
+ if (!value) {
8
+ return null;
9
+ }
10
+ // Parse common error patterns
11
+ const parseError = (error)=>{
12
+ // Check for different error types and provide user-friendly messages
13
+ if (error.includes('Request timeout')) {
14
+ return {
15
+ type: 'timeout',
16
+ title: 'Request Timeout',
17
+ message: 'The HTTP request took too long to complete. Consider increasing the timeout value or checking the target server.',
18
+ technical: error
19
+ };
20
+ }
21
+ if (error.includes('Network error') || error.includes('fetch')) {
22
+ return {
23
+ type: 'network',
24
+ title: 'Network Error',
25
+ message: 'Unable to connect to the target server. Please check the URL and network connectivity.',
26
+ technical: error
27
+ };
28
+ }
29
+ if (error.includes('Hook execution failed')) {
30
+ return {
31
+ type: 'hook',
32
+ title: 'Workflow Hook Failed',
33
+ message: 'The workflow trigger hook encountered an error. This may be due to PayloadCMS initialization issues.',
34
+ technical: error
35
+ };
36
+ }
37
+ if (error.includes('Executor not available')) {
38
+ return {
39
+ type: 'executor',
40
+ title: 'Workflow Engine Unavailable',
41
+ message: 'The workflow execution engine is not properly initialized. Try restarting the server.',
42
+ technical: error
43
+ };
44
+ }
45
+ if (error.includes('Collection slug is required') || error.includes('Document data is required')) {
46
+ return {
47
+ type: 'validation',
48
+ title: 'Invalid Input Data',
49
+ message: 'Required fields are missing from the workflow step configuration. Please check your step inputs.',
50
+ technical: error
51
+ };
52
+ }
53
+ if (error.includes('status') && error.includes('4')) {
54
+ return {
55
+ type: 'client',
56
+ title: 'Client Error (4xx)',
57
+ message: 'The request was rejected by the server. Check your API credentials and request format.',
58
+ technical: error
59
+ };
60
+ }
61
+ if (error.includes('status') && error.includes('5')) {
62
+ return {
63
+ type: 'server',
64
+ title: 'Server Error (5xx)',
65
+ message: 'The target server encountered an error. This is usually temporary - try again later.',
66
+ technical: error
67
+ };
68
+ }
69
+ // Generic error
70
+ return {
71
+ type: 'generic',
72
+ title: 'Workflow Error',
73
+ message: 'An error occurred during workflow execution. See technical details below.',
74
+ technical: error
75
+ };
76
+ };
77
+ const errorInfo = parseError(value);
78
+ const getErrorIcon = (type)=>{
79
+ switch(type){
80
+ case 'timeout':
81
+ return '⏰';
82
+ case 'network':
83
+ return '🌐';
84
+ case 'hook':
85
+ return '🔗';
86
+ case 'executor':
87
+ return '⚙️';
88
+ case 'validation':
89
+ return '📋';
90
+ case 'client':
91
+ return '🚫';
92
+ case 'server':
93
+ return '🔥';
94
+ default:
95
+ return '❗';
96
+ }
97
+ };
98
+ const getErrorColor = (type)=>{
99
+ switch(type){
100
+ case 'timeout':
101
+ return '#F59E0B';
102
+ case 'network':
103
+ return '#EF4444';
104
+ case 'hook':
105
+ return '#8B5CF6';
106
+ case 'executor':
107
+ return '#6B7280';
108
+ case 'validation':
109
+ return '#F59E0B';
110
+ case 'client':
111
+ return '#EF4444';
112
+ case 'server':
113
+ return '#DC2626';
114
+ default:
115
+ return '#EF4444';
116
+ }
117
+ };
118
+ const errorColor = getErrorColor(errorInfo.type);
119
+ return /*#__PURE__*/ _jsxs("div", {
120
+ style: {
121
+ border: `2px solid ${errorColor}30`,
122
+ borderRadius: '8px',
123
+ backgroundColor: `${errorColor}08`,
124
+ padding: '16px',
125
+ marginTop: '8px'
126
+ },
127
+ children: [
128
+ /*#__PURE__*/ _jsxs("div", {
129
+ style: {
130
+ display: 'flex',
131
+ alignItems: 'center',
132
+ gap: '12px',
133
+ marginBottom: '12px'
134
+ },
135
+ children: [
136
+ /*#__PURE__*/ _jsx("span", {
137
+ style: {
138
+ fontSize: '24px'
139
+ },
140
+ children: getErrorIcon(errorInfo.type)
141
+ }),
142
+ /*#__PURE__*/ _jsxs("div", {
143
+ children: [
144
+ /*#__PURE__*/ _jsx("h4", {
145
+ style: {
146
+ margin: 0,
147
+ color: errorColor,
148
+ fontSize: '16px',
149
+ fontWeight: '600'
150
+ },
151
+ children: errorInfo.title
152
+ }),
153
+ /*#__PURE__*/ _jsx("p", {
154
+ style: {
155
+ margin: '4px 0 0 0',
156
+ color: '#6B7280',
157
+ fontSize: '14px',
158
+ lineHeight: '1.4'
159
+ },
160
+ children: errorInfo.message
161
+ })
162
+ ]
163
+ })
164
+ ]
165
+ }),
166
+ /*#__PURE__*/ _jsxs("div", {
167
+ children: [
168
+ /*#__PURE__*/ _jsx("div", {
169
+ style: {
170
+ marginBottom: expanded ? '12px' : '0'
171
+ },
172
+ children: /*#__PURE__*/ _jsxs(Button, {
173
+ onClick: ()=>setExpanded(!expanded),
174
+ size: "small",
175
+ buttonStyle: "secondary",
176
+ children: [
177
+ expanded ? 'Hide' : 'Show',
178
+ " Technical Details"
179
+ ]
180
+ })
181
+ }),
182
+ expanded && /*#__PURE__*/ _jsx("div", {
183
+ style: {
184
+ backgroundColor: '#F8F9FA',
185
+ border: '1px solid #E5E7EB',
186
+ borderRadius: '6px',
187
+ padding: '12px',
188
+ fontFamily: 'monospace',
189
+ fontSize: '13px',
190
+ color: '#374151',
191
+ whiteSpace: 'pre-wrap',
192
+ overflowX: 'auto'
193
+ },
194
+ children: errorInfo.technical
195
+ })
196
+ ]
197
+ }),
198
+ /*#__PURE__*/ _jsxs("div", {
199
+ style: {
200
+ marginTop: '12px',
201
+ padding: '12px',
202
+ backgroundColor: `${errorColor}10`,
203
+ borderRadius: '6px',
204
+ fontSize: '13px'
205
+ },
206
+ children: [
207
+ /*#__PURE__*/ _jsx("strong", {
208
+ children: "💡 Quick fixes:"
209
+ }),
210
+ /*#__PURE__*/ _jsxs("ul", {
211
+ style: {
212
+ margin: '8px 0 0 0',
213
+ paddingLeft: '20px'
214
+ },
215
+ children: [
216
+ errorInfo.type === 'timeout' && /*#__PURE__*/ _jsxs(_Fragment, {
217
+ children: [
218
+ /*#__PURE__*/ _jsx("li", {
219
+ children: "Increase the timeout value in step configuration"
220
+ }),
221
+ /*#__PURE__*/ _jsx("li", {
222
+ children: "Check if the target server is responding slowly"
223
+ })
224
+ ]
225
+ }),
226
+ errorInfo.type === 'network' && /*#__PURE__*/ _jsxs(_Fragment, {
227
+ children: [
228
+ /*#__PURE__*/ _jsx("li", {
229
+ children: "Verify the URL is correct and accessible"
230
+ }),
231
+ /*#__PURE__*/ _jsx("li", {
232
+ children: "Check firewall and network connectivity"
233
+ })
234
+ ]
235
+ }),
236
+ errorInfo.type === 'hook' && /*#__PURE__*/ _jsxs(_Fragment, {
237
+ children: [
238
+ /*#__PURE__*/ _jsx("li", {
239
+ children: "Restart the PayloadCMS server"
240
+ }),
241
+ /*#__PURE__*/ _jsx("li", {
242
+ children: "Check server logs for initialization errors"
243
+ })
244
+ ]
245
+ }),
246
+ errorInfo.type === 'executor' && /*#__PURE__*/ _jsxs(_Fragment, {
247
+ children: [
248
+ /*#__PURE__*/ _jsx("li", {
249
+ children: "Restart the PayloadCMS application"
250
+ }),
251
+ /*#__PURE__*/ _jsx("li", {
252
+ children: "Verify the automation plugin is properly configured"
253
+ })
254
+ ]
255
+ }),
256
+ errorInfo.type === 'validation' && /*#__PURE__*/ _jsxs(_Fragment, {
257
+ children: [
258
+ /*#__PURE__*/ _jsx("li", {
259
+ children: "Check all required fields are filled in the workflow step"
260
+ }),
261
+ /*#__PURE__*/ _jsx("li", {
262
+ children: "Verify JSONPath expressions in step inputs"
263
+ })
264
+ ]
265
+ }),
266
+ (errorInfo.type === 'client' || errorInfo.type === 'server') && /*#__PURE__*/ _jsxs(_Fragment, {
267
+ children: [
268
+ /*#__PURE__*/ _jsx("li", {
269
+ children: "Check API credentials and permissions"
270
+ }),
271
+ /*#__PURE__*/ _jsx("li", {
272
+ children: "Verify the request format matches API expectations"
273
+ }),
274
+ /*#__PURE__*/ _jsx("li", {
275
+ children: "Try the request manually to test the endpoint"
276
+ })
277
+ ]
278
+ }),
279
+ errorInfo.type === 'generic' && /*#__PURE__*/ _jsxs(_Fragment, {
280
+ children: [
281
+ /*#__PURE__*/ _jsx("li", {
282
+ children: "Check the workflow configuration"
283
+ }),
284
+ /*#__PURE__*/ _jsx("li", {
285
+ children: "Review server logs for more details"
286
+ }),
287
+ /*#__PURE__*/ _jsx("li", {
288
+ children: "Try running the workflow again"
289
+ })
290
+ ]
291
+ })
292
+ ]
293
+ })
294
+ ]
295
+ }),
296
+ !readOnly && onChange && /*#__PURE__*/ _jsx("textarea", {
297
+ value: value,
298
+ onChange: (e)=>onChange(e.target.value),
299
+ style: {
300
+ display: 'none'
301
+ }
302
+ })
303
+ ]
304
+ });
305
+ };
306
+
307
+ //# sourceMappingURL=ErrorDisplay.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/components/ErrorDisplay.tsx"],"sourcesContent":["'use client'\n\nimport React, { useState } from 'react'\nimport { Button } from '@payloadcms/ui'\n\ninterface ErrorDisplayProps {\n value?: string\n onChange?: (value: string) => void\n readOnly?: boolean\n path?: string\n}\n\nexport const ErrorDisplay: React.FC<ErrorDisplayProps> = ({ \n value, \n onChange, \n readOnly = false \n}) => {\n const [expanded, setExpanded] = useState(false)\n\n if (!value) {\n return null\n }\n\n // Parse common error patterns\n const parseError = (error: string) => {\n // Check for different error types and provide user-friendly messages\n if (error.includes('Request timeout')) {\n return {\n type: 'timeout',\n title: 'Request Timeout',\n message: 'The HTTP request took too long to complete. Consider increasing the timeout value or checking the target server.',\n technical: error\n }\n }\n \n if (error.includes('Network error') || error.includes('fetch')) {\n return {\n type: 'network',\n title: 'Network Error',\n message: 'Unable to connect to the target server. Please check the URL and network connectivity.',\n technical: error\n }\n }\n \n if (error.includes('Hook execution failed')) {\n return {\n type: 'hook',\n title: 'Workflow Hook Failed',\n message: 'The workflow trigger hook encountered an error. This may be due to PayloadCMS initialization issues.',\n technical: error\n }\n }\n \n if (error.includes('Executor not available')) {\n return {\n type: 'executor',\n title: 'Workflow Engine Unavailable',\n message: 'The workflow execution engine is not properly initialized. Try restarting the server.',\n technical: error\n }\n }\n \n if (error.includes('Collection slug is required') || error.includes('Document data is required')) {\n return {\n type: 'validation',\n title: 'Invalid Input Data',\n message: 'Required fields are missing from the workflow step configuration. Please check your step inputs.',\n technical: error\n }\n }\n \n if (error.includes('status') && error.includes('4')) {\n return {\n type: 'client',\n title: 'Client Error (4xx)',\n message: 'The request was rejected by the server. Check your API credentials and request format.',\n technical: error\n }\n }\n \n if (error.includes('status') && error.includes('5')) {\n return {\n type: 'server',\n title: 'Server Error (5xx)',\n message: 'The target server encountered an error. This is usually temporary - try again later.',\n technical: error\n }\n }\n\n // Generic error\n return {\n type: 'generic',\n title: 'Workflow Error',\n message: 'An error occurred during workflow execution. See technical details below.',\n technical: error\n }\n }\n\n const errorInfo = parseError(value)\n\n const getErrorIcon = (type: string) => {\n switch (type) {\n case 'timeout': return '⏰'\n case 'network': return '🌐'\n case 'hook': return '🔗'\n case 'executor': return '⚙️'\n case 'validation': return '📋'\n case 'client': return '🚫'\n case 'server': return '🔥'\n default: return '❗'\n }\n }\n\n const getErrorColor = (type: string) => {\n switch (type) {\n case 'timeout': return '#F59E0B'\n case 'network': return '#EF4444'\n case 'hook': return '#8B5CF6'\n case 'executor': return '#6B7280'\n case 'validation': return '#F59E0B'\n case 'client': return '#EF4444'\n case 'server': return '#DC2626'\n default: return '#EF4444'\n }\n }\n\n const errorColor = getErrorColor(errorInfo.type)\n\n return (\n <div style={{ \n border: `2px solid ${errorColor}30`,\n borderRadius: '8px',\n backgroundColor: `${errorColor}08`,\n padding: '16px',\n marginTop: '8px'\n }}>\n {/* Error Header */}\n <div style={{ \n display: 'flex', \n alignItems: 'center', \n gap: '12px',\n marginBottom: '12px'\n }}>\n <span style={{ fontSize: '24px' }}>\n {getErrorIcon(errorInfo.type)}\n </span>\n <div>\n <h4 style={{ \n margin: 0, \n color: errorColor,\n fontSize: '16px',\n fontWeight: '600'\n }}>\n {errorInfo.title}\n </h4>\n <p style={{ \n margin: '4px 0 0 0',\n color: '#6B7280',\n fontSize: '14px',\n lineHeight: '1.4'\n }}>\n {errorInfo.message}\n </p>\n </div>\n </div>\n\n {/* Technical Details Toggle */}\n <div>\n <div style={{ marginBottom: expanded ? '12px' : '0' }}>\n <Button\n onClick={() => setExpanded(!expanded)}\n size=\"small\"\n buttonStyle=\"secondary\"\n >\n {expanded ? 'Hide' : 'Show'} Technical Details\n </Button>\n </div>\n \n {expanded && (\n <div style={{\n backgroundColor: '#F8F9FA',\n border: '1px solid #E5E7EB',\n borderRadius: '6px',\n padding: '12px',\n fontFamily: 'monospace',\n fontSize: '13px',\n color: '#374151',\n whiteSpace: 'pre-wrap',\n overflowX: 'auto'\n }}>\n {errorInfo.technical}\n </div>\n )}\n </div>\n\n {/* Quick Actions */}\n <div style={{ \n marginTop: '12px',\n padding: '12px',\n backgroundColor: `${errorColor}10`,\n borderRadius: '6px',\n fontSize: '13px'\n }}>\n <strong>💡 Quick fixes:</strong>\n <ul style={{ margin: '8px 0 0 0', paddingLeft: '20px' }}>\n {errorInfo.type === 'timeout' && (\n <>\n <li>Increase the timeout value in step configuration</li>\n <li>Check if the target server is responding slowly</li>\n </>\n )}\n {errorInfo.type === 'network' && (\n <>\n <li>Verify the URL is correct and accessible</li>\n <li>Check firewall and network connectivity</li>\n </>\n )}\n {errorInfo.type === 'hook' && (\n <>\n <li>Restart the PayloadCMS server</li>\n <li>Check server logs for initialization errors</li>\n </>\n )}\n {errorInfo.type === 'executor' && (\n <>\n <li>Restart the PayloadCMS application</li>\n <li>Verify the automation plugin is properly configured</li>\n </>\n )}\n {errorInfo.type === 'validation' && (\n <>\n <li>Check all required fields are filled in the workflow step</li>\n <li>Verify JSONPath expressions in step inputs</li>\n </>\n )}\n {(errorInfo.type === 'client' || errorInfo.type === 'server') && (\n <>\n <li>Check API credentials and permissions</li>\n <li>Verify the request format matches API expectations</li>\n <li>Try the request manually to test the endpoint</li>\n </>\n )}\n {errorInfo.type === 'generic' && (\n <>\n <li>Check the workflow configuration</li>\n <li>Review server logs for more details</li>\n <li>Try running the workflow again</li>\n </>\n )}\n </ul>\n </div>\n\n {/* Hidden textarea for editing if needed */}\n {!readOnly && onChange && (\n <textarea\n value={value}\n onChange={(e) => onChange(e.target.value)}\n style={{ display: 'none' }}\n />\n )}\n </div>\n )\n}"],"names":["React","useState","Button","ErrorDisplay","value","onChange","readOnly","expanded","setExpanded","parseError","error","includes","type","title","message","technical","errorInfo","getErrorIcon","getErrorColor","errorColor","div","style","border","borderRadius","backgroundColor","padding","marginTop","display","alignItems","gap","marginBottom","span","fontSize","h4","margin","color","fontWeight","p","lineHeight","onClick","size","buttonStyle","fontFamily","whiteSpace","overflowX","strong","ul","paddingLeft","li","textarea","e","target"],"mappings":"AAAA;;AAEA,OAAOA,SAASC,QAAQ,QAAQ,QAAO;AACvC,SAASC,MAAM,QAAQ,iBAAgB;AASvC,OAAO,MAAMC,eAA4C,CAAC,EACxDC,KAAK,EACLC,QAAQ,EACRC,WAAW,KAAK,EACjB;IACC,MAAM,CAACC,UAAUC,YAAY,GAAGP,SAAS;IAEzC,IAAI,CAACG,OAAO;QACV,OAAO;IACT;IAEA,8BAA8B;IAC9B,MAAMK,aAAa,CAACC;QAClB,qEAAqE;QACrE,IAAIA,MAAMC,QAAQ,CAAC,oBAAoB;YACrC,OAAO;gBACLC,MAAM;gBACNC,OAAO;gBACPC,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UD,SAAS;;;;0BAM1B,MAACK;gBAAIC,OAAO;oBACVK,WAAW;oBACXD,SAAS;oBACTD,iBAAiB,GAAGL,WAAW,EAAE,CAAC;oBAClCI,cAAc;oBACdS,UAAU;gBACZ;;kCACE,KAACa;kCAAO;;kCACR,MAACC;wBAAGzB,OAAO;4BAAEa,QAAQ;4BAAaa,aAAa;wBAAO;;4BACnD/B,UAAUJ,IAAI,KAAK,2BAClB;;kDACE,KAACoC;kDAAG;;kDACJ,KAACA;kDAAG;;;;4BAGPhC,UAAUJ,IAAI,KAAK,2BAClB;;kDACE,KAACoC;kDAAG;;kDACJ,KAACA;kDAAG;;;;4BAGPhC,UAAUJ,IAAI,KAAK,wBAClB;;kDACE,KAACoC;kDAAG;;kDACJ,KAACA;kDAAG;;;;4BAGPhC,UAAUJ,IAAI,KAAK,4BAClB;;kDACE,KAACoC;kDAAG;;kDACJ,KAACA;kDAAG;;;;4BAGPhC,UAAUJ,IAAI,KAAK,8BAClB;;kDACE,KAACoC;kDAAG;;kDACJ,KAACA;kDAAG;;;;4BAGNhC,CAAAA,UAAUJ,IAAI,KAAK,YAAYI,UAAUJ,IAAI,KAAK,QAAO,mBACzD;;kDACE,KAACoC;kDAAG;;kDACJ,KAACA;kDAAG;;kDACJ,KAACA;kDAAG;;;;4BAGPhC,UAAUJ,IAAI,KAAK,2BAClB;;kDACE,KAACoC;kDAAG;;kDACJ,KAACA;kDAAG;;kDACJ,KAACA;kDAAG;;;;;;;;YAOX,CAAC1C,YAAYD,0BACZ,KAAC4C;gBACC7C,OAAOA;gBACPC,UAAU,CAAC6C,IAAM7C,SAAS6C,EAAEC,MAAM,CAAC/C,KAAK;gBACxCiB,OAAO;oBAAEM,SAAS;gBAAO;;;;AAKnC,EAAC"}
@@ -1,3 +1,4 @@
1
1
  export { TriggerWorkflowButton } from '../components/TriggerWorkflowButton.js';
2
2
  export { StatusCell } from '../components/StatusCell.js';
3
+ export { ErrorDisplay } from '../components/ErrorDisplay.js';
3
4
  export { WorkflowExecutionStatus } from '../components/WorkflowExecutionStatus.js';
@@ -2,7 +2,7 @@
2
2
  // These are separated to avoid CSS import errors during Node.js type generation
3
3
  export { TriggerWorkflowButton } from '../components/TriggerWorkflowButton.js';
4
4
  export { StatusCell } from '../components/StatusCell.js';
5
- // export { ErrorDisplay } from '../components/ErrorDisplay.js' // Temporarily disabled
5
+ export { ErrorDisplay } from '../components/ErrorDisplay.js';
6
6
  export { WorkflowExecutionStatus } from '../components/WorkflowExecutionStatus.js'; // Future client components can be added here:
7
7
  // export { default as WorkflowDashboard } from '../components/WorkflowDashboard/index.js'
8
8
  // export { default as WorkflowBuilder } from '../components/WorkflowBuilder/index.js'
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/exports/client.ts"],"sourcesContent":["// Client-side components that may have CSS imports or PayloadCMS UI dependencies\n// These are separated to avoid CSS import errors during Node.js type generation\n\nexport { TriggerWorkflowButton } from '../components/TriggerWorkflowButton.js'\nexport { StatusCell } from '../components/StatusCell.js'\n// export { ErrorDisplay } from '../components/ErrorDisplay.js' // Temporarily disabled\nexport { WorkflowExecutionStatus } from '../components/WorkflowExecutionStatus.js'\n\n// Future client components can be added here:\n// export { default as WorkflowDashboard } from '../components/WorkflowDashboard/index.js'\n// export { default as WorkflowBuilder } from '../components/WorkflowBuilder/index.js'\n"],"names":["TriggerWorkflowButton","StatusCell","WorkflowExecutionStatus"],"mappings":"AAAA,iFAAiF;AACjF,gFAAgF;AAEhF,SAASA,qBAAqB,QAAQ,yCAAwC;AAC9E,SAASC,UAAU,QAAQ,8BAA6B;AACxD,uFAAuF;AACvF,SAASC,uBAAuB,QAAQ,2CAA0C,CAElF,8CAA8C;CAC9C,0FAA0F;CAC1F,sFAAsF"}
1
+ {"version":3,"sources":["../../src/exports/client.ts"],"sourcesContent":["// Client-side components that may have CSS imports or PayloadCMS UI dependencies\n// These are separated to avoid CSS import errors during Node.js type generation\n\nexport { TriggerWorkflowButton } from '../components/TriggerWorkflowButton.js'\nexport { StatusCell } from '../components/StatusCell.js'\nexport { ErrorDisplay } from '../components/ErrorDisplay.js'\nexport { WorkflowExecutionStatus } from '../components/WorkflowExecutionStatus.js'\n\n// Future client components can be added here:\n// export { default as WorkflowDashboard } from '../components/WorkflowDashboard/index.js'\n// export { default as WorkflowBuilder } from '../components/WorkflowBuilder/index.js'\n"],"names":["TriggerWorkflowButton","StatusCell","ErrorDisplay","WorkflowExecutionStatus"],"mappings":"AAAA,iFAAiF;AACjF,gFAAgF;AAEhF,SAASA,qBAAqB,QAAQ,yCAAwC;AAC9E,SAASC,UAAU,QAAQ,8BAA6B;AACxD,SAASC,YAAY,QAAQ,gCAA+B;AAC5D,SAASC,uBAAuB,QAAQ,2CAA0C,CAElF,8CAA8C;CAC9C,0FAA0F;CAC1F,sFAAsF"}
@@ -1,5 +1,9 @@
1
1
  import type { Field } from 'payload';
2
2
  import type { CustomTriggerConfig } from '../plugin/config-types.js';
3
+ interface FieldWithName {
4
+ name: string;
5
+ [key: string]: unknown;
6
+ }
3
7
  /**
4
8
  * Creates a virtual field for a trigger parameter that stores its value in the parameters JSON field
5
9
  *
@@ -24,7 +28,7 @@ import type { CustomTriggerConfig } from '../plugin/config-types.js';
24
28
  * }
25
29
  * ```
26
30
  */
27
- export declare function createTriggerField(field: any, triggerSlug: string): Field;
31
+ export declare function createTriggerField(field: FieldWithName, triggerSlug: string): Field;
28
32
  /**
29
33
  * Creates a custom trigger configuration with the provided fields
30
34
  *
@@ -52,4 +56,5 @@ export declare function createTriggerField(field: any, triggerSlug: string): Fie
52
56
  * ])
53
57
  * ```
54
58
  */
55
- export declare function createTrigger(slug: string, fields: Field[]): CustomTriggerConfig;
59
+ export declare function createTrigger(slug: string, fields: FieldWithName[]): CustomTriggerConfig;
60
+ export {};
@@ -30,16 +30,15 @@
30
30
  const uniqueFieldName = `__trigger_${triggerSlug}_${originalName}`;
31
31
  const resultField = {
32
32
  ...field,
33
- name: uniqueFieldName,
34
- virtual: true,
35
33
  admin: {
36
34
  ...field.admin || {},
37
35
  condition: (data, siblingData)=>{
38
36
  // Only show this field when the trigger type matches
39
37
  const triggerMatches = siblingData?.type === triggerSlug;
40
38
  // If the original field had a condition, combine it with our trigger condition
41
- if (field.admin?.condition) {
42
- return triggerMatches && field.admin.condition(data, siblingData);
39
+ const originalCondition = field.admin?.condition;
40
+ if (originalCondition && typeof originalCondition === 'function') {
41
+ return triggerMatches && originalCondition(data, siblingData);
43
42
  }
44
43
  return triggerMatches;
45
44
  }
@@ -50,35 +49,45 @@
50
49
  ...field.hooks?.afterRead || [],
51
50
  ({ siblingData })=>{
52
51
  // Read the value from the parameters JSON field
53
- return siblingData?.parameters?.[originalName] ?? field.defaultValue;
52
+ const parameters = siblingData?.parameters;
53
+ return parameters?.[originalName] ?? field.defaultValue;
54
54
  }
55
55
  ],
56
56
  beforeChange: [
57
57
  ...field.hooks?.beforeChange || [],
58
- ({ value, siblingData })=>{
58
+ ({ siblingData, value })=>{
59
59
  // Store the value in the parameters JSON field
60
60
  if (!siblingData.parameters) {
61
61
  siblingData.parameters = {};
62
62
  }
63
- siblingData.parameters[originalName] = value;
63
+ const parameters = siblingData.parameters;
64
+ parameters[originalName] = value;
64
65
  return undefined // Virtual field, don't store directly
65
66
  ;
66
67
  }
67
68
  ]
68
- }
69
+ },
70
+ name: uniqueFieldName,
71
+ virtual: true
69
72
  };
70
73
  // Only add validate if the field supports it (data fields)
71
- if (field.validate || field.required) {
74
+ const hasValidation = field.validate || field.required;
75
+ if (hasValidation) {
72
76
  resultField.validate = (value, args)=>{
73
- const paramValue = value ?? args.siblingData?.parameters?.[originalName];
77
+ const parameters = args.siblingData?.parameters;
78
+ const paramValue = value ?? parameters?.[originalName];
74
79
  // Check required validation
75
- if (field.required && args.siblingData?.type === triggerSlug && !paramValue) {
76
- const label = field.label || field.admin?.description || originalName;
80
+ const isRequired = field.required;
81
+ if (isRequired && args.siblingData?.type === triggerSlug && !paramValue) {
82
+ const fieldLabel = field.label;
83
+ const adminDesc = field.admin?.description;
84
+ const label = fieldLabel || adminDesc || originalName;
77
85
  return `${label} is required for ${triggerSlug}`;
78
86
  }
79
87
  // Run original validation if present
80
- if (field.validate) {
81
- return field.validate(paramValue, args);
88
+ const originalValidate = field.validate;
89
+ if (originalValidate && typeof originalValidate === 'function') {
90
+ return originalValidate(paramValue, args);
82
91
  }
83
92
  return true;
84
93
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/trigger-helpers.ts"],"sourcesContent":["import type { Field } from 'payload'\nimport type { CustomTriggerConfig } from '../plugin/config-types.js'\n\n/**\n * Creates a virtual field for a trigger parameter that stores its value in the parameters JSON field\n * \n * @param field - Standard PayloadCMS field configuration (must be a data field with a name)\n * @param triggerSlug - The slug of the trigger this field belongs to\n * @returns Modified field with virtual storage hooks and proper naming\n * \n * @example\n * ```typescript\n * const myTrigger: CustomTriggerConfig = {\n * slug: 'my-trigger',\n * inputs: [\n * createTriggerField({\n * name: 'webhookUrl',\n * type: 'text',\n * required: true,\n * admin: {\n * description: 'URL to call when triggered'\n * }\n * }, 'my-trigger')\n * ]\n * }\n * ```\n */\nexport function createTriggerField(field: any, triggerSlug: string): Field {\n const originalName = field.name\n if (!originalName) {\n throw new Error('Field must have a name property')\n }\n\n // Create a unique field name by prefixing with trigger slug\n const uniqueFieldName = `__trigger_${triggerSlug}_${originalName}`\n \n const resultField: any = {\n ...field,\n name: uniqueFieldName,\n virtual: true,\n admin: {\n ...(field.admin || {}),\n condition: (data: any, siblingData: any) => {\n // Only show this field when the trigger type matches\n const triggerMatches = siblingData?.type === triggerSlug\n \n // If the original field had a condition, combine it with our trigger condition\n if (field.admin?.condition) {\n return triggerMatches && field.admin.condition(data, siblingData)\n }\n \n return triggerMatches\n }\n },\n hooks: {\n ...(field.hooks || {}),\n afterRead: [\n ...(field.hooks?.afterRead || []),\n ({ siblingData }: any) => {\n // Read the value from the parameters JSON field\n return siblingData?.parameters?.[originalName] ?? field.defaultValue\n }\n ],\n beforeChange: [\n ...(field.hooks?.beforeChange || []),\n ({ value, siblingData }: any) => {\n // Store the value in the parameters JSON field\n if (!siblingData.parameters) {\n siblingData.parameters = {}\n }\n siblingData.parameters[originalName] = value\n return undefined // Virtual field, don't store directly\n }\n ]\n }\n }\n\n // Only add validate if the field supports it (data fields)\n if (field.validate || field.required) {\n resultField.validate = (value: any, args: any) => {\n const paramValue = value ?? args.siblingData?.parameters?.[originalName]\n \n // Check required validation\n if (field.required && args.siblingData?.type === triggerSlug && !paramValue) {\n const label = field.label || field.admin?.description || originalName\n return `${label} is required for ${triggerSlug}`\n }\n \n // Run original validation if present\n if (field.validate) {\n return field.validate(paramValue, args)\n }\n \n return true\n }\n }\n\n return resultField as Field\n}\n\n/**\n * Creates a custom trigger configuration with the provided fields\n * \n * @param slug - Unique identifier for the trigger\n * @param fields - Array of PayloadCMS fields that will be shown as trigger parameters\n * @returns Complete trigger configuration\n * \n * @example\n * ```typescript\n * const webhookTrigger = createTrigger('webhook', [\n * {\n * name: 'url',\n * type: 'text',\n * required: true,\n * admin: {\n * description: 'Webhook URL'\n * }\n * },\n * {\n * name: 'method',\n * type: 'select',\n * options: ['GET', 'POST', 'PUT', 'DELETE'],\n * defaultValue: 'POST'\n * }\n * ])\n * ```\n */\nexport function createTrigger(slug: string, fields: Field[]): CustomTriggerConfig {\n return {\n slug,\n inputs: fields.map(field => createTriggerField(field, slug))\n }\n}"],"names":["createTriggerField","field","triggerSlug","originalName","name","Error","uniqueFieldName","resultField","virtual","admin","condition","data","siblingData","triggerMatches","type","hooks","afterRead","parameters","defaultValue","beforeChange","value","undefined","validate","required","args","paramValue","label","description","createTrigger","slug","fields","inputs","map"],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;;;;;CAuBC,GACD,OAAO,SAASA,mBAAmBC,KAAU,EAAEC,WAAmB;IAChE,MAAMC,eAAeF,MAAMG,IAAI;IAC/B,IAAI,CAACD,cAAc;QACjB,MAAM,IAAIE,MAAM;IAClB;IAEA,4DAA4D;IAC5D,MAAMC,kBAAkB,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MAAMyB,KAAK,IAAIzB,MAAMQ,KAAK,EAAEkB,eAAexB;gBACzD,OAAO,GAAGuB,MAAM,iBAAiB,EAAExB,aAAa;YAClD;YAEA,qCAAqC;YACrC,IAAID,MAAMqB,QAAQ,EAAE;gBAClB,OAAOrB,MAAMqB,QAAQ,CAACG,YAAYD;YACpC;YAEA,OAAO;QACT;IACF;IAEA,OAAOjB;AACT;AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;CA0BC,GACD,OAAO,SAASqB,cAAcC,IAAY,EAAEC,MAAe;IACzD,OAAO;QACLD;QACAE,QAAQD,OAAOE,GAAG,CAAC/B,CAAAA,QAASD,mBAAmBC,OAAO4B;IACxD;AACF"}
1
+ {"version":3,"sources":["../../src/utils/trigger-helpers.ts"],"sourcesContent":["import type { Field } from 'payload'\n\nimport type { CustomTriggerConfig } from '../plugin/config-types.js'\n\n// Types for better type safety\ninterface FieldWithName {\n name: string\n [key: string]: unknown\n}\n\ninterface HookContext {\n siblingData: Record<string, unknown>\n value?: unknown\n}\n\ninterface ValidationContext {\n siblingData: Record<string, unknown>\n}\n\n/**\n * Creates a virtual field for a trigger parameter that stores its value in the parameters JSON field\n * \n * @param field - Standard PayloadCMS field configuration (must be a data field with a name)\n * @param triggerSlug - The slug of the trigger this field belongs to\n * @returns Modified field with virtual storage hooks and proper naming\n * \n * @example\n * ```typescript\n * const myTrigger: CustomTriggerConfig = {\n * slug: 'my-trigger',\n * inputs: [\n * createTriggerField({\n * name: 'webhookUrl',\n * type: 'text',\n * required: true,\n * admin: {\n * description: 'URL to call when triggered'\n * }\n * }, 'my-trigger')\n * ]\n * }\n * ```\n */\nexport function createTriggerField(field: FieldWithName, triggerSlug: string): Field {\n const originalName = field.name\n if (!originalName) {\n throw new Error('Field must have a name property')\n }\n\n // Create a unique field name by prefixing with trigger slug\n const uniqueFieldName = `__trigger_${triggerSlug}_${originalName}`\n \n const resultField: Record<string, unknown> = {\n ...field,\n admin: {\n ...(field.admin as Record<string, unknown> || {}),\n condition: (data: unknown, siblingData: Record<string, unknown>) => {\n // Only show this field when the trigger type matches\n const triggerMatches = siblingData?.type === triggerSlug\n \n // If the original field had a condition, combine it with our trigger condition\n const originalCondition = (field.admin as Record<string, unknown>)?.condition\n if (originalCondition && typeof originalCondition === 'function') {\n return triggerMatches && (originalCondition as (data: unknown, siblingData: Record<string, unknown>) => boolean)(data, siblingData)\n }\n \n return triggerMatches\n }\n },\n hooks: {\n ...(field.hooks as Record<string, unknown[]> || {}),\n afterRead: [\n ...((field.hooks as Record<string, unknown[]>)?.afterRead || []),\n ({ siblingData }: HookContext) => {\n // Read the value from the parameters JSON field\n const parameters = siblingData?.parameters as Record<string, unknown>\n return parameters?.[originalName] ?? (field as Record<string, unknown>).defaultValue\n }\n ],\n beforeChange: [\n ...((field.hooks as Record<string, unknown[]>)?.beforeChange || []),\n ({ siblingData, value }: HookContext) => {\n // Store the value in the parameters JSON field\n if (!siblingData.parameters) {\n siblingData.parameters = {}\n }\n const parameters = siblingData.parameters as Record<string, unknown>\n parameters[originalName] = value\n return undefined // Virtual field, don't store directly\n }\n ]\n },\n name: uniqueFieldName,\n virtual: true,\n }\n\n // Only add validate if the field supports it (data fields)\n const hasValidation = (field as Record<string, unknown>).validate || (field as Record<string, unknown>).required\n if (hasValidation) {\n resultField.validate = (value: unknown, args: ValidationContext) => {\n const parameters = args.siblingData?.parameters as Record<string, unknown>\n const paramValue = value ?? parameters?.[originalName]\n \n // Check required validation\n const isRequired = (field as Record<string, unknown>).required\n if (isRequired && args.siblingData?.type === triggerSlug && !paramValue) {\n const fieldLabel = (field as Record<string, unknown>).label as string\n const adminDesc = ((field as Record<string, unknown>).admin as Record<string, unknown>)?.description as string\n const label = fieldLabel || adminDesc || originalName\n return `${label} is required for ${triggerSlug}`\n }\n \n // Run original validation if present\n const originalValidate = (field as Record<string, unknown>).validate\n if (originalValidate && typeof originalValidate === 'function') {\n return (originalValidate as (value: unknown, args: ValidationContext) => boolean | string)(paramValue, args)\n }\n \n return true\n }\n }\n\n return resultField as Field\n}\n\n/**\n * Creates a custom trigger configuration with the provided fields\n * \n * @param slug - Unique identifier for the trigger\n * @param fields - Array of PayloadCMS fields that will be shown as trigger parameters\n * @returns Complete trigger configuration\n * \n * @example\n * ```typescript\n * const webhookTrigger = createTrigger('webhook', [\n * {\n * name: 'url',\n * type: 'text',\n * required: true,\n * admin: {\n * description: 'Webhook URL'\n * }\n * },\n * {\n * name: 'method',\n * type: 'select',\n * options: ['GET', 'POST', 'PUT', 'DELETE'],\n * defaultValue: 'POST'\n * }\n * ])\n * ```\n */\nexport function createTrigger(slug: string, fields: FieldWithName[]): CustomTriggerConfig {\n return {\n slug,\n inputs: fields.map(field => createTriggerField(field, slug))\n }\n}"],"names":["createTriggerField","field","triggerSlug","originalName","name","Error","uniqueFieldName","resultField","admin","condition","data","siblingData","triggerMatches","type","originalCondition","hooks","afterRead","parameters","defaultValue","beforeChange","value","undefined","virtual","hasValidation","validate","required","args","paramValue","isRequired","fieldLabel","label","adminDesc","description","originalValidate","createTrigger","slug","fields","inputs","map"],"mappings":"AAmBA;;;;;;;;;;;;;;;;;;;;;;;CAuBC,GACD,OAAO,SAASA,mBAAmBC,KAAoB,EAAEC,WAAmB;IAC1E,MAAMC,eAAeF,MAAMG,IAAI;IAC/B,IAAI,CAACD,cAAc;QACjB,MAAM,IAAIE,MAAM;IAClB;IAEA,4DAA4D;IAC5D,MAAMC,kBAAkB,CAAC,UAAU,EAAEJ,YAAY,CAAC,EAAEC,cAAc;IAElE,MAAMI,cAAuC;QAC3C,GAAGN,KAAK;QACRO,OAAO;YACL,GAAIP,MAAMO,KAAK,IAA+B,CAAC,CAAC;YAChDC,WAAW,CAACC,MAAeC;gBACzB,qDAAqD;gBACrD,MAAMC,iBAAiBD,aAAaE,SAASX;gBAE7C,+EAA+E;gBAC/E,MAAMY,oBAAqBb,MAAMO,KAAK,EAA8BC;gBACpE,IAAIK,qBAAqB,OAAOA,sBAAsB,YAAY;oBAChE,OAAOF,kBA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a;YAClD;YAEA,qCAAqC;YACrC,MAAM+B,mBAAmB,AAAChC,MAAkCuB,QAAQ;YACpE,IAAIS,oBAAoB,OAAOA,qBAAqB,YAAY;gBAC9D,OAAO,AAACA,iBAAmFN,YAAYD;YACzG;YAEA,OAAO;QACT;IACF;IAEA,OAAOnB;AACT;AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;CA0BC,GACD,OAAO,SAAS2B,cAAcC,IAAY,EAAEC,MAAuB;IACjE,OAAO;QACLD;QACAE,QAAQD,OAAOE,GAAG,CAACrC,CAAAA,QAASD,mBAAmBC,OAAOkC;IACxD;AACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xtr-dev/payload-automation",
3
- "version": "0.0.28",
3
+ "version": "0.0.30",
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",