@beliq/sdk 0.3.0 → 0.3.1
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 +5 -0
- package/dist/index.cjs +10 -4
- package/dist/index.d.cts +46 -42
- package/dist/index.d.ts +46 -42
- package/dist/index.js +10 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -215,6 +215,11 @@ var LIVE_CONVERT_TARGET_FORMATS = [
|
|
|
215
215
|
|
|
216
216
|
// src/transport.ts
|
|
217
217
|
var RETRYABLE_STATUSES = /* @__PURE__ */ new Set([429, 502, 503]);
|
|
218
|
+
var QUOTA_EXHAUSTED_CODE = "QUOTA_EXCEEDED";
|
|
219
|
+
function isRetryable(status, code) {
|
|
220
|
+
if (!RETRYABLE_STATUSES.has(status)) return false;
|
|
221
|
+
return !(status === 429 && code === QUOTA_EXHAUSTED_CODE);
|
|
222
|
+
}
|
|
218
223
|
var MAX_RETRY_AFTER_MS = 3e4;
|
|
219
224
|
var BACKOFF_BASE_MS = 500;
|
|
220
225
|
function authHeaders(config) {
|
|
@@ -262,12 +267,13 @@ async function send(config, req) {
|
|
|
262
267
|
});
|
|
263
268
|
const bytes = new Uint8Array(await res.arrayBuffer());
|
|
264
269
|
if (res.ok) return { status: res.status, headers: res.headers, bytes };
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
270
|
+
const apiError = errorFromResponse(res.status, bytes);
|
|
271
|
+
lastError = apiError;
|
|
272
|
+
if (!isRetryable(apiError.status, apiError.code) || attempt === config.maxRetries) {
|
|
273
|
+
throw apiError;
|
|
268
274
|
}
|
|
269
275
|
} catch (err) {
|
|
270
|
-
if (err instanceof BeliqApiError && !
|
|
276
|
+
if (err instanceof BeliqApiError && !isRetryable(err.status, err.code)) throw err;
|
|
271
277
|
if (controller.signal.aborted) {
|
|
272
278
|
throw new BeliqApiError(
|
|
273
279
|
`beliq: request to ${req.path} exceeded ${config.timeoutMs}ms`,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@beliq/sdk",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "Official beliq SDK: generate, validate, parse, and convert EU-compliant e-invoices (XRechnung, ZUGFeRD, Factur-X, Peppol BIS) against authority-pinned, drift-checked rules.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"beliq",
|