@xtr-dev/payload-automation 0.0.23 → 0.0.25

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.
@@ -57,78 +57,198 @@ export const createWorkflowCollection = ({ collectionTriggers, steps, triggers }
57
57
  ]
58
58
  },
59
59
  {
60
- name: 'collectionSlug',
60
+ name: 'parameters',
61
+ type: 'json',
62
+ admin: {
63
+ hidden: true
64
+ },
65
+ defaultValue: {}
66
+ },
67
+ // Virtual fields for collection trigger
68
+ {
69
+ name: '__builtin_collectionSlug',
61
70
  type: 'select',
62
71
  admin: {
63
72
  condition: (_, siblingData)=>siblingData?.type === 'collection-trigger',
64
73
  description: 'Collection that triggers the workflow'
65
74
  },
66
- options: Object.keys(collectionTriggers || {})
75
+ hooks: {
76
+ afterRead: [
77
+ ({ siblingData })=>{
78
+ return siblingData?.parameters?.collectionSlug || undefined;
79
+ }
80
+ ],
81
+ beforeChange: [
82
+ ({ siblingData, value })=>{
83
+ if (!siblingData.parameters) {
84
+ siblingData.parameters = {};
85
+ }
86
+ siblingData.parameters.collectionSlug = value;
87
+ return undefined // Virtual field, don't store directly
88
+ ;
89
+ }
90
+ ]
91
+ },
92
+ options: Object.keys(collectionTriggers || {}),
93
+ virtual: true
67
94
  },
68
95
  {
69
- name: 'operation',
96
+ name: '__builtin_operation',
70
97
  type: 'select',
71
98
  admin: {
72
99
  condition: (_, siblingData)=>siblingData?.type === 'collection-trigger',
73
100
  description: 'Collection operation that triggers the workflow'
74
101
  },
102
+ hooks: {
103
+ afterRead: [
104
+ ({ siblingData })=>{
105
+ return siblingData?.parameters?.operation || undefined;
106
+ }
107
+ ],
108
+ beforeChange: [
109
+ ({ siblingData, value })=>{
110
+ if (!siblingData.parameters) {
111
+ siblingData.parameters = {};
112
+ }
113
+ siblingData.parameters.operation = value;
114
+ return undefined // Virtual field, don't store directly
115
+ ;
116
+ }
117
+ ]
118
+ },
75
119
  options: [
76
120
  'create',
77
121
  'delete',
78
122
  'read',
79
123
  'update'
80
- ]
124
+ ],
125
+ virtual: true
81
126
  },
127
+ // Virtual fields for webhook trigger
82
128
  {
83
- name: 'webhookPath',
129
+ name: '__builtin_webhookPath',
84
130
  type: 'text',
85
131
  admin: {
86
132
  condition: (_, siblingData)=>siblingData?.type === 'webhook-trigger',
87
133
  description: 'URL path for the webhook (e.g., "my-webhook"). Full URL will be /api/workflows-webhook/my-webhook'
88
134
  },
135
+ hooks: {
136
+ afterRead: [
137
+ ({ siblingData })=>{
138
+ return siblingData?.parameters?.webhookPath || undefined;
139
+ }
140
+ ],
141
+ beforeChange: [
142
+ ({ siblingData, value })=>{
143
+ if (!siblingData.parameters) {
144
+ siblingData.parameters = {};
145
+ }
146
+ siblingData.parameters.webhookPath = value;
147
+ return undefined // Virtual field, don't store directly
148
+ ;
149
+ }
150
+ ]
151
+ },
89
152
  validate: (value, { siblingData })=>{
90
- if (siblingData?.type === 'webhook-trigger' && !value) {
153
+ if (siblingData?.type === 'webhook-trigger' && !value && !siblingData?.parameters?.webhookPath) {
91
154
  return 'Webhook path is required for webhook triggers';
92
155
  }
93
156
  return true;
94
- }
157
+ },
158
+ virtual: true
95
159
  },
