# Entity Operations Nodes

Nodes for querying, loading, and saving Drupal entities (content, users, taxonomy terms, etc.).

---

## Entity Query

Queries Drupal entities with conditions, pagination, and sorting. Returns matching entity IDs and optionally loads full entity data.

**Category:** Entity Operations

### Configuration

| Parameter | Type | Required | Default | Description |
|-----------|------|----------|---------|-------------|
| **entity_type** | String | Yes | — | Entity type to query (e.g., `node`, `user`, `taxonomy_term`) |
| **bundle** | String | No | — | Filter by bundle (e.g., `article`, `page`) |
| **limit** | Number | No | 10 | Maximum results (1-1000) |
| **offset** | Number | No | 0 | Number of results to skip |
| **published_only** | Boolean | No | true | Only return published entities |
| **sort_field** | String | No | — | Field to sort by |
| **sort_direction** | String | No | `ASC` | Sort direction: `ASC` or `DESC` |
| **load_entities** | Boolean | No | false | Load full entity data (slower but more data) |
| **access_check** | Boolean | No | true | Respect Drupal access permissions |

### Input Ports

| Port | Type | Description |
|------|------|-------------|
| **conditions** | Array | Dynamic query conditions |
| **changed_after** | String | Only entities changed after this timestamp |

### Output Ports

| Port | Type | Description |
|------|------|-------------|
| **success** | Boolean | Whether the query executed successfully |
| **count** | Number | Number of results found |
| **ids** | Array | Array of matching entity IDs |
| **entities** | Array | Full entity data (when `load_entities` is true) |
| **results** | Array | Raw query results |
| **has_more** | Boolean | Whether there are more results beyond the limit |
| **entity_type** | String | The entity type queried |
| **bundle** | String | The bundle filter used |

---

## Entity Context

Loads a specific Drupal entity by its type and ID. Returns the full serialized entity with all fields.

**Category:** Entity Operations

### Configuration

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| **entity_type** | String | Yes | Entity type (e.g., `node`, `user`, `taxonomy_term`) |
| **entity_id** | Number | Yes | The entity ID to load |
| **bundle** | String | No | Expected bundle (for validation) |
| **revision_id** | Number | No | Load a specific revision |

### Output Ports

| Port | Type | Description |
|------|------|-------------|
| **entity** | Object | The full serialized entity data |
| **entity_type** | String | The entity type |
| **entity_id** | Number | The entity ID |
| **bundle** | String | The entity bundle |
| **revision_id** | Number | The revision ID |
| **is_default_revision** | Boolean | Whether this is the default revision |

---

## Entity Save

Creates a new entity or updates an existing one. Supports patch mode for partial updates.

**Category:** Entity Operations

### Configuration

| Parameter | Type | Required | Default | Description |
|-----------|------|----------|---------|-------------|
| **entity_type** | String | Yes | — | Entity type to create/update |
| **bundle** | String | For new | — | Bundle for new entities |
| **entity_id** | Number | For update | — | ID of entity to update (omit to create new) |
| **patch_mode** | Boolean | No | false | Only update provided fields (true) or replace all fields (false) |
| **new_revision** | Boolean | No | false | Create a new revision when updating |
| **revision_log_message** | String | No | — | Revision log message |
| **access_check** | Boolean | No | true | Respect Drupal access permissions |

### Input Ports

| Port | Type | Description |
|------|------|-------------|
| **values** | Object | Field values to set on the entity |
| **allowed_fields** | Array | Whitelist of fields that can be set |

### Output Ports

| Port | Type | Description |
|------|------|-------------|
| **entity_id** | Number | The saved entity's ID |
| **entity_type** | String | The entity type |
| **bundle** | String | The entity bundle |
| **is_new** | Boolean | Whether a new entity was created |
| **label** | String | The entity label |
| **entity** | Object | The full saved entity data |

---

## Get Workflow Data

Retrieves initial data that was passed to the workflow at execution time. Useful when workflows receive input from triggers or parent workflows.

**Category:** Entity Operations

### Configuration

| Parameter | Type | Description |
|-----------|------|-------------|
| **path** | String | Dot-notation or bracket-notation path to extract a specific value (e.g., `entity.title`) |
| **default_value** | Mixed | Default value if the path doesn't exist |

### Output Ports

| Port | Type | Description |
|------|------|-------------|
| **data** | Mixed | The extracted value, or the full initial data if no path is specified |
| **path** | String | The extraction path used |
| **exists** | Boolean | Whether the path was found in the data |
| **initial_data** | Mixed | The complete initial data object |
| **workflow_id** | String | The current workflow ID |
| **pipeline_id** | String | The current pipeline ID |
| **execution_id** | String | The current execution ID |
