Skip to content
Merged
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
44 changes: 44 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ Instead, it builds on a core set of Seam modules:
- [Iterate over all pages](#iterate-over-all-pages)
- [Iterate over all resources](#iterate-over-all-resources)
- [Return all resources across all pages as an array](#return-all-resources-across-all-pages-as-an-array)
- [Error Handling](#error-handling)
- [Validation errors](#validation-errors)
- [Requests without a Workspace in scope](#requests-without-a-workspace-in-scope)
- [Personal Access Token](#personal-access-token-1)
- [Console Session Token](#console-session-token-1)
Expand Down Expand Up @@ -242,6 +244,11 @@ When the `waitForActionAttempt` option is enabled, the SDK:

- Polls the action attempt up to the `timeout`
at the `pollingInterval` (both in milliseconds).
Polling stops as soon as the `timeout` passes,
and every wait polls at least once,
even when the `timeout` is shorter than the `pollingInterval`.
The `timeout` must not be negative,
and the `pollingInterval` must be greater than zero.
- Resolves with a fresh copy of the successful action attempt.
- Rejects with a `SeamActionAttemptFailedError` if the action attempt is unsuccessful.
- Rejects with a `SeamActionAttemptTimeoutError` if the action attempt is still pending when the `timeout` is reached.
Expand Down Expand Up @@ -415,6 +422,43 @@ const pages = seam.createPaginator(
const devices = await pages.flattenToArray()
```

### Error Handling

Requests rejected by the Seam API throw a `SeamApiError` subclass
carrying the `statusCode`, the API error `code`, and the `requestId`.
The originating Axios error is retained as the standard `cause`.

#### Validation errors

When the API rejects a request because a parameter is invalid,
it throws a `SeamInvalidInputError`.

Look up the messages for a parameter you are already rendering,
for example a field in a form:

```ts
import { isSeamInvalidInputError } from 'seam'

try {
await seam.devices.list({ device_ids: ['not-a-uuid'] })
} catch (err) {
if (isSeamInvalidInputError(err)) {
console.log(err.getValidationErrorMessages('device_ids'))
}
}
```

Or read every parameter that failed validation,
for example to show a summary of what went wrong:

```ts
if (isSeamInvalidInputError(err)) {
for (const { parameterName, errorMessages } of err.validationErrors) {
console.log(`${parameterName}: ${errorMessages.join(', ')}`)
}
}
```

### Requests without a Workspace in scope

Some Seam API endpoints do not require a workspace in scope.
Expand Down
144 changes: 72 additions & 72 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@
},
"packageManager": "npm@11.19.0",
"dependencies": {
"@seamapi/cli": "0.34.1",
"@seamapi/http": "2.23.7",
"@seamapi/cli": "0.37.0",
"@seamapi/http": "2.26.0",
"@seamapi/webhook": "1.4.1"
},
"devDependencies": {
Expand Down
Loading