@seamapi/http 2.17.0 → 2.19.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 (46) hide show
  1. package/index.d.ts +5 -0
  2. package/index.js +5 -0
  3. package/index.js.map +1 -1
  4. package/lib/client.d.ts +12 -0
  5. package/lib/client.js.map +1 -1
  6. package/lib/index.d.ts +1 -1
  7. package/lib/index.js.map +1 -1
  8. package/lib/options.d.ts +105 -0
  9. package/lib/options.js +54 -0
  10. package/lib/options.js.map +1 -1
  11. package/lib/request-options.d.ts +13 -0
  12. package/lib/request-options.js +3 -0
  13. package/lib/request-options.js.map +1 -1
  14. package/lib/resolve-action-attempt.d.ts +47 -0
  15. package/lib/resolve-action-attempt.js +29 -0
  16. package/lib/resolve-action-attempt.js.map +1 -1
  17. package/lib/resources/access-code.d.ts +87 -0
  18. package/lib/resources/device.d.ts +0 -12
  19. package/lib/resources/unmanaged-access-code.d.ts +87 -0
  20. package/lib/routes/events/events.d.ts +2 -2
  21. package/lib/seam-http-error.d.ts +34 -0
  22. package/lib/seam-http-error.js +34 -0
  23. package/lib/seam-http-error.js.map +1 -1
  24. package/lib/seam-http-request.d.ts +31 -0
  25. package/lib/seam-http-request.js +31 -0
  26. package/lib/seam-http-request.js.map +1 -1
  27. package/lib/seam-paginator.d.ts +28 -0
  28. package/lib/seam-paginator.js +25 -0
  29. package/lib/seam-paginator.js.map +1 -1
  30. package/lib/version.d.ts +1 -1
  31. package/lib/version.js +1 -1
  32. package/package.json +3 -2
  33. package/src/index.ts +5 -0
  34. package/src/lib/client.ts +14 -0
  35. package/src/lib/index.ts +3 -0
  36. package/src/lib/options.ts +105 -0
  37. package/src/lib/request-options.ts +13 -0
  38. package/src/lib/resolve-action-attempt.ts +48 -0
  39. package/src/lib/resources/access-code.ts +100 -0
  40. package/src/lib/resources/device.ts +0 -12
  41. package/src/lib/resources/unmanaged-access-code.ts +100 -0
  42. package/src/lib/routes/events/events.ts +12 -0
  43. package/src/lib/seam-http-error.ts +38 -0
  44. package/src/lib/seam-http-request.ts +31 -0
  45. package/src/lib/seam-paginator.ts +28 -0
  46. package/src/lib/version.ts +1 -1
package/index.d.ts CHANGED
@@ -1 +1,6 @@
1
+ /**
2
+ * JavaScript HTTP client for the Seam API written in TypeScript.
3
+ *
4
+ * @packageDocumentation
5
+ */
1
6
  export * from './lib/index.js';
package/index.js CHANGED
@@ -1,2 +1,7 @@
1
+ /**
2
+ * JavaScript HTTP client for the Seam API written in TypeScript.
3
+ *
4
+ * @packageDocumentation
5
+ */
1
6
  export * from './lib/index.js';
2
7
  //# sourceMappingURL=index.js.map
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,cAAc,gBAAgB,CAAA"}
package/lib/client.d.ts CHANGED
@@ -3,8 +3,20 @@ import { type AxiosRetry } from 'axios-retry';
3
3
  export type Client = AxiosInstance;
4
4
  export declare const defaultTimeout = 30000;
5
5
  export interface ClientOptions {
6
+ /**
7
+ * Request timeout in milliseconds, applied per attempt.
8
+ * Set to 0 to disable the timeout. Defaults to 30 seconds.
9
+ */
6
10
  timeout?: number;
11
+ /**
12
+ * Options passed to the underlying Axios client.
13
+ */
7
14
  axiosOptions?: AxiosRequestConfig;
15
+ /**
16
+ * Options passed to axios-retry,
17
+ * which retries idempotent requests that fail
18
+ * because of a transport error, timeout, or HTTP 429 response.
19
+ */
8
20
  axiosRetryOptions?: AxiosRetryConfig;
9
21
  }
10
22
  type AxiosRetryConfig = Parameters<AxiosRetry>[1];
