seam 0.48.0 → 0.49.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 +83 -49
  2. package/package.json +5 -3
package/README.md CHANGED
@@ -5,10 +5,6 @@
5
5
 
6
6
  JavaScript SDK for the Seam API written in TypeScript.
7
7
 
8
- _This repository hosts the next major version of the Seam JavaScript SDK.
9
- This SDK is available for early preview.
10
- It will eventually replace the [seamapi](https://github.com/seamapi/javascript/) package._
11
-
12
8
  ## Description
13
9
 
14
10
  [Seam] makes it easy to integrate IoT devices with your applications.
@@ -19,12 +15,7 @@ The SDK is fully tree-shakeable
19
15
  and optimized for use in both client and server applications.
20
16
 
21
17
  The repository does not contain the SDK code.
22
- Instead, it re-exports from a core set of Seam modules.
23
-
24
- _While this SDK is still in preview,
25
- please refer to the individual README files in these repositories for
26
- additional usage documentation not yet available in the primary Seam documentation.
27
- See [this issue for a draft migration guide](https://github.com/seamapi/javascript-next/issues/1) from the seamapi package._
18
+ Instead, it re-exports from a core set of Seam modules:
28
19
 
29
20
  - [@seamapi/http]: JavaScript HTTP client for the Seam API written in TypeScript.
30
21
  - [@seamapi/webhook]: Webhook SDK for the Seam API written in TypeScript.
@@ -36,6 +27,47 @@ See [this issue for a draft migration guide](https://github.com/seamapi/javascri
36
27
  [@seamapi/http]: https://github.com/seamapi/javascript-http
37
28
  [@seamapi/webhook]: https://github.com/seamapi/javascript-webhook
38
29
 
30
+ ## Contents
31
+
32
+ <!-- toc -->
33
+
34
+ - [Installation](#installation)
35
+ - [Usage](#usage)
36
+ - [Examples](#examples)
37
+ - [List devices](#list-devices)
38
+ - [Unlock a door](#unlock-a-door)
39
+ - [Authentication Methods](#authentication-methods)
40
+ - [API Key](#api-key)
41
+ - [Client Session Token](#client-session-token)
42
+ - [Publishable Key](#publishable-key)
43
+ - [Personal Access Token](#personal-access-token)
44
+ - [Console Session Token](#console-session-token)
45
+ - [Action Attempts](#action-attempts)
46
+ - [Interacting with Multiple Workspaces](#interacting-with-multiple-workspaces)
47
+ - [Personal Access Token](#personal-access-token-1)
48
+ - [Console Session Token](#console-session-token-1)
49
+ - [Advanced Usage](#advanced-usage)
50
+ - [Additional Options](#additional-options)
51
+ - [Setting the endpoint](#setting-the-endpoint)
52
+ - [Configuring the Axios Client](#configuring-the-axios-client)
53
+ - [Using the Axios Client](#using-the-axios-client)
54
+ - [Overriding the Client](#overriding-the-client)
55
+ - [Inspecting the Request](#inspecting-the-request)
56
+ - [Receiving Webhooks](#receiving-webhooks)
57
+ - [Development and Testing](#development-and-testing)
58
+ - [Quickstart](#quickstart)
59
+ - [Source code](#source-code)
60
+ - [Requirements](#requirements)
61
+ - [Publishing](#publishing)
62
+ - [Automatic](#automatic)
63
+ - [Manual](#manual)
64
+ - [GitHub Actions](#github-actions)
65
+ - [Contributing](#contributing)
66
+ - [License](#license)
67
+ - [Warranty](#warranty)
68
+
69
+ <!-- tocstop -->
70
+
39
71
  ## Installation
40
72
 
41
73
  Add this as a dependency to your project using [npm] with
@@ -48,45 +80,6 @@ $ npm install seam
48
80
 
49
81
  ## Usage
50
82
 
51
- First, create a webhook using the Seam API or Seam Console
52
- and obtain a Seam webhook secret.
53
-
54
- _This example is for [Express], see the [Svix docs for more examples in specific frameworks](https://docs.svix.com/receiving/verifying-payloads/how)._
55
-
56
- ```js
57
- import { SeamWebhook } from 'seam'
58
- import express from 'express'
59
- import bodyParser from 'body-parser'
60
-
61
- import { storeEvent } from './store-event.js'
62
-
63
- const app = express()
64
-
65
- const webhook = new SeamWebhook(process.env.SEAM_WEBHOOK_SECRET)
66
-
67
- app.post(
68
- '/webhook',
69
- bodyParser.raw({ type: 'application/json' }),
70
- (req, res) => {
71
- let data
72
- try {
73
- data = webhook.verify(payload, headers)
74
- } catch {
75
- return res.status(400).send()
76
- }
77
-
78
- storeEvent(data, (err) => {
79
- if (err != null) {
80
- return res.status(500).send()
81
- }
82
- res.status(204).send()
83
- })
84
- },
85
- )
86
- ```
87
-
88
- [Express]: https://expressjs.com/
89
-
90
83
  ### Examples
91
84
 
92
85
  _These examples assume `SEAM_API_KEY` is set in your environment._
@@ -438,6 +431,47 @@ console.log(`${request.method} ${request.url}`, JSON.stringify(request.body))
438
431
  const devices = await request.execute()
439
432
  ```
440
433
 
434
+ ### Receiving Webhooks
435
+
436
+ First, create a webhook using the Seam API or Seam Console
437
+ and obtain a Seam webhook secret.
438
+
439
+ _This example is for [Express], see the [Svix docs for more examples in specific frameworks](https://docs.svix.com/receiving/verifying-payloads/how)._
440
+
441
+ ```js
442
+ import { SeamWebhook } from 'seam'
443
+ import express from 'express'
444
+ import bodyParser from 'body-parser'
445
+
446
+ import { storeEvent } from './store-event.js'
447
+
448
+ const app = express()
449
+
450
+ const webhook = new SeamWebhook(process.env.SEAM_WEBHOOK_SECRET)
451
+
452
+ app.post(
453
+ '/webhook',
454
+ bodyParser.raw({ type: 'application/json' }),
455
+ (req, res) => {
456
+ let data
457
+ try {
458
+ data = webhook.verify(payload, headers)
459
+ } catch {
460
+ return res.status(400).send()
461
+ }
462
+
463
+ storeEvent(data, (err) => {
464
+ if (err != null) {
465
+ return res.status(500).send()
466
+ }
467
+ res.status(204).send()
468
+ })
469
+ },
470
+ )
471
+ ```
472
+
473
+ [Express]: https://expressjs.com/
474
+
441
475
  ## Development and Testing
442
476
 
443
477
  ### Quickstart
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "seam",
3
- "version": "0.48.0",
3
+ "version": "0.49.0",
4
4
  "description": "JavaScript SDK for the Seam API written in TypeScript.",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -52,7 +52,8 @@
52
52
  "lint": "eslint --ignore-path .gitignore .",
53
53
  "prelint": "prettier --check --ignore-path .gitignore .",
54
54
  "postversion": "git push --follow-tags",
55
- "generate:readme": "tsx ./generate-readme.ts",
55
+ "generate": "tsx generate-readme.ts",
56
+ "postgenerate": "markdown-toc -i README.md --bullets '-'",
56
57
  "example": "tsx examples",
57
58
  "example:inspect": "tsx --inspect examples",
58
59
  "format": "eslint --ignore-path .gitignore --fix .",
@@ -64,7 +65,7 @@
64
65
  },
65
66
  "dependencies": {
66
67
  "@seamapi/http": "0.25.2",
67
- "@seamapi/types": "1.146.0",
68
+ "@seamapi/types": "1.147.1",
68
69
  "@seamapi/webhook": "1.0.0-rc.0",
69
70
  "seamapi-types": "1.42.0"
70
71
  },
@@ -78,6 +79,7 @@
78
79
  "eslint-plugin-simple-import-sort": "^12.0.0",
79
80
  "eslint-plugin-unused-imports": "^3.0.0",
80
81
  "landlubber": "^2.0.0",
82
+ "markdown-toc": "^1.2.0",
81
83
  "prettier": "^3.0.0",
82
84
  "tsc-alias": "^1.8.2",
83
85
  "tsup": "^8.0.1",