@scrapa/sdk 0.2.2 → 0.4.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 +47 -17
- package/dist/client.js +2 -2
- package/dist/client.js.map +1 -1
- package/dist/errors.js +1 -1
- package/dist/errors.js.map +1 -1
- package/dist/generated/contract.d.ts +66 -10
- package/dist/generated/contract.d.ts.map +1 -1
- package/dist/generated/contract.js +24 -9
- package/dist/generated/contract.js.map +1 -1
- package/dist/generated/operations.d.ts +77 -45
- package/dist/generated/operations.d.ts.map +1 -1
- package/dist/generated/operations.js +89 -43
- package/dist/generated/operations.js.map +1 -1
- package/dist/generated/params.d.ts +250 -98
- package/dist/generated/params.d.ts.map +1 -1
- package/dist/generated/retry.d.ts +2 -2
- package/dist/generated/retry.js +3 -3
- package/dist/generated/transport.js +2 -2
- package/package.json +2 -2
- package/src/client.ts +2 -2
- package/src/errors.ts +1 -1
- package/src/generated/contract.ts +81 -9
- package/src/generated/operations.ts +109 -43
- package/src/generated/params.ts +252 -98
- package/src/generated/retry.ts +3 -3
- package/src/generated/transport.ts +2 -2
package/src/generated/retry.ts
CHANGED
|
@@ -49,9 +49,9 @@ const DEFAULT_MAX_WAIT_SECS = 10;
|
|
|
49
49
|
/**
|
|
50
50
|
* Should this failure be retried?
|
|
51
51
|
*
|
|
52
|
-
* if (attempt < 3 &&
|
|
52
|
+
* if (attempt < 3 && isRetryable(error, { repeatable: method === "GET" || !!key }))
|
|
53
53
|
*/
|
|
54
|
-
export function
|
|
54
|
+
export function isRetryable(error: unknown, options: RetryOptions): boolean {
|
|
55
55
|
const { repeatable, durableCodes = [], maxWaitSecs = DEFAULT_MAX_WAIT_SECS } = options;
|
|
56
56
|
const status = statusOf(error);
|
|
57
57
|
// No answer at all: nothing about it is a refusal, but a write may have landed before the
|
|
@@ -145,7 +145,7 @@ export function parseRetryAfter(value: string | null | undefined): number | unde
|
|
|
145
145
|
* frees when another job ends. Present-and-`null` is the whole test; an absent key said nothing.
|
|
146
146
|
*
|
|
147
147
|
* Not exported. It is not "is this refusal durable?": it knows nothing of `durableCodes` or of a
|
|
148
|
-
* wait too long to hold, so a screen branching on it would disagree with `
|
|
148
|
+
* wait too long to hold, so a screen branching on it would disagree with `isRetryable`.
|
|
149
149
|
*/
|
|
150
150
|
function waitingNeverHelps(error: unknown): boolean {
|
|
151
151
|
const details = field(error, "details");
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
* - **The header is read first, in both its forms.** Two copies read the body's wait before the
|
|
25
25
|
* `Retry-After` header, and read the header only as seconds, so an HTTP date was no wait at all.
|
|
26
26
|
*/
|
|
27
|
-
import { parseRetryAfter, retryDelayMs,
|
|
27
|
+
import { parseRetryAfter, retryDelayMs, isRetryable } from "./retry.ts";
|
|
28
28
|
|
|
29
29
|
/** What a generated method tells the transport about its operation. */
|
|
30
30
|
export interface RequestSpec {
|
|
@@ -193,7 +193,7 @@ export async function send<T = unknown, M = unknown>(
|
|
|
193
193
|
};
|
|
194
194
|
const again =
|
|
195
195
|
attempt < maxRetries &&
|
|
196
|
-
|
|
196
|
+
isRetryable(answer, { repeatable, durableCodes: transport.durableCodes });
|
|
197
197
|
if (!again) throw transport.error(failure);
|
|
198
198
|
await sleep(retryDelayMs(attempt, answer), signal);
|
|
199
199
|
}
|