package/lib/client.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"client.js","sourceRoot":"","sources":["../src/lib/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAA+C,MAAM,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MAAM,wBAAwB,CAAA;AACzD,OAAO,EAAE,wBAAwB,EAAE,MAAM,mCAAmC,CAAA;AAI5E,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAA;AA0BpC,MAAM,wBAAwB,GAAG;IAC/B,OAAO,EAAE,CAAC;IACV,cAAc,EAAE,wBAAwB;IACxC,UAAU,EAAE,gBAAgB;IAC5B,kBAAkB,EAAE,IAAI;IACxB,OAAO,EAAE,GAAG,EAAE,CAAC,SAAS;IACxB,uBAAuB,EAAE,GAAG,EAAE,CAAC,SAAS;IACxC,gBAAgB,EAAE,IAAI;CACY,CAAA;AAEpC,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,OAAsB,EAAiB,EAAE;IACpE,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC;QAC1B,gBAAgB,EAAE,wBAAwB;QAC1C,OAAO,EAAE,OAAO;QAChB,OAAO,EAAE,OAAO,CAAC,OAAO,IAAI,cAAc;QAC1C,GAAG,OAAO,CAAC,YAAY;KACxB,CAAC,CAAA;IAEF,UAAU,CAAC,MAAM,EAAE;QACjB,GAAG,wBAAwB;QAC3B,GAAG,OAAO,CAAC,iBAAiB;KAC7B,CAAC,CAAA;IAEF,MAAM,CAAC,YAAY,CAAC,QAAQ,CAAC,GAAG,CAAC,SAAS,EAAE,gBAAgB,CAAC,CAAA;IAE7D,OAAO,MAAM,CAAA;AACf,CAAC,CAAA"}
package/lib/index.d.ts CHANGED
@@ -2,7 +2,7 @@ export { SeamHttpInvalidTokenError } from './auth.js';
2
2
  export * from './error-interceptor.js';
3
3
  export * from './openapi.js';
4
4
  export * from './options.js';
5
- export { isSeamActionAttemptError, isSeamActionAttemptFailedError, isSeamActionAttemptTimeoutError, SeamActionAttemptError, SeamActionAttemptFailedError, SeamActionAttemptTimeoutError, } from './resolve-action-attempt.js';
5
+ export { type FailedActionAttempt, isSeamActionAttemptError, isSeamActionAttemptFailedError, isSeamActionAttemptTimeoutError, type ResolveActionAttemptOptions, SeamActionAttemptError, SeamActionAttemptFailedError, SeamActionAttemptTimeoutError, type SucceededActionAttempt, } from './resolve-action-attempt.js';
6
6
  export * from './resources/index.js';
7
7
  export * from './routes/index.js';
8
8
  export * from './seam-http-error.js';
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/lib/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,WAAW,CAAA;AACrD,cAAc,wBAAwB,CAAA;AACtC,cAAc,cAAc,CAAA;AAC5B,cAAc,cAAc,CAAA;AAC5B,OAAO,EACL,wBAAwB,EACxB,8BAA8B,EAC9B,+BAA+B,EAC/B,sBAAsB,EACtB,4BAA4B,EAC5B,6BAA6B,GAC9B,MAAM,6BAA6B,CAAA;AACpC,cAAc,sBAAsB,CAAA;AACpC,cAAc,mBAAmB,CAAA;AACjC,cAAc,sBAAsB,CAAA;AACpC,cAAc,wBAAwB,CAAA;AACtC,cAAc,qBAAqB,CAAA;AACnC,OAAO,EACL,QAAQ,EACR,oBAAoB,EACpB,qBAAqB,EACrB,qBAAqB,EACrB,gBAAgB,GACjB,MAAM,YAAY,CAAA;AACnB,cAAc,mCAAmC,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/lib/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,WAAW,CAAA;AACrD,cAAc,wBAAwB,CAAA;AACtC,cAAc,cAAc,CAAA;AAC5B,cAAc,cAAc,CAAA;AAC5B,OAAO,EAEL,wBAAwB,EACxB,8BAA8B,EAC9B,+BAA+B,EAE/B,sBAAsB,EACtB,4BAA4B,EAC5B,6BAA6B,GAE9B,MAAM,6BAA6B,CAAA;AACpC,cAAc,sBAAsB,CAAA;AACpC,cAAc,mBAAmB,CAAA;AACjC,cAAc,sBAAsB,CAAA;AACpC,cAAc,wBAAwB,CAAA;AACtC,cAAc,qBAAqB,CAAA;AACnC,OAAO,EACL,QAAQ,EACR,oBAAoB,EACpB,qBAAqB,EACrB,qBAAqB,EACrB,gBAAgB,GACjB,MAAM,YAAY,CAAA;AACnB,cAAc,mCAAmC,CAAA"}
package/lib/options.d.ts CHANGED
@@ -1,54 +1,159 @@
1
1
  import type { Client, ClientOptions } from './client.js';
2
2
  import { type SeamHttpRequestOptions } from './request-options.js';
3
3
  export type { SeamHttpRequestOptions } from './request-options.js';
4
+ /**
5
+ * Options for creating a SeamHttpWithoutWorkspace client,
6
+ * which is not scoped to a single workspace.
7
+ */
4
8
  export type SeamHttpWithoutWorkspaceOptions = SeamHttpWithoutWorkspaceOptionsFromEnv | SeamHttpWithoutWorkspaceOptionsWithClient | SeamHttpWithoutWorkspaceOptionsWithConsoleSessionToken | SeamHttpWithoutWorkspaceOptionsWithPersonalAccessToken;
9
+ /**
10
+ * Options for creating a SeamHttp client.
11
+ */
5
12
  export type SeamHttpOptions = SeamHttpOptionsFromEnv | SeamHttpOptionsWithClient | SeamHttpOptionsWithApiKey | SeamHttpOptionsWithClientSessionToken | SeamHttpOptionsWithConsoleSessionToken | SeamHttpOptionsWithPersonalAccessToken;
