# FlowDrop Node Processor

Provides the plugin system and built-in processors for workflow node execution.

## Creating a Node Processor

Extend `AbstractFlowDropNodeProcessor` and annotate with `#[FlowDropNodeProcessor]`:

```php
use Drupal\flowdrop\Attribute\FlowDropNodeProcessor;
use Drupal\flowdrop\Plugin\FlowDropNodeProcessor\AbstractFlowDropNodeProcessor;
use Drupal\flowdrop\DTO\ParameterBagInterface;

#[FlowDropNodeProcessor(
  id: "my_processor",
  label: new TranslatableMarkup("My Processor"),
  description: "Does something useful",
  version: "1.0.0",
)]
class MyProcessor extends AbstractFlowDropNodeProcessor {

  public function process(ParameterBagInterface $params): array {
    $input = $params->getString('input_text');
    return ['output' => strtoupper($input)];
  }

  public function getParameterSchema(): array {
    return [
      'type' => 'object',
      'properties' => [
        'input_text' => ['type' => 'string', 'description' => 'Text input'],
      ],
    ];
  }

  public function getOutputSchema(): array {
    return [
      'type' => 'object',
      'properties' => [
        'output' => ['type' => 'string'],
      ],
    ];
  }
}
```

Plugin IDs are automatically namespaced as `{module}:{id}`.

## Plugin Interface

**`FlowDropNodeProcessorInterface`** (`\Drupal\flowdrop\Plugin\FlowDropNodeProcessor`)

| Method | Description |
|--------|-------------|
| `process(ParameterBagInterface $params): array` | Execute the node |
| `getParameterSchema(): array` | JSON Schema for input parameters |
| `getOutputSchema(): array` | JSON Schema for output structure |
| `validateParams(array $params): ValidationResult` | Validate before processing |

## Key DTOs

### ParameterBagInterface (`\Drupal\flowdrop\DTO`)

```php
$params->get('key', $default);
$params->getString('key');
$params->getInt('key');
$params->getBool('key');
$params->getArray('key');
$params->has('key'): bool;
$params->all(): array;
```

### ValidationResult (`\Drupal\flowdrop\DTO`)

```php
ValidationResult::success();
ValidationResult::failure($errors);
ValidationResult::error('param', 'message');
$result->isValid(): bool;
$result->getErrors(): array;
$result->merge($otherResult): self;
```

## Services

| Service ID | Description |
|------------|-------------|
| `flowdrop_node_processor.data_mapper` | Maps data between structures using PropertyAccessor |
| `flowdrop_node_processor.json_schema_validator` | Validates data against JSON Schema |

## Built-in Processors

The module includes 33+ processors across categories: data transformation, control flow, input/output, entity operations, HTTP, and utilities. All are `@internal`.
