@seamapi/http
Advanced tools
Comparing version 0.31.0 to 0.32.0
@@ -39,3 +39,3 @@ import { seamApiLtsVersion } from '../../../lib/lts-version.js'; | ||
const requestOptions = { | ||
waitForActionAttempt: options.waitForActionAttempt ?? false, | ||
waitForActionAttempt: options.waitForActionAttempt ?? true, | ||
}; | ||
@@ -42,0 +42,0 @@ if (isSeamHttpOptionsWithClient(options)) { |
@@ -1,2 +0,2 @@ | ||
declare const seamapiJavascriptHttpVersion = "0.31.0"; | ||
declare const seamapiJavascriptHttpVersion = "0.32.0"; | ||
export default seamapiJavascriptHttpVersion; |
@@ -1,3 +0,3 @@ | ||
const seamapiJavascriptHttpVersion = '0.31.0'; | ||
const seamapiJavascriptHttpVersion = '0.32.0'; | ||
export default seamapiJavascriptHttpVersion; | ||
//# sourceMappingURL=version.js.map |
{ | ||
"name": "@seamapi/http", | ||
"version": "0.31.0", | ||
"version": "0.32.0", | ||
"description": "JavaScript HTTP client for the Seam API written in TypeScript.", | ||
@@ -5,0 +5,0 @@ "type": "module", |
@@ -173,3 +173,3 @@ # Seam HTTP Client | ||
Obtain one from the Seam Console. | ||
A workspace id must be provided when using this method | ||
A workspace ID must be provided when using this method | ||
and all requests will be scoped to that workspace. | ||
@@ -196,3 +196,3 @@ | ||
This authentication method is only used by internal Seam applications. | ||
A workspace id must be provided when using this method | ||
A workspace ID must be provided when using this method | ||
and all requests will be scoped to that workspace. | ||
@@ -217,14 +217,31 @@ | ||
Some asynchronous operations, e.g., unlocking a door, return an [action attempt]. | ||
Seam tracks the progress of requested operation and updates the action attempt. | ||
Seam tracks the progress of the requested operation and updates the action attempt | ||
when it succeeds or fails. | ||
To make working with action attempts more convenient for applications, | ||
this library provides the `waitForActionAttempt` option. | ||
this library provides the `waitForActionAttempt` option and enables it by default. | ||
Pass the option per-request, | ||
When the `waitForActionAttempt` option is enabled, the SDK: | ||
- Polls the action attempt up to the `timeout` | ||
at the `pollingInterval` (both in milliseconds). | ||
- Resolves with a fresh copy of the successful action attempt. | ||
- Rejects with a `SeamActionAttemptFailedError` if the action attempt is unsuccessful. | ||
- Rejects with a `SeamActionAttemptTimeoutError` if the action attempt is still pending when the `timeout` is reached. | ||
- Both errors expose an `actionAttempt` property. | ||
If you already have an action attempt ID | ||
and want to wait for it to resolve, simply use | ||
```ts | ||
await seam.locks.unlockDoor( | ||
{ device_id }, | ||
await seam.actionAttempts.get({ action_attempt_id }) | ||
``` | ||
Or, to get the current state of an action attempt by ID without waiting, | ||
```ts | ||
await seam.actionAttempts.get( | ||
{ action_attempt_id }, | ||
{ | ||
waitForActionAttempt: true, | ||
waitForActionAttempt: false, | ||
}, | ||
@@ -234,3 +251,3 @@ ) | ||
or set the default option for the client: | ||
To disable this behavior, set the default option for the client, | ||
@@ -240,3 +257,3 @@ ```ts | ||
apiKey: 'your-api-key', | ||
waitForActionAttempt: true, | ||
waitForActionAttempt: false, | ||
}) | ||
@@ -247,10 +264,9 @@ | ||
If you have already have an action attempt id | ||
and want to wait for it to resolve, simply use | ||
or the behavior may be configured per-request, | ||
```ts | ||
await seam.actionAttempts.get( | ||
{ action_attempt_id }, | ||
await seam.locks.unlockDoor( | ||
{ device_id }, | ||
{ | ||
waitForActionAttempt: true, | ||
waitForActionAttempt: false, | ||
}, | ||
@@ -260,11 +276,4 @@ ) | ||
Using the `waitForActionAttempt` option: | ||
The `pollingInterval` and `timeout` may be configured for the client or per-request, for example | ||
- Polls the action attempt up to the `timeout` | ||
at the `pollingInterval` (both in milliseconds). | ||
- Resolves with a fresh copy of the successful action attempt. | ||
- Rejects with a `SeamActionAttemptFailedError` if the action attempt is unsuccessful. | ||
- Rejects with a `SeamActionAttemptTimeoutError` if the action attempt is still pending when the `timeout` is reached. | ||
- Both errors expose an `actionAttempt` property. | ||
```ts | ||
@@ -277,3 +286,8 @@ import { | ||
const seam = new SeamHttp('your-api-key') | ||
const seam = new SeamHttp('your-api-key', { | ||
waitForActionAttempt: { | ||
pollingInterval: 1000, | ||
timeout: 5000, | ||
}, | ||
}) | ||
@@ -285,11 +299,3 @@ const [lock] = await seam.locks.list() | ||
try { | ||
await seam.locks.unlockDoor( | ||
{ device_id: lock.device_id }, | ||
{ | ||
waitForActionAttempt: { | ||
pollingInterval: 1000, | ||
timeout: 5000, | ||
}, | ||
}, | ||
) | ||
await seam.locks.unlockDoor({ device_id: lock.device_id }) | ||
console.log('Door unlocked') | ||
@@ -296,0 +302,0 @@ } catch (err: unknown) { |
@@ -66,3 +66,3 @@ import { seamApiLtsVersion } from 'lib/lts-version.js' | ||
const requestOptions = { | ||
waitForActionAttempt: options.waitForActionAttempt ?? false, | ||
waitForActionAttempt: options.waitForActionAttempt ?? true, | ||
} | ||
@@ -69,0 +69,0 @@ |
@@ -1,3 +0,3 @@ | ||
const seamapiJavascriptHttpVersion = '0.31.0' | ||
const seamapiJavascriptHttpVersion = '0.32.0' | ||
export default seamapiJavascriptHttpVersion |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
1590252
571