6
13
  interface SeamHttpCommonOptions extends ClientOptions, SeamHttpRequestOptions {
14
+ /**
15
+ * The Seam API endpoint, e.g., `https://connect.getseam.com`.
16
+ * Defaults to the SEAM_ENDPOINT or SEAM_API_URL environment variable, if set.
17
+ */
7
18
  endpoint?: string;
8
19
  }
20
+ /**
21
+ * Options for creating a SeamHttp client with `SeamHttp.fromPublishableKey`.
22
+ */
9
23
  export interface SeamHttpFromPublishableKeyOptions extends SeamHttpCommonOptions {
10
24
  }
25
+ /**
26
+ * Options for creating a SeamHttp client that reads its configuration
27
+ * from the environment, e.g., the SEAM_API_KEY environment variable.
28
+ */
11
29
  export interface SeamHttpOptionsFromEnv extends SeamHttpCommonOptions {
12
30
  }
31
+ /**
32
+ * Options for creating a SeamHttpWithoutWorkspace client that reads
33
+ * its configuration from the environment,
34
+ * e.g., the SEAM_PERSONAL_ACCESS_TOKEN environment variable.
35
+ */
13
36
  export interface SeamHttpWithoutWorkspaceOptionsFromEnv extends SeamHttpCommonOptions {
14
37
  }
38
+ /**
39
+ * Options for creating a SeamHttpWithoutWorkspace client from an existing client.
40
+ */
15
41
  export interface SeamHttpWithoutWorkspaceOptionsWithClient extends SeamHttpCommonOptions {
16
42
  client: Client;
17
43
  }
44
+ /**
45
+ * Returns true if the options include a client.
46
+ *
47
+ * @throws {@link SeamHttpInvalidOptionsError} if the client option
48
+ * is used with any other option.
49
+ */
18
50
  export declare const isSeamHttpWithoutWorkspaceOptionsWithClient: (options: SeamHttpOptions) => options is SeamHttpWithoutWorkspaceOptionsWithClient;
51
+ /**
52
+ * Options for creating a SeamHttp client from an existing client.
53
+ */
19
54
  export interface SeamHttpOptionsWithClient extends SeamHttpRequestOptions {
20
55
  client: Client;
21
56
  }
57
+ /**
58
+ * Returns true if the options include a client.
59
+ *
60
+ * @throws {@link SeamHttpInvalidOptionsError} if the client option
61
+ * is used with any other option.
62
+ */
22
63
  export declare const isSeamHttpOptionsWithClient: (options: SeamHttpOptions) => options is SeamHttpOptionsWithClient;
64
+ /**
65
+ * Options for creating a SeamHttp client authenticated with an API key.
66
+ */
23
67
  export interface SeamHttpOptionsWithApiKey extends SeamHttpCommonOptions {
24
68
  apiKey: string;
25
69
  }
70
+ /**
71
+ * Returns true if the options include an apiKey.
72
+ *
73
+ * @throws {@link SeamHttpInvalidOptionsError} if the apiKey option
74
+ * is used with another authentication option.
75
+ */
26
76
  export declare const isSeamHttpOptionsWithApiKey: (options: SeamHttpOptions) => options is SeamHttpOptionsWithApiKey;
77
+ /**
78
+ * Options for creating a SeamHttp client authenticated with a client session token.
79
+ */
27
80
  export interface SeamHttpOptionsWithClientSessionToken extends SeamHttpCommonOptions {
28
81
  clientSessionToken: string;
29
82
  }
83
+ /**
84
+ * Returns true if the options include a clientSessionToken.
85
+ *
86
+ * @throws {@link SeamHttpInvalidOptionsError} if the clientSessionToken option
87
+ * is used with another authentication option.
88
+ */
30
89
  export declare const isSeamHttpOptionsWithClientSessionToken: (options: SeamHttpOptions) => options is SeamHttpOptionsWithClientSessionToken;
90
+ /**
91
+ * Options for creating a SeamHttpWithoutWorkspace client
92
+ * authenticated with a console session token.
93
+ */
31
94
  export interface SeamHttpWithoutWorkspaceOptionsWithConsoleSessionToken extends SeamHttpCommonOptions {
32
95
  consoleSessionToken: string;
33
96
  }
97
+ /**
98
+ * Returns true if the options include a consoleSessionToken.
99
+ *
100
+ * @throws {@link SeamHttpInvalidOptionsError} if the consoleSessionToken option
101
+ * is used with another authentication option.
102
+ */
34
103
  export declare const isSeamHttpWithoutWorkspaceOptionsWithConsoleSessionToken: (options: SeamHttpOptions) => options is SeamHttpWithoutWorkspaceOptionsWithConsoleSessionToken;
104
+ /**
105
+ * Options for creating a SeamHttp client
106
+ * authenticated with a console session token and scoped to a workspace.
107
+ */
35
108
  export interface SeamHttpOptionsWithConsoleSessionToken extends SeamHttpCommonOptions {
36
109
  consoleSessionToken: string;
37
110
  workspaceId: string;
38
111
  }
112
+ /**
113
+ * Returns true if the options include a consoleSessionToken and a workspaceId.
114
+ *
115
+ * @throws {@link SeamHttpInvalidOptionsError} if the consoleSessionToken option
116
+ * is used with another authentication option or without the workspaceId option.
117
+ */
39
118
  export declare const isSeamHttpOptionsWithConsoleSessionToken: (options: SeamHttpOptions) => options is SeamHttpOptionsWithConsoleSessionToken;
