@finteqhub/sdk-js 0.12.0-beta.4 → 0.12.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 +8 -0
- package/dist/src/processing.d.ts +1 -1
- package/dist/src/processing.js +4 -7
- package/dist/src/version.d.ts +1 -1
- package/dist/src/version.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -23,6 +23,14 @@ const processing = new FinteqHubProcessing('api-url', 'fingerprint-visitor-id',
|
|
|
23
23
|
});
|
|
24
24
|
```
|
|
25
25
|
|
|
26
|
+
To disable retries entirely, pass `retryCount: 0` — every request is then sent exactly once, as in 0.11.0. Error diagnostics (`RequestError`, the `console.error` dump) are still collected:
|
|
27
|
+
|
|
28
|
+
```
|
|
29
|
+
const processing = new FinteqHubProcessing('api-url', 'fingerprint-visitor-id', 'merchant-id', 'session-id', false, {
|
|
30
|
+
retryCount: 0,
|
|
31
|
+
});
|
|
32
|
+
```
|
|
33
|
+
|
|
26
34
|
The constructor throws a `TypeError` when `retryOptions` is not an object, `retryCount` is not a non-negative integer, or `retryStatusCode` is not a function.
|
|
27
35
|
|
|
28
36
|
Network errors (the browser could not reach the server at all, e.g. `TypeError: Failed to fetch`, or the connection dropped while the response body was being read) are always retried too.
|
package/dist/src/processing.d.ts
CHANGED
package/dist/src/processing.js
CHANGED
|
@@ -135,10 +135,10 @@ export class FinteqHubProcessing {
|
|
|
135
135
|
? sanitizeBody(e.message)
|
|
136
136
|
: "parse error message omitted (200 response body may carry credentials)",
|
|
137
137
|
};
|
|
138
|
-
throw this.
|
|
138
|
+
throw this.requestError("invalid_json", `request to ${url} returned invalid JSON (status ${response.status})`, url, options, attempts, { status: response.status, body }, parseError);
|
|
139
139
|
}
|
|
140
140
|
if ((result === null || result === void 0 ? void 0 : result.error) || response.status !== 200) {
|
|
141
|
-
throw this.
|
|
141
|
+
throw this.requestError("http_error", (result === null || result === void 0 ? void 0 : result.error) || `unexpected response status ${response.status}`, url, options, attempts, { status: response.status, body, error: result === null || result === void 0 ? void 0 : result.error });
|
|
142
142
|
}
|
|
143
143
|
return result;
|
|
144
144
|
});
|
|
@@ -165,10 +165,7 @@ export class FinteqHubProcessing {
|
|
|
165
165
|
// status is known when the failure happened while reading the body of a received response
|
|
166
166
|
attempts.push({ durationMs: Date.now() - startedAt, status: response === null || response === void 0 ? void 0 : response.status, error: e.message });
|
|
167
167
|
if (attempt > retryCount) {
|
|
168
|
-
|
|
169
|
-
const diagnostics = this.collectDiagnostics("network", url, options, attempts, e, response ? { status: response.status } : undefined);
|
|
170
|
-
console.error(`sdk-js: request failed: ${message}`, diagnostics);
|
|
171
|
-
throw new RequestError(message, diagnostics);
|
|
168
|
+
throw this.requestError("network", `request to ${url} failed after ${attempt} attempt(s): ${e.message}`, url, options, attempts, response ? { status: response.status } : undefined, e);
|
|
172
169
|
}
|
|
173
170
|
reason = e.message;
|
|
174
171
|
}
|
|
@@ -188,7 +185,7 @@ export class FinteqHubProcessing {
|
|
|
188
185
|
}
|
|
189
186
|
});
|
|
190
187
|
}
|
|
191
|
-
|
|
188
|
+
requestError(kind, message, url, options, attempts, response, error) {
|
|
192
189
|
const diagnostics = this.collectDiagnostics(kind, url, options, attempts, error, response);
|
|
193
190
|
console.error(`sdk-js: request failed: ${message}`, diagnostics);
|
|
194
191
|
return new RequestError(message, diagnostics);
|
package/dist/src/version.d.ts
CHANGED
package/dist/src/version.js
CHANGED