ai 7.0.89 → 7.0.91

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.
@@ -7,9 +7,13 @@ import { retryWithExponentialBackoffRespectingRetryHeaders } from '../util/retry
7
7
  export function prepareRetries({
8
8
  maxRetries,
9
9
  abortSignal,
10
+ parameter = 'maxRetries',
11
+ defaultMaxRetries = 2,
10
12
  }: {
11
13
  maxRetries: number | undefined;
12
14
  abortSignal: AbortSignal | undefined;
15
+ parameter?: string;
16
+ defaultMaxRetries?: number;
13
17
  }): {
14
18
  maxRetries: number;
15
19
  retry: RetryFunction;
@@ -17,22 +21,22 @@ export function prepareRetries({
17
21
  if (maxRetries != null) {
18
22
  if (!Number.isInteger(maxRetries)) {
19
23
  throw new InvalidArgumentError({
20
- parameter: 'maxRetries',
24
+ parameter,
21
25
  value: maxRetries,
22
- message: 'maxRetries must be an integer',
26
+ message: `${parameter} must be an integer`,
23
27
  });
24
28
  }
25
29
 
26
30
  if (maxRetries < 0) {
27
31
  throw new InvalidArgumentError({
28
- parameter: 'maxRetries',
32
+ parameter,
29
33
  value: maxRetries,
30
- message: 'maxRetries must be >= 0',
34
+ message: `${parameter} must be >= 0`,
31
35
  });
32
36
  }
33
37
  }
34
38
 
35
- const maxRetriesResult = maxRetries ?? 2;
39
+ const maxRetriesResult = maxRetries ?? defaultMaxRetries;
36
40
 
37
41
  return {
38
42
  maxRetries: maxRetriesResult,