160
+ // Virtual fields for global trigger
96
161
  {
97
- name: 'global',
162
+ name: '__builtin_global',
98
163
  type: 'select',
99
164
  admin: {
100
165
  condition: (_, siblingData)=>siblingData?.type === 'global-trigger',
101
166
  description: 'Global that triggers the workflow'
102
167
  },
103
- options: [] // Will be populated dynamically based on available globals
168
+ hooks: {
169
+ afterRead: [
170
+ ({ siblingData })=>{
171
+ return siblingData?.parameters?.global || undefined;
172
+ }
173
+ ],
174
+ beforeChange: [
175
+ ({ siblingData, value })=>{
176
+ if (!siblingData.parameters) {
177
+ siblingData.parameters = {};
178
+ }
179
+ siblingData.parameters.global = value;
180
+ return undefined // Virtual field, don't store directly
181
+ ;
182
+ }
183
+ ]
184
+ },
185
+ options: [],
186
+ virtual: true
104
187
  },
105
188
  {
106
- name: 'globalOperation',
189
+ name: '__builtin_globalOperation',
107
190
  type: 'select',
108
191
  admin: {
109
192
  condition: (_, siblingData)=>siblingData?.type === 'global-trigger',
110
193
  description: 'Global operation that triggers the workflow'
111
194
  },
195
+ hooks: {
196
+ afterRead: [
197
+ ({ siblingData })=>{
198
+ return siblingData?.parameters?.globalOperation || undefined;
199
+ }
200
+ ],
201
+ beforeChange: [
202
+ ({ siblingData, value })=>{
203
+ if (!siblingData.parameters) {
204
+ siblingData.parameters = {};
205
+ }
206
+ siblingData.parameters.globalOperation = value;
207
+ return undefined // Virtual field, don't store directly
208
+ ;
209
+ }
210
+ ]
211
+ },
112
212
  options: [
113
213
  'update'
114
- ]
214
+ ],
215
+ virtual: true
115
216
  },
