@xtr-dev/payload-automation 0.0.22 → 0.0.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +73 -2
- package/dist/collections/Workflow.js +187 -18
- package/dist/collections/Workflow.js.map +1 -1
- package/dist/collections/WorkflowRuns.js +14 -7
- package/dist/collections/WorkflowRuns.js.map +1 -1
- package/dist/components/StatusCell.d.ts +6 -0
- package/dist/components/StatusCell.js +75 -0
- package/dist/components/StatusCell.js.map +1 -0
- package/dist/components/WorkflowExecutionStatus.d.ts +6 -0
- package/dist/components/WorkflowExecutionStatus.js +287 -0
- package/dist/components/WorkflowExecutionStatus.js.map +1 -0
- package/dist/core/workflow-executor.d.ts +42 -2
- package/dist/core/workflow-executor.js +169 -14
- package/dist/core/workflow-executor.js.map +1 -1
- package/dist/exports/client.d.ts +2 -0
- package/dist/exports/client.js +4 -1
- package/dist/exports/client.js.map +1 -1
- package/dist/exports/helpers.d.ts +26 -0
- package/dist/exports/helpers.js +30 -0
- package/dist/exports/helpers.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js.map +1 -1
- package/dist/plugin/cron-scheduler.js +27 -27
- package/dist/plugin/cron-scheduler.js.map +1 -1
- package/dist/plugin/index.js +134 -43
- package/dist/plugin/index.js.map +1 -1
- package/dist/plugin/init-step-tasks.js +15 -1
- package/dist/plugin/init-step-tasks.js.map +1 -1
- package/dist/plugin/init-webhook.js +1 -1
- package/dist/plugin/init-webhook.js.map +1 -1
- package/dist/steps/create-document.js +1 -1
- package/dist/steps/create-document.js.map +1 -1
- package/dist/steps/delete-document.js +2 -2
- package/dist/steps/delete-document.js.map +1 -1
- package/dist/steps/http-request-handler.js +229 -10
- package/dist/steps/http-request-handler.js.map +1 -1
- package/dist/steps/http-request.d.ts +147 -4
- package/dist/steps/http-request.js +189 -3
- package/dist/steps/http-request.js.map +1 -1
- package/dist/steps/read-document.js +2 -2
- package/dist/steps/read-document.js.map +1 -1
- package/dist/steps/send-email.js +5 -5
- package/dist/steps/send-email.js.map +1 -1
- package/dist/steps/update-document.js +2 -2
- package/dist/steps/update-document.js.map +1 -1
- package/dist/test/create-document-step.test.js +378 -0
- package/dist/test/create-document-step.test.js.map +1 -0
- package/dist/test/http-request-step.test.js +361 -0
- package/dist/test/http-request-step.test.js.map +1 -0
- package/dist/test/workflow-executor.test.js +530 -0
- package/dist/test/workflow-executor.test.js.map +1 -0
- package/dist/utils/trigger-helpers.d.ts +46 -0
- package/dist/utils/trigger-helpers.js +100 -0
- package/dist/utils/trigger-helpers.js.map +1 -0
- package/dist/utils/trigger-presets.d.ts +60 -0
- package/dist/utils/trigger-presets.js +172 -0
- package/dist/utils/trigger-presets.js.map +1 -0
- package/package.json +9 -1
- package/dist/test/basic.test.d.ts +0 -1
package/README.md
CHANGED
|
@@ -63,11 +63,82 @@ import type { WorkflowsPluginConfig } from '@xtr-dev/payload-automation'
|
|
|
63
63
|
|
|
64
64
|
## Step Types
|
|
65
65
|
|
|
66
|
-
|
|
66
|
+
### HTTP Request
|
|
67
|
+
Make external API calls with comprehensive error handling and retry logic.
|
|
68
|
+
|
|
69
|
+
**Key Features:**
|
|
70
|
+
- Support for GET, POST, PUT, DELETE, PATCH methods
|
|
71
|
+
- Authentication: Bearer token, Basic auth, API key headers
|
|
72
|
+
- Configurable timeouts and retry logic
|
|
73
|
+
- JSONPath integration for dynamic URLs and request bodies
|
|
74
|
+
|
|
75
|
+
**Error Handling:**
|
|
76
|
+
HTTP Request steps use a **response-based success model** rather than status-code-based failures:
|
|
77
|
+
|
|
78
|
+
- ✅ **Successful completion**: All HTTP requests that receive a response (including 4xx/5xx status codes) are marked as "succeeded"
|
|
79
|
+
- ❌ **Failed execution**: Only network errors, timeouts, DNS failures, and connection issues cause step failure
|
|
80
|
+
- 📊 **Error information preserved**: HTTP error status codes (404, 500, etc.) are captured in the step output for workflow conditional logic
|
|
81
|
+
|
|
82
|
+
**Example workflow logic:**
|
|
83
|
+
```typescript
|
|
84
|
+
// Step outputs for a 404 response:
|
|
85
|
+
{
|
|
86
|
+
"status": 404,
|
|
87
|
+
"statusText": "Not Found",
|
|
88
|
+
"body": "Resource not found",
|
|
89
|
+
"headers": {...},
|
|
90
|
+
"duration": 1200
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// Use in workflow conditions:
|
|
94
|
+
// "$.steps.apiRequest.output.status >= 400" to handle errors
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
This design allows workflows to handle HTTP errors gracefully rather than failing completely, enabling robust error handling and retry logic.
|
|
98
|
+
|
|
99
|
+
**Enhanced Error Tracking:**
|
|
100
|
+
For network failures (timeouts, DNS errors, connection failures), the plugin provides detailed error information through an independent storage system that bypasses PayloadCMS's output limitations:
|
|
101
|
+
|
|
102
|
+
```typescript
|
|
103
|
+
// Timeout error details preserved in workflow context:
|
|
104
|
+
{
|
|
105
|
+
"steps": {
|
|
106
|
+
"httpStep": {
|
|
107
|
+
"state": "failed",
|
|
108
|
+
"error": "Task handler returned a failed state",
|
|
109
|
+
"errorDetails": {
|
|
110
|
+
"errorType": "timeout",
|
|
111
|
+
"duration": 2006,
|
|
112
|
+
"attempts": 1,
|
|
113
|
+
"finalError": "Request timeout after 2000ms",
|
|
114
|
+
"context": {
|
|
115
|
+
"url": "https://api.example.com/data",
|
|
116
|
+
"method": "GET",
|
|
117
|
+
"timeout": 2000
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
"executionInfo": {
|
|
121
|
+
"completed": true,
|
|
122
|
+
"success": false,
|
|
123
|
+
"executedAt": "2025-09-04T15:16:10.000Z",
|
|
124
|
+
"duration": 2006
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// Access in workflow conditions:
|
|
131
|
+
// "$.steps.httpStep.errorDetails.errorType == 'timeout'"
|
|
132
|
+
// "$.steps.httpStep.errorDetails.duration > 5000"
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### Document Operations
|
|
67
136
|
- **Create Document** - Create PayloadCMS documents
|
|
68
137
|
- **Read Document** - Query documents with filters
|
|
69
|
-
- **Update Document** - Modify existing documents
|
|
138
|
+
- **Update Document** - Modify existing documents
|
|
70
139
|
- **Delete Document** - Remove documents
|
|
140
|
+
|
|
141
|
+
### Communication
|
|
71
142
|
- **Send Email** - Send notifications via PayloadCMS email
|
|
72
143
|
|
|
73
144
|
## Data Resolution
|
|
@@ -31,6 +31,16 @@ export const createWorkflowCollection = ({ collectionTriggers, steps, triggers }
|
|
|
31
31
|
description: 'Optional description of what this workflow does'
|
|
32
32
|
}
|
|
33
33
|
},
|
|
34
|
+
{
|
|
35
|
+
name: 'executionStatus',
|
|
36
|
+
type: 'ui',
|
|
37
|
+
admin: {
|
|
38
|
+
components: {
|
|
39
|
+
Field: '@/components/WorkflowExecutionStatus'
|
|
40
|
+
},
|
|
41
|
+
condition: (data)=>!!data?.id // Only show for existing workflows
|
|
42
|
+
}
|
|
43
|
+
},
|
|
34
44
|
{
|
|
35
45
|
name: 'triggers',
|
|
36
46
|
type: 'array',
|
|
@@ -46,6 +56,15 @@ export const createWorkflowCollection = ({ collectionTriggers, steps, triggers }
|
|
|
46
56
|
...(triggers || []).map((t)=>t.slug)
|
|
47
57
|
]
|
|
48
58
|
},
|
|
59
|
+
{
|
|
60
|
+
name: 'parameters',
|
|
61
|
+
type: 'json',
|
|
62
|
+
admin: {
|
|
63
|
+
hidden: true
|
|
64
|
+
},
|
|
65
|
+
defaultValue: {}
|
|
66
|
+
},
|
|
67
|
+
// Virtual fields for collection trigger
|
|
49
68
|
{
|
|
50
69
|
name: 'collectionSlug',
|
|
51
70
|
type: 'select',
|
|
@@ -53,7 +72,25 @@ export const createWorkflowCollection = ({ collectionTriggers, steps, triggers }
|
|
|
53
72
|
condition: (_, siblingData)=>siblingData?.type === 'collection-trigger',
|
|
54
73
|
description: 'Collection that triggers the workflow'
|
|
55
74
|
},
|
|
56
|
-
|
|
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
|
|
57
94
|
},
|
|
58
95
|
{
|
|
59
96
|
name: 'operation',
|
|
@@ -62,27 +99,65 @@ export const createWorkflowCollection = ({ collectionTriggers, steps, triggers }
|
|
|
62
99
|
condition: (_, siblingData)=>siblingData?.type === 'collection-trigger',
|
|
63
100
|
description: 'Collection operation that triggers the workflow'
|
|
64
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
|
+
},
|
|
65
119
|
options: [
|
|
66
120
|
'create',
|
|
67
121
|
'delete',
|
|
68
122
|
'read',
|
|
69
123
|
'update'
|
|
70
|
-
]
|
|
124
|
+
],
|
|
125
|
+
virtual: true
|
|
71
126
|
},
|
|
127
|
+
// Virtual fields for webhook trigger
|
|
72
128
|
{
|
|
73
129
|
name: 'webhookPath',
|
|
74
130
|
type: 'text',
|
|
75
131
|
admin: {
|
|
76
132
|
condition: (_, siblingData)=>siblingData?.type === 'webhook-trigger',
|
|
77
|
-
description: 'URL path for the webhook (e.g., "my-webhook"). Full URL will be /api/workflows
|
|
133
|
+
description: 'URL path for the webhook (e.g., "my-webhook"). Full URL will be /api/workflows-webhook/my-webhook'
|
|
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
|
+
]
|
|
78
151
|
},
|
|
79
152
|
validate: (value, { siblingData })=>{
|
|
80
|
-
if (siblingData?.type === 'webhook-trigger' && !value) {
|
|
153
|
+
if (siblingData?.type === 'webhook-trigger' && !value && !siblingData?.parameters?.webhookPath) {
|
|
81
154
|
return 'Webhook path is required for webhook triggers';
|
|
82
155
|
}
|
|
83
156
|
return true;
|
|
84
|
-
}
|
|
157
|
+
},
|
|
158
|
+
virtual: true
|
|
85
159
|
},
|
|
160
|
+
// Virtual fields for global trigger
|
|
86
161
|
{
|
|
87
162
|
name: 'global',
|
|
88
163
|
type: 'select',
|
|
@@ -90,7 +165,25 @@ export const createWorkflowCollection = ({ collectionTriggers, steps, triggers }
|
|
|
90
165
|
condition: (_, siblingData)=>siblingData?.type === 'global-trigger',
|
|
91
166
|
description: 'Global that triggers the workflow'
|
|
92
167
|
},
|
|
93
|
-
|
|
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
|
|
94
187
|
},
|
|
95
188
|
{
|
|
96
189
|
name: 'globalOperation',
|
|
@@ -99,10 +192,29 @@ export const createWorkflowCollection = ({ collectionTriggers, steps, triggers }
|
|
|
99
192
|
condition: (_, siblingData)=>siblingData?.type === 'global-trigger',
|
|
100
193
|
description: 'Global operation that triggers the workflow'
|
|
101
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
|
+
},
|
|
102
212
|
options: [
|
|
103
213
|
'update'
|
|
104
|
-
]
|
|
214
|
+
],
|
|
215
|
+
virtual: true
|
|
105
216
|
},
|
|
217
|
+
// Virtual fields for cron trigger
|
|
106
218
|
{
|
|
107
219
|
name: 'cronExpression',
|
|
108
220
|
type: 'text',
|
|
@@ -111,14 +223,32 @@ export const createWorkflowCollection = ({ collectionTriggers, steps, triggers }
|
|
|
111
223
|
description: 'Cron expression for scheduled execution (e.g., "0 0 * * *" for daily at midnight)',
|
|
112
224
|
placeholder: '0 0 * * *'
|
|
113
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
|
+
},
|
|
114
243
|
validate: (value, { siblingData })=>{
|
|
115
|
-
|
|
244
|
+
const cronValue = value || siblingData?.parameters?.cronExpression;
|
|
245
|
+
if (siblingData?.type === 'cron-trigger' && !cronValue) {
|
|
116
246
|
return 'Cron expression is required for cron triggers';
|
|
117
247
|
}
|
|
118
248
|
// Validate cron expression format if provided
|
|
119
|
-
if (siblingData?.type === 'cron-trigger' &&
|
|
249
|
+
if (siblingData?.type === 'cron-trigger' && cronValue) {
|
|
120
250
|
// Basic format validation - should be 5 parts separated by spaces
|
|
121
|
-
const cronParts =
|
|
251
|
+
const cronParts = cronValue.trim().split(/\s+/);
|
|
122
252
|
if (cronParts.length !== 5) {
|
|
123
253
|
return 'Invalid cron expression format. Expected 5 parts: "minute hour day month weekday" (e.g., "0 9 * * 1")';
|
|
124
254
|
}
|
|
@@ -126,7 +256,8 @@ export const createWorkflowCollection = ({ collectionTriggers, steps, triggers }
|
|
|
126
256
|
// The main validation happens at runtime in the cron scheduler
|
|
127
257
|
}
|
|
128
258
|
return true;
|
|
129
|
-
}
|
|
259
|
+
},
|
|
260
|
+
virtual: true
|
|
130
261
|
},
|
|
131
262
|
{
|
|
132
263
|
name: 'timezone',
|
|
@@ -137,35 +268,73 @@ export const createWorkflowCollection = ({ collectionTriggers, steps, triggers }
|
|
|
137
268
|
placeholder: 'UTC'
|
|
138
269
|
},
|
|
139
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
|
+
},
|
|
140
288
|
validate: (value, { siblingData })=>{
|
|
141
|
-
|
|
289
|
+
const tzValue = value || siblingData?.parameters?.timezone;
|
|
290
|
+
if (siblingData?.type === 'cron-trigger' && tzValue) {
|
|
142
291
|
try {
|
|
143
292
|
// Test if timezone is valid by trying to create a date with it
|
|
144
293
|
new Intl.DateTimeFormat('en', {
|
|
145
|
-
timeZone:
|
|
294
|
+
timeZone: tzValue
|
|
146
295
|
});
|
|
147
296
|
return true;
|
|
148
297
|
} catch {
|
|
149
|
-
return `Invalid timezone: ${
|
|
298
|
+
return `Invalid timezone: ${tzValue}. Please use a valid IANA timezone identifier (e.g., "America/New_York", "Europe/London")`;
|
|
150
299
|
}
|
|
151
300
|
}
|
|
152
301
|
return true;
|
|
153
|
-
}
|
|
302
|
+
},
|
|
303
|
+
virtual: true
|
|
154
304
|
},
|
|
155
305
|
{
|
|
156
306
|
name: 'condition',
|
|
157
307
|
type: 'text',
|
|
158
308
|
admin: {
|
|
159
|
-
description: 'JSONPath expression that must evaluate to true for this trigger to execute the workflow (e.g., "$.doc.status == \'published\'")'
|
|
309
|
+
description: 'JSONPath expression that must evaluate to true for this trigger to execute the workflow (e.g., "$.trigger.doc.status == \'published\'")'
|
|
160
310
|
},
|
|
161
311
|
required: false
|
|
162
312
|
},
|
|
163
|
-
|
|
313
|
+
// Virtual fields for custom triggers
|
|
314
|
+
...(triggers || []).flatMap((t)=>(t.inputs || []).filter((f)=>'name' in f && f.name).map((f)=>({
|
|
164
315
|
...f,
|
|
165
316
|
admin: {
|
|
166
317
|
...f.admin || {},
|
|
167
318
|
condition: (...args)=>args[1]?.type === t.slug && (f.admin?.condition ? f.admin.condition.call(this, ...args) : true)
|
|
168
|
-
}
|
|
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
|
|
169
338
|
})))
|
|
170
339
|
]
|
|
171
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: '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., \"$.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","options","map","t","condition","_","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;gBACNF,QAAQ;oBACN;wBACEC,MAAM;wBACNC,MAAM;wBACNE,SAAS;4BACP;4BACA;4BACA;4BACA;+BACG,AAAChB,CAAAA,YAAY,EAAE,AAAD,EAAGiB,GAAG,CAACC,CAAAA,IAAKA,EAAEjB,IAAI;yBACpC;oBACH;oBACA;wBACEY,MAAM;wBACNC,MAAM;wBACNP,OAAO;4BACLY,WAAW,CAACC,GAAGC,cAAgBA,aAAaP,SAAS;4BACrDL,aAAa;wBACf;wBACAO,SAASM,OAAOC,IAAI,CAACzB,sBAAsB,CAAC;oBAC9C;oBACA;wBACEe,MAAM;wBACNC,MAAM;wBAC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CAACK,CAAAA,OAAQ,AAACA,CAAAA,KAAKC,WAAW,IAAI,EAAE,AAAD,EAAGxB,GAAG,CAACyB,CAAAA,QAAU,CAAA;gCACtE,GAAGA,KAAK;gCACRnC,OAAO;oCACL,GAAImC,MAAMnC,KAAK,IAAI,CAAC,CAAC;oCACrBY,WAAW,CAAC,GAAGmB,OAASA,IAAI,CAAC,EAAE,EAAEE,SAASA,KAAKvC,IAAI,IACjDyC,CAAAA,MAAMnC,KAAK,EAAEY,YACXuB,MAAMnC,KAAK,CAACY,SAAS,CAACoB,IAAI,CAAC,IAAI,KAAKD,QACpC,IAAG;gCAET;4BACF,CAAA;oBACA;wBACEzB,MAAM;wBACNC,MAAM;wBACNP,OAAO;4BACLE,aAAa;wBACf;wBACAkC,SAAS;wBACT5B,UAAU;oBACZ;oBACA;wBACEF,MAAM;wBACNC,MAAM;wBACNP,OAAO;4BACLE,aAAa;wBACf;wBACAM,UAAU;oBACZ;iBACD;YACH;SACD;QACD6B,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: '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: '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: '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: '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: '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: '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: '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,QAA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YG,UAAU,GAAG,CAAC;4CAAC;4CACzDH,YAAYG,UAAU,CAAC,AAAC4B,EAAU7C,IAAI,CAAC,GAAGqB;4CAC1C,OAAOF,UAAU,sCAAsC;;wCACzD;qCACD;gCACH;gCACAK,SAAS;4BACX,CAAA;iBACD;YACH;YACA;gBACExB,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,CAACM,CAAAA,OAAQ,AAACA,CAAAA,KAAKC,WAAW,IAAI,EAAE,AAAD,EAAGxC,GAAG,CAACyC,CAAAA,QAAU,CAAA;gCACtE,GAAGA,KAAK;gCACRxD,OAAO;oCACL,GAAIwD,MAAMxD,KAAK,IAAI,CAAC,CAAC;oCACrBW,WAAW,CAAC,GAAGyC,OAASA,IAAI,CAAC,EAAE,EAAEE,SAASA,KAAK5D,IAAI,IACjD8D,CAAAA,MAAMxD,KAAK,EAAEW,YACX6C,MAAMxD,KAAK,CAACW,SAAS,CAAC0C,IAAI,CAAC,IAAI,KAAKD,QACpC,IAAG;gCAET;4BACF,CAAA;oBACA;wBACE9C,MAAM;wBACNC,MAAM;wBACNP,OAAO;4BACLE,aAAa;wBACf;wBACAuD,SAAS;wBACTjD,UAAU;oBACZ;oBACA;wBACEF,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"}
|
|
@@ -42,28 +42,31 @@ export const WorkflowRunsCollection = {
|
|
|
42
42
|
name: 'status',
|
|
43
43
|
type: 'select',
|
|
44
44
|
admin: {
|
|
45
|
-
description: 'Current execution status'
|
|
45
|
+
description: 'Current execution status',
|
|
46
|
+
components: {
|
|
47
|
+
Cell: '@/components/StatusCell'
|
|
48
|
+
}
|
|
46
49
|
},
|
|
47
50
|
defaultValue: 'pending',
|
|
48
51
|
options: [
|
|
49
52
|
{
|
|
50
|
-
label: 'Pending',
|
|
53
|
+
label: '⏳ Pending',
|
|
51
54
|
value: 'pending'
|
|
52
55
|
},
|
|
53
56
|
{
|
|
54
|
-
label: 'Running',
|
|
57
|
+
label: '🔄 Running',
|
|
55
58
|
value: 'running'
|
|
56
59
|
},
|
|
57
60
|
{
|
|
58
|
-
label: 'Completed',
|
|
61
|
+
label: '✅ Completed',
|
|
59
62
|
value: 'completed'
|
|
60
63
|
},
|
|
61
64
|
{
|
|
62
|
-
label: 'Failed',
|
|
65
|
+
label: '❌ Failed',
|
|
63
66
|
value: 'failed'
|
|
64
67
|
},
|
|
65
68
|
{
|
|
66
|
-
label: 'Cancelled',
|
|
69
|
+
label: '⏹️ Cancelled',
|
|
67
70
|
value: 'cancelled'
|
|
68
71
|
}
|
|
69
72
|
],
|
|
@@ -139,7 +142,11 @@ export const WorkflowRunsCollection = {
|
|
|
139
142
|
name: 'error',
|
|
140
143
|
type: 'textarea',
|
|
141
144
|
admin: {
|
|
142
|
-
description: 'Error message if workflow execution failed'
|
|
145
|
+
description: 'Error message if workflow execution failed',
|
|
146
|
+
condition: (_, siblingData)=>siblingData?.status === 'failed',
|
|
147
|
+
components: {
|
|
148
|
+
Field: '@/components/ErrorDisplay'
|
|
149
|
+
}
|
|
143
150
|
}
|
|
144
151
|
},
|
|
145
152
|
{
|
|
@@ -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 },\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 },\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","defaultValue","options","label","value","date","displayFormat","readOnly"],"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;
|
|
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"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import React from 'react';
|
|
4
|
+
export const StatusCell = ({ cellData })=>{
|
|
5
|
+
const getStatusDisplay = (status)=>{
|
|
6
|
+
switch(status){
|
|
7
|
+
case 'pending':
|
|
8
|
+
return {
|
|
9
|
+
icon: '⏳',
|
|
10
|
+
color: '#6B7280',
|
|
11
|
+
label: 'Pending'
|
|
12
|
+
};
|
|
13
|
+
case 'running':
|
|
14
|
+
return {
|
|
15
|
+
icon: '🔄',
|
|
16
|
+
color: '#3B82F6',
|
|
17
|
+
label: 'Running'
|
|
18
|
+
};
|
|
19
|
+
case 'completed':
|
|
20
|
+
return {
|
|
21
|
+
icon: '✅',
|
|
22
|
+
color: '#10B981',
|
|
23
|
+
label: 'Completed'
|
|
24
|
+
};
|
|
25
|
+
case 'failed':
|
|
26
|
+
return {
|
|
27
|
+
icon: '❌',
|
|
28
|
+
color: '#EF4444',
|
|
29
|
+
label: 'Failed'
|
|
30
|
+
};
|
|
31
|
+
case 'cancelled':
|
|
32
|
+
return {
|
|
33
|
+
icon: '⏹️',
|
|
34
|
+
color: '#F59E0B',
|
|
35
|
+
label: 'Cancelled'
|
|
36
|
+
};
|
|
37
|
+
default:
|
|
38
|
+
return {
|
|
39
|
+
icon: '❓',
|
|
40
|
+
color: '#6B7280',
|
|
41
|
+
label: status || 'Unknown'
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
const { icon, color, label } = getStatusDisplay(cellData);
|
|
46
|
+
return /*#__PURE__*/ _jsxs("div", {
|
|
47
|
+
style: {
|
|
48
|
+
display: 'flex',
|
|
49
|
+
alignItems: 'center',
|
|
50
|
+
gap: '8px',
|
|
51
|
+
padding: '4px 8px',
|
|
52
|
+
borderRadius: '6px',
|
|
53
|
+
backgroundColor: `${color}15`,
|
|
54
|
+
border: `1px solid ${color}30`,
|
|
55
|
+
fontSize: '14px',
|
|
56
|
+
fontWeight: '500'
|
|
57
|
+
},
|
|
58
|
+
children: [
|
|
59
|
+
/*#__PURE__*/ _jsx("span", {
|
|
60
|
+
style: {
|
|
61
|
+
fontSize: '16px'
|
|
62
|
+
},
|
|
63
|
+
children: icon
|
|
64
|
+
}),
|
|
65
|
+
/*#__PURE__*/ _jsx("span", {
|
|
66
|
+
style: {
|
|
67
|
+
color
|
|
68
|
+
},
|
|
69
|
+
children: label
|
|
70
|
+
})
|
|
71
|
+
]
|
|
72
|
+
});
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
//# sourceMappingURL=StatusCell.js.map
|