Skip to content

Commit 3f9ee28

Browse files
committed
ci: Generate code
1 parent dff64c2 commit 3f9ee28

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,31 @@ When the `waitForActionAttempt` option is enabled, the SDK:
254254
- Rejects with a `SeamActionAttemptTimeoutError` if the action attempt is still pending when the `timeout` is reached.
255255
- Both errors expose an `actionAttempt` property.
256256

257+
The `ActionAttempt` type is a union discriminated by `action_type` and `status`.
258+
The `error` and `result` properties are typed as `null`
259+
except for the status that populates them,
260+
so narrow on the `status` before reading them:
261+
262+
```ts
263+
const actionAttempt = await seam.locks.unlockDoor(
264+
{ device_id },
265+
{ waitForActionAttempt: false },
266+
)
267+
268+
if (actionAttempt.status === 'success') {
269+
console.log(actionAttempt.result) // The result is non-null here.
270+
}
271+
272+
if (actionAttempt.status === 'error') {
273+
console.log(actionAttempt.error.message) // The error is non-null here.
274+
}
275+
```
276+
277+
Waiting for an action attempt resolves with the successful action attempt,
278+
so after checking `status === 'success'` the `result` is immediately usable.
279+
Use the `SucceededActionAttempt` and `FailedActionAttempt` types
280+
to extract the success and error members from any action attempt type.
281+
257282
If you already have an action attempt ID
258283
and want to wait for it to resolve, simply use
259284

0 commit comments

Comments
 (0)