@hunt-labs/bytekit-sdk 0.11.5 → 0.11.7
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/CHANGELOG.md +18 -0
- package/README.md +1 -1
- package/dist/client.d.ts +1 -1
- package/dist/client.js +2 -2
- package/dist/generated/api.d.ts +54 -83
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -10,6 +10,24 @@ today, see [README.md](./README.md), which remains the authoritative usage guide
|
|
|
10
10
|
|
|
11
11
|
## [Unreleased]
|
|
12
12
|
|
|
13
|
+
## [0.11.7] - 2026-09-29
|
|
14
|
+
|
|
15
|
+
### Changed
|
|
16
|
+
|
|
17
|
+
- **Internal `GET /v1/billing/topup-balance` types add `bandwidth.debt_bytes` (#4960, #4975).**
|
|
18
|
+
The bytes the account still owes for bandwidth a finished request used beyond everything it
|
|
19
|
+
could pay for, net of any repaid. Declared on that endpoint only, not on the shared
|
|
20
|
+
`BandwidthBalance` schema `GET /v1/usage` returns. No SDK method calls it.
|
|
21
|
+
|
|
22
|
+
## [0.11.6] - 2026-09-24
|
|
23
|
+
|
|
24
|
+
### Changed
|
|
25
|
+
|
|
26
|
+
- Regenerated `src/generated/api.d.ts` (#4865): a documentation-wording correction to the
|
|
27
|
+
`POST /v1/schema` billing description, which now says the page bandwidth is billed at its
|
|
28
|
+
upstream wire bytes with no endpoint factor instead of "exactly like `/v1/scrape`". No
|
|
29
|
+
behavior change: doc comments only, no SDK signature moves.
|
|
30
|
+
|
|
13
31
|
## [0.11.5] - 2026-09-22
|
|
14
32
|
|
|
15
33
|
### Changed
|
package/README.md
CHANGED
|
@@ -358,7 +358,7 @@ try {
|
|
|
358
358
|
|
|
359
359
|
Note that `details` is populated only from the API's canonical
|
|
360
360
|
`{ error: { … } }` envelope. A few endpoints answer with a flat, vendor-masked
|
|
361
|
-
body instead (`/v1/search` returns `
|
|
361
|
+
body instead (`/v1/search` returns `503 {"error":"search_provider_error"}`);
|
|
362
362
|
those carry no structured detail, so `err.details` stays `undefined` there —
|
|
363
363
|
`err.code` is still the machine-readable reason.
|
|
364
364
|
|
package/dist/client.d.ts
CHANGED
|
@@ -103,7 +103,7 @@ export declare class ByteKitError extends Error {
|
|
|
103
103
|
* The envelope's `error.details`, when it carried one — `undefined` otherwise.
|
|
104
104
|
*
|
|
105
105
|
* Populated ONLY from the canonical `{ error: { … } }` envelope. A flat
|
|
106
|
-
* vendor-masked body (`/v1/search`
|
|
106
|
+
* vendor-masked body (`/v1/search` 503 `{"error":"search_provider_error"}`)
|
|
107
107
|
* has no envelope to read a detail from, so it never grows one (#2685 E3).
|
|
108
108
|
*
|
|
109
109
|
* A `details` that is not a JSON object — which the untyped spec field
|
package/dist/client.js
CHANGED
|
@@ -470,9 +470,9 @@ export class ByteKit {
|
|
|
470
470
|
}
|
|
471
471
|
}
|
|
472
472
|
else if (typeof json.error === 'string' && json.error.length > 0) {
|
|
473
|
-
// Flat vendor-masked shape, e.g. /v1/search
|
|
473
|
+
// Flat vendor-masked shape, e.g. /v1/search 503
|
|
474
474
|
// {"error":"search_provider_error"} (docs/api/openapi.yaml §/v1/search
|
|
475
|
-
//
|
|
475
|
+
// 503). The string IS the error code. `message` falls back to it only
|
|
476
476
|
// when the response carried no statusText, so the thrown error is
|
|
477
477
|
// never message-empty.
|
|
478
478
|
code = json.error;
|
package/dist/generated/api.d.ts
CHANGED
|
@@ -640,7 +640,8 @@ export interface paths {
|
|
|
640
640
|
* `wait_for_selector`) cause a `400 unsupported_option`.
|
|
641
641
|
*
|
|
642
642
|
* Dual-axis billing: a fixed per-request credit charge **plus** the
|
|
643
|
-
* underlying page's bandwidth, billed
|
|
643
|
+
* underlying page's bandwidth, billed at its upstream wire bytes with no
|
|
644
|
+
* endpoint factor (a 100 KiB estimate is pre-charged, then reconciled). The
|
|
644
645
|
* bandwidth is still billed when the scrape succeeds but extraction later
|
|
645
646
|
* fails; both axes are refunded only when the scrape itself never runs.
|
|
646
647
|
*
|
|
@@ -2837,10 +2838,13 @@ export interface components {
|
|
|
2837
2838
|
* performed. The unified `Error` envelope carries one of the billing codes
|
|
2838
2839
|
* below in `error.code`; match on the code, never on the prose.
|
|
2839
2840
|
*
|
|
2840
|
-
* - `quota_exceeded` — the enforced balance for this request's meter
|
|
2841
|
-
*
|
|
2841
|
+
* - `quota_exceeded` — the enforced balance for this request's meter
|
|
2842
|
+
* cannot fund it. Capture endpoints (`/v1/scrape`, `/v1/fetch`,
|
|
2842
2843
|
* `/v1/screenshots`, `/v1/sitemap` and the bulk siblings) meter
|
|
2843
|
-
* bandwidth
|
|
2844
|
+
* bandwidth: they reject when the balance cannot fund the request's
|
|
2845
|
+
* byte reservation, and `error.details.required_bytes` and
|
|
2846
|
+
* `error.details.available_bytes` report the bytes the request reserves
|
|
2847
|
+
* and the bytes available. `/v1/search` meters credits.
|
|
2844
2848
|
* - `spending_cap_reached` — the request would push overage spend past the
|
|
2845
2849
|
* account's configured cap. Only reachable on a custom overage-enabled
|
|
2846
2850
|
* plan; standard plans stop at `quota_exceeded`.
|
|
@@ -2863,9 +2867,13 @@ export interface components {
|
|
|
2863
2867
|
* "status": "failed",
|
|
2864
2868
|
* "error": {
|
|
2865
2869
|
* "code": "quota_exceeded",
|
|
2866
|
-
* "message": "
|
|
2870
|
+
* "message": "Insufficient bandwidth balance: this request reserves 102400 bytes and 4321 are available.",
|
|
2867
2871
|
* "http_status": 402,
|
|
2868
|
-
* "failed_at": "2026-01-15T12:00:00Z"
|
|
2872
|
+
* "failed_at": "2026-01-15T12:00:00Z",
|
|
2873
|
+
* "details": {
|
|
2874
|
+
* "required_bytes": 102400,
|
|
2875
|
+
* "available_bytes": 4321
|
|
2876
|
+
* }
|
|
2869
2877
|
* }
|
|
2870
2878
|
* }
|
|
2871
2879
|
*/
|
|
@@ -4175,35 +4183,20 @@ export interface operations {
|
|
|
4175
4183
|
"application/json": components["schemas"]["Error"];
|
|
4176
4184
|
};
|
|
4177
4185
|
};
|
|
4178
|
-
/**
|
|
4179
|
-
* @description Content transform failed, or a non-2xx upstream response relayed as the unified
|
|
4180
|
-
* Error envelope. On an upstream relay the HTTP status equals the upstream status
|
|
4181
|
-
* (code `upstream_error`), so any 4xx/5xx the target returns surfaces here as an
|
|
4182
|
-
* Error envelope rather than a raw body (#1462).
|
|
4183
|
-
*
|
|
4184
|
-
* **One divergence.** An upstream `502` is relayed at HTTP `503`, not `502` — see
|
|
4185
|
-
* the `503` response below. A fetch service that cannot be reached also answers
|
|
4186
|
-
* `503`, not `502` (#3373); this status no longer covers that condition.
|
|
4187
|
-
*/
|
|
4188
|
-
502: {
|
|
4189
|
-
headers: {
|
|
4190
|
-
[name: string]: unknown;
|
|
4191
|
-
};
|
|
4192
|
-
content: {
|
|
4193
|
-
"application/json": components["schemas"]["Error"];
|
|
4194
|
-
};
|
|
4195
|
-
};
|
|
4196
4186
|
/**
|
|
4197
4187
|
* @description Two distinct conditions answer `503`, and they disagree about what the body's
|
|
4198
4188
|
* `error.http_status` reports. Read `error.code` to tell them apart.
|
|
4199
4189
|
*
|
|
4200
|
-
* - **`upstream_error`** — the target returned HTTP `502`, relayed here as
|
|
4201
|
-
* Cloudflare fronts this API and replaces a clean origin 502 with its
|
|
4202
|
-
* `text/plain` error page, discarding the envelope before it reaches
|
|
4203
|
-
* 503 is passed through unchanged. The body's `error.http_status`
|
|
4204
|
-
* the **true upstream status**, `502` — not `503` — and is
|
|
4205
|
-
* record of what the target answered, so the body rather than
|
|
4206
|
-
* authoritative here (#3355).
|
|
4190
|
+
* - **`upstream_error`** — the target returned HTTP `502` or `504`, relayed here as
|
|
4191
|
+
* `503`. Cloudflare fronts this API and replaces a clean origin 502 or 504 with its
|
|
4192
|
+
* own generic `text/plain` error page, discarding the envelope before it reaches
|
|
4193
|
+
* you, while a 503 is passed through unchanged. The body's `error.http_status`
|
|
4194
|
+
* still reports the **true upstream status**, `502` or `504` — not `503` — and is
|
|
4195
|
+
* the only surviving record of what the target answered, so the body rather than
|
|
4196
|
+
* the HTTP status is authoritative here (#3355, #4891). Every other non-2xx
|
|
4197
|
+
* upstream response is relayed at its own HTTP status with the same
|
|
4198
|
+
* `upstream_error` envelope, so any other 4xx/5xx the target returns surfaces as an
|
|
4199
|
+
* Error envelope rather than a raw body (#1462).
|
|
4207
4200
|
* - **`internal_error`** (message `Fetch service unavailable.`) — no fetch service
|
|
4208
4201
|
* endpoint could be resolved on this deployment, a fault of this API and not of the
|
|
4209
4202
|
* target. There is no upstream status to preserve: the `503` is this API's own
|
|
@@ -4325,35 +4318,20 @@ export interface operations {
|
|
|
4325
4318
|
"application/json": components["schemas"]["Error"];
|
|
4326
4319
|
};
|
|
4327
4320
|
};
|
|
4328
|
-
/**
|
|
4329
|
-
* @description Content transform failed, or a non-2xx upstream response relayed as the unified
|
|
4330
|
-
* Error envelope. On an upstream relay the HTTP status equals the upstream status
|
|
4331
|
-
* (code `upstream_error`), so any 4xx/5xx the target returns surfaces here as an
|
|
4332
|
-
* Error envelope rather than a raw body (#1462).
|
|
4333
|
-
*
|
|
4334
|
-
* **One divergence.** An upstream `502` is relayed at HTTP `503`, not `502` — see
|
|
4335
|
-
* the `503` response below. A fetch service that cannot be reached also answers
|
|
4336
|
-
* `503`, not `502` (#3373); this status no longer covers that condition.
|
|
4337
|
-
*/
|
|
4338
|
-
502: {
|
|
4339
|
-
headers: {
|
|
4340
|
-
[name: string]: unknown;
|
|
4341
|
-
};
|
|
4342
|
-
content: {
|
|
4343
|
-
"application/json": components["schemas"]["Error"];
|
|
4344
|
-
};
|
|
4345
|
-
};
|
|
4346
4321
|
/**
|
|
4347
4322
|
* @description Two distinct conditions answer `503`, and they disagree about what the body's
|
|
4348
4323
|
* `error.http_status` reports. Read `error.code` to tell them apart.
|
|
4349
4324
|
*
|
|
4350
|
-
* - **`upstream_error`** — the target returned HTTP `502`, relayed here as
|
|
4351
|
-
* Cloudflare fronts this API and replaces a clean origin 502 with its
|
|
4352
|
-
* `text/plain` error page, discarding the envelope before it reaches
|
|
4353
|
-
* 503 is passed through unchanged. The body's `error.http_status`
|
|
4354
|
-
* the **true upstream status**, `502` — not `503` — and is
|
|
4355
|
-
* record of what the target answered, so the body rather than
|
|
4356
|
-
* authoritative here (#3355).
|
|
4325
|
+
* - **`upstream_error`** — the target returned HTTP `502` or `504`, relayed here as
|
|
4326
|
+
* `503`. Cloudflare fronts this API and replaces a clean origin 502 or 504 with its
|
|
4327
|
+
* own generic `text/plain` error page, discarding the envelope before it reaches
|
|
4328
|
+
* you, while a 503 is passed through unchanged. The body's `error.http_status`
|
|
4329
|
+
* still reports the **true upstream status**, `502` or `504` — not `503` — and is
|
|
4330
|
+
* the only surviving record of what the target answered, so the body rather than
|
|
4331
|
+
* the HTTP status is authoritative here (#3355, #4891). Every other non-2xx
|
|
4332
|
+
* upstream response is relayed at its own HTTP status with the same
|
|
4333
|
+
* `upstream_error` envelope, so any other 4xx/5xx the target returns surfaces as an
|
|
4334
|
+
* Error envelope rather than a raw body (#1462).
|
|
4357
4335
|
* - **`internal_error`** (message `Fetch service unavailable.`) — no fetch service
|
|
4358
4336
|
* endpoint could be resolved on this deployment, a fault of this API and not of the
|
|
4359
4337
|
* target. There is no upstream status to preserve: the `503` is this API's own
|
|
@@ -5737,13 +5715,14 @@ export interface operations {
|
|
|
5737
5715
|
};
|
|
5738
5716
|
};
|
|
5739
5717
|
/**
|
|
5740
|
-
* @description Upstream search provider error
|
|
5718
|
+
* @description Upstream search provider error, answered at `503` rather than `502` because
|
|
5719
|
+
* Cloudflare replaces an origin 502 body with its own page (#4891). The body is a fixed,
|
|
5741
5720
|
* vendor-masked shape — deliberately NOT the unified `Error`
|
|
5742
5721
|
* envelope. The upstream provider's identity and message are
|
|
5743
5722
|
* never surfaced, so the response carries only the constant
|
|
5744
5723
|
* `error` code `search_provider_error`.
|
|
5745
5724
|
*/
|
|
5746
|
-
|
|
5725
|
+
503: {
|
|
5747
5726
|
headers: {
|
|
5748
5727
|
[name: string]: unknown;
|
|
5749
5728
|
};
|
|
@@ -5903,16 +5882,15 @@ export interface operations {
|
|
|
5903
5882
|
"application/json": components["schemas"]["Error"];
|
|
5904
5883
|
};
|
|
5905
5884
|
};
|
|
5906
|
-
/**
|
|
5907
|
-
|
|
5908
|
-
|
|
5909
|
-
|
|
5910
|
-
|
|
5911
|
-
|
|
5912
|
-
|
|
5913
|
-
|
|
5914
|
-
|
|
5915
|
-
/** @description Extraction provider unconfigured (`provider_unavailable`). */
|
|
5885
|
+
/**
|
|
5886
|
+
* @description Read `error.code` to tell the conditions apart: underlying scrape failed or the
|
|
5887
|
+
* extraction service was unreachable (`scrape_failed`), upstream provider error
|
|
5888
|
+
* (`provider_error`), extraction provider unconfigured (`provider_unavailable`), or
|
|
5889
|
+
* upstream provider timed out (`provider_timeout`). None of these answers `502` or
|
|
5890
|
+
* `504`: Cloudflare fronts this API and replaces an origin 502 or 504 with its own
|
|
5891
|
+
* `text/plain` page, discarding the error envelope, while a 503 passes through
|
|
5892
|
+
* unchanged (#4891).
|
|
5893
|
+
*/
|
|
5916
5894
|
503: {
|
|
5917
5895
|
headers: {
|
|
5918
5896
|
[name: string]: unknown;
|
|
@@ -5921,15 +5899,6 @@ export interface operations {
|
|
|
5921
5899
|
"application/json": components["schemas"]["Error"];
|
|
5922
5900
|
};
|
|
5923
5901
|
};
|
|
5924
|
-
/** @description Upstream provider timed out (`provider_timeout`). */
|
|
5925
|
-
504: {
|
|
5926
|
-
headers: {
|
|
5927
|
-
[name: string]: unknown;
|
|
5928
|
-
};
|
|
5929
|
-
content: {
|
|
5930
|
-
"application/json": components["schemas"]["Error"];
|
|
5931
|
-
};
|
|
5932
|
-
};
|
|
5933
5902
|
};
|
|
5934
5903
|
};
|
|
5935
5904
|
getUsage: {
|
|
@@ -6401,8 +6370,8 @@ export interface operations {
|
|
|
6401
6370
|
"application/json": components["schemas"]["Error"];
|
|
6402
6371
|
};
|
|
6403
6372
|
};
|
|
6404
|
-
/** @description Stripe error creating the Checkout session. */
|
|
6405
|
-
|
|
6373
|
+
/** @description Stripe error creating the Checkout session (`stripe_error`). Answered at `503`, not `502`, because Cloudflare replaces an origin 502 body with its own page (#4891). */
|
|
6374
|
+
503: {
|
|
6406
6375
|
headers: {
|
|
6407
6376
|
[name: string]: unknown;
|
|
6408
6377
|
};
|
|
@@ -6473,8 +6442,8 @@ export interface operations {
|
|
|
6473
6442
|
"application/json": components["schemas"]["Error"];
|
|
6474
6443
|
};
|
|
6475
6444
|
};
|
|
6476
|
-
/** @description The Stripe subscription schedule could not be read. */
|
|
6477
|
-
|
|
6445
|
+
/** @description The Stripe subscription schedule could not be read (`stripe_error`). Answered at `503`, not `502`, because Cloudflare replaces an origin 502 body with its own page (#4891). */
|
|
6446
|
+
503: {
|
|
6478
6447
|
headers: {
|
|
6479
6448
|
[name: string]: unknown;
|
|
6480
6449
|
};
|
|
@@ -6635,6 +6604,8 @@ export interface operations {
|
|
|
6635
6604
|
bandwidth: components["schemas"]["BandwidthBalance"] & {
|
|
6636
6605
|
/** @description Remaining balance of your subscription allowance: bytes still unspent across all allowance lots, the current period's and any rolled over from earlier periods alike, after active refund reservations. This is a remaining balance and falls to zero as the allowance is drawn down. It is not `included_bytes`, which is the plan's configured grant for a period and does not move as it is spent; do not subtract one from the other. `rollover_bytes` is a subset of this figure. */
|
|
6637
6606
|
remaining_allowance_bytes: number;
|
|
6607
|
+
/** @description Bytes you still owe: bandwidth your finished requests used beyond everything your account could pay for, net of any already paid back. It is reported beside the other bandwidth figures and is not subtracted from `remaining_bytes` or `remaining_allowance_bytes`. 0 when nothing is owed. */
|
|
6608
|
+
debt_bytes: number;
|
|
6638
6609
|
};
|
|
6639
6610
|
credits: components["schemas"]["CreditBalance"];
|
|
6640
6611
|
rates: {
|
|
@@ -6871,8 +6842,8 @@ export interface operations {
|
|
|
6871
6842
|
"application/json": components["schemas"]["Error"];
|
|
6872
6843
|
};
|
|
6873
6844
|
};
|
|
6874
|
-
/** @description Stripe API error. */
|
|
6875
|
-
|
|
6845
|
+
/** @description Stripe API error (`stripe_error`). Answered at `503`, not `502`, because Cloudflare replaces an origin 502 body with its own page (#4891). */
|
|
6846
|
+
503: {
|
|
6876
6847
|
headers: {
|
|
6877
6848
|
[name: string]: unknown;
|
|
6878
6849
|
};
|
package/dist/version.d.ts
CHANGED
|
@@ -5,4 +5,4 @@
|
|
|
5
5
|
* outbound request carries — see the emit site in `client.ts`. The header name is spelled
|
|
6
6
|
* only there, so issue #2905's pre-merge gate 1 counts exactly one occurrence in `src/`.
|
|
7
7
|
*/
|
|
8
|
-
export declare const SDK_VERSION = "0.11.
|
|
8
|
+
export declare const SDK_VERSION = "0.11.7";
|
package/dist/version.js
CHANGED