Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .claude/skills/build-plugin/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,8 @@ my-plugin/
myStream.json
scripts/
myScript.js
errorHandling/
myStream.js # errorHandling scripts referenced by path, like postRequestScript
defaultContent/
manifest.json
scopes.json
Expand Down
16 changes: 14 additions & 2 deletions .claude/skills/build-plugin/references/data-streams.md
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,19 @@ The `paging` block in `config` controls how SquaredUp fetches multiple pages.
"errorHandling": { "type": "path", "realm": "payload", "path": "error.message" }

// Custom script β€” access response (.status, .body) and data
"errorHandling": { "type": "script", "script": "result = response.status + ': ' + data.error;" }
"errorHandling": { "type": "script", "script": "errorHandling/incidents.js" }
```

### Script files

Reference the script as a file β€” the same mechanism [`postRequestScript`](#post-request-scripts) uses. Place the file in `dataStreams/scripts/errorHandling/`, named after the stream's `name` field, and set `script` to its path relative to `dataStreams/scripts/` β€” **the `.js` extension is required** (a bare `.js` path with no newline is what marks the value as a file reference; deploy inlines the file's source, and an unresolvable reference is a validation error).

Script file (`dataStreams/scripts/errorHandling/incidents.js`) β€” `{{ ... }}` expressions work in script files too:

```javascript
const apiMsg = data && (data.message || data.error);

result = apiMsg || ('Request failed with HTTP ' + response.status);
```

---
Expand Down Expand Up @@ -736,7 +748,7 @@ Scripts run after the HTTP response is received. Input is `data` (parsed JSON bo

### Wiring a script to a stream

Set `postRequestScript` inside `config` to the script's filename β€” **the `.js` extension is required**. Name the file after the stream's `name` field and place it in `dataStreams/scripts/`.
Set `postRequestScript` inside `config` to the script's filename β€” **the `.js` extension is required**. Name the file after the stream's `name` field and place it in `dataStreams/scripts/`. ([errorHandling scripts](#errorhandling) use the same file-reference mechanism, from the `errorHandling/` sub-folder.)

Stream JSON (`dataStreams/incidents.json`):

Expand Down
Loading