@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 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.
@@ -59,6 +59,6 @@ export declare class FinteqHubProcessing {
59
59
  private sendPost;
60
60
  private request;
61
61
  private fetchWithRetry;
62
- private responseError;
62
+ private requestError;
63
63
  private collectDiagnostics;
64
64
  }
@@ -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.responseError("invalid_json", `request to ${url} returned invalid JSON (status ${response.status})`, url, options, attempts, { status: response.status, body }, parseError);
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.responseError("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 });
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
- const message = `request to ${url} failed after ${attempt} attempt(s): ${e.message}`;
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
- responseError(kind, message, url, options, attempts, response, error) {
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);
@@ -1,3 +1,3 @@
1
1
  export declare const SDK_HEADER_NAME = "X-Finteqhub-SDK";
2
- export declare const SDK_VERSION = "0.12.0-beta.4";
2
+ export declare const SDK_VERSION = "0.12.0";
3
3
  export declare const SDK_HEADER_VALUE: string;
@@ -1,3 +1,3 @@
1
1
  export const SDK_HEADER_NAME = "X-Finteqhub-SDK";
2
- export const SDK_VERSION = "0.12.0-beta.4";
2
+ export const SDK_VERSION = "0.12.0";
3
3
  export const SDK_HEADER_VALUE = `sdk-js/${SDK_VERSION}`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@finteqhub/sdk-js",
3
- "version": "0.12.0-beta.4",
3
+ "version": "0.12.0",
4
4
  "description": "SDK for interacting with FinteqHub processing API",
5
5
  "main": "./dist/index.js",
6
6
  "typings": "./dist/index.d.ts",