119
+ /**
120
+ * Options for creating a SeamHttpWithoutWorkspace client
121
+ * authenticated with a personal access token.
122
+ */
40
123
  export interface SeamHttpWithoutWorkspaceOptionsWithPersonalAccessToken extends SeamHttpCommonOptions {
41
124
  personalAccessToken: string;
42
125
  }
126
+ /**
127
+ * Returns true if the options include a personalAccessToken.
128
+ *
129
+ * @throws {@link SeamHttpInvalidOptionsError} if the personalAccessToken option
130
+ * is used with another authentication option.
131
+ */
43
132
  export declare const isSeamHttpWithoutWorkspaceOptionsWithPersonalAccessToken: (options: SeamHttpOptions) => options is SeamHttpWithoutWorkspaceOptionsWithPersonalAccessToken;
133
+ /**
134
+ * Options for creating a SeamHttp client
135
+ * authenticated with a personal access token and scoped to a workspace.
136
+ */
44
137
  export interface SeamHttpOptionsWithPersonalAccessToken extends SeamHttpCommonOptions {
45
138
  personalAccessToken: string;
46
139
  workspaceId: string;
47
140
  }
141
+ /**
142
+ * Returns true if the options include a personalAccessToken and a workspaceId.
143
+ *
144
+ * @throws {@link SeamHttpInvalidOptionsError} if the personalAccessToken option
145
+ * is used with another authentication option or without the workspaceId option.
146
+ */
48
147
  export declare const isSeamHttpOptionsWithPersonalAccessToken: (options: SeamHttpOptions) => options is SeamHttpOptionsWithPersonalAccessToken;
148
+ /**
149
+ * Error thrown when a SeamHttp client is created with invalid options.
150
+ */
49
151
  export declare class SeamHttpInvalidOptionsError extends Error {
50
152
  constructor(message: string);
51
153
  }
154
+ /**
155
+ * Error thrown when a SeamHttpWithoutWorkspace client is created with invalid options.
156
+ */
52
157
  export declare class SeamHttpWithoutWorkspaceInvalidOptionsError extends Error {
53
158
  constructor(message: string);
54
159
  }
package/lib/options.js CHANGED
@@ -1,5 +1,17 @@
1
1
  import { isSeamHttpRequestOption, } from './request-options.js';
2
+ /**
3
+ * Returns true if the options include a client.
4
+ *
5
+ * @throws {@link SeamHttpInvalidOptionsError} if the client option
6
+ * is used with any other option.
7
+ */
2
8
  export const isSeamHttpWithoutWorkspaceOptionsWithClient = (options) => isSeamHttpOptionsWithClient(options);
9
+ /**
10
+ * Returns true if the options include a client.
11
+ *
12
+ * @throws {@link SeamHttpInvalidOptionsError} if the client option
13
+ * is used with any other option.
14
+ */
3
15
  export const isSeamHttpOptionsWithClient = (options) => {
4
16
  if (!('client' in options))
5
17
  return false;
@@ -11,6 +23,12 @@ export const isSeamHttpOptionsWithClient = (options) => {
11
23
  }
12
24
  return true;
13
25
  };
26
+ /**
27
+ * Returns true if the options include an apiKey.
28
+ *
29
+ * @throws {@link SeamHttpInvalidOptionsError} if the apiKey option
30
+ * is used with another authentication option.
31
+ */
14
32
  export const isSeamHttpOptionsWithApiKey = (options) => {
15
33
  if (!('apiKey' in options))
16
34
  return false;
@@ -27,6 +45,12 @@ export const isSeamHttpOptionsWithApiKey = (options) => {
27
45
  }
28
46
  return true;
29
47
  };
48
+ /**
49
+ * Returns true if the options include a clientSessionToken.
50
+ *
51
+ * @throws {@link SeamHttpInvalidOptionsError} if the clientSessionToken option
52
+ * is used with another authentication option.
53
+ */
30
54
  export const isSeamHttpOptionsWithClientSessionToken = (options) => {
31
55
  if (!('clientSessionToken' in options))
32
56
  return false;
@@ -43,6 +67,12 @@ export const isSeamHttpOptionsWithClientSessionToken = (options) => {
43
67
  }
44
68
  return true;
45
69
  };
70
+ /**
71
+ * Returns true if the options include a consoleSessionToken.
72
+ *
73
+ * @throws {@link SeamHttpInvalidOptionsError} if the consoleSessionToken option
74
+ * is used with another authentication option.
75
+ */
46
76
  export const isSeamHttpWithoutWorkspaceOptionsWithConsoleSessionToken = (options) => {
47
77
  if (!('consoleSessionToken' in options))
48
78
  return false;
@@ -59,6 +89,12 @@ export const isSeamHttpWithoutWorkspaceOptionsWithConsoleSessionToken = (options
59
89
  }
60
90
  return true;
61
91
  };
