seam 1.237.0 → 1.239.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 +43 -0
  2. package/package.json +3 -3
package/README.md CHANGED
@@ -254,6 +254,31 @@ When the `waitForActionAttempt` option is enabled, the SDK:
254
254
  - Rejects with a `SeamActionAttemptTimeoutError` if the action attempt is still pending when the `timeout` is reached.
255
255
  - Both errors expose an `actionAttempt` property.
256
256
 
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
+
257
282
  If you already have an action attempt ID
258
283
  and want to wait for it to resolve, simply use
259
284
 
@@ -916,6 +941,24 @@ Use it to parse and validate [Seam webhook events](https://docs.seam.co/latest/d
916
941
  Refer to the [Svix docs on Consuming Webhooks](https://docs.svix.com/receiving/introduction)
917
942
  for an in-depth guide on best-practices for handling webhooks in your application.
918
943
 
944
+ Verification failures throw Svix's `WebhookVerificationError`, re-exported as
945
+ `SeamWebhookVerificationError`.
946
+ A payload that is correctly signed but unreadable throws a `SeamInvalidWebhookPayloadError`.
947
+
948
+ ```js
949
+ import { isSeamInvalidWebhookPayloadError, SeamWebhook } from 'seam'
950
+
951
+ try {
952
+ data = webhook.verify(req.body, req.headers)
953
+ } catch (err) {
954
+ if (isSeamInvalidWebhookPayloadError(err)) {
955
+ console.error('Unreadable Seam webhook payload', err)
956
+ return res.status(204).send()
957
+ }
958
+ return res.status(400).send()
959
+ }
960
+ ```
961
+
919
962
  > [!TIP]
920
963
  > This example is for [Express](https://expressjs.com/),
921
964
  > see the [Svix docs for more examples in specific frameworks](https://docs.svix.com/receiving/verifying-payloads/how).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "seam",
3
- "version": "1.237.0",
3
+ "version": "1.239.0",
4
4
  "description": "JavaScript SDK for the Seam API written in TypeScript.",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -76,8 +76,8 @@
76
76
  "packageManager": "npm@11.19.0",
77
77
  "dependencies": {
78
78
  "@seamapi/cli": "0.37.0",
79
- "@seamapi/http": "2.26.0",
80
- "@seamapi/webhook": "1.4.1"
79
+ "@seamapi/http": "2.27.0",
80
+ "@seamapi/webhook": "1.5.0"
81
81
  },
82
82
  "devDependencies": {
83
83
  "@types/node": "^24.10.9",