Skip to content

Commit d5ae89f

Browse files
committed
ci: Generate code
1 parent b36263a commit d5ae89f

File tree

1 file changed

+39
-33
lines changed

1 file changed

+39
-33
lines changed

README.md

Lines changed: 39 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ or create a new empty client session.
175175

176176
A Personal Access Token is scoped to a Seam Console user.
177177
Obtain one from the Seam Console.
178-
A workspace id must be provided when using this method
178+
A workspace ID must be provided when using this method
179179
and all requests will be scoped to that workspace.
180180

181181
```ts
@@ -197,7 +197,7 @@ const seam = Seam.fromPersonalAccessToken(
197197

198198
A Console Session Token is used by the Seam Console.
199199
This authentication method is only used by internal Seam applications.
200-
A workspace id must be provided when using this method
200+
A workspace ID must be provided when using this method
201201
and all requests will be scoped to that workspace.
202202

203203
```ts
@@ -217,53 +217,62 @@ const seam = Seam.fromConsoleSessionToken(
217217
### Action Attempts
218218

219219
Some asynchronous operations, e.g., unlocking a door, return an [action attempt].
220-
Seam tracks the progress of requested operation and updates the action attempt.
220+
Seam tracks the progress of the requested operation and updates the action attempt
221+
when it succeeds or fails.
221222

222223
To make working with action attempts more convenient for applications,
223-
this library provides the `waitForActionAttempt` option.
224+
this library provides the `waitForActionAttempt` option and enables it by default.
224225

225-
Pass the option per-request,
226+
When the `waitForActionAttempt` option is enabled, the SDK:
227+
228+
- Polls the action attempt up to the `timeout`
229+
at the `pollingInterval` (both in milliseconds).
230+
- Resolves with a fresh copy of the successful action attempt.
231+
- Rejects with a `SeamActionAttemptFailedError` if the action attempt is unsuccessful.
232+
- Rejects with a `SeamActionAttemptTimeoutError` if the action attempt is still pending when the `timeout` is reached.
233+
- Both errors expose an `actionAttempt` property.
234+
235+
If you already have an action attempt ID
236+
and want to wait for it to resolve, simply use
226237

227238
```ts
228-
await seam.locks.unlockDoor(
229-
{ device_id },
239+
await seam.actionAttempts.get({ action_attempt_id })
240+
```
241+
242+
Or, to get the current state of an action attempt by ID without waiting,
243+
244+
```ts
245+
await seam.actionAttempts.get(
246+
{ action_attempt_id },
230247
{
231-
waitForActionAttempt: true,
248+
waitForActionAttempt: false,
232249
},
233250
)
234251
```
235252

236-
or set the default option for the client:
253+
To disable this behavior, set the default option for the client,
237254

238255
```ts
239256
const seam = new Seam({
240257
apiKey: 'your-api-key',
241-
waitForActionAttempt: true,
258+
waitForActionAttempt: false,
242259
})
243260

244261
await seam.locks.unlockDoor({ device_id })
245262
```
246263

247-
If you have already have an action attempt id
248-
and want to wait for it to resolve, simply use
264+
or the behavior may be configured per-request,
249265

250266
```ts
251-
await seam.actionAttempts.get(
252-
{ action_attempt_id },
267+
await seam.locks.unlockDoor(
268+
{ device_id },
253269
{
254-
waitForActionAttempt: true,
270+
waitForActionAttempt: false,
255271
},
256272
)
257273
```
258274

259-
Using the `waitForActionAttempt` option:
260-
261-
- Polls the action attempt up to the `timeout`
262-
at the `pollingInterval` (both in milliseconds).
263-
- Resolves with a fresh copy of the successful action attempt.
264-
- Rejects with a `SeamActionAttemptFailedError` if the action attempt is unsuccessful.
265-
- Rejects with a `SeamActionAttemptTimeoutError` if the action attempt is still pending when the `timeout` is reached.
266-
- Both errors expose an `actionAttempt` property.
275+
The `pollingInterval` and `timeout` may be configured for the client or per-request, for example
267276

268277
```ts
269278
import {
@@ -272,22 +281,19 @@ import {
272281
isSeamActionAttemptTimeoutError,
273282
} from 'seam'
274283

275-
const seam = new Seam('your-api-key')
284+
const seam = new Seam('your-api-key', {
285+
waitForActionAttempt: {
286+
pollingInterval: 1000,
287+
timeout: 5000,
288+
},
289+
})
276290

277291
const [lock] = await seam.locks.list()
278292

279293
if (lock == null) throw new Error('No locks in this workspace')
280294

281295
try {
282-
await seam.locks.unlockDoor(
283-
{ device_id: lock.device_id },
284-
{
285-
waitForActionAttempt: {
286-
pollingInterval: 1000,
287-
timeout: 5000,
288-
},
289-
},
290-
)
296+
await seam.locks.unlockDoor({ device_id: lock.device_id })
291297
console.log('Door unlocked')
292298
} catch (err: unknown) {
293299
if (isSeamActionAttemptFailedError(err)) {

0 commit comments

Comments
 (0)