92
+ /**
93
+ * Returns true if the options include a consoleSessionToken and a workspaceId.
94
+ *
95
+ * @throws {@link SeamHttpInvalidOptionsError} if the consoleSessionToken option
96
+ * is used with another authentication option or without the workspaceId option.
97
+ */
62
98
  export const isSeamHttpOptionsWithConsoleSessionToken = (options) => {
63
99
  if (!isSeamHttpWithoutWorkspaceOptionsWithConsoleSessionToken(options)) {
64
100
  return false;
@@ -68,6 +104,12 @@ export const isSeamHttpOptionsWithConsoleSessionToken = (options) => {
68
104
  }
69
105
  return true;
70
106
  };
107
+ /**
108
+ * Returns true if the options include a personalAccessToken.
109
+ *
110
+ * @throws {@link SeamHttpInvalidOptionsError} if the personalAccessToken option
111
+ * is used with another authentication option.
112
+ */
71
113
  export const isSeamHttpWithoutWorkspaceOptionsWithPersonalAccessToken = (options) => {
72
114
  if (!('personalAccessToken' in options))
73
115
  return false;
@@ -84,6 +126,12 @@ export const isSeamHttpWithoutWorkspaceOptionsWithPersonalAccessToken = (options
84
126
  }
85
127
  return true;
86
128
  };
129
+ /**
130
+ * Returns true if the options include a personalAccessToken and a workspaceId.
131
+ *
132
+ * @throws {@link SeamHttpInvalidOptionsError} if the personalAccessToken option
133
+ * is used with another authentication option or without the workspaceId option.
134
+ */
87
135
  export const isSeamHttpOptionsWithPersonalAccessToken = (options) => {
88
136
  if (!isSeamHttpWithoutWorkspaceOptionsWithPersonalAccessToken(options)) {
89
137
  return false;
@@ -93,12 +141,18 @@ export const isSeamHttpOptionsWithPersonalAccessToken = (options) => {
93
141
  }
94
142
  return true;
95
143
  };
144
+ /**
145
+ * Error thrown when a SeamHttp client is created with invalid options.
146
+ */
96
147
  export class SeamHttpInvalidOptionsError extends Error {
97
148
  constructor(message) {
98
149
  super(`SeamHttp received invalid options: ${message}`);
99
150
  this.name = this.constructor.name;
100
151
  }
101
152
  }
153
+ /**
154
+ * Error thrown when a SeamHttpWithoutWorkspace client is created with invalid options.
155
+ */
102
156
  export class SeamHttpWithoutWorkspaceInvalidOptionsError extends Error {
103
157
  constructor(message) {
104
158
  super(`SeamHttpWithoutWorkspace received invalid options: ${message}`);
@@ -1 +1 @@
1
- {"version":3,"file":"options.js","sourceRoot":"","sources":["../src/lib/options.ts"],"names":[],"mappings":"AACA,OAAO,EACL,uBAAuB,GAExB,MAAM,sBAAsB,CAAA;AAgC7B,MAAM,CAAC,MAAM,2CAA2C,GAAG,CACzD,OAAwB,EAC8B,EAAE,CACxD,2BAA2B,CAAC,OAAO,CAAC,CAAA;AAMtC,MAAM,CAAC,MAAM,2BAA2B,GAAG,CACzC,OAAwB,EACc,EAAE;IACxC,IAAI,CAAC,CAAC,QAAQ,IAAI,OAAO,CAAC;QAAE,OAAO,KAAK,CAAA;IACxC,IAAI,OAAO,CAAC,MAAM,IAAI,IAAI;QAAE,OAAO,KAAK,CAAA;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,CAC3D,CAAA;IACH,CAAC;IAED,OAAO,IAAI,CAAA;AACb,CAAC,CAAA;AAED;;GAEG;AACH,MAAM,OAAO,2BAA4B,SAAQ,KAAK;IACpD,YAAY,OAAe;QACzB,KAAK,CAAC,sCAAsC,OAAO,EAAE,CAAC,CAAA;QACtD,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAA;IACnC,CAAC;CACF;AAED;;GAEG;AACH,MAAM,OAAO,2CAA4C,SAAQ,KAAK;IACpE,YAAY,OAAe;QACzB,KAAK,CAAC,sDAAsD,OAAO,EAAE,CAAC,CAAA;QACtE,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAA;IACnC,CAAC;CACF"}
@@ -1,5 +1,18 @@
1
1
  import type { ResolveActionAttemptOptions } from './resolve-action-attempt.js';
2
+ /**
3
+ * Options for how a {@link SeamHttpRequest} is executed.
4
+ */
2
5
  export interface SeamHttpRequestOptions {
6
+ /**
7
+ * Controls whether to wait for the action attempt to resolve
8
+ * when a request returns an action attempt.
9
+ * Pass a boolean to toggle waiting,
10
+ * or {@link ResolveActionAttemptOptions} to also configure
11
+ * the timeout and polling interval.
12
+ */
3
13
  waitForActionAttempt?: boolean | ResolveActionAttemptOptions;
4
14
  }
15
+ /**
16
+ * Returns true if the key is the name of a {@link SeamHttpRequestOptions} property.
17
+ */
5
18
  export declare const isSeamHttpRequestOption: (key: string) => key is keyof SeamHttpRequestOptions;
@@ -1,3 +1,6 @@
1
+ /**
2
+ * Returns true if the key is the name of a {@link SeamHttpRequestOptions} property.
3
+ */
1
4
  export const isSeamHttpRequestOption = (key) => {
2
5
  const keys = {
3
6
  waitForActionAttempt: true,
@@ -1 +1 @@
1
- {"version":3,"file":"request-options.js","sourceRoot":"","sources":["../src/lib/request-options.ts"],"names":[],"mappings":"AAMA,MAAM,CAAC,MAAM,uBAAuB,GAAG,CACrC,GAAW,EAC0B,EAAE;IACvC,MAAM,IAAI,GAA+C;QACvD,oBAAoB,EAAE,IAAI;KAC3B,CAAA;IACD,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAA;AACxC,CAAC,CAAA"}
1
+ {"version":3,"file":"request-options.js","sourceRoot":"","sources":["../src/lib/request-options.ts"],"names":[],"mappings":"AAgBA;;GAEG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,CACrC,GAAW,EAC0B,EAAE;IACvC,MAAM,IAAI,GAA+C;QACvD,oBAAoB,EAAE,IAAI;KAC3B,CAAA;IACD,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAA;AACxC,CAAC,CAAA"}
@@ -1,31 +1,78 @@
1
1
  import type { ActionAttempt } from './resources/action-attempt.js';
2
+ /**
3
+ * Client used to poll action attempts by id, e.g., `SeamHttpActionAttempts`.
4
+ */
2
5
  export interface ActionAttemptsClient {
3
6
  get(parameters: {
4
7
  action_attempt_id: string;
5
8
  }): PromiseLike<ActionAttempt>;
6
9
  }
10
+ /**
11
+ * Options for waiting until an action attempt resolves.
12
+ */
7
13
  export interface ResolveActionAttemptOptions {
14
+ /**
15
+ * Maximum time in milliseconds to wait for the action attempt to resolve.
16
+ */
8
17
  timeout?: number;
18
+ /**
19
+ * Time in milliseconds to wait between polls of the action attempt.
20
+ */
9
21
  pollingInterval?: number;
10
22
  }
23
+ /**
24
+ * Polls a pending action attempt until it succeeds, fails, or times out.
25
+ *
26
+ * @returns The succeeded action attempt.
27
+ * @throws {@link SeamActionAttemptFailedError} if the action attempt fails.
28
+ * @throws {@link SeamActionAttemptTimeoutError} if the action attempt
29
+ * does not resolve within the timeout.
30
+ */
11
31
  export declare const resolveActionAttempt: <T extends ActionAttempt>(actionAttempt: T, actionAttempts: ActionAttemptsClient, { timeout, pollingInterval }: ResolveActionAttemptOptions) => Promise<SucceededActionAttempt<T>>;
32
+ /**
33
+ * Returns true if the error is a {@link SeamActionAttemptError}.
34
+ */
12
35
  export declare const isSeamActionAttemptError: <T extends ActionAttempt>(error: unknown) => error is SeamActionAttemptError<T>;
36
+ /**
37
+ * Error relating to an action attempt.
38
+ */
13
39
  export declare class SeamActionAttemptError<T extends ActionAttempt> extends Error {
14
40
  actionAttempt: T;
15
41
  constructor(message: string, actionAttempt: T);
16
42
  }
43
+ /**
44
+ * Returns true if the error is a {@link SeamActionAttemptFailedError}.
45
+ */
17
46
  export declare const isSeamActionAttemptFailedError: <T extends ActionAttempt>(error: unknown) => error is SeamActionAttemptFailedError<T>;
47
+ /**
48
+ * Error thrown when an action attempt fails.
49
+ */
18
50
  export declare class SeamActionAttemptFailedError<T extends ActionAttempt> extends SeamActionAttemptError<T> {
51
+ /**
52
+ * Error type returned by the Seam API for the failed action attempt.
53
+ */
19
54
  code: string;
20
55
  constructor(actionAttempt: FailedActionAttempt<T>);
21
56
  }
57
+ /**
58
+ * Returns true if the error is a {@link SeamActionAttemptTimeoutError}.
59
+ */
22
60
  export declare const isSeamActionAttemptTimeoutError: <T extends ActionAttempt>(error: unknown) => error is SeamActionAttemptTimeoutError<T>;
61
+ /**
62
+ * Error thrown when an action attempt does not resolve within the timeout.
63
+ */
23
64
  export declare class SeamActionAttemptTimeoutError<T extends ActionAttempt> extends SeamActionAttemptError<T> {
24
65
  constructor(actionAttempt: T, timeout: number);
25
66
  }
67
+ /**
68
+ * An action attempt that has succeeded.
69
+ */
26
70
  export type SucceededActionAttempt<T extends ActionAttempt> = T & {
27
71
  status: 'success';
28
72
  };
73
+ /**
74
+ * An action attempt that has failed.
75
+ */
29
76
  export type FailedActionAttempt<T extends ActionAttempt> = T & {
30
77
  status: 'error';
31
78
  };
@@ -1,3 +1,11 @@
1
+ /**
2
+ * Polls a pending action attempt until it succeeds, fails, or times out.
3
+ *
4
+ * @returns The succeeded action attempt.
5
+ * @throws {@link SeamActionAttemptFailedError} if the action attempt fails.
6
+ * @throws {@link SeamActionAttemptTimeoutError} if the action attempt
7
+ * does not resolve within the timeout.
8
+ */
1
9
  export const resolveActionAttempt = async (actionAttempt, actionAttempts, { timeout = 10_000, pollingInterval = 1_000 }) => {
2
10
  let timeoutRef;
3
11
  const timeoutPromise = new Promise((_resolve, reject) => {
@@ -29,9 +37,15 @@ const pollActionAttempt = async (actionAttempt, actionAttempts, options) => {
29
37
  });
30
38
  return await pollActionAttempt(nextActionAttempt, actionAttempts, options);
31
39
  };
40
+ /**
41
+ * Returns true if the error is a {@link SeamActionAttemptError}.
42
+ */
32
43
  export const isSeamActionAttemptError = (error) => {
33
44
  return error instanceof SeamActionAttemptError;
34
45
  };
46
+ /**
47
+ * Error relating to an action attempt.
48
+ */
35
49
  export class SeamActionAttemptError extends Error {
36
50
  actionAttempt;
37
51
  constructor(message, actionAttempt) {
@@ -40,10 +54,19 @@ export class SeamActionAttemptError extends Error {
40
54
  this.actionAttempt = actionAttempt;
41
55
  }
42
56
  }
57
+ /**
58
+ * Returns true if the error is a {@link SeamActionAttemptFailedError}.
59
+ */
43
60
  export const isSeamActionAttemptFailedError = (error) => {
44
61
  return error instanceof SeamActionAttemptFailedError;
45
62
  };
63
+ /**
64
+ * Error thrown when an action attempt fails.
65
+ */
46
66
  export class SeamActionAttemptFailedError extends SeamActionAttemptError {
67
+ /**
68
+ * Error type returned by the Seam API for the failed action attempt.
69
+ */
47
70
  code;
48
71
  constructor(actionAttempt) {
49
72
  super(actionAttempt.error.message, actionAttempt);
@@ -51,9 +74,15 @@ export class SeamActionAttemptFailedError extends SeamActionAttemptError {
51
74
  this.code = actionAttempt.error.type;
52
75
  }
53
76
  }
77
+ /**
78
+ * Returns true if the error is a {@link SeamActionAttemptTimeoutError}.
79
+ */
54
80
  export const isSeamActionAttemptTimeoutError = (error) => {
55
81
  return error instanceof SeamActionAttemptTimeoutError;
56
82
  };
83
+ /**
84
+ * Error thrown when an action attempt does not resolve within the timeout.
85
+ */
57
86
  export class SeamActionAttemptTimeoutError extends SeamActionAttemptError {
58
87
  constructor(actionAttempt, timeout) {
59
88
  super(`Timed out waiting for action action attempt after ${timeout}ms`, actionAttempt);
@@ -1 +1 @@
1
- {"version":3,"file":"resolve-action-attempt.js","sourceRoot":"","sources":["../src/lib/resolve-action-attempt.ts"],"names":[],"mappings":"AAWA,MAAM,CAAC,MAAM,oBAAoB,GAAG,KAAK,EACvC,aAAgB,EAChB,cAAoC,EACpC,EAAE,OAAO,GAAG,MAAM,EAAE,eAAe,GAAG,KAAK,EAA+B,EACtC,EAAE;IACtC,IAAI,UAAU,CAAA;IACd,MAAM,cAAc,GAAG,IAAI,OAAO,CAChC,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE;QACnB,UAAU,GAAG,UAAU,CAAC,UAAU,CAAC,GAAG,EAAE;YACtC,MAAM,CAAC,IAAI,6BAA6B,CAAI,aAAa,EAAE,OAAO,CAAC,CAAC,CAAA;QACtE,CAAC,EAAE,OAAO,CAAC,CAAA;IACb,CAAC,CACF,CAAA;IAED,IAAI,CAAC;QACH,OAAO,MAAM,OAAO,CAAC,IAAI,CAAC;YACxB,iBAAiB,CAAI,aAAa,EAAE,cAAc,EAAE,EAAE,eAAe,EAAE,CAAC;YACxE,cAAc;SACf,CAAC,CAAA;IACJ,CAAC;YAAS,CAAC;QACT,IAAI,UAAU,IAAI,IAAI;YAAE,UAAU,CAAC,YAAY,CAAC,UAAU,CAAC,CAAA;IAC7D,CAAC;AACH,CAAC,CAAA;AAED,MAAM,iBAAiB,GAAG,KAAK,EAC7B,aAAgB,EAChB,cAAoC,EACpC,OAA6D,EACzB,EAAE;IACtC,IAAI,yBAAyB,CAAC,aAAa,CAAC,EAAE,CAAC;QAC7C,OAAO,aAAa,CAAA;IACtB,CAAC;IAED,IAAI,qBAAqB,CAAC,aAAa,CAAC,EAAE,CAAC;QACzC,MAAM,IAAI,4BAA4B,CAAC,aAAa,CAAC,CAAA;IACvD,CAAC;IAED,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAA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AAE,aAAa,CAAC,CAAA;QACjD,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAA;QACjC,IAAI,CAAC,IAAI,GAAG,aAAa,CAAC,KAAK,CAAC,IAAI,CAAA;IACtC,CAAC;CACF;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,+BAA+B,GAAG,CAC7C,KAAc,EAC6B,EAAE;IAC7C,OAAO,KAAK,YAAY,6BAA6B,CAAA;AACvD,CAAC,CAAA;AAED;;GAEG;AACH,MAAM,OAAO,6BAEX,SAAQ,sBAAyB;IACjC,YAAY,aAAgB,EAAE,OAAe;QAC3C,KAAK,CACH,qDAAqD,OAAO,IAAI,EAChE,aAAa,CACd,CAAA;QACD,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAA;IACnC,CAAC;CACF;AAED,MAAM,yBAAyB,GAAG,CAChC,aAAgB,EAC4B,EAAE,CAC9C,aAAa,CAAC,MAAM,KAAK,SAAS,CAAA;AAEpC,MAAM,qBAAqB,GAAG,CAC5B,aAAgB,EACyB,EAAE,CAAC,aAAa,CAAC,MAAM,KAAK,OAAO,CAAA"}
@@ -258,6 +258,63 @@ export type AccessCode = {
258
258
  */
259
259
  message: string;
260
260
  } /**
261
+ * Seam was unable to issue this access code before its start time, so the recipient may be unable to unlock the device. This usually points to a problem that needs attention, such as an offline or disconnected device. Seam keeps retrying, and this error clears automatically if the access code is eventually issued.
262
+ */ | {
263
+ /**
264
+ * Date and time at which Seam created the error.
265
+ */
266
+ created_at?: string | undefined;
267
+ /**
268
+ * Unique identifier of the type of error. Enables quick recognition and categorization of the issue.
269
+ */
270
+ error_code: 'failed_to_issue';
271
+ /**
272
+ * Indicates that this is an access code error.
273
+ */
274
+ is_access_code_error: true;
275
+ /**
276
+ * Detailed description of the error. Provides insights into the issue and potentially how to rectify it.
277
+ */
278
+ message: string;
279
+ } /**
280
+ * Seam was unable to apply this access code's pending mutations to the device, so the code on the device does not match its requested state. Seam keeps retrying, and this error clears automatically once the mutations are applied.
281
+ */ | {
282
+ /**
283
+ * Date and time at which Seam created the error.
284
+ */
285
+ created_at?: string | undefined;
286
+ /**
287
+ * Unique identifier of the type of error. Enables quick recognition and categorization of the issue.
288
+ */
289
+ error_code: 'failed_to_apply_mutations';
290
+ /**
291
+ * Indicates that this is an access code error.
292
+ */
293
+ is_access_code_error: true;
294
+ /**
295
+ * Detailed description of the error. Provides insights into the issue and potentially how to rectify it.
296
+ */
297
+ message: string;
298
+ } /**
299
+ * This access code is still active on the device even though its `ends_at` has passed, so the recipient may still be able to unlock the device after their access window ended. Seam is attempting to remove it, and this error clears automatically once the access code is no longer active.
300
+ */ | {
301
+ /**
302
+ * Date and time at which Seam created the error.
303
+ */
304
+ created_at?: string | undefined;
305
+ /**
306
+ * Unique identifier of the type of error. Enables quick recognition and categorization of the issue.
307
+ */
308
+ error_code: 'failed_to_expire';
309
+ /**
310
+ * Indicates that this is an access code error.
311
+ */
312
+ is_access_code_error: true;
313
+ /**
314
+ * Detailed description of the error. Provides insights into the issue and potentially how to rectify it.
315
+ */
316
+ message: string;
317
+ } /**
261
318
  * Indicates that the account is disconnected.
262
319
  */ | {
263
320
  /**
@@ -860,6 +917,36 @@ export type AccessCode = {
860
917
  */
861
918
  warning_code: 'delay_in_removing_from_device';
862
919
  } /**
920
+ * Seam has not yet issued this access code, even though its start time is approaching, so access may not be ready when the recipient arrives. Seam is still attempting to issue it, and this warning clears automatically once issuance succeeds.
921
+ */ | {
922
+ /**
923
+ * Date and time at which Seam created the warning.
924
+ */
925
+ created_at?: string | undefined;
926
+ /**
927
+ * Detailed description of the warning. Provides insights into the issue and potentially how to rectify it.
928
+ */
929
+ message: string;
930
+ /**
931
+ * Unique identifier of the type of warning. Enables quick recognition and categorization of the issue.
932
+ */
933
+ warning_code: 'delay_in_issuing';
934
+ } /**
935
+ * Seam has not yet applied this access code's pending mutations to the device, so the code on the device does not yet match its requested state. Seam is still attempting to apply them, and this warning clears automatically once the mutations are applied.
936
+ */ | {
937
+ /**
938
+ * Date and time at which Seam created the warning.
939
+ */
940
+ created_at?: string | undefined;
941
+ /**
942
+ * Detailed description of the warning. Provides insights into the issue and potentially how to rectify it.
943
+ */
944
+ message: string;
945
+ /**
946
+ * Unique identifier of the type of warning. Enables quick recognition and categorization of the issue.
947
+ */
948
+ warning_code: 'delay_in_applying_mutations';
949
+ } /**
863
950
  * Third-party integration detected that may cause access codes to fail.
864
951
  */ | {
865
952
  /**