@xtr-dev/payload-automation 0.0.43 → 0.0.45
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 +221 -49
- package/dist/collections/Steps.d.ts +6 -0
- package/dist/collections/Steps.js +166 -0
- package/dist/collections/Steps.js.map +1 -0
- package/dist/collections/Triggers.d.ts +7 -0
- package/dist/collections/Triggers.js +224 -0
- package/dist/collections/Triggers.js.map +1 -0
- package/dist/collections/Workflow.d.ts +5 -2
- package/dist/collections/Workflow.js +179 -39
- package/dist/collections/Workflow.js.map +1 -1
- package/dist/collections/WorkflowRuns.d.ts +4 -0
- package/dist/collections/WorkflowRuns.js +219 -24
- package/dist/collections/WorkflowRuns.js.map +1 -1
- package/dist/components/WorkflowBuilder/WorkflowBuilder.js.map +1 -1
- package/dist/core/expression-engine.d.ts +58 -0
- package/dist/core/expression-engine.js +191 -0
- package/dist/core/expression-engine.js.map +1 -0
- package/dist/core/workflow-executor.d.ts +70 -56
- package/dist/core/workflow-executor.js +354 -677
- package/dist/core/workflow-executor.js.map +1 -1
- package/dist/exports/client.js +1 -3
- package/dist/exports/client.js.map +1 -1
- package/dist/exports/views.js +2 -4
- package/dist/exports/views.js.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/plugin/config-types.d.ts +43 -5
- package/dist/plugin/config-types.js +3 -1
- package/dist/plugin/config-types.js.map +1 -1
- package/dist/plugin/index.d.ts +1 -1
- package/dist/plugin/index.js +82 -28
- package/dist/plugin/index.js.map +1 -1
- package/dist/plugin/trigger-hook.d.ts +13 -0
- package/dist/plugin/trigger-hook.js +184 -0
- package/dist/plugin/trigger-hook.js.map +1 -0
- package/dist/steps/create-step.d.ts +66 -0
- package/dist/steps/create-step.js +59 -0
- package/dist/steps/create-step.js.map +1 -0
- package/dist/steps/index.d.ts +2 -0
- package/dist/steps/index.js +3 -0
- package/dist/steps/index.js.map +1 -1
- package/dist/steps/read-document-handler.js +1 -1
- package/dist/steps/read-document-handler.js.map +1 -1
- package/dist/steps/update-document-handler.js +1 -1
- package/dist/steps/update-document-handler.js.map +1 -1
- package/dist/triggers/hook-options.d.ts +34 -0
- package/dist/triggers/hook-options.js +158 -0
- package/dist/triggers/hook-options.js.map +1 -0
- package/dist/triggers/index.d.ts +2 -2
- package/dist/triggers/index.js +1 -2
- package/dist/triggers/index.js.map +1 -1
- package/dist/types/index.d.ts +8 -0
- package/dist/types/index.js +4 -5
- package/dist/types/index.js.map +1 -1
- package/dist/utils/validation.d.ts +64 -0
- package/dist/utils/validation.js +107 -0
- package/dist/utils/validation.js.map +1 -0
- package/package.json +2 -1
- package/dist/plugin/collection-hook.d.ts +0 -1
- package/dist/plugin/collection-hook.js +0 -92
- package/dist/plugin/collection-hook.js.map +0 -1
- package/dist/plugin/global-hook.d.ts +0 -1
- package/dist/plugin/global-hook.js +0 -83
- package/dist/plugin/global-hook.js.map +0 -1
- package/dist/triggers/collection-trigger.d.ts +0 -2
- package/dist/triggers/collection-trigger.js +0 -36
- package/dist/triggers/collection-trigger.js.map +0 -1
- package/dist/triggers/global-trigger.d.ts +0 -2
- package/dist/triggers/global-trigger.js +0 -29
- package/dist/triggers/global-trigger.js.map +0 -1
- package/dist/triggers/types.d.ts +0 -5
- package/dist/triggers/types.js +0 -3
- package/dist/triggers/types.js.map +0 -1
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* WorkflowRuns collection for tracking workflow executions.
|
|
3
|
+
* Enhanced with structured step results and trigger tracking.
|
|
4
|
+
*/ export const WorkflowRunsCollection = {
|
|
2
5
|
slug: 'workflow-runs',
|
|
3
6
|
access: {
|
|
4
7
|
create: ()=>true,
|
|
@@ -10,7 +13,7 @@ export const WorkflowRunsCollection = {
|
|
|
10
13
|
defaultColumns: [
|
|
11
14
|
'workflow',
|
|
12
15
|
'status',
|
|
13
|
-
'
|
|
16
|
+
'firedTrigger',
|
|
14
17
|
'startedAt',
|
|
15
18
|
'duration'
|
|
16
19
|
],
|
|
@@ -35,9 +38,25 @@ export const WorkflowRunsCollection = {
|
|
|
35
38
|
type: 'number',
|
|
36
39
|
admin: {
|
|
37
40
|
description: 'Version of the workflow that was executed'
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
// Track which trigger fired
|
|
44
|
+
{
|
|
45
|
+
name: 'firedTrigger',
|
|
46
|
+
type: 'relationship',
|
|
47
|
+
admin: {
|
|
48
|
+
description: 'The trigger that initiated this workflow run'
|
|
38
49
|
},
|
|
39
|
-
|
|
50
|
+
relationTo: 'automation-triggers'
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
name: 'triggerData',
|
|
54
|
+
type: 'json',
|
|
55
|
+
admin: {
|
|
56
|
+
description: 'Snapshot of the trigger context when the workflow was fired'
|
|
57
|
+
}
|
|
40
58
|
},
|
|
59
|
+
// Status and timing
|
|
41
60
|
{
|
|
42
61
|
name: 'status',
|
|
43
62
|
type: 'select',
|
|
@@ -50,23 +69,23 @@ export const WorkflowRunsCollection = {
|
|
|
50
69
|
defaultValue: 'pending',
|
|
51
70
|
options: [
|
|
52
71
|
{
|
|
53
|
-
label: '
|
|
72
|
+
label: 'Pending',
|
|
54
73
|
value: 'pending'
|
|
55
74
|
},
|
|
56
75
|
{
|
|
57
|
-
label: '
|
|
76
|
+
label: 'Running',
|
|
58
77
|
value: 'running'
|
|
59
78
|
},
|
|
60
79
|
{
|
|
61
|
-
label: '
|
|
80
|
+
label: 'Completed',
|
|
62
81
|
value: 'completed'
|
|
63
82
|
},
|
|
64
83
|
{
|
|
65
|
-
label: '
|
|
84
|
+
label: 'Failed',
|
|
66
85
|
value: 'failed'
|
|
67
86
|
},
|
|
68
87
|
{
|
|
69
|
-
label: '
|
|
88
|
+
label: 'Cancelled',
|
|
70
89
|
value: 'cancelled'
|
|
71
90
|
}
|
|
72
91
|
],
|
|
@@ -101,9 +120,130 @@ export const WorkflowRunsCollection = {
|
|
|
101
120
|
readOnly: true
|
|
102
121
|
}
|
|
103
122
|
},
|
|
123
|
+
// Structured step results
|
|
124
|
+
{
|
|
125
|
+
name: 'stepResults',
|
|
126
|
+
type: 'array',
|
|
127
|
+
admin: {
|
|
128
|
+
description: 'Detailed results for each step execution'
|
|
129
|
+
},
|
|
130
|
+
fields: [
|
|
131
|
+
{
|
|
132
|
+
name: 'step',
|
|
133
|
+
type: 'relationship',
|
|
134
|
+
admin: {
|
|
135
|
+
description: 'Reference to the step that was executed'
|
|
136
|
+
},
|
|
137
|
+
relationTo: 'automation-steps'
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
name: 'stepName',
|
|
141
|
+
type: 'text',
|
|
142
|
+
admin: {
|
|
143
|
+
description: 'Name of the step at execution time'
|
|
144
|
+
}
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
name: 'stepIndex',
|
|
148
|
+
type: 'number',
|
|
149
|
+
admin: {
|
|
150
|
+
description: 'Position of the step in the workflow'
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
name: 'status',
|
|
155
|
+
type: 'select',
|
|
156
|
+
admin: {
|
|
157
|
+
description: 'Step execution status'
|
|
158
|
+
},
|
|
159
|
+
options: [
|
|
160
|
+
{
|
|
161
|
+
label: 'Pending',
|
|
162
|
+
value: 'pending'
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
label: 'Running',
|
|
166
|
+
value: 'running'
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
label: 'Succeeded',
|
|
170
|
+
value: 'succeeded'
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
label: 'Failed',
|
|
174
|
+
value: 'failed'
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
label: 'Skipped',
|
|
178
|
+
value: 'skipped'
|
|
179
|
+
}
|
|
180
|
+
]
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
name: 'startedAt',
|
|
184
|
+
type: 'date',
|
|
185
|
+
admin: {
|
|
186
|
+
date: {
|
|
187
|
+
displayFormat: 'yyyy-MM-dd HH:mm:ss'
|
|
188
|
+
},
|
|
189
|
+
description: 'When this step started'
|
|
190
|
+
}
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
name: 'completedAt',
|
|
194
|
+
type: 'date',
|
|
195
|
+
admin: {
|
|
196
|
+
date: {
|
|
197
|
+
displayFormat: 'yyyy-MM-dd HH:mm:ss'
|
|
198
|
+
},
|
|
199
|
+
description: 'When this step completed'
|
|
200
|
+
}
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
name: 'duration',
|
|
204
|
+
type: 'number',
|
|
205
|
+
admin: {
|
|
206
|
+
description: 'Step execution time in milliseconds'
|
|
207
|
+
}
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
name: 'input',
|
|
211
|
+
type: 'json',
|
|
212
|
+
admin: {
|
|
213
|
+
description: 'Input data passed to this step (after template resolution)'
|
|
214
|
+
}
|
|
215
|
+
},
|
|
216
|
+
{
|
|
217
|
+
name: 'output',
|
|
218
|
+
type: 'json',
|
|
219
|
+
admin: {
|
|
220
|
+
description: 'Output data returned by this step'
|
|
221
|
+
}
|
|
222
|
+
},
|
|
223
|
+
{
|
|
224
|
+
name: 'error',
|
|
225
|
+
type: 'textarea',
|
|
226
|
+
admin: {
|
|
227
|
+
description: 'Error message if this step failed'
|
|
228
|
+
}
|
|
229
|
+
},
|
|
230
|
+
{
|
|
231
|
+
name: 'retryCount',
|
|
232
|
+
type: 'number',
|
|
233
|
+
admin: {
|
|
234
|
+
description: 'Number of retry attempts for this step'
|
|
235
|
+
},
|
|
236
|
+
defaultValue: 0
|
|
237
|
+
}
|
|
238
|
+
]
|
|
239
|
+
},
|
|
240
|
+
// Execution context
|
|
104
241
|
{
|
|
105
242
|
name: 'context',
|
|
106
|
-
type: 'json'
|
|
243
|
+
type: 'json',
|
|
244
|
+
admin: {
|
|
245
|
+
description: 'Full execution context including trigger data and step outputs'
|
|
246
|
+
}
|
|
107
247
|
},
|
|
108
248
|
{
|
|
109
249
|
name: 'inputs',
|
|
@@ -111,8 +251,7 @@ export const WorkflowRunsCollection = {
|
|
|
111
251
|
admin: {
|
|
112
252
|
description: 'Input data provided when the workflow was triggered'
|
|
113
253
|
},
|
|
114
|
-
defaultValue: {}
|
|
115
|
-
required: true
|
|
254
|
+
defaultValue: {}
|
|
116
255
|
},
|
|
117
256
|
{
|
|
118
257
|
name: 'outputs',
|
|
@@ -121,6 +260,7 @@ export const WorkflowRunsCollection = {
|
|
|
121
260
|
description: 'Final output data from completed steps'
|
|
122
261
|
}
|
|
123
262
|
},
|
|
263
|
+
// Metadata
|
|
124
264
|
{
|
|
125
265
|
name: 'triggeredBy',
|
|
126
266
|
type: 'text',
|
|
@@ -129,15 +269,7 @@ export const WorkflowRunsCollection = {
|
|
|
129
269
|
},
|
|
130
270
|
required: true
|
|
131
271
|
},
|
|
132
|
-
|
|
133
|
-
name: 'steps',
|
|
134
|
-
type: 'json',
|
|
135
|
-
admin: {
|
|
136
|
-
description: 'Array of step execution results'
|
|
137
|
-
},
|
|
138
|
-
defaultValue: [],
|
|
139
|
-
required: true
|
|
140
|
-
},
|
|
272
|
+
// Error information
|
|
141
273
|
{
|
|
142
274
|
name: 'error',
|
|
143
275
|
type: 'textarea',
|
|
@@ -149,16 +281,79 @@ export const WorkflowRunsCollection = {
|
|
|
149
281
|
}
|
|
150
282
|
}
|
|
151
283
|
},
|
|
284
|
+
// Structured logs
|
|
152
285
|
{
|
|
153
286
|
name: 'logs',
|
|
154
|
-
type: '
|
|
287
|
+
type: 'array',
|
|
155
288
|
admin: {
|
|
156
289
|
description: 'Detailed execution logs'
|
|
157
290
|
},
|
|
158
|
-
|
|
159
|
-
|
|
291
|
+
fields: [
|
|
292
|
+
{
|
|
293
|
+
name: 'timestamp',
|
|
294
|
+
type: 'date',
|
|
295
|
+
admin: {
|
|
296
|
+
date: {
|
|
297
|
+
displayFormat: 'yyyy-MM-dd HH:mm:ss.SSS'
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
},
|
|
301
|
+
{
|
|
302
|
+
name: 'level',
|
|
303
|
+
type: 'select',
|
|
304
|
+
options: [
|
|
305
|
+
{
|
|
306
|
+
label: 'Debug',
|
|
307
|
+
value: 'debug'
|
|
308
|
+
},
|
|
309
|
+
{
|
|
310
|
+
label: 'Info',
|
|
311
|
+
value: 'info'
|
|
312
|
+
},
|
|
313
|
+
{
|
|
314
|
+
label: 'Warning',
|
|
315
|
+
value: 'warn'
|
|
316
|
+
},
|
|
317
|
+
{
|
|
318
|
+
label: 'Error',
|
|
319
|
+
value: 'error'
|
|
320
|
+
}
|
|
321
|
+
]
|
|
322
|
+
},
|
|
323
|
+
{
|
|
324
|
+
name: 'message',
|
|
325
|
+
type: 'text'
|
|
326
|
+
},
|
|
327
|
+
{
|
|
328
|
+
name: 'stepIndex',
|
|
329
|
+
type: 'number',
|
|
330
|
+
admin: {
|
|
331
|
+
description: 'Index of the step that generated this log (optional)'
|
|
332
|
+
}
|
|
333
|
+
},
|
|
334
|
+
{
|
|
335
|
+
name: 'data',
|
|
336
|
+
type: 'json',
|
|
337
|
+
admin: {
|
|
338
|
+
description: 'Additional data for this log entry'
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
]
|
|
160
342
|
}
|
|
161
|
-
]
|
|
343
|
+
],
|
|
344
|
+
hooks: {
|
|
345
|
+
beforeChange: [
|
|
346
|
+
// Calculate duration when completedAt is set
|
|
347
|
+
async ({ data })=>{
|
|
348
|
+
if (data?.completedAt && data?.startedAt) {
|
|
349
|
+
const started = new Date(data.startedAt).getTime();
|
|
350
|
+
const completed = new Date(data.completedAt).getTime();
|
|
351
|
+
data.duration = completed - started;
|
|
352
|
+
}
|
|
353
|
+
return data;
|
|
354
|
+
}
|
|
355
|
+
]
|
|
356
|
+
}
|
|
162
357
|
};
|
|
163
358
|
|
|
164
359
|
//# sourceMappingURL=WorkflowRuns.js.map
|
|
@@ -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: '@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"}
|
|
1
|
+
{"version":3,"sources":["../../src/collections/WorkflowRuns.ts"],"sourcesContent":["import type { CollectionConfig } from 'payload'\n\n/**\n * WorkflowRuns collection for tracking workflow executions.\n * Enhanced with structured step results and trigger tracking.\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', 'firedTrigger', '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 },\n // Track which trigger fired\n {\n name: 'firedTrigger',\n type: 'relationship',\n admin: {\n description: 'The trigger that initiated this workflow run',\n },\n relationTo: 'automation-triggers',\n },\n {\n name: 'triggerData',\n type: 'json',\n admin: {\n description: 'Snapshot of the trigger context when the workflow was fired',\n },\n },\n // Status and timing\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 { label: 'Pending', value: 'pending' },\n { label: 'Running', value: 'running' },\n { label: 'Completed', value: 'completed' },\n { label: 'Failed', value: 'failed' },\n { label: 'Cancelled', value: 'cancelled' },\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 // Structured step results\n {\n name: 'stepResults',\n type: 'array',\n admin: {\n description: 'Detailed results for each step execution',\n },\n fields: [\n {\n name: 'step',\n type: 'relationship',\n admin: {\n description: 'Reference to the step that was executed',\n },\n relationTo: 'automation-steps',\n },\n {\n name: 'stepName',\n type: 'text',\n admin: {\n description: 'Name of the step at execution time',\n },\n },\n {\n name: 'stepIndex',\n type: 'number',\n admin: {\n description: 'Position of the step in the workflow',\n },\n },\n {\n name: 'status',\n type: 'select',\n admin: {\n description: 'Step execution status',\n },\n options: [\n { label: 'Pending', value: 'pending' },\n { label: 'Running', value: 'running' },\n { label: 'Succeeded', value: 'succeeded' },\n { label: 'Failed', value: 'failed' },\n { label: 'Skipped', value: 'skipped' },\n ],\n },\n {\n name: 'startedAt',\n type: 'date',\n admin: {\n date: {\n displayFormat: 'yyyy-MM-dd HH:mm:ss',\n },\n description: 'When this step started',\n },\n },\n {\n name: 'completedAt',\n type: 'date',\n admin: {\n date: {\n displayFormat: 'yyyy-MM-dd HH:mm:ss',\n },\n description: 'When this step completed',\n },\n },\n {\n name: 'duration',\n type: 'number',\n admin: {\n description: 'Step execution time in milliseconds',\n },\n },\n {\n name: 'input',\n type: 'json',\n admin: {\n description: 'Input data passed to this step (after template resolution)',\n },\n },\n {\n name: 'output',\n type: 'json',\n admin: {\n description: 'Output data returned by this step',\n },\n },\n {\n name: 'error',\n type: 'textarea',\n admin: {\n description: 'Error message if this step failed',\n },\n },\n {\n name: 'retryCount',\n type: 'number',\n admin: {\n description: 'Number of retry attempts for this step',\n },\n defaultValue: 0,\n },\n ],\n },\n // Execution context\n {\n name: 'context',\n type: 'json',\n admin: {\n description: 'Full execution context including trigger data and step outputs',\n },\n },\n {\n name: 'inputs',\n type: 'json',\n admin: {\n description: 'Input data provided when the workflow was triggered',\n },\n defaultValue: {},\n },\n {\n name: 'outputs',\n type: 'json',\n admin: {\n description: 'Final output data from completed steps',\n },\n },\n // Metadata\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 // Error information\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 // Structured logs\n {\n name: 'logs',\n type: 'array',\n admin: {\n description: 'Detailed execution logs',\n },\n fields: [\n {\n name: 'timestamp',\n type: 'date',\n admin: {\n date: {\n displayFormat: 'yyyy-MM-dd HH:mm:ss.SSS',\n },\n },\n },\n {\n name: 'level',\n type: 'select',\n options: [\n { label: 'Debug', value: 'debug' },\n { label: 'Info', value: 'info' },\n { label: 'Warning', value: 'warn' },\n { label: 'Error', value: 'error' },\n ],\n },\n {\n name: 'message',\n type: 'text',\n },\n {\n name: 'stepIndex',\n type: 'number',\n admin: {\n description: 'Index of the step that generated this log (optional)',\n },\n },\n {\n name: 'data',\n type: 'json',\n admin: {\n description: 'Additional data for this log entry',\n },\n },\n ],\n },\n ],\n hooks: {\n beforeChange: [\n // Calculate duration when completedAt is set\n async ({ data }) => {\n if (data?.completedAt && data?.startedAt) {\n const started = new Date(data.startedAt).getTime()\n const completed = new Date(data.completedAt).getTime()\n data.duration = completed - started\n }\n return data\n }\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","hooks","beforeChange","data","completedAt","startedAt","started","Date","getTime","completed","duration"],"mappings":"AAEA;;;CAGC,GACD,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;YAAgB;YAAa;SAAW;QAC/EC,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;QACF;QACA,4BAA4B;QAC5B;YACEF,MAAM;YACN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BAAWC,OAAO;wBAAU;wBACrC;4BAAED,OAAO;4BAAaC,OAAO;wBAAY;wBACzC;4BAAED,OAAO;4BAAUC,OAAO;wBAAS;wBACnC;4BAAED,OAAO;4BAAWC,OAAO;wBAAU;qBACtC;gBACH;gBACA;oBACEV,MAAM;oBACNC,MAAM;oBACNR,OAAO;wBACLkB,MAAM;4BACJC,eAAe;wBACjB;wBACAV,aAAa;oBACf;gBACF;gBACA;oBACEF,MAAM;oBACNC,MAAM;oBACNR,OAAO;wBACLkB,MAAM;4BACJC,eAAe;wBACjB;wBACAV,aAAa;oBACf;gBACF;gBACA;oBACEF,MAAM;oBACNC,MAAM;oBACNR,OAAO;wBACLS,aAAa;oBACf;gBACF;gBACA;oBACEF,MAAM;oBACNC,MAAM;oBACNR,OAAO;wBACLS,aAAa;oBACf;gBACF;gBACA;oBACEF,MAAM;oBACNC,MAAM;oBACNR,OAAO;wBACLS,aAAa;oBACf;gBACF;gBACA;oBACEF,MAAM;oBACNC,MAAM;oBACNR,OAAO;wBACLS,aAAa;oBACf;gBACF;gBACA;oBACEF,MAAM;oBACNC,MAAM;oBACNR,OAAO;wBACLS,aAAa;oBACf;oBACAK,cAAc;gBAChB;aACD;QACH;QACA,oBAAoB;QACpB;YACEP,MAAM;YACNC,MAAM;YACNR,OAAO;gBACLS,aAAa;YACf;QACF;QACA;YACEF,MAAM;YACNC,MAAM;YACNR,OAAO;gBACLS,aAAa;YACf;YACAK,cAAc,CAAC;QACjB;QACA;YACEP,MAAM;YACNC,MAAM;YACNR,OAAO;gBACLS,aAAa;YACf;QACF;QACA,WAAW;QACX;YACEF,MAAM;YACNC,MAAM;YACNR,OAAO;gBACLS,aAAa;YACf;YACAE,UAAU;QACZ;QACA,oBAAoB;QACpB;YACEJ,MAAM;YACNC,MAAM;YACNR,OAAO;gBACLS,aAAa;gBACbY,WAAW,CAACC,GAAGC,cAAgBA,aAAaC,WAAW;gBACvDZ,YAAY;oBACVa,OAAO;gBACT;YACF;QACF;QACA,kBAAkB;QAClB;YACElB,MAAM;YACNC,MAAM;YACNR,OAAO;gBACLS,aAAa;YACf;YACAH,QAAQ;gBACN;oBACEC,MAAM;oBACNC,MAAM;oBACNR,OAAO;wBACLkB,MAAM;4BACJC,eAAe;wBACjB;oBACF;gBACF;gBACA;oBACEZ,MAAM;oBACNC,MAAM;oBACNO,SAAS;wBACP;4BAAEC,OAAO;4BAASC,OAAO;wBAAQ;wBACjC;4BAAED,OAAO;4BAAQC,OAAO;wBAAO;wBAC/B;4BAAED,OAAO;4BAAWC,OAAO;wBAAO;wBAClC;4BAAED,OAAO;4BAASC,OAAO;wBAAQ;qBAClC;gBACH;gBACA;oBACEV,MAAM;oBACNC,MAAM;gBACR;gBACA;oBACED,MAAM;oBACNC,MAAM;oBACNR,OAAO;wBACLS,aAAa;oBACf;gBACF;gBACA;oBACEF,MAAM;oBACNC,MAAM;oBACNR,OAAO;wBACLS,aAAa;oBACf;gBACF;aACD;QACH;KACD;IACDiB,OAAO;QACLC,cAAc;YACZ,6CAA6C;YAC7C,OAAO,EAAEC,IAAI,EAAE;gBACb,IAAIA,MAAMC,eAAeD,MAAME,WAAW;oBACxC,MAAMC,UAAU,IAAIC,KAAKJ,KAAKE,SAAS,EAAEG,OAAO;oBAChD,MAAMC,YAAY,IAAIF,KAAKJ,KAAKC,WAAW,EAAEI,OAAO;oBACpDL,KAAKO,QAAQ,GAAGD,YAAYH;gBAC9B;gBACA,OAAOH;YACT;SACD;IACH;AACF,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/WorkflowBuilder/WorkflowBuilder.tsx"],"sourcesContent":["'use client'\n\nimport React, { useCallback, useMemo, useState } from 'react'\nimport { \n ReactFlow,\n Node,\n Edge,\n addEdge,\n Connection,\n useNodesState,\n useEdgesState,\n Controls,\n Background,\n BackgroundVariant,\n MiniMap,\n Panel\n} from '@xyflow/react'\nimport '@xyflow/react/dist/style.css'\n\n// Import custom node types\nimport { StepNode } from './nodes/StepNode.js'\nimport { WorkflowToolbar } from './WorkflowToolbar.js'\nimport { StepConfigurationForm } from './StepConfigurationForm.js'\n\n// Define node types for React Flow\nconst nodeTypes = {\n stepNode: StepNode,\n}\n\ninterface WorkflowData {\n id: string\n name: string\n steps?: Array<{\n name: string\n type: string\n position?: { x: number; y: number }\n visual?: { color?: string; icon?: string }\n dependencies?: string[]\n }>\n layout?: {\n viewport?: { x: number; y: number; zoom: number }\n }\n}\n\ninterface StepType {\n slug: string\n label?: string\n inputSchema?: any[]\n outputSchema?: any[]\n}\n\ninterface WorkflowBuilderProps {\n workflow?: WorkflowData\n availableStepTypes?: StepType[]\n onSave?: (workflow: WorkflowData) => void\n readonly?: boolean\n}\n\nexport const WorkflowBuilder: React.FC<WorkflowBuilderProps> = ({\n workflow,\n availableStepTypes = [],\n onSave,\n readonly = false\n}) => {\n const [selectedNode, setSelectedNode] = useState<Node | null>(null)\n\n // Convert workflow steps to React Flow nodes\n const initialNodes: Node[] = useMemo(() => {\n if (!workflow?.steps) return []\n\n return workflow.steps.map((step, index) => ({\n id: step.name || `step-${index}`,\n type: 'stepNode',\n position: step.position || { x: 100 + index * 200, y: 100 },\n data: {\n label: step.name || 'Unnamed Step',\n stepType: step.type,\n color: step.visual?.color || '#3b82f6',\n icon: step.visual?.icon,\n dependencies: step.dependencies || []\n }\n }))\n }, [workflow?.steps])\n\n // Convert dependencies to React Flow edges\n const initialEdges: Edge[] = useMemo(() => {\n if (!workflow?.steps) return []\n\n const edges: Edge[] = []\n \n workflow.steps.forEach((step, index) => {\n const targetId = step.name || `step-${index}`\n \n if (step.dependencies) {\n step.dependencies.forEach((depName) => {\n // Find the source step\n const sourceStep = workflow.steps?.find(s => s.name === depName)\n if (sourceStep) {\n const sourceId = sourceStep.name || `step-${workflow.steps?.indexOf(sourceStep)}`\n edges.push({\n id: `${sourceId}-${targetId}`,\n source: sourceId,\n target: targetId,\n type: 'smoothstep'\n })\n }\n })\n }\n })\n\n return edges\n }, [workflow?.steps])\n\n const [nodes, setNodes, onNodesChange] = useNodesState(initialNodes)\n const [edges, setEdges, onEdgesChange] = useEdgesState(initialEdges)\n\n // Handle new connections\n const onConnect = useCallback((params: Connection) => {\n if (readonly) return\n \n setEdges((eds) => addEdge({\n ...params,\n type: 'smoothstep'\n }, eds))\n }, [setEdges, readonly])\n\n // Handle node selection\n const onNodeClick = useCallback((_event: React.MouseEvent, node: Node) => {\n console.log('Node clicked:', node.id, node.data.label)\n setSelectedNode(node)\n }, [])\n\n // Handle adding new step\n const onAddStep = useCallback((stepType: string) => {\n if (readonly) return\n\n const newStep: Node = {\n id: `step-${Date.now()}`,\n type: 'stepNode',\n position: { x: 100, y: 100 },\n data: {\n label: 'New Step',\n stepType,\n color: '#3b82f6',\n dependencies: []\n }\n }\n\n setNodes((nds) => [...nds, newStep])\n }, [setNodes, readonly])\n\n // Handle updating a node's data\n const handleNodeUpdate = useCallback((nodeId: string, newData: Partial<Node['data']>) => {\n setNodes((nds) => \n nds.map((node) => \n node.id === nodeId \n ? { ...node, data: { ...node.data, ...newData } }\n : node\n )\n )\n }, [setNodes])\n\n // Handle saving workflow\n const handleSave = useCallback(() => {\n if (!workflow || !onSave) return\n\n // Convert nodes and edges back to workflow format\n const updatedSteps = nodes.map((node) => {\n // Find dependencies from edges\n const dependencies = edges\n .filter(edge => edge.target === node.id)\n .map(edge => edge.source)\n\n return {\n name: node.id,\n type: node.data.stepType as string,\n position: node.position,\n visual: {\n color: node.data.color as string,\n icon: node.data.icon as string\n },\n dependencies: dependencies.length > 0 ? dependencies : undefined\n }\n })\n\n const updatedWorkflow: WorkflowData = {\n ...workflow,\n steps: updatedSteps\n }\n\n onSave(updatedWorkflow)\n }, [workflow, nodes, edges, onSave])\n\n return (\n <div style={{ \n width: '100%', \n height: '600px',\n display: 'flex',\n background: 'var(--theme-bg)',\n borderRadius: '4px',\n border: '1px solid var(--theme-elevation-100)'\n }}>\n {/* Main canvas area */}\n <div style={{ \n flex: selectedNode ? '1 1 70%' : '1 1 100%',\n transition: 'flex 0.3s ease'\n }}>\n <ReactFlow\n nodes={nodes}\n edges={edges}\n onNodesChange={onNodesChange}\n onEdgesChange={onEdgesChange}\n onConnect={onConnect}\n onNodeClick={onNodeClick}\n nodeTypes={nodeTypes}\n fitView\n attributionPosition=\"top-right\"\n >\n <Controls />\n <MiniMap />\n <Background variant={BackgroundVariant.Dots} gap={12} size={1} />\n \n {!readonly && (\n <Panel position=\"top-left\">\n <WorkflowToolbar \n availableStepTypes={availableStepTypes}\n onAddStep={onAddStep}\n onSave={handleSave}\n />\n </Panel>\n )}\n </ReactFlow>\n </div>\n\n {/* Side panel for step configuration */}\n {selectedNode && !readonly && (\n <div style={{\n flex: '0 0 30%',\n borderLeft: '1px solid var(--theme-elevation-100)',\n background: 'var(--theme-elevation-0)',\n display: 'flex',\n flexDirection: 'column'\n }}>\n <StepConfigurationForm\n selectedNode={selectedNode}\n availableStepTypes={availableStepTypes}\n availableSteps={nodes.map(node => node.id)}\n onNodeUpdate={handleNodeUpdate}\n onClose={() => setSelectedNode(null)}\n />\n </div>\n )}\n </div>\n )\n}"],"names":["React","useCallback","useMemo","useState","ReactFlow","addEdge","useNodesState","useEdgesState","Controls","Background","BackgroundVariant","MiniMap","Panel","StepNode","WorkflowToolbar","StepConfigurationForm","nodeTypes","stepNode","WorkflowBuilder","workflow","availableStepTypes","onSave","readonly","selectedNode","setSelectedNode","initialNodes","steps","map","step","index","id","name","type","position","x","y","data","label","stepType","color","visual","icon","dependencies","initialEdges","edges","forEach","targetId","depName","sourceStep","find","s","sourceId","indexOf","push","source","target","nodes","setNodes","onNodesChange","setEdges","onEdgesChange","onConnect","params","eds","onNodeClick","_event","node","console","log","onAddStep","newStep","Date","now","nds","handleNodeUpdate","nodeId","newData","handleSave","updatedSteps","filter","edge","length","undefined","updatedWorkflow","div","style","width","height","display","background","borderRadius","border","flex","transition","fitView","attributionPosition","variant","Dots","gap","size","borderLeft","flexDirection","availableSteps","onNodeUpdate","onClose"],"mappings":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,GAAG;QAAChE;QAAUqC;QAAOZ;QAAOvB;KAAO;IAEnC,qBACE,MAAC+D;QAAIC,OAAO;YACVC,OAAO;YACPC,QAAQ;YACRC,SAAS;YACTC,YAAY;YACZC,cAAc;YACdC,QAAQ;QACV;;0BAEE,KAACP;gBAAIC,OAAO;oBACVO,MAAMrE,eAAe,YAAY;oBACjCsE,YAAY;gBACd;0BACE,cAAA,MAACzF;oBACCoD,OAAOA;oBACPZ,OAAOA;oBACPc,eAAeA;oBACfE,eAAeA;oBACfC,WAAWA;oBACXG,aAAaA;oBACbhD,WAAWA;oBACX8E,OAAO;oBACPC,qBAAoB;;sCAEpB,KAACvF;sCACD,KAACG;sCACD,KAACF;4BAAWuF,SAAStF,kBAAkBuF,IAAI;4BAAEC,KAAK;4BAAIC,MAAM;;wBAE3D,CAAC7E,0BACA,KAACV;4BAAMqB,UAAS;sCACd,cAAA,KAACnB;gCACCM,oBAAoBA;gCACpBiD,WAAWA;gCACXhD,QAAQwD;;;;;;YAQjBtD,gBAAgB,CAACD,0BAChB,KAAC8D;gBAAIC,OAAO;oBACVO,MAAM;oBACNQ,YAAY;oBACZX,YAAY;oBACZD,SAAS;oBACTa,eAAe;gBACjB;0BACE,cAAA,KAACtF;oBACCQ,cAAcA;oBACdH,oBAAoBA;oBACpBkF,gBAAgB9C,MAAM7B,GAAG,CAACuC,CAAAA,OAAQA,KAAKpC,EAAE;oBACzCyE,cAAc7B;oBACd8B,SAAS,IAAMhF,gBAAgB;;;;;AAM3C,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../../src/components/WorkflowBuilder/WorkflowBuilder.tsx"],"sourcesContent":["'use client'\n\nimport React, { useCallback, useMemo, useState } from 'react'\nimport { \n ReactFlow,\n Node,\n Edge,\n addEdge,\n Connection,\n useNodesState,\n useEdgesState,\n Controls,\n Background,\n BackgroundVariant,\n MiniMap,\n Panel\n} from '@xyflow/react'\nimport '@xyflow/react/dist/style.css'\n\n// Import custom node types\nimport { StepNode } from './nodes/StepNode.js'\nimport { WorkflowToolbar } from './WorkflowToolbar.js'\nimport { StepConfigurationForm } from './StepConfigurationForm.js'\n\n// Define node types for React Flow\nconst nodeTypes = {\n stepNode: StepNode,\n}\n\ninterface WorkflowData {\n id: string\n name: string\n steps?: Array<{\n name: string\n type: string\n position?: { x: number; y: number }\n visual?: { color?: string; icon?: string }\n dependencies?: string[]\n }>\n layout?: {\n viewport?: { x: number; y: number; zoom: number }\n }\n}\n\ninterface StepType {\n slug: string\n label?: string\n inputSchema?: any[]\n outputSchema?: any[]\n}\n\ninterface WorkflowBuilderProps {\n workflow?: WorkflowData\n availableStepTypes?: StepType[]\n onSave?: (workflow: WorkflowData) => void\n readonly?: boolean\n}\n\nexport const WorkflowBuilder: React.FC<WorkflowBuilderProps> = ({\n workflow,\n availableStepTypes = [],\n onSave,\n readonly = false\n}) => {\n const [selectedNode, setSelectedNode] = useState<Node | null>(null)\n\n // Convert workflow steps to React Flow nodes\n const initialNodes: Node[] = useMemo(() => {\n if (!workflow?.steps) return []\n\n return workflow.steps.map((step, index) => ({\n id: step.name || `step-${index}`,\n type: 'stepNode',\n position: step.position || { x: 100 + index * 200, y: 100 },\n data: {\n label: step.name || 'Unnamed Step',\n stepType: step.type,\n color: step.visual?.color || '#3b82f6',\n icon: step.visual?.icon,\n dependencies: step.dependencies || []\n }\n }))\n }, [workflow?.steps])\n\n // Convert dependencies to React Flow edges\n const initialEdges: Edge[] = useMemo(() => {\n if (!workflow?.steps) return []\n\n const edges: Edge[] = []\n \n workflow.steps.forEach((step, index) => {\n const targetId = step.name || `step-${index}`\n \n if (step.dependencies) {\n step.dependencies.forEach((depName) => {\n // Find the source step\n const sourceStep = workflow.steps?.find(s => s.name === depName)\n if (sourceStep) {\n const sourceId = sourceStep.name || `step-${workflow.steps?.indexOf(sourceStep)}`\n edges.push({\n id: `${sourceId}-${targetId}`,\n source: sourceId,\n target: targetId,\n type: 'smoothstep'\n })\n }\n })\n }\n })\n\n return edges\n }, [workflow?.steps])\n\n const [nodes, setNodes, onNodesChange] = useNodesState(initialNodes)\n const [edges, setEdges, onEdgesChange] = useEdgesState(initialEdges)\n\n // Handle new connections\n const onConnect = useCallback((params: Connection) => {\n if (readonly) return\n \n setEdges((eds: Edge[]) => addEdge({\n ...params,\n type: 'smoothstep'\n }, eds))\n }, [setEdges, readonly])\n\n // Handle node selection\n const onNodeClick = useCallback((_event: React.MouseEvent, node: Node) => {\n console.log('Node clicked:', node.id, node.data.label)\n setSelectedNode(node)\n }, [])\n\n // Handle adding new step\n const onAddStep = useCallback((stepType: string) => {\n if (readonly) return\n\n const newStep: Node = {\n id: `step-${Date.now()}`,\n type: 'stepNode',\n position: { x: 100, y: 100 },\n data: {\n label: 'New Step',\n stepType,\n color: '#3b82f6',\n dependencies: []\n }\n }\n\n setNodes((nds: Node[]) => [...nds, newStep])\n }, [setNodes, readonly])\n\n // Handle updating a node's data\n const handleNodeUpdate = useCallback((nodeId: string, newData: Partial<Node['data']>) => {\n setNodes((nds: Node[]) =>\n nds.map((node: Node) =>\n node.id === nodeId\n ? { ...node, data: { ...node.data, ...newData } }\n : node\n )\n )\n }, [setNodes])\n\n // Handle saving workflow\n const handleSave = useCallback(() => {\n if (!workflow || !onSave) return\n\n // Convert nodes and edges back to workflow format\n const updatedSteps = nodes.map((node: Node) => {\n // Find dependencies from edges\n const dependencies = edges\n .filter((edge: Edge) => edge.target === node.id)\n .map((edge: Edge) => edge.source)\n\n return {\n name: node.id,\n type: node.data.stepType as string,\n position: node.position,\n visual: {\n color: node.data.color as string,\n icon: node.data.icon as string\n },\n dependencies: dependencies.length > 0 ? dependencies : undefined\n }\n })\n\n const updatedWorkflow: WorkflowData = {\n ...workflow,\n steps: updatedSteps\n }\n\n onSave(updatedWorkflow)\n }, [workflow, nodes, edges, onSave])\n\n return (\n <div style={{ \n width: '100%', \n height: '600px',\n display: 'flex',\n background: 'var(--theme-bg)',\n borderRadius: '4px',\n border: '1px solid var(--theme-elevation-100)'\n }}>\n {/* Main canvas area */}\n <div style={{ \n flex: selectedNode ? '1 1 70%' : '1 1 100%',\n transition: 'flex 0.3s ease'\n }}>\n <ReactFlow\n nodes={nodes}\n edges={edges}\n onNodesChange={onNodesChange}\n onEdgesChange={onEdgesChange}\n onConnect={onConnect}\n onNodeClick={onNodeClick}\n nodeTypes={nodeTypes}\n fitView\n attributionPosition=\"top-right\"\n >\n <Controls />\n <MiniMap />\n <Background variant={BackgroundVariant.Dots} gap={12} size={1} />\n \n {!readonly && (\n <Panel position=\"top-left\">\n <WorkflowToolbar \n availableStepTypes={availableStepTypes}\n onAddStep={onAddStep}\n onSave={handleSave}\n />\n </Panel>\n )}\n </ReactFlow>\n </div>\n\n {/* Side panel for step configuration */}\n {selectedNode && !readonly && (\n <div style={{\n flex: '0 0 30%',\n borderLeft: '1px solid var(--theme-elevation-100)',\n background: 'var(--theme-elevation-0)',\n display: 'flex',\n flexDirection: 'column'\n }}>\n <StepConfigurationForm\n selectedNode={selectedNode}\n availableStepTypes={availableStepTypes}\n availableSteps={nodes.map((node: Node) => node.id)}\n onNodeUpdate={handleNodeUpdate}\n onClose={() => setSelectedNode(null)}\n />\n </div>\n )}\n </div>\n )\n}"],"names":["React","useCallback","useMemo","useState","ReactFlow","addEdge","useNodesState","useEdgesState","Controls","Background","BackgroundVariant","MiniMap","Panel","StepNode","WorkflowToolbar","StepConfigurationForm","nodeTypes","stepNode","WorkflowBuilder","workflow","availableStepTypes","onSave","readonly","selectedNode","setSelectedNode","initialNodes","steps","map","step","index","id","name","type","position","x","y","data","label","stepType","color","visual","icon","dependencies","initialEdges","edges","forEach","targetId","depName","sourceStep","find","s","sourceId","indexOf","push","source","target","nodes","setNodes","onNodesChange","setEdges","onEdgesChange","onConnect","params","eds","onNodeClick","_event","node","console","log","onAddStep","newStep","Date","now","nds","handleNodeUpdate","nodeId","newData","handleSave","updatedSteps","filter","edge","length","undefined","updatedWorkflow","div","style","width","height","display","background","borderRadius","border","flex","transition","fitView","attributionPosition","variant","Dots","gap","size","border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;YACXO,OAAOoD;QACT;QAEAzD,OAAO8D;IACT,GAAG;QAAChE;QAAUqC;QAAOZ;QAAOvB;KAAO;IAEnC,qBACE,MAAC+D;QAAIC,OAAO;YACVC,OAAO;YACPC,QAAQ;YACRC,SAAS;YACTC,YAAY;YACZC,cAAc;YACdC,QAAQ;QACV;;0BAEE,KAACP;gBAAIC,OAAO;oBACVO,MAAMrE,eAAe,YAAY;oBACjCsE,YAAY;gBACd;0BACE,cAAA,MAACzF;oBACCoD,OAAOA;oBACPZ,OAAOA;oBACPc,eAAeA;oBACfE,eAAeA;oBACfC,WAAWA;oBACXG,aAAaA;oBACbhD,WAAWA;oBACX8E,OAAO;oBACPC,qBAAoB;;sCAEpB,KAACvF;sCACD,KAACG;sCACD,KAACF;4BAAWuF,SAAStF,kBAAkBuF,IAAI;4BAAEC,KAAK;4BAAIC,MAAM;;wBAE3D,CAAC7E,0BACA,KAACV;4BAAMqB,UAAS;sCACd,cAAA,KAACnB;gCACCM,oBAAoBA;gCACpBiD,WAAWA;gCACXhD,QAAQwD;;;;;;YAQjBtD,gBAAgB,CAACD,0BAChB,KAAC8D;gBAAIC,OAAO;oBACVO,MAAM;oBACNQ,YAAY;oBACZX,YAAY;oBACZD,SAAS;oBACTa,eAAe;gBACjB;0BACE,cAAA,KAACtF;oBACCQ,cAAcA;oBACdH,oBAAoBA;oBACpBkF,gBAAgB9C,MAAM7B,GAAG,CAAC,CAACuC,OAAeA,KAAKpC,EAAE;oBACjDyE,cAAc7B;oBACd8B,SAAS,IAAMhF,gBAAgB;;;;;AAM3C,EAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Expression engine using JSONata for safe, sandboxed expression evaluation.
|
|
3
|
+
* Used for both conditions and data transformation in workflows.
|
|
4
|
+
*
|
|
5
|
+
* @example Conditions
|
|
6
|
+
* ```
|
|
7
|
+
* trigger.doc._status = "published"
|
|
8
|
+
* trigger.doc.count > 10 and trigger.doc.enabled
|
|
9
|
+
* $exists(steps.validate.output.error) = false
|
|
10
|
+
* ```
|
|
11
|
+
*
|
|
12
|
+
* @example Data Transformation
|
|
13
|
+
* ```
|
|
14
|
+
* {
|
|
15
|
+
* "id": trigger.doc.id,
|
|
16
|
+
* "title": $uppercase(trigger.doc.title),
|
|
17
|
+
* "tags": trigger.doc.tags[category = "featured"].name
|
|
18
|
+
* }
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export interface ExpressionContext {
|
|
22
|
+
trigger: Record<string, unknown>;
|
|
23
|
+
steps: Record<string, unknown>;
|
|
24
|
+
[key: string]: unknown;
|
|
25
|
+
}
|
|
26
|
+
export interface EvaluateOptions {
|
|
27
|
+
/** Timeout in milliseconds (default: 5000) */
|
|
28
|
+
timeout?: number;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Evaluate a JSONata expression against a context
|
|
32
|
+
*/
|
|
33
|
+
export declare function evaluate(expression: string, context: ExpressionContext, options?: EvaluateOptions): Promise<unknown>;
|
|
34
|
+
/**
|
|
35
|
+
* Evaluate a condition expression and return a boolean
|
|
36
|
+
*/
|
|
37
|
+
export declare function evaluateCondition(expression: string, context: ExpressionContext, options?: EvaluateOptions): Promise<boolean>;
|
|
38
|
+
/**
|
|
39
|
+
* Transform data using a JSONata expression
|
|
40
|
+
* The expression can be a JSONata query or a JSON object with embedded expressions
|
|
41
|
+
*/
|
|
42
|
+
export declare function transform(template: unknown, context: ExpressionContext, options?: EvaluateOptions): Promise<unknown>;
|
|
43
|
+
/**
|
|
44
|
+
* Resolve a step input configuration using JSONata
|
|
45
|
+
* Handles both simple values and expressions
|
|
46
|
+
*/
|
|
47
|
+
export declare function resolveStepInput(config: Record<string, unknown>, context: ExpressionContext, options?: EvaluateOptions): Promise<Record<string, unknown>>;
|
|
48
|
+
/**
|
|
49
|
+
* Clear the expression cache
|
|
50
|
+
*/
|
|
51
|
+
export declare function clearCache(): void;
|
|
52
|
+
/**
|
|
53
|
+
* Get cache statistics
|
|
54
|
+
*/
|
|
55
|
+
export declare function getCacheStats(): {
|
|
56
|
+
size: number;
|
|
57
|
+
maxSize: number;
|
|
58
|
+
};
|