217
+ // Virtual fields for cron trigger
116
218
  {
117
- name: 'cronExpression',
219
+ name: '__builtin_cronExpression',
118
220
  type: 'text',
119
221
  admin: {
120
222
  condition: (_, siblingData)=>siblingData?.type === 'cron-trigger',
121
223
  description: 'Cron expression for scheduled execution (e.g., "0 0 * * *" for daily at midnight)',
122
224
  placeholder: '0 0 * * *'
123
225
  },
226
+ hooks: {
227
+ afterRead: [
228
+ ({ siblingData })=>{
229
+ return siblingData?.parameters?.cronExpression || undefined;
230
+ }
231
+ ],
232
+ beforeChange: [
233
+ ({ siblingData, value })=>{
234
+ if (!siblingData.parameters) {
235
+ siblingData.parameters = {};
236
+ }
237
+ siblingData.parameters.cronExpression = value;
238
+ return undefined // Virtual field, don't store directly
239
+ ;
240
+ }
241
+ ]
242
+ },
124
243
  validate: (value, { siblingData })=>{
125
- if (siblingData?.type === 'cron-trigger' && !value) {
244
+ const cronValue = value || siblingData?.parameters?.cronExpression;
245
+ if (siblingData?.type === 'cron-trigger' && !cronValue) {
126
246
  return 'Cron expression is required for cron triggers';
127
247
  }
128
248
  // Validate cron expression format if provided
129
- if (siblingData?.type === 'cron-trigger' && value) {
249
+ if (siblingData?.type === 'cron-trigger' && cronValue) {
130
250
  // Basic format validation - should be 5 parts separated by spaces
131
- const cronParts = value.trim().split(/\s+/);
251
+ const cronParts = cronValue.trim().split(/\s+/);
132
252
  if (cronParts.length !== 5) {
133
253
  return 'Invalid cron expression format. Expected 5 parts: "minute hour day month weekday" (e.g., "0 9 * * 1")';
134
254
  }
@@ -136,10 +256,11 @@ export const createWorkflowCollection = ({ collectionTriggers, steps, triggers }
136
256
  // The main validation happens at runtime in the cron scheduler
137
257
  }
138
258
  return true;
139
- }
259
+ },
260
+ virtual: true
140
261
  },
141
262
  {
142
- name: 'timezone',
263
+ name: '__builtin_timezone',
143
264
  type: 'text',
144
265
  admin: {
145
266
  condition: (_, siblingData)=>siblingData?.type === 'cron-trigger',
@@ -147,20 +268,39 @@ export const createWorkflowCollection = ({ collectionTriggers, steps, triggers }
147
268
  placeholder: 'UTC'
148
269
  },
149
270
  defaultValue: 'UTC',
271
+ hooks: {
272
+ afterRead: [
273
+ ({ siblingData })=>{
274
+ return siblingData?.parameters?.timezone || 'UTC';
275
+ }
276
+ ],
277
+ beforeChange: [
278
+ ({ siblingData, value })=>{
279
+ if (!siblingData.parameters) {
280
+ siblingData.parameters = {};
281
+ }
282
+ siblingData.parameters.timezone = value || 'UTC';
283
+ return undefined // Virtual field, don't store directly
284
+ ;
285
+ }
286
+ ]
287
+ },
150
288
  validate: (value, { siblingData })=>{
151
- if (siblingData?.type === 'cron-trigger' && value) {
289
+ const tzValue = value || siblingData?.parameters?.timezone;
290
+ if (siblingData?.type === 'cron-trigger' && tzValue) {
152
291
  try {
153
292
  // Test if timezone is valid by trying to create a date with it
154
293
  new Intl.DateTimeFormat('en', {
155
- timeZone: value
294
+ timeZone: tzValue
156
295
  });
157
296
  return true;
158
297
  } catch {
159
- return `Invalid timezone: ${value}. Please use a valid IANA timezone identifier (e.g., "America/New_York", "Europe/London")`;
298
+ return `Invalid timezone: ${tzValue}. Please use a valid IANA timezone identifier (e.g., "America/New_York", "Europe/London")`;
160
299
  }
161
300
  }
162
301
  return true;
163
- }
302
+ },
303
+ virtual: true
164
304
  },
165
305
  {
166
306
  name: 'condition',
@@ -170,12 +310,31 @@ export const createWorkflowCollection = ({ collectionTriggers, steps, triggers }
170
310
  },
171
311
  required: false
172
312
  },
173
- ...(triggers || []).flatMap((t)=>(t.inputs || []).map((f)=>({
313
+ // Virtual fields for custom triggers
314
+ ...(triggers || []).flatMap((t)=>(t.inputs || []).filter((f)=>'name' in f && f.name).map((f)=>({
174
315
  ...f,
175
316
  admin: {
176
317
  ...f.admin || {},
177
318
  condition: (...args)=>args[1]?.type === t.slug && (f.admin?.condition ? f.admin.condition.call(this, ...args) : true)
178
- }
319
+ },
320
+ hooks: {
321
+ afterRead: [
322
+ ({ siblingData })=>{
323
+ return siblingData?.parameters?.[f.name] || undefined;
324
+ }
325
+ ],
326
+ beforeChange: [
327
+ ({ siblingData, value })=>{
328
+ if (!siblingData.parameters) {
329
+ siblingData.parameters = {};
330
+ }
331
+ siblingData.parameters[f.name] = value;
332
+ return undefined // Virtual field, don't store directly
333
+ ;
334
+ }
335
+ ]
336
+ },
337
+ virtual: true
179
338
  })))
180
339
  ]
181
340
  },
@@ -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: 'collectionSlug',\n type: 'select',\n admin: {\n condition: (_, siblingData) => siblingData?.type === 'collection-trigger',\n description: 'Collection that triggers the workflow',\n },\n options: Object.keys(collectionTriggers || {})\n },\n {\n name: 'operation',\n type: 'select',\n admin: {\n condition: (_, siblingData) => siblingData?.type === 'collection-trigger',\n description: 'Collection operation that triggers the workflow',\n },\n options: [\n 'create',\n 'delete',\n 'read',\n 'update',\n ]\n },\n {\n name: '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 validate: (value: any, {siblingData}: any) => {\n if (siblingData?.type === 'webhook-trigger' && !value) {\n return 'Webhook path is required for webhook triggers'\n }\n return true\n }\n },\n {\n name: 'global',\n type: 'select',\n admin: {\n condition: (_, siblingData) => siblingData?.type === 'global-trigger',\n description: 'Global that triggers the workflow',\n },\n options: [] // Will be populated dynamically based on available globals\n },\n {\n name: 'globalOperation',\n type: 'select',\n admin: {\n condition: (_, siblingData) => siblingData?.type === 'global-trigger',\n description: 'Global operation that triggers the workflow',\n },\n options: [\n 'update'\n ]\n },\n {\n name: '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 validate: (value: any, {siblingData}: any) => {\n if (siblingData?.type === 'cron-trigger' && !value) {\n return 'Cron expression is required for cron triggers'\n }\n\n // Validate cron expression format if provided\n if (siblingData?.type === 'cron-trigger' && value) {\n // Basic format validation - should be 5 parts separated by spaces\n const cronParts = value.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 },\n {\n name: '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 validate: (value: any, {siblingData}: any) => {\n if (siblingData?.type === 'cron-trigger' && value) {\n try {\n // Test if timezone is valid by trying to create a date with it\n new Intl.DateTimeFormat('en', {timeZone: value})\n return true\n } catch {\n return `Invalid timezone: ${value}. Please use a valid IANA timezone identifier (e.g., \"America/New_York\", \"Europe/London\")`\n }\n }\n return true\n }\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 ...(triggers || []).flatMap(t => (t.inputs || []).map(f => ({\n ...f,\n admin: {\n ...(f.admin || {}),\n condition: (...args) => args[1]?.type === t.slug && (\n f.admin?.condition ?\n f.admin.condition.call(this, ...args) :\n true\n ),\n },\n } as Field)))\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","_","siblingData","Object","keys","validate","value","placeholder","cronParts","trim","split","length","defaultValue","Intl","DateTimeFormat","timeZone","flatMap","inputs","f","args","call","step","inputSchema","field","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,MAAM;wBACNO,SAAS;4BACP;4BACA;4BACA;4BACA;+BACG,AAACrB,CAAAA,YAAY,EAAE,AAAD,EAAGsB,GAAG,CAACC,CAAAA,IAAKA,EAA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AAM;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,EAAGwC,OAAO,CAACK,CAAAA,OAAQ,AAACA,CAAAA,KAAKC,WAAW,IAAI,EAAE,AAAD,EAAGvB,GAAG,CAACwB,CAAAA,QAAU,CAAA;gCACtE,GAAGA,KAAK;gCACRvC,OAAO;oCACL,GAAIuC,MAAMvC,KAAK,IAAI,CAAC,CAAC;oCACrBW,WAAW,CAAC,GAAGwB,OAASA,IAAI,CAAC,EAAE,EAAEE,SAASA,KAAK3C,IAAI,IACjD6C,CAAAA,MAAMvC,KAAK,EAAEW,YACX4B,MAAMvC,KAAK,CAACW,SAAS,CAACyB,IAAI,CAAC,IAAI,KAAKD,QACpC,IAAG;gCAET;4BACF,CAAA;oBACA;wBACE7B,MAAM;wBACNC,MAAM;wBACNP,OAAO;4BACLE,aAAa;wBACf;wBACAsC,SAAS;wBACThC,UAAU;oBACZ;oBACA;wBACEF,MAAM;wBACNC,MAAM;wBACNP,OAAO;4BACLE,aAAa;wBACf;wBACAM,UAAU;oBACZ;iBACD;YACH;SACD;QACDiC,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: '@/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 ...(triggers || []).flatMap(t => (t.inputs || []).filter(f => 'name' in f && f.name).map(f => ({\n ...f,\n admin: {\n ...(f.admin || {}),\n condition: (...args) => args[1]?.type === t.slug && (\n f.admin?.condition ?\n f.admin.condition.call(this, ...args) :\n true\n ),\n },\n hooks: {\n afterRead: [\n ({ siblingData }) => {\n return siblingData?.parameters?.[(f as any).name] || undefined\n }\n ],\n beforeChange: [\n ({ siblingData, value }) => {\n if (!siblingData.parameters) {siblingData.parameters = {}}\n siblingData.parameters[(f as any).name] = value\n return undefined // Virtual field, don't store directly\n }\n ]\n },\n virtual: true,\n } as Field)))\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","filter","f","args","call","step","inputSchema","field","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,MAAM;wBACNO,SAAS;4BACP;4BACA;4BACA;4BACA;+BACG,AAACrB,CAAAA,YAAY,EAAE,AAAD,EAAGsB,GAAG,CAACC,CAAAA,IAAKA,EAAEtB,IAAI;yBACpC;oBACH;oBACA;wBACEY,MAAM;wBACNC,MAAM;wBACNP,OAAO;4BACLiB,QAAQ;wBACV;wBACAC,cAAc,CAAC;oBACjB;oBACA,wCAAwC;oBACxC;wBACEZ,MAAM;wBACNC,MAAM;wBACNP,OAAO;4BACLW,WAAW,CAACQ,GAAGC,cAAgBA,aAAab,SAAS;4BACrDL,aAAa;wBACf;wBACAm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EF,MAAM;wBACNC,MAAM;wBACNP,OAAO;4BACLE,aAAa;wBACf;wBACAM,UAAU;oBACZ;iBACD;YACH;SACD;QACDkD,UAAU;YACRC,QAAQ;gBACNC,UAAU;YACZ;YACAC,WAAW;QACb;IACF,CAAA,EAAE"}
@@ -5,9 +5,17 @@ export type PayloadWorkflow = {
5
5
  description?: string | null;
6
6
  triggers?: Array<{
7
7
  type?: string | null;
8
- collectionSlug?: string | null;
9
- operation?: string | null;
10
8
  condition?: string | null;
9
+ parameters?: {
10
+ collectionSlug?: string | null;
11
+ operation?: string | null;
12
+ webhookPath?: string | null;
13
+ cronExpression?: string | null;
14
+ timezone?: string | null;
15
+ global?: string | null;
16
+ globalOperation?: string | null;
17
+ [key: string]: unknown;
18
+ } | null;
11
19
  [key: string]: unknown;
12
20
  }> | null;
13
21
  steps?: Array<{
@@ -794,12 +794,12 @@ export class WorkflowExecutor {
794
794
  triggerCount: triggers?.length || 0,
795
795
  triggers: triggers?.map((t)=>({
796
796
  type: t.type,
797
- collection: t.collection,
798
- collectionSlug: t.collectionSlug,
799
- operation: t.operation
797
+ collection: t.parameters?.collection,
798
+ collectionSlug: t.parameters?.collectionSlug,
799
+ operation: t.parameters?.operation
800
800
  }))
801
801
  }, 'Checking workflow triggers');
802
- const matchingTriggers = triggers?.filter((trigger)=>trigger.type === 'collection-trigger' && (trigger.collection === collection || trigger.collectionSlug === collection) && trigger.operation === operation) || [];
802
+ const matchingTriggers = triggers?.filter((trigger)=>trigger.type === 'collection-trigger' && (trigger.parameters?.collection === collection || trigger.parameters?.collectionSlug === collection) && trigger.parameters?.operation === operation) || [];
803
803
  this.logger.info({
804
804
  workflowId: workflow.id,
805
805
  workflowName: workflow.name,
@@ -813,9 +813,9 @@ export class WorkflowExecutor {
813
813
  workflowName: workflow.name,
814
814
  triggerDetails: {
815
815
  type: trigger.type,
816
- collection: trigger.collection,
817
- collectionSlug: trigger.collectionSlug,
818
- operation: trigger.operation,
816
+ collection: trigger.parameters?.collection,
817
+ collectionSlug: trigger.parameters?.collectionSlug,
818
+ operation: trigger.parameters?.operation,
819
819
  hasCondition: !!trigger.condition
820
820
  }
821
821
  }, 'Processing matching trigger - about to execute workflow');