@aouda/client 0.1.8 → 0.1.9
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/dist/cli/index.cjs +37 -12
- package/dist/cli/index.cjs.map +1 -1
- package/dist/cli/index.d.cts +1 -1
- package/dist/cli/index.d.ts +1 -1
- package/dist/cli/index.js +37 -12
- package/dist/cli/index.js.map +1 -1
- package/dist/{client-TIOp5NUu.d.cts → client-CxP9Vnc8.d.cts} +48 -1
- package/dist/{client-TIOp5NUu.d.ts → client-CxP9Vnc8.d.ts} +48 -1
- package/dist/index.cjs +37 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -4
- package/dist/index.d.ts +5 -4
- package/dist/index.js +37 -12
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cli/index.d.cts
CHANGED
package/dist/cli/index.d.ts
CHANGED
package/dist/cli/index.js
CHANGED
|
@@ -392,7 +392,7 @@ import { fileURLToPath } from "url";
|
|
|
392
392
|
// package.json
|
|
393
393
|
var package_default = {
|
|
394
394
|
name: "@aouda/client",
|
|
395
|
-
version: "0.1.
|
|
395
|
+
version: "0.1.9",
|
|
396
396
|
description: "Official TypeScript/JavaScript client library for Aouda",
|
|
397
397
|
type: "module",
|
|
398
398
|
main: "./dist/index.cjs",
|
|
@@ -507,12 +507,13 @@ var AoudaResponseError = class extends AoudaError {
|
|
|
507
507
|
}
|
|
508
508
|
};
|
|
509
509
|
var AoudaApiError = class extends AoudaError {
|
|
510
|
-
constructor(message, code, statusCode, details, requestId) {
|
|
510
|
+
constructor(message, code, statusCode, details, requestId, retryAfterSeconds) {
|
|
511
511
|
super(message);
|
|
512
512
|
this.code = code;
|
|
513
513
|
this.statusCode = statusCode;
|
|
514
514
|
this.details = details;
|
|
515
515
|
this.requestId = requestId;
|
|
516
|
+
this.retryAfterSeconds = retryAfterSeconds;
|
|
516
517
|
this.name = "AoudaApiError";
|
|
517
518
|
}
|
|
518
519
|
};
|
|
@@ -535,8 +536,8 @@ var AoudaValidationError = class extends AoudaApiError {
|
|
|
535
536
|
}
|
|
536
537
|
};
|
|
537
538
|
var AoudaServerError = class extends AoudaApiError {
|
|
538
|
-
constructor(message, code, statusCode, details, requestId) {
|
|
539
|
-
super(message, code, statusCode, details, requestId);
|
|
539
|
+
constructor(message, code, statusCode, details, requestId, retryAfterSeconds) {
|
|
540
|
+
super(message, code, statusCode, details, requestId, retryAfterSeconds);
|
|
540
541
|
this.name = "AoudaServerError";
|
|
541
542
|
}
|
|
542
543
|
};
|
|
@@ -1475,6 +1476,8 @@ var ERROR_CODE_MAP = {
|
|
|
1475
1476
|
SERVICE_UNAVAILABLE: AoudaServerError,
|
|
1476
1477
|
TIMEOUT: AoudaServerError,
|
|
1477
1478
|
OVERLOADED: AoudaServerError,
|
|
1479
|
+
MEMORY_BUDGET_EXCEEDED: AoudaServerError,
|
|
1480
|
+
WAL_CAPACITY_EXCEEDED: AoudaServerError,
|
|
1478
1481
|
AUTH_TOKEN_MISSING: AoudaAuthenticationError,
|
|
1479
1482
|
AUTH_TOKEN_EXPIRED: AoudaAuthenticationError,
|
|
1480
1483
|
AUTH_TOKEN_INVALID: AoudaAuthenticationError,
|
|
@@ -1502,13 +1505,22 @@ function createComposedAbortController(...signals) {
|
|
|
1502
1505
|
}
|
|
1503
1506
|
return controller;
|
|
1504
1507
|
}
|
|
1505
|
-
function
|
|
1508
|
+
function parseRetryAfterSeconds(header) {
|
|
1509
|
+
if (header == null || header.trim() === "") return void 0;
|
|
1510
|
+
const trimmed = header.trim();
|
|
1511
|
+
if (!/^\d+$/.test(trimmed)) return void 0;
|
|
1512
|
+
const n = Number.parseInt(trimmed, 10);
|
|
1513
|
+
if (!Number.isFinite(n) || n < 0) return void 0;
|
|
1514
|
+
return n;
|
|
1515
|
+
}
|
|
1516
|
+
function createApiError(statusCode, statusText, body, retryAfterHeader) {
|
|
1506
1517
|
const message = body.error ?? `${statusCode} ${statusText}`;
|
|
1507
1518
|
const code = body.code ?? "UNKNOWN";
|
|
1508
1519
|
const details = body.details;
|
|
1509
1520
|
const requestId = body.requestId;
|
|
1521
|
+
const retryAfterSeconds = parseRetryAfterSeconds(retryAfterHeader ?? null);
|
|
1510
1522
|
const Ctor = ERROR_CODE_MAP[code] ?? AoudaApiError;
|
|
1511
|
-
return new Ctor(message, code, statusCode, details, requestId);
|
|
1523
|
+
return new Ctor(message, code, statusCode, details, requestId, retryAfterSeconds);
|
|
1512
1524
|
}
|
|
1513
1525
|
var HttpTransport = class {
|
|
1514
1526
|
constructor(options) {
|
|
@@ -1601,7 +1613,8 @@ var HttpTransport = class {
|
|
|
1601
1613
|
throw createApiError(
|
|
1602
1614
|
response.status,
|
|
1603
1615
|
response.statusText,
|
|
1604
|
-
errorBody
|
|
1616
|
+
errorBody,
|
|
1617
|
+
response.headers.get("Retry-After")
|
|
1605
1618
|
);
|
|
1606
1619
|
}
|
|
1607
1620
|
throw new AoudaResponseError(
|
|
@@ -1711,7 +1724,8 @@ var HttpTransport = class {
|
|
|
1711
1724
|
throw createApiError(
|
|
1712
1725
|
response.status,
|
|
1713
1726
|
response.statusText,
|
|
1714
|
-
errorBody
|
|
1727
|
+
errorBody,
|
|
1728
|
+
response.headers.get("Retry-After")
|
|
1715
1729
|
);
|
|
1716
1730
|
}
|
|
1717
1731
|
throw new AoudaResponseError(
|
|
@@ -2057,6 +2071,17 @@ var CIRCUIT_BREAKER_POLICY_DISABLED = {
|
|
|
2057
2071
|
|
|
2058
2072
|
// src/resilience/resilient-transport.ts
|
|
2059
2073
|
var REQUEST_ID_HEADER3 = "X-Request-Id";
|
|
2074
|
+
function isCapacityBackPressure(error) {
|
|
2075
|
+
return error instanceof AoudaApiError && (error.code === "MEMORY_BUDGET_EXCEEDED" || error.code === "WAL_CAPACITY_EXCEEDED");
|
|
2076
|
+
}
|
|
2077
|
+
function retryDelayMs(retryPolicy, attempt, error) {
|
|
2078
|
+
const backoff = calculateDelay(retryPolicy, attempt);
|
|
2079
|
+
if (!isCapacityBackPressure(error) || !(error instanceof AoudaApiError)) {
|
|
2080
|
+
return backoff;
|
|
2081
|
+
}
|
|
2082
|
+
const headerMs = error.retryAfterSeconds != null ? error.retryAfterSeconds * 1e3 : 0;
|
|
2083
|
+
return Math.max(backoff, headerMs);
|
|
2084
|
+
}
|
|
2060
2085
|
function delayMs(ms, signal) {
|
|
2061
2086
|
if (ms <= 0) return Promise.resolve();
|
|
2062
2087
|
return new Promise((resolve4, reject) => {
|
|
@@ -2111,7 +2136,7 @@ var ResilientTransport = class {
|
|
|
2111
2136
|
} catch (error) {
|
|
2112
2137
|
lastError = error;
|
|
2113
2138
|
const retryable = isRetryable(error);
|
|
2114
|
-
if (retryable) {
|
|
2139
|
+
if (retryable && !isCapacityBackPressure(error)) {
|
|
2115
2140
|
this.circuitBreaker.recordFailure(error);
|
|
2116
2141
|
}
|
|
2117
2142
|
if (!retryable) {
|
|
@@ -2121,7 +2146,7 @@ var ResilientTransport = class {
|
|
|
2121
2146
|
if (attempt > this.retryPolicy.maxRetries) {
|
|
2122
2147
|
throw error;
|
|
2123
2148
|
}
|
|
2124
|
-
const delay =
|
|
2149
|
+
const delay = retryDelayMs(this.retryPolicy, attempt, error);
|
|
2125
2150
|
try {
|
|
2126
2151
|
await delayMs(delay, config.signal);
|
|
2127
2152
|
} catch {
|
|
@@ -2157,7 +2182,7 @@ var ResilientTransport = class {
|
|
|
2157
2182
|
} catch (error) {
|
|
2158
2183
|
lastError = error;
|
|
2159
2184
|
const retryable = isRetryable(error);
|
|
2160
|
-
if (retryable) {
|
|
2185
|
+
if (retryable && !isCapacityBackPressure(error)) {
|
|
2161
2186
|
this.circuitBreaker.recordFailure(error);
|
|
2162
2187
|
}
|
|
2163
2188
|
if (!retryable) {
|
|
@@ -2167,7 +2192,7 @@ var ResilientTransport = class {
|
|
|
2167
2192
|
if (attempt > this.retryPolicy.maxRetries) {
|
|
2168
2193
|
throw error;
|
|
2169
2194
|
}
|
|
2170
|
-
const delay =
|
|
2195
|
+
const delay = retryDelayMs(this.retryPolicy, attempt, error);
|
|
2171
2196
|
try {
|
|
2172
2197
|
await delayMs(delay, config.signal);
|
|
2173
2198
|
} catch {
|