@@ -170,7 +170,7 @@ or create a new empty client session.
170170
171171A Personal Access Token is scoped to a Seam Console user.
172172Obtain one from the Seam Console.
173- A workspace id must be provided when using this method
173+ A workspace ID must be provided when using this method
174174and all requests will be scoped to that workspace.
175175
176176``` ts
@@ -192,7 +192,7 @@ const seam = SeamHttp.fromPersonalAccessToken(
192192
193193A Console Session Token is used by the Seam Console.
194194This authentication method is only used by internal Seam applications.
195- A workspace id must be provided when using this method
195+ A workspace ID must be provided when using this method
196196and all requests will be scoped to that workspace.
197197
198198``` ts
@@ -212,53 +212,62 @@ const seam = SeamHttp.fromConsoleSessionToken(
212212### Action Attempts
213213
214214Some asynchronous operations, e.g., unlocking a door, return an [ action attempt] .
215- Seam tracks the progress of requested operation and updates the action attempt.
215+ Seam tracks the progress of the requested operation and updates the action attempt
216+ when it succeeds or fails.
216217
217218To make working with action attempts more convenient for applications,
218- this library provides the ` waitForActionAttempt ` option.
219+ this library provides the ` waitForActionAttempt ` option and enables it by default .
219220
220- Pass the option per-request,
221+ When the ` waitForActionAttempt ` option is enabled, the SDK:
222+
223+ - Polls the action attempt up to the ` timeout `
224+ at the ` pollingInterval ` (both in milliseconds).
225+ - Resolves with a fresh copy of the successful action attempt.
226+ - Rejects with a ` SeamActionAttemptFailedError ` if the action attempt is unsuccessful.
227+ - Rejects with a ` SeamActionAttemptTimeoutError ` if the action attempt is still pending when the ` timeout ` is reached.
228+ - Both errors expose an ` actionAttempt ` property.
229+
230+ If you already have an action attempt ID
231+ and want to wait for it to resolve, simply use
221232
222233``` ts
223- await seam .locks .unlockDoor (
224- { device_id },
234+ await seam .actionAttempts .get ({ action_attempt_id })
235+ ```
236+
237+ Or, to get the current state of an action attempt by ID without waiting,
238+
239+ ``` ts
240+ await seam .actionAttempts .get (
241+ { action_attempt_id },
225242 {
226- waitForActionAttempt: true ,
243+ waitForActionAttempt: false ,
227244 },
228245)
229246```
230247
231- or set the default option for the client:
248+ To disable this behavior, set the default option for the client,
232249
233250``` ts
234251const seam = new SeamHttp ({
235252 apiKey: ' your-api-key' ,
236- waitForActionAttempt: true ,
253+ waitForActionAttempt: false ,
237254})
238255
239256await seam .locks .unlockDoor ({ device_id })
240257```
241258
242- If you have already have an action attempt id
243- and want to wait for it to resolve, simply use
259+ or the behavior may be configured per-request,
244260
245261``` ts
246- await seam .actionAttempts . get (
247- { action_attempt_id },
262+ await seam .locks . unlockDoor (
263+ { device_id },
248264 {
249- waitForActionAttempt: true ,
265+ waitForActionAttempt: false ,
250266 },
251267)
252268```
253269
254- Using the ` waitForActionAttempt ` option:
255-
256- - Polls the action attempt up to the ` timeout `
257- at the ` pollingInterval ` (both in milliseconds).
258- - Resolves with a fresh copy of the successful action attempt.
259- - Rejects with a ` SeamActionAttemptFailedError ` if the action attempt is unsuccessful.
260- - Rejects with a ` SeamActionAttemptTimeoutError ` if the action attempt is still pending when the ` timeout ` is reached.
261- - Both errors expose an ` actionAttempt ` property.
270+ The ` pollingInterval ` and ` timeout ` may be configured for the client or per-request, for example
262271
263272``` ts
264273import {
@@ -267,22 +276,19 @@ import {
267276 isSeamActionAttemptTimeoutError ,
268277} from ' @seamapi/http/connect'
269278
270- const seam = new SeamHttp (' your-api-key' )
279+ const seam = new SeamHttp (' your-api-key' , {
280+ waitForActionAttempt: {
281+ pollingInterval: 1000 ,
282+ timeout: 5000 ,
283+ },
284+ })
271285
272286const [lock] = await seam .locks .list ()
273287
274288if (lock == null ) throw new Error (' No locks in this workspace' )
275289
276290try {
277- await seam .locks .unlockDoor (
278- { device_id: lock .device_id },
279- {
280- waitForActionAttempt: {
281- pollingInterval: 1000 ,
282- timeout: 5000 ,
283- },
284- },
285- )
291+ await seam .locks .unlockDoor ({ device_id: lock .device_id })
286292 console .log (' Door unlocked' )
287293} catch (err : unknown ) {
288294 if (isSeamActionAttemptFailedError (err )) {
0 commit comments