Add subject data to automation editor registry
[MAILPOET-4946]
This commit is contained in:
@ -20,6 +20,27 @@ export type Registry = {
|
||||
};
|
||||
}
|
||||
>;
|
||||
subjects: Record<
|
||||
string,
|
||||
{
|
||||
key: string;
|
||||
name: string;
|
||||
args_schema: {
|
||||
type: 'object';
|
||||
properties?: Record<string, { type: string; default?: unknown }>;
|
||||
};
|
||||
field_keys: string[];
|
||||
}
|
||||
>;
|
||||
fields: Record<
|
||||
string,
|
||||
{
|
||||
key: string;
|
||||
type: 'string' | 'enum_array';
|
||||
name: string;
|
||||
args: Record<string, unknown>;
|
||||
}
|
||||
>;
|
||||
};
|
||||
|
||||
export type Context = Record<string, unknown>;
|
||||
|
@ -105,7 +105,34 @@ class AutomationEditor {
|
||||
'args_schema' => $step->getArgsSchema()->toArray(),
|
||||
];
|
||||
}
|
||||
return ['steps' => $steps];
|
||||
|
||||
$subjects = [];
|
||||
foreach ($this->registry->getSubjects() as $key => $subject) {
|
||||
$subjects[$key] = [
|
||||
'key' => $subject->getKey(),
|
||||
'name' => $subject->getName(),
|
||||
'args_schema' => $subject->getArgsSchema()->toArray(),
|
||||
'field_keys' => array_map(function ($field) {
|
||||
return $field->getKey();
|
||||
}, $subject->getFields()),
|
||||
];
|
||||
}
|
||||
|
||||
$fields = [];
|
||||
foreach ($this->registry->getFields() as $key => $field) {
|
||||
$fields[$key] = [
|
||||
'key' => $field->getKey(),
|
||||
'type' => $field->getType(),
|
||||
'name' => $field->getName(),
|
||||
'args' => $field->getArgs(),
|
||||
];
|
||||
}
|
||||
|
||||
return [
|
||||
'steps' => $steps,
|
||||
'subjects' => $subjects,
|
||||
'fields' => $fields,
|
||||
];
|
||||
}
|
||||
|
||||
private function buildContext(): array {
|
||||
|
Reference in New Issue
Block a user