seam 1.232.1 → 1.233.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.
- package/README.md +69 -6
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -59,6 +59,7 @@ Instead, it builds on a core set of Seam modules:
|
|
|
59
59
|
- [Overriding the Client](#overriding-the-client)
|
|
60
60
|
- [Alternative endpoint path interface](#alternative-endpoint-path-interface)
|
|
61
61
|
- [Inspecting the Request](#inspecting-the-request)
|
|
62
|
+
- [Serializing URL search params](#serializing-url-search-params)
|
|
62
63
|
- [Command Line Interface](#command-line-interface)
|
|
63
64
|
- [Output](#output)
|
|
64
65
|
- [Pagination](#pagination-1)
|
|
@@ -513,8 +514,10 @@ const seam = new Seam({
|
|
|
513
514
|
```
|
|
514
515
|
|
|
515
516
|
Set `timeout` to `0` to disable the timeout entirely.
|
|
516
|
-
A request that times out rejects with an Axios `ETIMEDOUT` error
|
|
517
|
-
|
|
517
|
+
A request that times out rejects with an Axios `ETIMEDOUT` error.
|
|
518
|
+
Timed-out idempotent requests are retried according to the retry options, with
|
|
519
|
+
the timeout reset for each attempt. Non-idempotent requests are not retried by
|
|
520
|
+
default.
|
|
518
521
|
|
|
519
522
|
#### Configuring the Axios Client
|
|
520
523
|
|
|
@@ -522,6 +525,15 @@ The Axios client and retry behavior may be configured with custom initiation opt
|
|
|
522
525
|
via [`axiosOptions`][axiosOptions] and [`axiosRetryOptions`][axiosRetryOptions].
|
|
523
526
|
Options are deep merged with the default options.
|
|
524
527
|
|
|
528
|
+
By default, the SDK makes up to three attempts: the initial request and two
|
|
529
|
+
retries. Retries are limited to `GET`, `HEAD`, `OPTIONS`, `PUT`, and `DELETE`
|
|
530
|
+
requests that fail because of a transport error, timeout, HTTP 429 response, or
|
|
531
|
+
HTTP 5xx response. `POST` and `PATCH` requests are not retried.
|
|
532
|
+
|
|
533
|
+
Retries use exponential backoff with jitter: approximately 200–240 ms before
|
|
534
|
+
the first retry and 400–480 ms before the second. A longer `Retry-After` header
|
|
535
|
+
is honored. The request timeout is reset for each attempt.
|
|
536
|
+
|
|
525
537
|
[axiosOptions]: https://axios-http.com/docs/config_defaults
|
|
526
538
|
[axiosRetryOptions]: https://github.com/softonic/axios-retry
|
|
527
539
|
|
|
@@ -574,6 +586,53 @@ console.log(`${request.method} ${request.url}`, JSON.stringify(request.body))
|
|
|
574
586
|
const devices = await request.execute()
|
|
575
587
|
```
|
|
576
588
|
|
|
589
|
+
#### Serializing URL search params
|
|
590
|
+
|
|
591
|
+
The Seam API parses URL search params as complex types.
|
|
592
|
+
If you call it with your own HTTP client, use `serializeUrlSearchParams`:
|
|
593
|
+
|
|
594
|
+
```ts
|
|
595
|
+
import axios from 'axios'
|
|
596
|
+
import { serializeUrlSearchParams } from 'seam'
|
|
597
|
+
|
|
598
|
+
await axios.get('https://connect.getseam.com/devices/list', {
|
|
599
|
+
params: { device_ids: ['device1', 'device2'] },
|
|
600
|
+
paramsSerializer: serializeUrlSearchParams,
|
|
601
|
+
headers: { Authorization: 'Bearer your-api-key' },
|
|
602
|
+
})
|
|
603
|
+
```
|
|
604
|
+
|
|
605
|
+
or `updateUrlSearchParams`:
|
|
606
|
+
|
|
607
|
+
```ts
|
|
608
|
+
import { updateUrlSearchParams } from 'seam'
|
|
609
|
+
|
|
610
|
+
const searchParams = new URLSearchParams()
|
|
611
|
+
updateUrlSearchParams(searchParams, { device_ids: ['device1', 'device2'] })
|
|
612
|
+
|
|
613
|
+
Array.from(searchParams)
|
|
614
|
+
// => [['device_ids', 'device1'], ['device_ids', 'device2'], ['_strict', 'true']]
|
|
615
|
+
|
|
616
|
+
searchParams.toString()
|
|
617
|
+
// => 'device_ids=device1&device_ids=device2&_strict=true'
|
|
618
|
+
```
|
|
619
|
+
|
|
620
|
+
The helpers wrap the [reference implementation].
|
|
621
|
+
The serialization defines the name and string value of each search param.
|
|
622
|
+
[`URLSearchParams`][URLSearchParams] holds those pairs and renders the query string:
|
|
623
|
+
The `_strict=true` parameter is added to any non-empty query so the Seam API uses
|
|
624
|
+
strict, schema-aware parsing.
|
|
625
|
+
A query with no serializable params remains empty.
|
|
626
|
+
|
|
627
|
+
A param set to `undefined` is omitted, while a param set to `null` is serialized
|
|
628
|
+
to an empty value, which the Seam API reads as null.
|
|
629
|
+
A param that cannot be represented raises an `UnserializableParamError`.
|
|
630
|
+
The Seam API parses these params with the corresponding [parser].
|
|
631
|
+
|
|
632
|
+
[URLSearchParams]: https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams
|
|
633
|
+
[reference implementation]: https://github.com/seamapi/url-search-params-serializer
|
|
634
|
+
[parser]: https://github.com/seamapi/url-search-params-parser
|
|
635
|
+
|
|
577
636
|
### Command Line Interface
|
|
578
637
|
|
|
579
638
|
Every `seam` command makes its request as soon as every required property is
|
|
@@ -582,8 +641,9 @@ suggestions.
|
|
|
582
641
|
|
|
583
642
|
Pass `--interactive` (or `-i`) to always be prompted to review and edit
|
|
584
643
|
properties before the request is made. The prompt is prefilled with whatever
|
|
585
|
-
you passed as arguments
|
|
586
|
-
|
|
644
|
+
you passed as arguments or piped in as JSON, and each property you open is
|
|
645
|
+
prefilled with the value it has, ready to edit rather than retype. This is the
|
|
646
|
+
way to add optional properties, or to check a request before making it.
|
|
587
647
|
|
|
588
648
|
For scripts and CI, pass `--non-interactive` (or `-y`) to never be prompted.
|
|
589
649
|
The command must then be complete: if the command itself is ambiguous, or any
|
|
@@ -674,8 +734,8 @@ one yourself. Run `seam <command> --help` to see whether a command paginates.
|
|
|
674
734
|
|
|
675
735
|
### JSON
|
|
676
736
|
|
|
677
|
-
Request params may be piped or redirected in as a JSON object
|
|
678
|
-
arguments win over
|
|
737
|
+
Request params may be piped or redirected in as a JSON object, or passed
|
|
738
|
+
inline with `--raw`. Params given as arguments win over raw or stdin params.
|
|
679
739
|
|
|
680
740
|
An argument the command does not accept is an error, so a typo is reported
|
|
681
741
|
rather than sent. Params read from stdin are passed through as given, so
|
|
@@ -688,6 +748,9 @@ seam locks unlock-door < params.json
|
|
|
688
748
|
# Or from another program
|
|
689
749
|
echo '{"device_id": "'"$MY_DOOR"'"}' | seam locks unlock-door
|
|
690
750
|
|
|
751
|
+
# Pass request params inline as JSON
|
|
752
|
+
seam devices list --raw '{"search":"bar"}'
|
|
753
|
+
|
|
691
754
|
# --device-id wins over any device_id in params.json
|
|
692
755
|
seam devices list --limit 5 < params.json
|
|
693
756
|
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "seam",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.233.0",
|
|
4
4
|
"description": "JavaScript SDK for the Seam API written in TypeScript.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.js",
|
|
@@ -73,9 +73,10 @@
|
|
|
73
73
|
"version": "^11.0.0 || ^10.0.0"
|
|
74
74
|
}
|
|
75
75
|
},
|
|
76
|
+
"packageManager": "npm@11.19.0",
|
|
76
77
|
"dependencies": {
|
|
77
|
-
"@seamapi/cli": "0.
|
|
78
|
-
"@seamapi/http": "2.
|
|
78
|
+
"@seamapi/cli": "0.28.0",
|
|
79
|
+
"@seamapi/http": "2.11.2",
|
|
79
80
|
"@seamapi/webhook": "1.4.1"
|
|
80
81
|
},
|
|
81
82
|
"devDependencies": {
|