@seamapi/http 2.11.1 → 2.11.2

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
@@ -465,8 +465,10 @@ const seam = new SeamHttp({
465
465
  ```
466
466
 
467
467
  Set `timeout` to `0` to disable the timeout entirely.
468
- A request that times out rejects with an Axios `ETIMEDOUT` error,
469
- and is retried according to the retry options.
468
+ A request that times out rejects with an Axios `ETIMEDOUT` error.
469
+ Timed-out idempotent requests are retried according to the retry options, with
470
+ the timeout reset for each attempt. Non-idempotent requests are not retried by
471
+ default.
470
472
 
471
473
  #### Configuring the Axios Client
472
474
 
@@ -474,6 +476,15 @@ The Axios client and retry behavior may be configured with custom initiation opt
474
476
  via [`axiosOptions`][axiosOptions] and [`axiosRetryOptions`][axiosRetryOptions].
475
477
  Options are deep merged with the default options.
476
478
 
479
+ By default, the SDK makes up to three attempts: the initial request and two
480
+ retries. Retries are limited to `GET`, `HEAD`, `OPTIONS`, `PUT`, and `DELETE`
481
+ requests that fail because of a transport error, timeout, HTTP 429 response, or
482
+ HTTP 5xx response. `POST` and `PATCH` requests are not retried.
483
+
484
+ Retries use exponential backoff with jitter: approximately 200–240 ms before
485
+ the first retry and 400–480 ms before the second. A longer `Retry-After` header
486
+ is honored. The request timeout is reset for each attempt.
487
+
477
488
  [axiosOptions]: https://axios-http.com/docs/config_defaults
478
489
  [axiosRetryOptions]: https://github.com/softonic/axios-retry
479
490
 
package/lib/client.js CHANGED
@@ -3,6 +3,15 @@ import axiosRetry, { exponentialDelay, isIdempotentRequestError, } from 'axios-r
3
3
  import { errorInterceptor } from './error-interceptor.js';
4
4
  import { serializeUrlSearchParams } from './url-search-params-serializer.js';
5
5
  export const defaultTimeout = 30_000;
6
+ const defaultAxiosRetryOptions = {
7
+ retries: 2,
8
+ retryCondition: isIdempotentRequestError,
9
+ retryDelay: exponentialDelay,
10
+ shouldResetTimeout: true,
11
+ onRetry: () => undefined,
12
+ onMaxRetryTimesExceeded: () => undefined,
13
+ validateResponse: null,
14
+ };
6
15
  export const createClient = (options) => {
7
16
  const client = axios.create({
8
17
  paramsSerializer: serializeUrlSearchParams,
@@ -11,9 +20,7 @@ export const createClient = (options) => {
11
20
  ...options.axiosOptions,
12
21
  });
13
22
  axiosRetry(client, {
14
- retries: 2,
15
- retryDelay: exponentialDelay,
16
- retryCondition: isIdempotentRequestError,
23
+ ...defaultAxiosRetryOptions,
17
24
  ...options.axiosRetryOptions,
18
25
  });
19
26
  client.interceptors.response.use(undefined, errorInterceptor);
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,OAAO,CAAA;AAC1E,OAAO,UAAU,EAAE,EAEjB,gBAAgB,EAChB,wBAAwB,GACzB,MAAM,aAAa,CAAA;AAEpB,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AACzD,OAAO,EAAE,wBAAwB,EAAE,MAAM,mCAAmC,CAAA;AAI5E,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAA;AAUpC,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,OAAO,EAAE,CAAC;QACV,UAAU,EAAE,gBAAgB;QAC5B,cAAc,EAAE,wBAAwB;QACxC,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"}
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../src/lib/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAA+C,MAAM,OAAO,CAAA;AAC1E,OAAO,UAAU,EAAE,EAEjB,gBAAgB,EAChB,wBAAwB,GACzB,MAAM,aAAa,CAAA;AAEpB,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AACzD,OAAO,EAAE,wBAAwB,EAAE,MAAM,mCAAmC,CAAA;AAI5E,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAA;AAYpC,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/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- declare const seamapiJavascriptHttpVersion = "2.11.1";
1
+ declare const seamapiJavascriptHttpVersion = "2.11.2";
2
2
  export default seamapiJavascriptHttpVersion;
package/lib/version.js CHANGED
@@ -1,3 +1,3 @@
1
- const seamapiJavascriptHttpVersion = '2.11.1';
1
+ const seamapiJavascriptHttpVersion = '2.11.2';
2
2
  export default seamapiJavascriptHttpVersion;
3
3
  //# sourceMappingURL=version.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seamapi/http",
3
- "version": "2.11.1",
3
+ "version": "2.11.2",
4
4
  "description": "JavaScript HTTP client for the Seam API written in TypeScript.",
5
5
  "type": "module",
6
6
  "main": "index.js",
package/src/lib/client.ts CHANGED
@@ -20,6 +20,18 @@ export interface ClientOptions {
20
20
 
21
21
  type AxiosRetryConfig = Parameters<AxiosRetry>[1]
22
22
 
23
+ type RequiredAxiosRetryConfig = Required<NonNullable<AxiosRetryConfig>>
24
+
25
+ const defaultAxiosRetryOptions = {
26
+ retries: 2,
27
+ retryCondition: isIdempotentRequestError,
28
+ retryDelay: exponentialDelay,
29
+ shouldResetTimeout: true,
30
+ onRetry: () => undefined,
31
+ onMaxRetryTimesExceeded: () => undefined,
32
+ validateResponse: null,
33
+ } satisfies RequiredAxiosRetryConfig
34
+
23
35
  export const createClient = (options: ClientOptions): AxiosInstance => {
24
36
  const client = axios.create({
25
37
  paramsSerializer: serializeUrlSearchParams,
@@ -29,9 +41,7 @@ export const createClient = (options: ClientOptions): AxiosInstance => {
29
41
  })
30
42
 
31
43
  axiosRetry(client, {
32
- retries: 2,
33
- retryDelay: exponentialDelay,
34
- retryCondition: isIdempotentRequestError,
44
+ ...defaultAxiosRetryOptions,
35
45
  ...options.axiosRetryOptions,
36
46
  })
37
47
 
@@ -1,3 +1,3 @@
1
- const seamapiJavascriptHttpVersion = '2.11.1'
1
+ const seamapiJavascriptHttpVersion = '2.11.2'
2
2
 
3
3
  export default seamapiJavascriptHttpVersion