Automations editor:
- {{ }} expression autocomplete in CodeMirror, scoped to the braces and
graph-aware (suggests only what upstream nodes provide + variables + now);
migrate the Generate prompt to CodeMirror so it shares the same completions
- Expandable editors: an expand button slides out a side-by-side panel
(matching the sidebar card), with a minimize control; the inline field
collapses to a hint while editing in the panel
- Hover-revealed editor toolbar (expand/copy) with styled tooltips so the
buttons no longer obscure the text while reading
- Beta badge on the Automations sidebar item
- Delete a single connection with Backspace/Delete (edge selection)
- Re-key node config so switching between same-type nodes refreshes the form
HTTP fetch node — cover every JSON response shape:
- Top-level array, object map (items_path=*), array of primitives, and NDJSON
- Key-based dedup via item_key_path (seen-set, FIFO-capped) for feeds without
dates; first poll records a baseline and emits nothing (date path too)
Fan-out test visibility:
- root_run_id links every forked branch back to the run that started a test,
so the test panel aggregates all branches instead of one
Fix a few pre-existing type issues (ScheduleData import, padded minute,
optional created_at).
55 lines
1.4 KiB
PHP
55 lines
1.4 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Actions\Automation\Run;
|
|
|
|
use App\Enums\Automation\Run\Status;
|
|
use App\Models\Automation;
|
|
use App\Models\AutomationRun;
|
|
use App\Models\AutomationTriggerItem;
|
|
|
|
class DispatchAutomationRun
|
|
{
|
|
public function __construct(private AdvanceAutomationRun $advance) {}
|
|
|
|
public function __invoke(Automation $automation, AutomationTriggerItem $triggerItem): AutomationRun
|
|
{
|
|
$targets = $this->triggerTargets($automation);
|
|
|
|
$run = AutomationRun::create([
|
|
'automation_id' => $automation->id,
|
|
'trigger_item_id' => $triggerItem->id,
|
|
'status' => Status::Pending,
|
|
'context' => ['trigger' => $triggerItem->payload],
|
|
]);
|
|
|
|
if ($targets === []) {
|
|
$run->update([
|
|
'status' => Status::Failed,
|
|
'error' => ['message' => __('automations.errors.no_trigger_connection')],
|
|
'finished_at' => now(),
|
|
]);
|
|
|
|
return $run;
|
|
}
|
|
|
|
$this->advance->dispatchBranches($run, $targets);
|
|
|
|
return $run;
|
|
}
|
|
|
|
/**
|
|
* @return array<int, string>
|
|
*/
|
|
private function triggerTargets(Automation $automation): array
|
|
{
|
|
$triggerNode = collect($automation->nodes ?? [])->firstWhere('type', 'trigger');
|
|
|
|
if ($triggerNode === null) {
|
|
return [];
|
|
}
|
|
|
|
return $this->advance->targetsFor($automation, $triggerNode['id']);
|
|
}
|
|
}
|