@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/README.md
CHANGED
|
@@ -88,6 +88,11 @@ costs you a second document.
|
|
|
88
88
|
the work may still be running on beliq's side, so retrying risks producing a
|
|
89
89
|
second document rather than recovering the first.
|
|
90
90
|
|
|
91
|
+
A `429` carrying `QUOTA_EXCEEDED` is not retried either. `RATE_LIMITED` and
|
|
92
|
+
`ACCOUNT_THROTTLED` clear on their own, but a spent monthly allowance only returns
|
|
93
|
+
when your billing window turns, so the error is raised straight away and names the
|
|
94
|
+
cause instead of sleeping against it.
|
|
95
|
+
|
|
91
96
|
The default deadline is generous because beliq runs the full Schematron rule set
|
|
92
97
|
over each document, and a generate or validate can legitimately take tens of
|
|
93
98
|
seconds. If you lower it, keep it above the latency you actually see: a deadline
|
package/dist/index.cjs
CHANGED
|
@@ -255,6 +255,11 @@ var LIVE_CONVERT_TARGET_FORMATS = [
|
|
|
255
255
|
|
|
256
256
|
// src/transport.ts
|
|
257
257
|
var RETRYABLE_STATUSES = /* @__PURE__ */ new Set([429, 502, 503]);
|
|
258
|
+
var QUOTA_EXHAUSTED_CODE = "QUOTA_EXCEEDED";
|
|
259
|
+
function isRetryable(status, code) {
|
|
260
|
+
if (!RETRYABLE_STATUSES.has(status)) return false;
|
|
261
|
+
return !(status === 429 && code === QUOTA_EXHAUSTED_CODE);
|
|
262
|
+
}
|
|
258
263
|
var MAX_RETRY_AFTER_MS = 3e4;
|
|
259
264
|
var BACKOFF_BASE_MS = 500;
|
|
260
265
|
function authHeaders(config) {
|
|
@@ -302,12 +307,13 @@ async function send(config, req) {
|
|
|
302
307
|
});
|
|
303
308
|
const bytes = new Uint8Array(await res.arrayBuffer());
|
|
304
309
|
if (res.ok) return { status: res.status, headers: res.headers, bytes };
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
310
|
+
const apiError = errorFromResponse(res.status, bytes);
|
|
311
|
+
lastError = apiError;
|
|
312
|
+
if (!isRetryable(apiError.status, apiError.code) || attempt === config.maxRetries) {
|
|
313
|
+
throw apiError;
|
|
308
314
|
}
|
|
309
315
|
} catch (err) {
|
|
310
|
-
if (err instanceof BeliqApiError && !
|
|
316
|
+
if (err instanceof BeliqApiError && !isRetryable(err.status, err.code)) throw err;
|
|
311
317
|
if (controller.signal.aborted) {
|
|
312
318
|
throw new BeliqApiError(
|
|
313
319
|
`beliq: request to ${req.path} exceeded ${config.timeoutMs}ms`,
|