|
| 1 | +--- |
| 2 | +title: Summary |
| 3 | +description: An overview of the key features and capabilities of the Bridge language, organized by category. |
| 4 | +--- |
| 5 | + |
| 6 | +### 1. Data Routing & Logic |
| 7 | + |
| 8 | +*The core primitives for mapping data from tools to the output.* |
| 9 | + |
| 10 | +| Feature | Example | |
| 11 | +| --- | --- | |
| 12 | +| **Pull wires** (`<-`) | `out.name <- api.name` | |
| 13 | +| **Constant wires** (`=`) | `api.method = "GET"` | |
| 14 | +| **Nullish coalescing** (`??`) | `out.x <- api.x ?? "default"` | |
| 15 | +| **Falsy fallback** (`\|\|`) | `out.x <- api.x \|\| backup.x` | |
| 16 | +| **Conditional (Ternary)** | `api.mode <- i.premium ? "full" : "basic"` | |
| 17 | +| **Lazy Evaluation** | Only the chosen branch in a ternary is executed | |
| 18 | +| **Overdefinition** | Multiple wires to the same target (`o.x <- a` and `o.x <- b`) resolve as first non-null wins | |
| 19 | +| **Root passthrough** | `o <- api` (maps the entire object) | |
| 20 | +| **Context access** | `api.token <- ctx.apiKey` | |
| 21 | + |
| 22 | +### 2. Variables & Expressions |
| 23 | + |
| 24 | +*Tools for data manipulation and code organization.* |
| 25 | + |
| 26 | +| Feature | Example | |
| 27 | +| --- | --- | |
| 28 | +| **`alias` declarations** | `alias api.result.data as d` | |
| 29 | +| **Safe-exec aliases** (`?.`) | `alias api?.value as safeVal` | |
| 30 | +| **Alias fallbacks** | `alias (expr) ? val : null ?? panic "msg" as x` | |
| 31 | +| **Math / Comparison** | `o.total <- i.price * i.qty`, `o.isAdult <- i.age >= 18` | |
| 32 | +| **String interpolation** | `o.msg <- "Hello, {i.name}!"` | |
| 33 | +| **Pipe operators** | `o.loud <- tu:i.text` | |
| 34 | +| **`const` blocks** | `const geo = { "lat": 0 }` (Inlined at compile time) | |
| 35 | +| **`define` blocks** | `define profile { ... }` (Virtual containers) | |
| 36 | + |
| 37 | +### 3. Array Processing |
| 38 | + |
| 39 | +*Zero-allocation iteration using native JavaScript loops.* |
| 40 | + |
| 41 | +| Feature | Example | |
| 42 | +| --- | --- | |
| 43 | +| **Array mapping** | `out.items <- api.list[] as el { .id <- el.id }` | |
| 44 | +| **Nested arrays** | `o <- items[] as i { .sub <- i.list[] as j { ... } }` | |
| 45 | +| **Array Control Flow** | `item.name ?? break`, `item.name ?? continue` | |
| 46 | +| **Nested Control Flow** | `break 1`/`continue 2` scopes correctly in sub-arrays | |
| 47 | +| **Interpolation in arrays** | `o <- items[] as it { .url <- "/items/{it.id}" }` | |
| 48 | +| **Null array preservation** | If source is `null`, output is `null` (not `[]`) | |
| 49 | + |
| 50 | +### 4. Error Handling & Control Flow |
| 51 | + |
| 52 | +*Granular control over tool failures and execution halting.* |
| 53 | + |
| 54 | +| Feature | Example | |
| 55 | +| --- | --- | |
| 56 | +| **`catch` fallbacks** | `out.data <- api.result catch "fallback"` | |
| 57 | +| **`catch` ref fallbacks** | `out.data <- primary.val catch backup.val` | |
| 58 | +| **`throw`** | `o.name <- i.name \|\| throw "name is required"` | |
| 59 | +| **`panic` (Fatal)** | `o.name <- i.name ?? panic "fatal error"` (Bypasses catch) | |
| 60 | +| **`force` (Critical tool)** | `force audit` (Execution halts if tool fails) | |
| 61 | +| **`force catch null`** | `force ping catch null` (Fire-and-forget execution) | |
| 62 | + |
| 63 | +### 5. Tool Composition (`ToolDef`) |
| 64 | + |
| 65 | +*Reusable tool configurations defined in the schema.* |
| 66 | + |
| 67 | +| Feature | Example | |
| 68 | +| --- | --- | |
| 69 | +| **Pre-wired Inputs** | `tool api from httpCall { .method = "GET" }` | |
| 70 | +| **Tool inheritance** | `tool childApi from parentApi { .path = "/v2" }` | |
| 71 | +| **Centralized `on error`** | `tool api from httpCall { on error = {...} }` | |
| 72 | +| **Override mechanics** | Bridge wires override ToolDef wires by key | |
| 73 | + |
| 74 | +### 6. Compiler & Runtime Guarantees |
| 75 | + |
| 76 | +*Under-the-hood engine features that ensure stability and performance.* |
| 77 | + |
| 78 | +| Feature | Description | |
| 79 | +| --- | --- | |
| 80 | +| **Dead-Code Elimination** | Unrequested GraphQL/Sparse fields are pruned; unneeded tools are mathematically excluded from the JIT compilation. | |
| 81 | +| **Tool Timeouts** | Automatic `Promise.race` with memory-leak prevention (`clearTimeout`) based on `toolTimeoutMs`. | |
| 82 | +| **Cycle Detection** | Compile-time detection of circular tool dependencies (Kahn's algorithm) throws an immediate initialization error. | |
| 83 | +| **Abort Signals** | Pre-tool `signal.aborted` checks throw `BridgeAbortError`, which safely bypasses standard `catch` blocks. | |
| 84 | +| **Telemetry Injection** | Automatically passes `{ logger, signal }` via `ctx` to custom tool functions. | |
| 85 | + |
0 commit comments