seam 0.84.0 → 0.86.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +39 -33
  2. package/package.json +3 -3
package/README.md CHANGED
@@ -175,7 +175,7 @@ or create a new empty client session.
175
175
 
176
176
  A Personal Access Token is scoped to a Seam Console user.
177
177
  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
179
179
  and all requests will be scoped to that workspace.
180
180
 
181
181
  ```ts
@@ -197,7 +197,7 @@ const seam = Seam.fromPersonalAccessToken(
197
197
 
198
198
  A Console Session Token is used by the Seam Console.
199
199
  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
201
201
  and all requests will be scoped to that workspace.
202
202
 
203
203
  ```ts
@@ -217,53 +217,62 @@ const seam = Seam.fromConsoleSessionToken(
217
217
  ### Action Attempts
218
218
 
219
219
  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.
221
222
 
222
223
  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.
224
225
 
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
226
237
 
227
238
  ```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 },
230
247
  {
231
- waitForActionAttempt: true,
248
+ waitForActionAttempt: false,
232
249
  },
233
250
  )
234
251
  ```
235
252
 
236
- or set the default option for the client:
253
+ To disable this behavior, set the default option for the client,
237
254
 
238
255
  ```ts
239
256
  const seam = new Seam({
240
257
  apiKey: 'your-api-key',
241
- waitForActionAttempt: true,
258
+ waitForActionAttempt: false,
242
259
  })
243
260
 
244
261
  await seam.locks.unlockDoor({ device_id })
245
262
  ```
246
263
 
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,
249
265
 
250
266
  ```ts
251
- await seam.actionAttempts.get(
252
- { action_attempt_id },
267
+ await seam.locks.unlockDoor(
268
+ { device_id },
253
269
  {
254
- waitForActionAttempt: true,
270
+ waitForActionAttempt: false,
255
271
  },
256
272
  )
257
273
  ```
258
274
 
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
267
276
 
268
277
  ```ts
269
278
  import {
@@ -272,22 +281,19 @@ import {
272
281
  isSeamActionAttemptTimeoutError,
273
282
  } from 'seam'
274
283
 
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
+ })
276
290
 
277
291
  const [lock] = await seam.locks.list()
278
292
 
279
293
  if (lock == null) throw new Error('No locks in this workspace')
280
294
 
281
295
  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 })
291
297
  console.log('Door unlocked')
292
298
  } catch (err: unknown) {
293
299
  if (isSeamActionAttemptFailedError(err)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "seam",
3
- "version": "0.84.0",
3
+ "version": "0.86.0",
4
4
  "description": "JavaScript SDK for the Seam API written in TypeScript.",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -65,8 +65,8 @@
65
65
  "npm": ">= 9.0.0"
66
66
  },
67
67
  "dependencies": {
68
- "@seamapi/http": "1.0.0-rc.1",
69
- "@seamapi/types": "1.185.0",
68
+ "@seamapi/http": "1.0.0-rc.2",
69
+ "@seamapi/types": "1.186.0",
70
70
  "@seamapi/webhook": "1.0.0",
71
71
  "seamapi-types": "1.42.0",
72
72
  "zod": "^3.21.4"