> ## Documentation Index
> Fetch the complete documentation index at: https://docs.launchblitz.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Logic

> Conditional and branching nodes for Scrapist graphs.

### `logic.if` — If Condition

Branches execution based on a boolean.

**Inputs**

| Port        | Kind | Type      | Structure |
| ----------- | ---- | --------- | --------- |
| `exec-in`   | exec | —         | —         |
| `condition` | data | `boolean` | scalar    |

**Outputs**

| Port         | Kind | Notes                            |
| ------------ | ---- | -------------------------------- |
| `exec-true`  | exec | Selected when condition is true  |
| `exec-false` | exec | Selected when condition is false |

### `logic.optional.ifExists` — If Exists

Branches based on whether an optional value exists (non-null), and unwraps it.

**Inputs**

| Port             | Kind | Type      | Structure | Notes                                      |
| ---------------- | ---- | --------- | --------- | ------------------------------------------ |
| `exec-in`        | exec | —         | —         |                                            |
| `optional-value` | data | (generic) | (generic) | Optional input; `null` counts as “missing” |

**Outputs**

| Port          | Kind | Type      | Structure | Notes                           |
| ------------- | ---- | --------- | --------- | ------------------------------- |
| `exec-exists` | exec | —         | —         | Runs when value is non-null     |
| `exec-null`   | exec | —         | —         | Runs when value is null/missing |
| `value`       | data | (generic) | (generic) | Only set on the “exists” branch |

### `logic.compare` — Compare

Compares two values using an operator (configured via metadata).

**Inputs**

| Port    | Kind | Type      | Structure |
| ------- | ---- | --------- | --------- |
| `left`  | data | (generic) | (generic) |
| `right` | data | (generic) | (generic) |

**Outputs**

| Port     | Kind | Type      | Structure |
| -------- | ---- | --------- | --------- |
| `result` | data | `boolean` | scalar    |

Config notes:

* `operator` in node config supports: `==`, `!=`, `>`, `<`, `>=`, `<=`
* Numeric operators require numeric inputs (`integer`/`number`)

### `logic.and` — And

Logical AND of two booleans.

**Inputs**

| Port | Kind | Type      | Structure |
| ---- | ---- | --------- | --------- |
| `a`  | data | `boolean` | scalar    |
| `b`  | data | `boolean` | scalar    |

**Outputs**

| Port     | Kind | Type      | Structure |
| -------- | ---- | --------- | --------- |
| `result` | data | `boolean` | scalar    |

### `logic.or` — Or

Logical OR of two booleans.

**Inputs**

| Port | Kind | Type      | Structure |
| ---- | ---- | --------- | --------- |
| `a`  | data | `boolean` | scalar    |
| `b`  | data | `boolean` | scalar    |

**Outputs**

| Port     | Kind | Type      | Structure |
| -------- | ---- | --------- | --------- |
| `result` | data | `boolean` | scalar    |

### `logic.not` — Not

Logical NOT of a boolean.

**Inputs**

| Port    | Kind | Type      | Structure |
| ------- | ---- | --------- | --------- |
| `value` | data | `boolean` | scalar    |

**Outputs**

| Port     | Kind | Type      | Structure |
| -------- | ---- | --------- | --------- |
| `result` | data | `boolean` | scalar    |

### `logic.switch` — Switch

Branches execution based on a discrete case match.

**Inputs**

| Port      | Kind | Type      | Structure |
| --------- | ---- | --------- | --------- |
| `exec-in` | exec | —         | —         |
| `value`   | data | (generic) | scalar    |

**Outputs**

* `exec-default` (optional; can be removed if `includeDefault = false`)
* One exec output per configured case (port names are derived from case values)

Notes:

* First matching case wins; if no match and default is disabled, the node emits no exec output (flow ends).

Config:

* `cases` (array) — each entry becomes an exec output port (name derived from the case value)
* `includeDefault` (bool, default true) — controls whether `exec-default` exists and is used on no-match
