@getanyapi/sdk 0.9.7 → 0.9.8
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/index.cjs +14 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +14 -5
- package/dist/index.d.ts +14 -5
- package/dist/index.js +14 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -8,8 +8,11 @@ interface RunResult<T> {
|
|
|
8
8
|
provider: "AnyAPI";
|
|
9
9
|
/** Amount charged in USD for this call. */
|
|
10
10
|
costUsd: number;
|
|
11
|
-
/**
|
|
12
|
-
|
|
11
|
+
/**
|
|
12
|
+
* Number of result rows returned. Always present on the wire: the gateway's field
|
|
13
|
+
* carries no `omitempty`, and a metadata-only replay preserves the original count.
|
|
14
|
+
*/
|
|
15
|
+
items: number;
|
|
13
16
|
/**
|
|
14
17
|
* True when the gateway served a stored response for a repeated Idempotency-Key instead
|
|
15
18
|
* of running the SKU again. A replay is not billed twice. Always present on the wire.
|
|
@@ -55,8 +58,11 @@ interface BareRunResult<T> {
|
|
|
55
58
|
provider: "AnyAPI";
|
|
56
59
|
/** Amount charged in USD for this call. */
|
|
57
60
|
costUsd: number;
|
|
58
|
-
/**
|
|
59
|
-
|
|
61
|
+
/**
|
|
62
|
+
* Number of result rows returned. Always present on the wire: the gateway's field
|
|
63
|
+
* carries no `omitempty`, and a metadata-only replay preserves the original count.
|
|
64
|
+
*/
|
|
65
|
+
items: number;
|
|
60
66
|
/**
|
|
61
67
|
* True when the gateway served a stored response for a repeated Idempotency-Key instead
|
|
62
68
|
* of running the SKU again. A replay is not billed twice. Always present on the wire.
|
|
@@ -337,7 +343,10 @@ declare function paginate<Item, Page extends RunResult<unknown> | BareRunResult<
|
|
|
337
343
|
declare class AnyAPIError extends Error {
|
|
338
344
|
/** HTTP status code, or 0 for transport-level failures (connection/timeout). */
|
|
339
345
|
readonly status: number;
|
|
340
|
-
/**
|
|
346
|
+
/**
|
|
347
|
+
* The gateway's X-Anyapi-Request-Id response header when present (falling back to a
|
|
348
|
+
* proxy-set x-request-id), else undefined. Quote it to AnyAPI support.
|
|
349
|
+
*/
|
|
341
350
|
readonly requestId?: string;
|
|
342
351
|
/** Stable gateway error code when the JSON body includes one, else undefined. */
|
|
343
352
|
readonly code?: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -8,8 +8,11 @@ interface RunResult<T> {
|
|
|
8
8
|
provider: "AnyAPI";
|
|
9
9
|
/** Amount charged in USD for this call. */
|
|
10
10
|
costUsd: number;
|
|
11
|
-
/**
|
|
12
|
-
|
|
11
|
+
/**
|
|
12
|
+
* Number of result rows returned. Always present on the wire: the gateway's field
|
|
13
|
+
* carries no `omitempty`, and a metadata-only replay preserves the original count.
|
|
14
|
+
*/
|
|
15
|
+
items: number;
|
|
13
16
|
/**
|
|
14
17
|
* True when the gateway served a stored response for a repeated Idempotency-Key instead
|
|
15
18
|
* of running the SKU again. A replay is not billed twice. Always present on the wire.
|
|
@@ -55,8 +58,11 @@ interface BareRunResult<T> {
|
|
|
55
58
|
provider: "AnyAPI";
|
|
56
59
|
/** Amount charged in USD for this call. */
|
|
57
60
|
costUsd: number;
|
|
58
|
-
/**
|
|
59
|
-
|
|
61
|
+
/**
|
|
62
|
+
* Number of result rows returned. Always present on the wire: the gateway's field
|
|
63
|
+
* carries no `omitempty`, and a metadata-only replay preserves the original count.
|
|
64
|
+
*/
|
|
65
|
+
items: number;
|
|
60
66
|
/**
|
|
61
67
|
* True when the gateway served a stored response for a repeated Idempotency-Key instead
|
|
62
68
|
* of running the SKU again. A replay is not billed twice. Always present on the wire.
|
|
@@ -337,7 +343,10 @@ declare function paginate<Item, Page extends RunResult<unknown> | BareRunResult<
|
|
|
337
343
|
declare class AnyAPIError extends Error {
|
|
338
344
|
/** HTTP status code, or 0 for transport-level failures (connection/timeout). */
|
|
339
345
|
readonly status: number;
|
|
340
|
-
/**
|
|
346
|
+
/**
|
|
347
|
+
* The gateway's X-Anyapi-Request-Id response header when present (falling back to a
|
|
348
|
+
* proxy-set x-request-id), else undefined. Quote it to AnyAPI support.
|
|
349
|
+
*/
|
|
341
350
|
readonly requestId?: string;
|
|
342
351
|
/** Stable gateway error code when the JSON body includes one, else undefined. */
|
|
343
352
|
readonly code?: string;
|
package/dist/index.js
CHANGED
|
@@ -2,7 +2,10 @@
|
|
|
2
2
|
var AnyAPIError = class extends Error {
|
|
3
3
|
/** HTTP status code, or 0 for transport-level failures (connection/timeout). */
|
|
4
4
|
status;
|
|
5
|
-
/**
|
|
5
|
+
/**
|
|
6
|
+
* The gateway's X-Anyapi-Request-Id response header when present (falling back to a
|
|
7
|
+
* proxy-set x-request-id), else undefined. Quote it to AnyAPI support.
|
|
8
|
+
*/
|
|
6
9
|
requestId;
|
|
7
10
|
/** Stable gateway error code when the JSON body includes one, else undefined. */
|
|
8
11
|
code;
|
|
@@ -37,6 +40,14 @@ var ConnectionError = class extends AnyAPIError {
|
|
|
37
40
|
};
|
|
38
41
|
var TimeoutError = class extends AnyAPIError {
|
|
39
42
|
};
|
|
43
|
+
var REQUEST_ID_HEADERS = ["x-anyapi-request-id", "x-request-id"];
|
|
44
|
+
function requestIdOf(headers) {
|
|
45
|
+
for (const name of REQUEST_ID_HEADERS) {
|
|
46
|
+
const value = headers.get(name);
|
|
47
|
+
if (value) return value;
|
|
48
|
+
}
|
|
49
|
+
return void 0;
|
|
50
|
+
}
|
|
40
51
|
function errorFromStatus(status, message, requestId, code) {
|
|
41
52
|
switch (status) {
|
|
42
53
|
case 400:
|
|
@@ -407,7 +418,7 @@ async function agentSignup(options = {}) {
|
|
|
407
418
|
0
|
|
408
419
|
);
|
|
409
420
|
}
|
|
410
|
-
const requestId = response.headers
|
|
421
|
+
const requestId = requestIdOf(response.headers);
|
|
411
422
|
const text = await response.text().catch(() => "");
|
|
412
423
|
if (response.status !== 200) {
|
|
413
424
|
let message = `request failed with status ${response.status}`;
|
|
@@ -750,7 +761,7 @@ var AnyAPI = class {
|
|
|
750
761
|
}
|
|
751
762
|
throw connErr;
|
|
752
763
|
}
|
|
753
|
-
const requestId = response.headers
|
|
764
|
+
const requestId = requestIdOf(response.headers);
|
|
754
765
|
if (response.status === 200) {
|
|
755
766
|
const text = await response.text();
|
|
756
767
|
try {
|