Skip to content

Commit e62f5b9

Browse files
committed
Enhance documentation
1 parent c1d8944 commit e62f5b9

4 files changed

Lines changed: 44 additions & 1 deletion

File tree

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ You write the topology; the engine handles the execution.
2323

2424
### Why a language instead of code?
2525

26-
- **Zero Orchestration Boilerplate:** The engine inherently knows which tools can run concurrently. No manual `Promise.all` or batching logic required.
26+
- **Zero Orchestration Boilerplate:** The engine inherently knows which tools can run concurrently. No manual `Promise.all`, DataLoader plumbing, or batching glue required.
2727
- **Separation of Concerns:** Keep your core business logic inside isolated TypeScript tools, completely separate from your routing, mapping, and orchestration logic.
2828
- **Safe for LLM Automation:** Because The Bridge is a strictly declarative, constrained dataflow language, it is much safer for AI generation than general-purpose code. You can confidently let an LLM wire up your API mappings without the risk of it hallucinating infinite loops, memory leaks, or rogue system calls.
2929
- **Hot-Reloadable Logic:** Since `.bridge` files are just text parsed into an execution graph, you don't need to recompile, rebuild, or redeploy your entire Node application to change a data mapping or swap an API provider. You can update and hot-reload your rules on the fly.
@@ -40,6 +40,11 @@ Because The Bridge strictly controls how data flows from inputs to tools to outp
4040
1. **[The Rule Engine / Policy Evaluator](https://bridge.sdk42.com/guides/rule-engine/)**
4141
Encapsulate complex conditional business logic and data enrichment into a single, highly readable file that returns a boolean. Perfect for authorization checks or fraud detection flows.
4242

43+
### Feature Highlights
44+
45+
- **Human-Readable Runtime Errors:** `formatBridgeError(err)` renders Rust-style source snippets with filename, line/column, and carets pointing at the failing wire.
46+
- **Native DataLoader Pattern:** Mark a custom tool with `bridge.batch` and Bridge batches loop-scoped calls automatically in both the interpreter and the compiler.
47+
4348
## The Playground
4449

4550
Try The Bridge instantly in your browser at **[https://bridge.sdk42.com/playground/](https://bridge.sdk42.com/playground/)**
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,93 @@
1+
import type { ToolMetadata } from "@stackables/bridge-types";
2+
3+
const syncUtility = {
4+
sync: true,
5+
trace: false,
6+
} satisfies ToolMetadata;
7+
18
/** Add two numbers. Returns `a + b`. */
29
export function add(opts: { a: number; b: number }): number {
310
return Number(opts.a) + Number(opts.b);
411
}
12+
add.bridge = syncUtility;
13+
514
/** Subtract two numbers. Returns `a - b`. */
615
export function subtract(opts: { a: number; b: number }): number {
716
return Number(opts.a) - Number(opts.b);
817
}
18+
subtract.bridge = syncUtility;
19+
920
/** Multiply two numbers. Returns `a * b`. */
1021
export function multiply(opts: { a: number; b: number }): number {
1122
return Number(opts.a) * Number(opts.b);
1223
}
24+
multiply.bridge = syncUtility;
25+
1326
/** Divide two numbers. Returns `a / b`. */
1427
export function divide(opts: { a: number; b: number }): number {
1528
return Number(opts.a) / Number(opts.b);
1629
}
30+
divide.bridge = syncUtility;
31+
1732
/** Strict equality. Returns `true` if `a === b`, `false` otherwise. */
1833
export function eq(opts: { a: any; b: any }): boolean {
1934
return opts.a === opts.b;
2035
}
36+
eq.bridge = syncUtility;
37+
2138
/** Strict inequality. Returns `true` if `a !== b`, `false` otherwise. */
2239
export function neq(opts: { a: any; b: any }): boolean {
2340
return opts.a !== opts.b;
2441
}
42+
neq.bridge = syncUtility;
43+
2544
/** Greater than. Returns `true` if `a > b`, `false` otherwise. */
2645
export function gt(opts: { a: number; b: number }): boolean {
2746
return Number(opts.a) > Number(opts.b);
2847
}
48+
gt.bridge = syncUtility;
49+
2950
/** Greater than or equal. Returns `true` if `a >= b`, `false` otherwise. */
3051
export function gte(opts: { a: number; b: number }): boolean {
3152
return Number(opts.a) >= Number(opts.b);
3253
}
54+
gte.bridge = syncUtility;
55+
3356
/** Less than. Returns `true` if `a < b`, `false` otherwise. */
3457
export function lt(opts: { a: number; b: number }): boolean {
3558
return Number(opts.a) < Number(opts.b);
3659
}
60+
lt.bridge = syncUtility;
61+
3762
/** Less than or equal. Returns `true` if `a <= b`, `false` otherwise. */
3863
export function lte(opts: { a: number; b: number }): boolean {
3964
return Number(opts.a) <= Number(opts.b);
4065
}
66+
lte.bridge = syncUtility;
67+
4168
/** Logical NOT. Returns `true` if `a` is falsy. */
4269
export function not(opts: { a: any }): boolean {
4370
return !opts.a;
4471
}
72+
not.bridge = syncUtility;
73+
4574
/** Logical AND. Returns `true` if both `a` and `b` are truthy. */
4675
export function and(opts: { a: any; b: any }): boolean {
4776
return Boolean(opts.a) && Boolean(opts.b);
4877
}
78+
and.bridge = syncUtility;
79+
4980
/** Logical OR. Returns `true` if either `a` or `b` is truthy. */
5081
export function or(opts: { a: any; b: any }): boolean {
5182
return Boolean(opts.a) || Boolean(opts.b);
5283
}
84+
or.bridge = syncUtility;
85+
5386
/** String concatenation. Joins all parts into a single string. */
5487
export function concat(opts: { parts: unknown[] }): { value: string } {
5588
const result = (opts.parts ?? [])
5689
.map((v) => (v == null ? "" : String(v)))
5790
.join("");
5891
return { value: result };
5992
}
93+
concat.bridge = syncUtility;

packages/docs-site/src/content/docs/index.mdx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ bridge Query.should_i_go_outside {
6161
### Why a language instead of code?
6262

6363
- **Zero Orchestration Boilerplate:** The engine inherently knows which tools can run concurrently. No manual `Promise.all` or batching logic required.
64+
- **Readable Failures:** Runtime errors can be rendered as Rust-style source snippets with filename, line/column, and carets pointing at the exact failing wire.
65+
- **Native DataLoader:** Custom tools can opt into built-in batching, so list resolvers avoid N+1 calls without manual DataLoader plumbing.
6466
- **Separation of Concerns:** Keep your core business logic inside isolated TypeScript tools, completely separate from your routing, mapping, and orchestration logic.
6567
- **Safe for LLM Automation:** Because The Bridge is a strictly declarative, constrained dataflow language, it is much safer for AI generation than general-purpose code. You can confidently let an LLM wire up your API mappings without the risk of it hallucinating infinite loops, memory leaks, or rogue system calls.
6668
- **Hot-Reloadable Logic:** Since `.bridge` files are just text parsed into an execution graph, you don't need to recompile, rebuild, or redeploy your entire Node application to change a data mapping or swap an API provider. You can update and hot-reload your rules on the fly.

packages/docs-site/src/content/docs/reference/summary.mdx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ _Zero-allocation iteration using native JavaScript loops._
5151
| **Nested Control Flow** | `break 1`/`continue 2` scopes correctly in sub-arrays |
5252
| **Interpolation in arrays** | `o <- items[] as it { .url <- "/items/{it.id}" }` |
5353
| **Null array preservation** | If source is `null`, output is `null` (not `[]`) |
54+
| **Native batching** | `fetchUsers.bridge = { batch: true }` | Built-in DataLoader-style batching for loop-scoped tool calls |
5455

5556
### 4. Error Handling & Control Flow
5657

@@ -87,3 +88,4 @@ _Under-the-hood engine features that ensure stability and performance._
8788
| **Cycle Detection** | Compile-time detection of circular tool dependencies (Kahn's algorithm) throws an immediate initialization error. |
8889
| **Abort Signals** | Pre-tool `signal.aborted` checks throw `BridgeAbortError`, which safely bypasses standard `catch` blocks. |
8990
| **Telemetry Injection** | Automatically passes `{ logger, signal }` via `ctx` to custom tool functions. |
91+
| **Human-readable errors** | `formatBridgeError(err)` renders filename, line/column, and a careted source snippet for runtime failures. |

0 commit comments

Comments
 (0)