Skip to content

Commit 944b18b

Browse files
mpywclaude
andcommitted
docs: add shorthand syntax examples to SCHEMA.md
- global_helpers: string shorthand for inline JS - post (type: many): string shorthand for all transform Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 163886f commit 944b18b

1 file changed

Lines changed: 16 additions & 4 deletions

File tree

SCHEMA.md

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,11 @@ dsn: postgres://${DB_USER}:${DB_PASSWORD}@${DB_HOST:-localhost}:${DB_PORT:-5432}
6767
JavaScript functions available in all [`pre`](#pre-transform), [`post`](#post-transform) transforms, [mock JS sources](#mock-js-variables), [`filter`](#filter), and [`csv.value_parser`](#csv-config).
6868

6969
```yaml
70-
# Full form
70+
# Shorthand (inline JS only)
71+
global_helpers: |
72+
function validate(x) { ... }
73+
74+
# Full form (with js_files)
7175
global_helpers:
7276
js: |
7377
function validate(x) { ... }
@@ -80,6 +84,8 @@ global_helpers:
8084
| `js` | string | Inline JavaScript code |
8185
| `js_files` | string[] | Paths to JavaScript files (relative to config) |
8286

87+
> **Shorthand:** `global_helpers: |` is equivalent to `global_helpers: { js: | }`
88+
8389
## CSV Config
8490

8591
Custom value parsing for CSV [mock](#mock) data.
@@ -405,24 +411,30 @@ post: |
405411
**For type: many:**
406412

407413
```yaml
408-
# Each row
414+
# Shorthand: transform entire array
415+
post: |
416+
return { data: output, count: output.length };
417+
418+
# Full form: each row only
409419
post:
410420
each: |
411421
return { ...output, processed: true };
412422
413-
# Entire array
423+
# Full form: entire array only
414424
post:
415425
all: |
416426
return { data: output, count: output.length };
417427
418-
# Both (each runs first)
428+
# Full form: both (each runs first, then all)
419429
post:
420430
each: |
421431
return { ...output, upper: output.name.toUpperCase() };
422432
all: |
423433
return { items: output };
424434
```
425435

436+
> **Shorthand:** `post: |` is equivalent to `post: { all: | }`
437+
426438
## Error Handling
427439

428440
Throw an object with `status` and `body` in any [transform](#transform):

0 commit comments

Comments
 (0)