@seamapi/http 2.25.0 → 2.27.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 CHANGED
@@ -203,6 +203,31 @@ When the `waitForActionAttempt` option is enabled, the SDK:
203
203
  - Rejects with a `SeamActionAttemptTimeoutError` if the action attempt is still pending when the `timeout` is reached.
204
204
  - Both errors expose an `actionAttempt` property.
205
205
 
206
+ The `ActionAttempt` type is a union discriminated by `action_type` and `status`.
207
+ The `error` and `result` properties are typed as `null`
208
+ except for the status that populates them,
209
+ so narrow on the `status` before reading them:
210
+
211
+ ```ts
212
+ const actionAttempt = await seam.locks.unlockDoor(
213
+ { device_id },
214
+ { waitForActionAttempt: false },
215
+ )
216
+
217
+ if (actionAttempt.status === 'success') {
218
+ console.log(actionAttempt.result) // The result is non-null here.
219
+ }
220
+
221
+ if (actionAttempt.status === 'error') {
222
+ console.log(actionAttempt.error.message) // The error is non-null here.
223
+ }
224
+ ```
225
+
226
+ Waiting for an action attempt resolves with the successful action attempt,
227
+ so after checking `status === 'success'` the `result` is immediately usable.
228
+ Use the `SucceededActionAttempt` and `FailedActionAttempt` types
229
+ to extract the success and error members from any action attempt type.
230
+
206
231
  If you already have an action attempt ID
207
232
  and want to wait for it to resolve, simply use
208
233
 
@@ -69,12 +69,12 @@ export declare class SeamActionAttemptTimeoutError<T extends ActionAttempt> exte
69
69
  /**
70
70
  * An action attempt that has succeeded.
71
71
  */
72
- export type SucceededActionAttempt<T extends ActionAttempt> = T & {
72
+ export type SucceededActionAttempt<T extends ActionAttempt> = Extract<T, {
73
73
  status: 'success';
74
- };
74
+ }>;
75
75
  /**
76
76
  * An action attempt that has failed.
77
77
  */
78
- export type FailedActionAttempt<T extends ActionAttempt> = T & {
78
+ export type FailedActionAttempt<T extends ActionAttempt> = Extract<T, {
79
79
  status: 'error';
80
- };
80
+ }>;
@@ -30,6 +30,10 @@ export type AccessCode = {
30
30
  * Unique identifier for the device associated with the access code.
31
31
  */
32
32
  device_id: string;
33
+ /**
34
+ * Human-readable label for where this access code sits in its lifecycle, for example `Active`, `Issuing`, or `Expired`. For display only. The wording is not stable and is not an enumeration — it may change at any time, so never compare against or branch on it. To make decisions, read `pending_mutations`, `errors`, `warnings`, `starts_at`, and `ends_at`.
35
+ */
36
+ display_status: string;
33
37
  /**
34
38
  * Metadata for a dormakaba Oracode managed access code. Only present for access codes from dormakaba Oracode devices.
35
39
  */
@@ -809,6 +813,7 @@ export type AccessCode = {
809
813
  starts_at?: string | null | undefined;
810
814
  /**
811
815
  * Current status of the access code within the operational lifecycle. Values are `setting`, a transitional phase that indicates that the code is being configured or activated; `set`, which indicates that the code is active and operational; `unset`, which indicates a deactivated or unused state, either before activation or after deliberate deactivation; `removing`, which indicates a transitional period in which the code is being deleted or made inactive; and `unknown`, which indicates an indeterminate state, due to reasons such as system errors or incomplete data, that highlights a potential need for system review or troubleshooting. See also [Lifecycle of Access Codes](https://docs.seam.co/low-level-apis/smart-locks/access-codes/lifecycle-of-access-codes).
816
+ * @deprecated Use `display_status` to show a person the code's state. To make decisions, read `pending_mutations`, `errors`, `warnings`, `starts_at`, and `ends_at`.
812
817
  */
813
818
  status: 'setting' | 'set' | 'unset' | 'removing' | 'unknown';
814
819
  /**